home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / umask.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  1KB  |  47 lines

  1. /***
  2. *umask.c - set file permission mask
  3. *
  4. *       Copyright (c) 1989-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines _umask() - sets file permission mask of current process*
  8. *       affecting files created by creat, open, or sopen.
  9. *
  10. *******************************************************************************/
  11.  
  12. #include <cruntime.h>
  13. #include <internal.h>
  14. #include <io.h>
  15.  
  16. /***
  17. *int _umask(mode) - set the file mode mask
  18. *
  19. *Purpose:
  20. *       Sets the file-permission mask of the current process* which
  21. *       modifies the permission setting of new files created by creat,
  22. *       open, or sopen.
  23. *
  24. *Entry:
  25. *       int mode - new file permission mask
  26. *                  may contain S_IWRITE, S_IREAD, S_IWRITE | S_IREAD.
  27. *                  The S_IREAD bit has no effect under Win32
  28. *
  29. *Exit:
  30. *       returns the previous setting of the file permission mask.
  31. *
  32. *Exceptions:
  33. *
  34. *******************************************************************************/
  35.  
  36. int __cdecl _umask (
  37.         int mode
  38.         )
  39. {
  40.         register int oldmode;           /* old umask value */
  41.  
  42.         mode &= 0x180;                  /* only user read/write permitted */
  43.         oldmode = _umaskval;            /* remember old value */
  44.         _umaskval = mode;               /* set new value */
  45.         return oldmode;                 /* return old value */
  46. }
  47.