Skip to content

Commit

Permalink
Attempt a long path for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Erotemic committed Jan 30, 2024
1 parent e446729 commit d729f72
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/xdoctest/utils/util_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,20 @@ def __del__(self):

def ensure(self):
import tempfile
import sys
if not self.dpath:
self.dpath = tempfile.mkdtemp()
dpath = tempfile.mkdtemp()
if sys.platform.startswith('win32'):
# Force a long path
# References:
# https://stackoverflow.com/questions/11420689/how-to-get-long-file-system-path-from-python-on-windows
from ctypes import create_unicode_buffer, windll
BUFFER_SIZE = 500
buffer = create_unicode_buffer(BUFFER_SIZE)
get_long_path_name = windll.kernel32.GetLongPathNameW
get_long_path_name(dpath, buffer, BUFFER_SIZE)
dpath = buffer.value
self.dpath = dpath
return self.dpath

def cleanup(self):
Expand Down

0 comments on commit d729f72

Please sign in to comment.