File tree 2 files changed +9
-12
lines changed 2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -114,8 +114,8 @@ extension Path {
114
114
}
115
115
116
116
public var suffix : String ? {
117
- if let ext = ` extension` {
118
- return " . \( ext ) "
117
+ if let ext = self . extension {
118
+ return " . " + ext
119
119
} else {
120
120
return nil
121
121
}
Original file line number Diff line number Diff line change 19
19
20
20
import TSCLibc
21
21
import Foundation
22
- import SystemPackage
23
22
24
23
/// Returns the "real path" corresponding to `path` by resolving any symbolic links.
25
24
public func resolveSymlinks( _ path: AbsolutePath ) -> AbsolutePath {
@@ -169,18 +168,16 @@ extension AbsolutePath {
169
168
/// Returns a path suitable for display to the user (if possible, it is made
170
169
/// to be relative to the current working directory).
171
170
public func prettyPath( cwd: AbsolutePath ? = localFileSystem. currentWorkingDirectory) -> String {
172
- guard let dir = cwd else {
173
- // No current directory, display as is.
171
+ guard let dir = cwd,
172
+ let rel = try ? relative ( to: dir) else {
173
+ // Cannot create relative path, display as is.
174
174
return self . pathString
175
175
}
176
- // FIXME: Instead of string prefix comparison we should add a proper API
177
- // to AbsolutePath to determine ancestry.
178
- if self == dir {
179
- return " . "
180
- } else if self . pathString. hasPrefix ( dir. pathString + " / " ) {
181
- return try ! " ./ " + self . relative ( to: dir) . pathString
176
+ if let first = rel. components. first,
177
+ first != " .. " {
178
+ return " ./ " + rel. pathString
182
179
} else {
183
- return self . pathString
180
+ return rel . pathString
184
181
}
185
182
}
186
183
}
You can’t perform that action at this time.
0 commit comments