Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
[John Fairhurst](https://github.com/johnfairh)
* Improve reporting of `sourcekitdInProc` loading failures.
[Daniel Sunarjo](https://github.com/sunarjodaniel)
* Avoid `getcwd` in `absolutePathRepresentation()` for absolute paths.
[Brett Best](https://github.com/Brett-Best)

#### Bug Fixes

Expand Down
5 changes: 4 additions & 1 deletion Source/SourceKittenFramework/String+SourceKitten.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,12 @@ extension NSString {
Returns self represented as an absolute path.

- parameter rootDirectory: Absolute parent path if not already an absolute path.
Comment thread
johnfairh marked this conversation as resolved.
Uses the current directory by default, evaluated only
if this path is relative.
*/
public func absolutePathRepresentation(rootDirectory: String = FileManager.default.currentDirectoryPath) -> String {
public func absolutePathRepresentation(rootDirectory: String? = nil) -> String {
if isAbsolutePath { return expandingTildeInPath }
let rootDirectory = rootDirectory ?? FileManager.default.currentDirectoryPath
#if os(Linux)
return NSURL(fileURLWithPath: NSURL.fileURL(withPathComponents: [rootDirectory, bridge()])!.path).standardizingPath!.path
#else
Expand Down
Loading