Skip to content

Commit 7b892e5

Browse files
committed
Fix bugs
1 parent c13a770 commit 7b892e5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Sources/TSCBasic/Path.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,18 +449,20 @@ private struct UNIXPath: Path {
449449

450450
var dirname: String {
451451
#if os(Windows)
452-
guard string != "" else {
453-
return "."
454-
}
455452
let fsr: UnsafePointer<Int8> = string.fileSystemRepresentation
456453
defer { fsr.deallocate() }
457454

458455
let path: String = String(cString: fsr)
459-
return path.withCString(encodedAs: UTF16.self) {
456+
let dir: String = path.withCString(encodedAs: UTF16.self) {
460457
let data = UnsafeMutaßlePointer(mutating: $0)
461458
PathCchRemoveFileSpec(data, path.count)
462459
return String(decodingCString: data, as: UTF16.self)
463460
}
461+
// These two expressions represent for the current directory.
462+
if dir == "\\" || dir == "" {
463+
return "."
464+
}
465+
return dir
464466
#else
465467
// FIXME: This method seems too complicated; it should be simplified,
466468
// if possible, and certainly optimized (using UTF8View).

0 commit comments

Comments
 (0)