setFilePermissions()

Sets the permissions for a file.

Synopsis

int setFilePermissions( string filename, int permissions);

Parameters

Parameter Meaning
filename The file path. The relative path is relative to the project directory. An absolute path can be given.
permissions

A bit-or combination of the following constants:

  • FILE_READ_OWNER
  • FILE_WRITE_OWNER
  • FILE_EXECUTE_OWNER
  • FILE_READ_GROUP
  • FILE_WRITE_GROUP
  • FILE_EXECUTE_GROUP
  • FILE_READ_OTHER
  • FILE_WRITE_OTHER
  • FILE_EXECUTE_OTHER

Note: On windows the permissions FILE_EXECUTE_OWNER, FILE_EXECUTE_GROUP and FILE_EXECUTE_OTHER cannot be set.

Return value

The function will fail with a -1 return code when it is not possible to modify the file permissions (e.g. no right, file does not exist).

Errors

A wrong number of arguments will throw an exception.

Description

Sets the permissions for a file.

Anmerkung: The understanding of file permissions is limited, which affects especially this function. On Windows, only the legacy read-only flag is set, and that only when none of the Write* flags are passed. Access control lists (ACLs) are not manipulated, which makes this function mostly useless for NTFS volumes. It may still be of use for USB sticks that use VFAT file systems. POSIX ACLs are not manipulated, either.

Assignment

File functions

Availability

CTRL