Improve permission setting in setfilepermissions