@@ -15,16 +15,16 @@ import var Foundation.NSLocalizedDescriptionKey
1515public protocol Path : Hashable , Codable , CustomStringConvertible {
1616 /// Underlying type, based on SwiftSystem.
1717 var filepath : FilePath { get }
18-
18+
1919 /// Public initializer from FilePath.
2020 init ( _ filepath: FilePath )
21-
21+
2222 /// Public initializer from String.
2323 init ( _ string: String )
24-
24+
2525 /// Convenience initializer that verifies that the path lexically.
2626 init ( validating path: String ) throws
27-
27+
2828 /// Normalized string representation (the normalization rules are described
2929 /// in the documentation of the initializer). This string is never empty.
3030 var pathString : String { get }
@@ -38,35 +38,35 @@ public protocol Path: Hashable, Codable, CustomStringConvertible {
3838
3939 /// Last path component (including the suffix, if any).
4040 var basename : String { get }
41-
41+
4242 /// Returns the basename without the extension.
4343 var basenameWithoutExt : String { get }
44-
44+
4545 /// Extension of the give path's basename. This follow same rules as
4646 /// suffix except that it doesn't include leading `.` character.
4747 var `extension` : String ? { get }
48-
48+
4949 /// Suffix (including leading `.` character) if any. Note that a basename
5050 /// that starts with a `.` character is not considered a suffix, nor is a
5151 /// trailing `.` character.
5252 var suffix : String ? { get }
53-
53+
5454 /// True if the path is a root directory.
5555 var isRoot : Bool { get }
56-
56+
5757 /// Returns the path with an additional literal component appended.
5858 ///
5959 /// This method accepts pseudo-path like '.' or '..', but should not contain "/".
6060 func appending( component: String ) -> Self
61-
61+
6262 /// Returns the relative path with additional literal components appended.
6363 ///
6464 /// This method should only be used in cases where the input is guaranteed
6565 /// to be a valid path component (i.e., it cannot be empty, contain a path
6666 /// separator, or be a pseudo-path like '.' or '..').
6767 func appending( components names: [ String ] ) -> Self
6868 func appending( components names: String ... ) -> Self
69-
69+
7070 /// Returns an array of strings that make up the path components of the
7171 /// path. This is the same sequence of strings as the basenames of each
7272 /// successive path component.
@@ -83,35 +83,35 @@ extension Path {
8383 }
8484 return filepath. string
8585 }
86-
86+
8787 public var root : String ? {
8888 return filepath. root? . string
8989 }
90-
90+
9191 public var dirname : String {
9292 let dirname = filepath. removingLastComponent ( ) . string
9393 if dirname. isEmpty {
9494 return " . "
9595 }
9696 return dirname
9797 }
98-
98+
9999 public var basename : String {
100100 return filepath. lastComponent? . string ?? root ?? " . "
101101 }
102-
102+
103103 public var basenameWithoutExt : String {
104104 return filepath. lastComponent? . stem ?? root ?? " . "
105105 }
106-
106+
107107 public var `extension` : String ? {
108108 guard let ext = filepath. extension,
109109 !ext. isEmpty else {
110110 return nil
111111 }
112112 return filepath. extension
113113 }
114-
114+
115115 public var suffix : String ? {
116116 if let ext = `extension` {
117117 return " . \( ext) "
@@ -123,7 +123,7 @@ extension Path {
123123 public var isRoot : Bool {
124124 return filepath. isRoot
125125 }
126-
126+
127127 public func appending( component: String ) -> Self {
128128 return Self ( filepath. appending (
129129 FilePath . Component ( stringLiteral: component) ) )
@@ -137,15 +137,15 @@ extension Path {
137137 public func appending( components names: String ... ) -> Self {
138138 appending ( components: names)
139139 }
140-
140+
141141 public var components : [ String ] {
142142 var components = filepath. components. map ( \. string)
143143 if filepath. isRelative && components. isEmpty {
144144 components. append ( " . " )
145145 }
146146 return components
147147 }
148-
148+
149149 public var description : String {
150150 return pathString
151151 }
@@ -424,7 +424,7 @@ extension FilePath {
424424 }
425425#endif
426426 }
427-
427+
428428 var isRoot : Bool {
429429 root != nil && components. isEmpty
430430 }
0 commit comments