Normalize a path for cache identity without folding case. Windows spellings can differ in separators and in the optional extended-length prefix. Case is not equivalent on every volume a Windows process can reach, so the key keeps the caller's case. Use paths.os_long_path() for the p
(path: Path)
| 534 | |
| 535 | |
| 536 | def _normalize_path(path: Path) -> Path: |
| 537 | """Normalize a path for cache identity without folding case. |
| 538 | |
| 539 | Windows spellings can differ in separators and in the optional |
| 540 | extended-length prefix. Case is not equivalent on every volume a Windows |
| 541 | process can reach, so the key keeps the caller's case. Use |
| 542 | paths.os_long_path() for the path handed to the filesystem. |
| 543 | """ |
| 544 | import sys |
| 545 | if sys.platform != "win32": |
| 546 | return path |
| 547 | s = str(path) |
| 548 | if s.startswith("\\\\?\\UNC\\"): |
| 549 | s = "\\\\" + s[8:] # \\?\UNC\server\share -> \\server\share |
| 550 | elif s.startswith("\\\\?\\"): |
| 551 | s = s[4:] # strip extended-length prefix \\?\ |
| 552 | return Path(os.path.normpath(s)) |
| 553 | |
| 554 | |
| 555 | def _file_salt( |
no outgoing calls
no test coverage detected