Skip to content

Path: use isAbsolutePath instead of re-implenting #2294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

compnerd
Copy link
Member

This is needed to properly handle Windows paths which are not Unix-like.
Absolute paths are spelt with a prefix of \\ or .:. Rely on
Foundation to provide sufficient abstraction for determining if the path
is absolute.

@compnerd
Copy link
Member Author

@swift-ci please smoke test

This is needed to properly handle Windows paths which are not Unix-like.
Absolute paths are spelt with a prefix of `\\` or `.:`.  Rely on
Foundation to provide sufficient abstraction for determining if the path
is absolute.
@compnerd compnerd force-pushed the absolutely-unequivocally-absolute branch from 1490b8c to 9809ced Compare August 15, 2019 16:10
@compnerd
Copy link
Member Author

@swift-ci please smoke test

case "~":
throw PathValidationError.startsWithTilde(path)
default:
throw PathValidationError.invalidAbsolutePath(path)
guard (path as NSString).isAbsolutePath else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worried about the performance impact of this. Can we measure the difference or otherwise reimplement it Windows?

https://github.com/apple/swift-corelibs-foundation/blob/c5357f39dd15ae858dc72d15bbabe5435376db70/Foundation/NSPathUtilities.swift#L120-L126

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an easy/automated way to test the performance impact?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can generate Xcode project with SwiftPM perf tests enabled using: Utilities/bootstrap --generate-xcodeproj --enable-perf-tests

Then add a perf test here and run using the PerformanceTest:
You can write a test here: https://github.com/apple/swift-package-manager/tree/master/Tests/BasicPerformanceTests

See: https://github.com/apple/swift-package-manager/blob/master/Documentation/Development.md#running-the-performance-tests

@compnerd
Copy link
Member Author

I think that this is obsoleted by swiftlang/swift-tools-support-core#114

@compnerd compnerd closed this Aug 20, 2020
@compnerd compnerd deleted the absolutely-unequivocally-absolute branch August 20, 2020 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants