Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

C/C++ API Documentation | 2026.1

# FileSys::Chmod( FilePerm, Error * )

Modify the file mode bits of the file specified by the `path` protected `FileSys` member.

Virtual? | Yes |
Class | `FileSys` |
Arguments | `FilePerm perms` | permissions to change the file, either `FPM_RO` (read only) or `FPM_RW` (read/write)
| `Error *error` | returned error status
Returns | `void` |

## Notes

This method is called to make a client file writable (`FPM_RW`) when it is opened for `edit`, or to change it to read-only (`FPM_RO`) after a `submit`.

A `FilePerm` is an `enum` taking one of the following values:

Argument | Value | Meaning
--- | --- | ---
`FPM_RO` | `0x00` | leave file read-only.
`FPM_RW` | `0x01` | allow read and write operations

## Example

To use `Chmod()` to create a configuration file and set its permissions to read-only:

Copy

    FileSys *f = FileSys::Create( FST_ATEXT );
    Error e;

    f-&gt;Set( "c:\\configfile.txt" );
    f-&gt;Chmod( FPM_RO, &amp;e );

To reimplement `Chmod()` under UNIX:

Copy

    void FileSysDemo::Chmod( FilePerm perms, Error *e )
    {
        int bits = IsExec() ? PERM_0777 : PERM_0666;

        if ( perms == FPM_RO )
            bits &amp;= ~PERM_0222;

        if ( chmod( Name(), bits &amp; ~myumask ) &lt; 0 )
            e-&gt;Sys( "chmod", Name() );

        if ( DEBUG )
            printf( "Debug (Chmod): %s\n", Name() );
    }

Your search for returned results