Skip to content

Commit 2b26c30

Browse files
committed
refine(win): dedup IO_REPARSE_TAG_SYMLINK,IO_REPARSE_TAG_MOUNT_POINT
1 parent e979be2 commit 2b26c30

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/pylib/Lib/os_impl/posix_like/links.nim

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ when InJs:
2626
)
2727
else:
2828
when defined(windows):
29-
import std/winlean
29+
import ../util/mywinlean
3030
type
3131
LPVOID = pointer
3232
LPDWORD = ptr DWORD
@@ -158,9 +158,6 @@ else:
158158
result.add chr(0xFFFD shr 6 and ones(6) or 0b10_0000_00)
159159
result.add chr(0xFFFD and ones(6) or 0b10_0000_00)
160160
161-
const
162-
IO_REPARSE_TAG_SYMLINK = ULONG 0xA000000C
163-
IO_REPARSE_TAG_MOUNT_POINT = ULONG 0xA0000003
164161
# _Py_MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 )
165162
166163
const REPARSE_BUFSIZE = 16 * 1024

src/pylib/Lib/os_impl/util/mywinlean.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,13 @@ const
146146

147147
GENERIC_READ* = cast[DWORD](0x80000000)
148148
149-
IO_REPARSE_TAG_SYMLINK* = 0xA000000C
149+
IO_REPARSE_TAG_SYMLINK* = cast[DWORD](0xA000000C)
150150
151151
FILE_READ_ATTRIBUTES* = 128
152152
153+
FILE_ATTRIBUTE_REPARSE_POINT* = cast[DWORD](0x400)
154+
IO_REPARSE_TAG_MOUNT_POINT* = cast[DWORD](0xA0000003)
155+
153156
let
154157
INVALID_FILE_ATTRIBUTES*{.importc, header: "<WinNT.h>".}: DWORD
155158

src/pylib/Lib/stat_impl/consts.nim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ definition are defined on these versions of macOS.]#
114114
#const stat_filemode_doc = "Convert a file's mode to a string of the form '-rwxrwxrwx'"
115115

116116
when DW:
117+
import ../os_impl/util/mywinlean
118+
template exp(name) =
119+
const name* = int(mywinlean.name)
117120
template impExp(name) =
118121
let
119122
`c name`{.importc: astToStr(name), header: WINNT_H.}: cint
@@ -138,6 +141,6 @@ when DW:
138141
impExp(FILE_ATTRIBUTE_TEMPORARY)
139142
impExp(FILE_ATTRIBUTE_VIRTUAL)
140143

141-
impExp(IO_REPARSE_TAG_SYMLINK)
142-
impExp(IO_REPARSE_TAG_MOUNT_POINT)
144+
exp(IO_REPARSE_TAG_SYMLINK)
145+
exp(IO_REPARSE_TAG_MOUNT_POINT)
143146
#impExp(IO_REPARSE_TAG_APPEXECLINK)

0 commit comments

Comments
 (0)