Follow upstream changes -- rest
[git-darcs-import.git] / src / umask.c
blobdccfb7f7c96acafefbfe863546286439b6d92454
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <stdlib.h>
4 #include <errno.h>
5 #include "umask.h"
7 int
8 set_umask(char *mask_string)
10 #ifndef WIN32
11 int rc;
12 unsigned mask;
13 char *end;
15 mask = strtoul(mask_string, &end, 8);
16 if(!end || *end != '\0') {
17 errno = EINVAL;
18 return -1;
21 rc = umask(mask);
22 return rc;
23 #else
24 /* umask() has no useful meaning on win32. */
25 return 0;
26 #endif /* #ifndef WIN32 ... else ... */
29 int
30 reset_umask(int old_mask)
32 umask(old_mask);
33 return 1;