File tree Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -276,8 +276,28 @@ public struct AbsolutePath: Path {
276
276
if let rootPath = localFileSystem. currentWorkingDirectory? . root {
277
277
return AbsolutePath ( rootPath)
278
278
} else {
279
- return AbsolutePath ( FilePath . _root)
279
+ #if !os(Windows)
280
+ return AbsolutePath ( " / " )
281
+ #else
282
+ if let drive = ProcessEnv . vars [ " SystemDrive " ] ?? ProcessEnv . vars [ " HomeDrive " ] {
283
+ return AbsolutePath ( drive + " \\ " )
284
+ } else {
285
+ fatalError ( " cannot determine the drive " )
286
+ }
287
+ #endif
288
+ }
289
+ }
290
+
291
+ public static func withPOSIX( path: String ) -> AbsolutePath {
292
+ #if os(Windows)
293
+ var filepath = FilePath ( path)
294
+ if !filepath. isAbsolute {
295
+ filepath. root = root. filepath. root
280
296
}
297
+ return AbsolutePath ( filepath)
298
+ #else
299
+ return AbsolutePath ( path)
300
+ #endif
281
301
}
282
302
}
283
303
@@ -408,14 +428,6 @@ extension PathValidationError: CustomNSError {
408
428
}
409
429
410
430
extension FilePath {
411
- static var _root : FilePath {
412
- #if os(Windows)
413
- return FilePath ( " \\ " )
414
- #else
415
- return FilePath ( " / " )
416
- #endif
417
- }
418
-
419
431
init ( validatingAbsolutePath path: String ) throws {
420
432
self . init ( path)
421
433
guard self . isAbsolute else {
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ class TemporaryFileTests: XCTestCase {
137
137
XCTAssertFalse ( localFileSystem. isDirectory ( pathTwo) )
138
138
}
139
139
140
+ #if !os(Windows)
140
141
/// Check that the temporary file doesn't leak file descriptors.
141
142
func testLeaks( ) throws {
142
143
// We check this by testing that we get back the same FD after a
@@ -150,4 +151,5 @@ class TemporaryFileTests: XCTestCase {
150
151
let endFD = try Int ( withTemporaryFile { return $0. fileHandle. fileDescriptor } )
151
152
XCTAssertEqual ( initialFD, endFD)
152
153
}
154
+ #endif
153
155
}
You can’t perform that action at this time.
0 commit comments