Skip to content

Conversation

daveinglis
Copy link

  • This keeps any UNC long file or device prefix (\?\ and \.) out of URL that were relative and then resolved to absolute urls.

@daveinglis
Copy link
Author

@swift-ci test

@jakepetroules
Copy link
Contributor

Could we add tests for this?

@daveinglis
Copy link
Author

test added

@daveinglis
Copy link
Author

@swift-ci test

@daveinglis daveinglis force-pushed the strip_unc_lf_preifx branch 2 times, most recently from a02ed6f to 82bf6bf Compare September 18, 2025 15:39
- This keeps any UNC long file or device prefix (\\?\) out of
  URL that were relative and then resolved to absolute urls.
@daveinglis
Copy link
Author

@swift-ci test

@daveinglis
Copy link
Author

@swift-ci test windows

@daveinglis
Copy link
Author

@swift-ci test linux

@daveinglis
Copy link
Author

@swift-ci test


// Get original directory for restoration
var originalBuffer = [CChar](repeating: 0, count: Int(MAX_PATH))
guard _NS_getcwd(&originalBuffer, originalBuffer.count) != nil else {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the user level API that this is supposed to affect? _NS_getcwd is clearly for internal use only.

Copy link
Author

Choose a reason for hiding this comment

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

it looks like NSURL::fileSystemRepresentation with a relative path would use it to make it absolute, could be other places too but it was that test that was failing due to the long path prefix

Copy link
Contributor

@parkera parkera left a comment

Choose a reason for hiding this comment

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

Let's identify the user level API this is supposed to change - this CF API should not be used directly, and in any case is all eventually being replaced by Swift code.

@daveinglis
Copy link
Author

So the swift API that would be affected was going to have this as well (FileManager.currentDirectoryPath - see swiftlang/swift-foundation#1479) but that PR also cause the NSURL test to fail so it was reverted (swiftlang/swift-foundation#1512) until a fix could be put in place (this).

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.

3 participants