Skip to content

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

Closed
@ahoppen

Description

@ahoppen
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).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions