Skip to content

Commit

Permalink
Capitalize drive letter on windows path conversion
Browse files Browse the repository at this point in the history
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
  • Loading branch information
amorphousWaste authored and Jawabiscuit committed Sep 15, 2023
1 parent a9d4de5 commit 7057632
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/rez/utils/sourcecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@ def __init__(self, source=None, func=None, filepath=None,

self.filepath = filepath
if self.filepath:
self.filepath = _drive_start_regex.sub("/\\1/", filepath)
self.filepath = self.filepath.replace("\\", '/')
drive_letter_match = _drive_start_regex.match(filepath)
# If converting the drive letter to posix, capitalize the drive
# letter as per cygwin behavior.
if drive_letter_match:
self.filepath = _drive_start_regex.sub(
drive_letter_match.expand("/\\1/").upper(), filepath
)
self.filepath = self.filepath.replace("\\", "/")

self.eval_as_function = eval_as_function
self.package = None
Expand Down
8 changes: 7 additions & 1 deletion src/rezplugins/shell/_utils/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ def _repl(m):
path = _env_var_regex.sub(_repl, path)

# C:\ ==> /C/
path = _drive_start_regex.sub("/\\1/", path)
drive_letter_match = _drive_start_regex.match(path)
# If converting the drive letter to posix, capitalize the drive
# letter as per cygwin behavior.
if drive_letter_match:
path = _drive_start_regex.sub(
drive_letter_match.expand("/\\1/").upper(), path
)

# backslash ==> fwdslash
path = path.replace('\\', '/')
Expand Down

0 comments on commit 7057632

Please sign in to comment.