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

URL.withUnsafeFileSystemRepresentation drops trailing backslash even if it is significant on Windows #976

Open
ahoppen opened this issue Oct 10, 2024 · 0 comments
Assignees

Comments

@ahoppen
Copy link
Member

ahoppen commented Oct 10, 2024

let url = URL(fileURLWithPath: #"C:\"#)
url.withUnsafeFileSystemRepresentation { filePath in
    print(String(cString: filePath! , encoding: .utf8))
}

prints C:. Dropping the trailing backslash is problematic here because C:\ is considered a root directory in Windows but C: is not (see table of examples in https://learn.microsoft.com/en-us/windows/win32/api/pathcch/nf-pathcch-pathcchisroot).

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

No branches or pull requests

2 participants