Skip to content

Commit 84c218f

Browse files
committed
feat(Lib/os): umask
1 parent ac405b0 commit 84c218f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/pylib/Lib/os_impl/posix_like.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import ./posix_like/[
44
fdopen, open_close, lseek, seek_consts, truncate, stat, scandirImpl, mkrmdir, unlink,
5-
rename, isatty, links, utime, get_id, chmods
5+
rename, isatty, links, utime, get_id, chmods, umaskImpl
66
]
77

88
export seek_consts except toCSEEK
99
export stat except statAttr
1010
export
1111
fdopen, open_close, lseek, truncate, scandirImpl, mkrmdir, unlink,
12-
rename, isatty, links, utime, get_id, chmods
12+
rename, isatty, links, utime, get_id, chmods, umaskImpl
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
when defined(windows):
3+
proc umask(mode: cint): cint {.importc: "_umask", header: "<sys/stat.h>".}
4+
else:
5+
import std/posix
6+
7+
import ../common # raiseErrno
8+
9+
proc umask*(mode: int): int{.discardable.} =
10+
result =
11+
when defined(windows): int umask(mode.cint)
12+
else: int posix.umask(mode.Mode)
13+
if result < 0:
14+
raiseErrno()

0 commit comments

Comments
 (0)