Skip to content
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

FoundationEssentials: add withNTPathRepresentation #531

Merged
merged 7 commits into from
Apr 9, 2024

Conversation

compnerd
Copy link
Collaborator

@compnerd compnerd commented Apr 5, 2024

This helper allows us to convert paths to the NT path representation. The NT Path representation is important for internal usage as it allows us to bypass the MAX_PATH (261) limit for Win32 APIs. In order to do this, we simply escape the string with the NT prefix (\\?\) which requires that the path is normalised (uses \ rather than /) and generally should be an absolute path. Using the NT path allows us to use the fully supported 32k character path length of the NT kernel.

This helper allows us to convert paths to the NT path representation.
The NT Path representation is important for internal usage as it allows
us to bypass the `MAX_PATH` (261) limit for Win32 APIs. In order to do
this, we simply escape the string with the NT prefix (`\\?\`) which
requires that the path is normalised (uses `\` rather than `/`) and
generally should be an absolute path. Using the NT path allows us to use
the fully supported 32k character path length of the NT kernel.
Co-authored-by: Alexander Smarus <[email protected]>
@compnerd
Copy link
Collaborator Author

compnerd commented Apr 8, 2024

@swift-ci please test

@compnerd
Copy link
Collaborator Author

compnerd commented Apr 8, 2024

@swift-ci please test

@compnerd
Copy link
Collaborator Author

compnerd commented Apr 9, 2024

@jmschonfeld I think that this is ready to go - with this in, I think that #527 should be possible to merge. That will allow me to start making more progress towards FileManager support on Windows.

@jckarter
Copy link
Member

jckarter commented Apr 9, 2024

Should this API also handle device names (so that e.g. #"C:\some\path\aux.txt"# resolves to #"\\?\AUX"#, or at least raises an error of some kind so that APIs don't inadvertently create a file that can't be opened by a Win32 path)?

@compnerd
Copy link
Collaborator Author

compnerd commented Apr 9, 2024

Should this API also handle device names (so that e.g. #"C:\some\path\aux.txt"# resolves to #"\\?\AUX"#, or at least raises an error of some kind so that APIs don't inadvertently create a file that can't be opened by a Win32 path)?

I do like this suggestion, however, I do wonder if we need to implement that immediately. Right now the build is entirely overwhelming due to the number of errors and so testing is also impossible. Getting enough of the skeleton in place would allow us to ensure that we get the nuances like this correct.

@compnerd
Copy link
Collaborator Author

compnerd commented Apr 9, 2024

@swift-ci please test

@compnerd
Copy link
Collaborator Author

compnerd commented Apr 9, 2024

@swift-ci please test

@compnerd
Copy link
Collaborator Author

compnerd commented Apr 9, 2024

@swift-ci please test

@compnerd compnerd merged commit 3a7c84e into apple:main Apr 9, 2024
2 checks passed
@compnerd compnerd deleted the ntpath branch April 9, 2024 21:23
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.

None yet

4 participants