@@ -12,11 +12,7 @@ import Foundation
1212import WinSDK
1313#endif
1414
15- #if os(Windows)
16- private typealias PathImpl = UNIXPath
17- #else
1815private typealias PathImpl = UNIXPath
19- #endif
2016
2117/// Represents an absolute file system path, independently of what (or whether
2218/// anything at all) exists at that path in the file system at any given time.
@@ -453,16 +449,12 @@ private struct UNIXPath: Path {
453449 defer { fsr. deallocate ( ) }
454450
455451 let path : String = String ( cString: fsr)
456- let dir : String = path. withCString ( encodedAs: UTF16 . self) {
452+ let result : String = path. withCString ( encodedAs: UTF16 . self) {
457453 let data = UnsafeMutablePointer ( mutating: $0)
458454 PathCchRemoveFileSpec ( data, path. count)
459455 return String ( decodingCString: data, as: UTF16 . self)
460456 }
461- // Blank path represents for the current directory.
462- if dir == " " {
463- return " . "
464- }
465- return dir
457+ return result. isEmpty ? " . " : result
466458#else
467459 // FIXME: This method seems too complicated; it should be simplified,
468460 // if possible, and certainly optimized (using UTF8View).
@@ -621,12 +613,12 @@ private struct UNIXPath: Path {
621613
622614 init ( normalizingRelativePath path: String ) {
623615 let pathSeparator : Character
624- #if os(Windows)
616+ #if os(Windows)
625617 pathSeparator = " \\ "
626618 let path = path. replacingOccurrences ( of: " / " , with: " \\ " )
627- #else
619+ #else
628620 pathSeparator = " / "
629- #endif
621+ #endif
630622 precondition ( path. first != pathSeparator)
631623
632624 // FIXME: Here we should also keep track of whether anything actually has
@@ -690,7 +682,7 @@ private struct UNIXPath: Path {
690682 }
691683
692684 init ( validatingAbsolutePath path: String ) throws {
693- #if os(Windows)
685+ #if os(Windows)
694686 guard path != " " else {
695687 throw PathValidationError . invalidAbsolutePath ( path)
696688 }
@@ -702,7 +694,7 @@ private struct UNIXPath: Path {
702694 throw PathValidationError . invalidAbsolutePath ( path)
703695 }
704696 self . init ( normalizingAbsolutePath: path)
705- #else
697+ #else
706698 switch path. first {
707699 case " / " :
708700 self . init ( normalizingAbsolutePath: path)
@@ -711,11 +703,11 @@ private struct UNIXPath: Path {
711703 default :
712704 throw PathValidationError . invalidAbsolutePath ( path)
713705 }
714- #endif
706+ #endif
715707 }
716708
717709 init ( validatingRelativePath path: String ) throws {
718- #if os(Windows)
710+ #if os(Windows)
719711 guard path != " " else {
720712 self . init ( normalizingRelativePath: path)
721713 return
@@ -728,14 +720,14 @@ private struct UNIXPath: Path {
728720 throw PathValidationError . invalidRelativePath ( path)
729721 }
730722 self . init ( normalizingRelativePath: path)
731- #else
723+ #else
732724 switch path. first {
733725 case " / " , " ~ " :
734726 throw PathValidationError . invalidRelativePath ( path)
735727 default :
736728 self . init ( normalizingRelativePath: path)
737729 }
738- #endif
730+ #endif
739731 }
740732
741733 func suffix( withDot: Bool ) -> String ? {
0 commit comments