File tree Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -114,8 +114,8 @@ extension Path {
114114 }
115115
116116 public var suffix : String ? {
117- if let ext = ` extension` {
118- return " . \( ext ) "
117+ if let ext = self . extension {
118+ return " . " + ext
119119 } else {
120120 return nil
121121 }
Original file line number Diff line number Diff line change 1919
2020import TSCLibc
2121import Foundation
22- import SystemPackage
2322
2423/// Returns the "real path" corresponding to `path` by resolving any symbolic links.
2524public func resolveSymlinks( _ path: AbsolutePath ) -> AbsolutePath {
@@ -169,18 +168,16 @@ extension AbsolutePath {
169168 /// Returns a path suitable for display to the user (if possible, it is made
170169 /// to be relative to the current working directory).
171170 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.
174174 return self . pathString
175175 }
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
182179 } else {
183- return self . pathString
180+ return rel . pathString
184181 }
185182 }
186183}
You can’t perform that action at this time.
0 commit comments