FileSys::Chmod( FilePerm, Error * )
Modify the file mode bits of the file specified by the path
protected FileSys
member.
Virtual? |
Yes |
|
Class |
||
Arguments |
|
permissions to change the file, either |
|
returned error status |
|
Returns |
|
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 |
---|---|---|
|
|
leave file read-only. |
|
|
allow read and write operations |
Example
To use Chmod()
to create a
configuration file and set its permissions to read-only:
FileSys *f = FileSys::Create( FST_ATEXT ); Error e; f->Set( "c:\\configfile.txt" ); f->Chmod( FPM_RO, &e );
To reimplement Chmod()
under UNIX:
void FileSysDemo::Chmod( FilePerm perms, Error *e ) { int bits = IsExec() ? PERM_0777 : PERM_0666; if ( perms == FPM_RO ) bits &= ~PERM_0222; if ( chmod( Name(), bits & ~myumask ) < 0 ) e->Sys( "chmod", Name() ); if ( DEBUG ) printf( "Debug (Chmod): %s\n", Name() ); }