Get the extended-length version of a path (Windows). On Windows, by default, the maximum length of a path (MAX_PATH) is 260 characters, and operations on paths longer than that fail. But it is possible to overcome this by converting the path to "extended-length" form before performi
(path: Path)
| 129 | |
| 130 | |
| 131 | def ensure_extended_length_path(path: Path) -> Path: |
| 132 | class="st">"""Get the extended-length version of a path (Windows). |
| 133 | |
| 134 | On Windows, by default, the maximum length of a path (MAX_PATH) is 260 |
| 135 | characters, and operations on paths longer than that fail. But it is possible |
| 136 | to overcome this by converting the path to class="st">"extended-length" form before |
| 137 | performing the operation: |
| 138 | https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-fileclass="cm">#maximum-path-length-limitation |
| 139 | |
| 140 | On Windows, this function returns the extended-length absolute version of path. |
| 141 | On other platforms it returns path unchanged. |
| 142 | class="st">""" |
| 143 | if sys.platform.startswith(class="st">"win32"): |
| 144 | path = path.resolve() |
| 145 | path = Path(get_extended_length_path_str(str(path))) |
| 146 | return path |
| 147 | |
| 148 | |
| 149 | def get_extended_length_path_str(path: str) -> str: |
no test coverage detected