MCPcopy
hub / github.com/pytest-dev/pytest / ensure_extended_length_path

Function ensure_extended_length_path

src/_pytest/pathlib.py:131–146  ·  src/_pytest/pathlib.py::ensure_extended_length_path

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)

Source from the content-addressed store, hash-verified

129
130
131def 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
149def get_extended_length_path_str(path: str) -> str:

Callers 2

rm_rfFunction · 0.85

Calls 1

Tested by

no test coverage detected