@@ -4,7 +4,10 @@ import std/os
4
4
import ../ common
5
5
import ../ consts
6
6
7
+ type NotImplForNonNode = object of RootEffect
8
+
7
9
when defined(js):
10
+ template notImpl = raise newException(NotImplementedError, " " )
8
11
when defined(nodejs):
9
12
proc openSync(path: cstring , flags, mode: cint ): cint {.importNode(fs, openSync).}
10
13
# in fact flags, mode is optional and accepts cstring, but we don't need such variants here
@@ -17,10 +20,11 @@ when defined(js):
17
20
catchJsErrAsCode msg, closeSync(fd)
18
21
else :
19
22
const openNotImpl = " not impl for non-nodejs JS engine"
20
- proc openSync(path: cstring , flags, mode: cint ): cint {.error:
21
- openNotImpl.}
23
+ proc openSync(path: cstring , flags, mode: cint ): cint {.tags: [NotImplForNonNode].} =
22
24
# XXX: Deno.openSync returns FsFile instead of integer
23
- proc c_close(fd: cint , msg: var string ): int {.error: openNotImpl.}
25
+ notImpl
26
+ proc c_close(fd: cint ): int {.tags: [NotImplForNonNode].} = notImpl
27
+ proc c_close(fd: cint , msg: var string ): int {.tags: [NotImplForNonNode].} = notImpl
24
28
25
29
else :
26
30
let EINTR{.importc, header: " <errno.h>" .}: cint
55
59
let DEFAULT_DIR_FD{.importc, nodecl.}: cint
56
60
57
61
58
- proc open* (path: PathLike, flags: int , mode= 0o 777 , dir_fd = - 1 ): int =
62
+ proc open* (path: PathLike, flags: int , mode= 0o 777 , dir_fd = - 1 ): int {.forbids: [NotImplForNonNode]. } =
59
63
# # `dir_fd` is ignored under Windows
60
64
sys.audit(" open" , path, mode, flags)
61
65
when defined(js):
0 commit comments