Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

  1. /***
  2. *umask.c - set file permission mask
  3. *
  4. * Copyright (c) 1989-2001, 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. *Revision History:
  11. * 06-02-89 PHG module created
  12. * 03-16-90 GJF Made calling type _CALLTYPE1, added #include
  13. * <cruntime.h> and fixed the copyright. Also, cleaned
  14. * up the formatting a bit.
  15. * 04-05-90 GJF Added #include <io.h>.
  16. * 10-04-90 GJF New-style function declarator.
  17. * 01-17-91 GJF ANSI naming.
  18. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  19. *
  20. *******************************************************************************/
  21. #include <cruntime.h>
  22. #include <internal.h>
  23. #include <io.h>
  24. /***
  25. *int _umask(mode) - set the file mode mask
  26. *
  27. *Purpose:
  28. * Sets the file-permission mask of the current process* which
  29. * modifies the permission setting of new files created by creat,
  30. * open, or sopen.
  31. *
  32. *Entry:
  33. * int mode - new file permission mask
  34. * may contain S_IWRITE, S_IREAD, S_IWRITE | S_IREAD.
  35. * The S_IREAD bit has no effect under Win32
  36. *
  37. *Exit:
  38. * returns the previous setting of the file permission mask.
  39. *
  40. *Exceptions:
  41. *
  42. *******************************************************************************/
  43. int __cdecl _umask (
  44. int mode
  45. )
  46. {
  47. register int oldmode; /* old umask value */
  48. mode &= 0x180; /* only user read/write permitted */
  49. oldmode = _umaskval; /* remember old value */
  50. _umaskval = mode; /* set new value */
  51. return oldmode; /* return old value */
  52. }