Repository navigation
[windows] handle drive letters and backslashes in paths - #2280
Merged
Merged
Conversation
jeremydubreil
force-pushed
the
windows-paths
branch
3 times, most recently
from
October 27, 2026 11:29
4bda4ae to
3a61074
Compare
jeremydubreil
marked this pull request as ready for review
October 27, 2026 11:32
jeremydubreil
force-pushed
the
windows-paths
branch
from
October 28, 2026 09:55
3a61074 to
2defc80
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows, infer cannot take paths apart, which makes it loop forever and run out of memory as soon as it normalizes a path such as
C:/infer/...:Filename.partsnever terminates on a path with a drive letter, asFilename.dirname "C:/"is"C:/"again, nor on a path rooted at a backslash, asFilename.dirname "\\"is"\\"again.getcwdanswer with\as separator, andUnix.realpatheven answers in the extended-length form\?\C:\dir\file(\?\UNC\server\share\filefor a network path). infer builds its paths with^/and compares them as strings, so it needs a single form.This pull request adds four helpers to
Utils:of_win32_pathbrings a Windows path back to theC:/dir/fileform;split_drivesplits off the drive letter on Windows, so thatFilename.partsonly sees the rest of the path;path_partsandof_path_partssplit and join paths with the drive letter kept in front of the root part, and always join with/, asFilename.dir_sepis a backslash on Windows.normalize_path_from,flatten_pathandfilename_to_relativeuse them, andrealpathreturns paths in theC:/dir/fileform on Windows. Inflatten_path, the drive letter ofC:/is kept without the:, which a file name cannot contain.On Linux and macOS,
split_drivereturns the path unchanged, so these functions give the same results as before.