Syntax
#include <io.h> #include <sys\stat.h> int umask(int pmode);Description
umask sets the file permission mask of the environment for the currently running process to the mode specified by pmode. The file permission mask modifies the permission setting of new files created by creat, open, or _sopen.
If a bit in the mask is 1, the corresponding bit in the requested permission value of the file is set to 0 (disallowed). If a bit in the mask is 0, the corresponding bit is left unchanged. The permission setting for a new file is not set until the file is closed for the first time.
The possible values for pmode are defined in <sys\stat.h>: compact break=fit.
Value
If the write bit is set in the mask, any new files will be read-only. You cannot give write-only permission, meaning that setting the read bit has no effect.
umask returns the previous value of pmode. A return value of -1 indicates that the value used for pmode was not valid, and errno is set to EINVAL.
This example sets the permission mask to create a write-only file.
#include <sys\stat.h>#include <io.h> #include <stdio.h> int main(void) { int oldMask; oldMask = umask(S_IWRITE); printf("\nDefault system startup mask is %d.\n", oldMask); return 0; /**************************************************************************** The output should be: Default system startup mask is 0. ****************************************************************************/ }Related Information