Change permissions() implementation to work correctly on MinGW and on Windows variants without _wchmod