Skip to content

Commit

Permalink
Fix UNC bug in _win32_longpath.
Browse files Browse the repository at this point in the history
  • Loading branch information
bilderbuchi committed Oct 14, 2020
1 parent 39792e9 commit 878a988
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pytest_datadir/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def _win32_longpath(path):
# (See https://docs.microsoft.com/pt-br/windows/desktop/FileIO/naming-a-file)
normalized = os.path.normpath(path)
if not normalized.startswith("\\\\?\\"):
normalized = '\\\\?\\' + normalized
is_unc = normalized.startswith('\\\\')
# see https://en.wikipedia.org/wiki/Path_(computing)#Universal_Naming_Convention
if is_unc: # then we need to insert an additional "UNC\" to the longpath prefix
normalized = normalized.replace('\\\\', '\\\\?\\UNC\\')
else:
normalized = '\\\\?\\' + normalized
return normalized
else:
return path
Expand Down

0 comments on commit 878a988

Please # to comment.