File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -29,8 +29,8 @@ internal func getTemporaryDirectory() throws -> FilePath {
29
29
capacity: Int ( MAX_PATH) + 1 ) {
30
30
buffer in
31
31
32
- let count = GetTempPath2W ( DWORD ( buffer. count) , buffer. baseAddress)
33
- if count == 0 {
32
+ guard let count = GetTempPath2W ( DWORD ( buffer. count) , buffer. baseAddress) ,
33
+ count != 0 else {
34
34
throw Errno ( windowsError: GetLastError ( ) )
35
35
}
36
36
@@ -116,7 +116,7 @@ internal func getTemporaryDirectory() throws -> FilePath {
116
116
while true {
117
117
let path : FilePath ? = withUnsafeTemporaryAllocation (
118
118
of: CInterop . PlatformChar. self,
119
- capacity: 1024 ) { buffer in
119
+ capacity: capacity ) { buffer in
120
120
let len = system_confstr ( SYSTEM_CS_DARWIN_USER_TEMP_DIR,
121
121
buffer. baseAddress!,
122
122
buffer. count)
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ private var contextualMockingEnabled: Bool {
110
110
extension MockingDriver {
111
111
internal static var enabled : Bool { mockingEnabled }
112
112
113
- internal static var forceWindowsPaths : Optional < Bool > {
113
+ internal static var forceWindowsPaths : Bool ? {
114
114
currentMockingDriver? . forceWindowsSyntaxForPaths
115
115
}
116
116
}
@@ -128,7 +128,7 @@ internal var mockingEnabled: Bool {
128
128
}
129
129
130
130
@inline ( __always)
131
- internal var forceWindowsPaths : Optional < Bool > {
131
+ internal var forceWindowsPaths : Bool ? {
132
132
#if !ENABLE_MOCKING
133
133
return false
134
134
#else
Original file line number Diff line number Diff line change @@ -160,14 +160,25 @@ internal func mkdir(
160
160
_ path: UnsafePointer < CInterop . PlatformChar > ,
161
161
_ mode: CInterop . Mode
162
162
) -> CInt {
163
- return _wmkdir ( path)
163
+ // TODO: Read/write permissions (these need mapping to a SECURITY_DESCRIPTOR).
164
+ if !CreateDirectoryW( path, nil ) {
165
+ ucrt. _set_errno ( mapWindowsErrorToErrno ( GetLastError ( ) ) )
166
+ return - 1
167
+ }
168
+
169
+ return 0 ;
164
170
}
165
171
166
172
@inline ( __always)
167
173
internal func rmdir(
168
174
_ path: UnsafePointer < CInterop . PlatformChar >
169
175
) -> CInt {
170
- return _wrmdir ( path)
176
+ if !RemoveDirectoryW( path) {
177
+ ucrt. _set_errno ( mapWindowsErrorToErrno ( GetLastError ( ) ) )
178
+ return - 1
179
+ }
180
+
181
+ return 0 ;
171
182
}
172
183
173
184
@usableFromInline
You can’t perform that action at this time.
0 commit comments