@@ -46,38 +46,38 @@ public struct Path {
4646 /// Create a Path by joining multiple path components together
4747 #if !swift(>=3.0)
4848 public init < S : Collection where S. Generator. Element == String > ( components: S ) {
49- if components. isEmpty {
50- path = " . "
51- } else if components. first == Path . separator && components. count > 1 {
52- let p = components. joinWithSeparator ( Path . separator)
53- #if os(Linux)
54- let index = p. startIndex. distanceTo ( p. startIndex. successor ( ) )
55- path = NSString ( string: p) . substringFromIndex ( index)
56- #else
57- path = p. substringFromIndex ( p. startIndex. successor ( ) )
58- #endif
59-
60- } else {
61- path = components. joinWithSeparator ( Path . separator)
62- }
63- }
64- #else
65- public init < S : Collection where S. Iterator. Element == String > ( components: S ) {
6649 if components. isEmpty {
6750 path = " . "
6851 } else if components. first == Path . separator && components. count > 1 {
69- let p = components. joined ( separator : Path . separator)
52+ let p = components. joinWithSeparator ( Path . separator)
7053 #if os(Linux)
7154 let index = p. startIndex. distanceTo ( p. startIndex. successor ( ) )
7255 path = NSString ( string: p) . substringFromIndex ( index)
7356 #else
74- path = p. substring ( from : p. startIndex. successor ( ) )
57+ path = p. substringFromIndex ( p. startIndex. successor ( ) )
7558 #endif
7659
7760 } else {
78- path = components. joined ( separator : Path . separator)
61+ path = components. joinWithSeparator ( Path . separator)
7962 }
8063 }
64+ #else
65+ public init < S : Collection where S. Iterator. Element == String > ( components: S ) {
66+ if components. isEmpty {
67+ path = " . "
68+ } else if components. first == Path . separator && components. count > 1 {
69+ let p = components. joined ( separator: Path . separator)
70+ #if os(Linux)
71+ let index = p. startIndex. distanceTo ( p. startIndex. successor ( ) )
72+ path = NSString ( string: p) . substringFromIndex ( index)
73+ #else
74+ path = p. substring ( from: p. startIndex. successor ( ) )
75+ #endif
76+
77+ } else {
78+ path = components. joined ( separator: Path . separator)
79+ }
80+ }
8181
8282 #endif
8383}
@@ -158,11 +158,11 @@ extension Path {
158158 /// representation.
159159 ///
160160 public func normalize( ) -> Path {
161- #if !swift(>=3.0)
162- return Path ( NSString ( string: self . path) . stringByStandardizingPath)
163- #else
164- return Path ( NSString ( string: self . path) . standardizingPath)
165- #endif
161+ #if !swift(>=3.0)
162+ return Path ( NSString ( string: self . path) . stringByStandardizingPath)
163+ #else
164+ return Path ( NSString ( string: self . path) . standardizingPath)
165+ #endif
166166 }
167167
168168 /// De-normalizes the path, by replacing the current user home directory with "~".
@@ -176,10 +176,10 @@ extension Path {
176176 return self
177177 #else
178178 #if !swift(>=3.0)
179- return Path ( NSString ( string: self . path) . stringByAbbreviatingWithTildeInPath)
179+ return Path ( NSString ( string: self . path) . stringByAbbreviatingWithTildeInPath)
180180 #else
181- return Path ( NSString ( string: self . path) . abbreviatingWithTildeInPath)
182- #endif
181+ return Path ( NSString ( string: self . path) . abbreviatingWithTildeInPath)
182+ #endif
183183 #endif
184184 }
185185
@@ -222,9 +222,9 @@ extension Path {
222222 ///
223223 public var lastComponentWithoutExtension : String {
224224 #if !swift(>=3.0)
225- return NSString ( string: lastComponent) . stringByDeletingPathExtension
225+ return NSString ( string: lastComponent) . stringByDeletingPathExtension
226226 #else
227- return NSString ( string: lastComponent) . deletingPathExtension
227+ return NSString ( string: lastComponent) . deletingPathExtension
228228 #endif
229229 }
230230
@@ -262,7 +262,7 @@ extension Path {
262262 ///
263263 public var exists : Bool {
264264 #if !swift(>=3.0)
265- return Path . fileManager. fileExistsAtPath ( self . path)
265+ return Path . fileManager. fileExistsAtPath ( self . path)
266266 #else
267267 return Path . fileManager. fileExists ( atPath: self . path)
268268 #endif
@@ -277,9 +277,9 @@ extension Path {
277277 public var isDirectory : Bool {
278278 var directory = ObjCBool ( false )
279279 #if !swift(>=3.0)
280- guard Path . fileManager. fileExistsAtPath ( normalize ( ) . path, isDirectory: & directory) else {
280+ guard Path . fileManager. fileExistsAtPath ( normalize ( ) . path, isDirectory: & directory) else {
281281 return false
282- }
282+ }
283283 #else
284284 guard Path . fileManager. fileExists ( atPath: normalize ( ) . path, isDirectory: & directory) else {
285285 return false
@@ -299,7 +299,7 @@ extension Path {
299299 var directory = ObjCBool ( false )
300300 #if !swift(>=3.0)
301301 guard Path . fileManager. fileExistsAtPath ( normalize ( ) . path, isDirectory: & directory) else {
302- return false
302+ return false
303303 }
304304 #else
305305 guard Path . fileManager. fileExists ( atPath: normalize ( ) . path, isDirectory: & directory) else {
@@ -552,9 +552,9 @@ extension Path {
552552 ///
553553 public static func uniqueTemporary( ) throws -> Path {
554554 #if !swift(>=3.0)
555- let path = try processUniqueTemporary ( ) + NSUUID( ) . UUIDString
555+ let path = try processUniqueTemporary ( ) + NSUUID( ) . UUIDString
556556 #else
557- let path = try processUniqueTemporary ( ) + NSUUID( ) . uuidString
557+ let path = try processUniqueTemporary ( ) + NSUUID( ) . uuidString
558558 #endif
559559 try path. mkdir ( )
560560 return path
@@ -582,9 +582,9 @@ extension Path {
582582 ///
583583 public func read( encoding: NSStringEncoding = NSUTF8StringEncoding) throws -> String {
584584 #if !swift(>=3.0)
585- return try NSString ( contentsOfFile: path, encoding: encoding) . substringFromIndex ( 0 ) as String
585+ return try NSString ( contentsOfFile: path, encoding: encoding) . substringFromIndex ( 0 ) as String
586586 #else
587- return try NSString ( contentsOfFile: path, encoding: encoding) . substring ( from: 0 ) as String
587+ return try NSString ( contentsOfFile: path, encoding: encoding) . substring ( from: 0 ) as String
588588 #endif
589589 }
590590
@@ -617,9 +617,9 @@ extension Path {
617617 ///
618618 public func write( string: String , encoding: NSStringEncoding = NSUTF8StringEncoding) throws {
619619 #if !swift(>=3.0)
620- try NSString ( string: string) . writeToFile ( normalize ( ) . path, atomically: true , encoding: encoding)
620+ try NSString ( string: string) . writeToFile ( normalize ( ) . path, atomically: true , encoding: encoding)
621621 #else
622- try NSString ( string: string) . write ( toFile: normalize ( ) . path, atomically: true , encoding: encoding)
622+ try NSString ( string: string) . write ( toFile: normalize ( ) . path, atomically: true , encoding: encoding)
623623 #endif
624624 }
625625}
@@ -642,12 +642,12 @@ extension Path {
642642 ///
643643 public func children( ) throws -> [ Path ] {
644644 #if !swift(>=3.0)
645- return try Path . fileManager. contentsOfDirectoryAtPath ( path) . map {
645+ return try Path . fileManager. contentsOfDirectoryAtPath ( path) . map {
646646 self + Path( $0)
647647 }
648648 #else
649- return try Path . fileManager. contentsOfDirectory ( atPath: path) . map {
650- self + Path( $0)
649+ return try Path . fileManager. contentsOfDirectory ( atPath: path) . map {
650+ self + Path( $0)
651651 }
652652 #endif
653653
@@ -660,13 +660,13 @@ extension Path {
660660 ///
661661 public func recursiveChildren( ) throws -> [ Path ] {
662662 #if !swift(>=3.0)
663- return try Path . fileManager. subpathsOfDirectoryAtPath ( path) . map {
663+ return try Path . fileManager. subpathsOfDirectoryAtPath ( path) . map {
664664 self + Path( $0)
665- }
665+ }
666666 #else
667- return try Path . fileManager. subpathsOfDirectory ( atPath: path) . map {
668- self + Path( $0)
669- }
667+ return try Path . fileManager. subpathsOfDirectory ( atPath: path) . map {
668+ self + Path( $0)
669+ }
670670 #endif
671671 }
672672}
@@ -691,20 +691,20 @@ extension Path {
691691 let matchc = gt. gl_matchc
692692 #endif
693693 #if !swift(>=3.0)
694- return ( 0 ..< Int ( matchc) ) . flatMap { index in
694+ return ( 0 ..< Int ( matchc) ) . flatMap { index in
695695 if let path = String . fromCString ( gt. gl_pathv [ index] ) {
696- return Path ( path)
696+ return Path ( path)
697697 }
698698
699699 return nil
700- }
700+ }
701701 #else
702702 return ( 0 ..< Int ( matchc) ) . flatMap { index in
703703 if let path = String ( validatingUTF8: gt. gl_pathv [ index] ) {
704- return Path ( path)
705- }
704+ return Path ( path)
705+ }
706706
707- return nil
707+ return nil
708708 }
709709 #endif
710710 }
@@ -759,11 +759,11 @@ extension Path : Sequence {
759759 ///
760760 #if !swift(>=3.0)
761761 public func generate( ) -> DirectoryEnumerator {
762- return DirectoryEnumerator ( path: self )
762+ return DirectoryEnumerator ( path: self )
763763 }
764764 #else
765765 public func makeIterator( ) -> DirectoryEnumerator {
766- return DirectoryEnumerator ( path: self )
766+ return DirectoryEnumerator ( path: self )
767767 }
768768 #endif
769769}
0 commit comments