Skip to content

Commit b9c489b

Browse files
committed
Fixed long paths for windows (again, but for real :))
1 parent bbd8c0a commit b9c489b

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

utils.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ def path_join(base, *rest):
2626

2727
rpath = u'/'.join(new_rest)
2828

29-
if os.path.isabs(rpath):
30-
return rpath
31-
else:
32-
return base + u'/' + rpath
29+
if not os.path.isabs(rpath):
30+
rpath = base + u'/' + rpath
31+
32+
if is_windows():
33+
rpath = rpath.replace('/', '\\')
34+
return rpath
3335

3436
def get_data_path(dir_path):
3537
parts = dir_path.split('/')
@@ -52,31 +54,31 @@ def get_data_file_path(file_path):
5254
def rmtree(path, **kwargs):
5355
if is_windows():
5456
if os.path.isabs(path):
55-
path = u'//?/'+path
57+
path = '\\\\?\\'+path.replace('/', '\\')
5658
shutil.rmtree(path, **kwargs)
5759

5860
def copy(src, dest, **kwargs):
5961
if is_windows():
6062
if os.path.isabs(src):
61-
src = u'//?/'+src
63+
src = '\\\\?\\'+src.replace('/', '\\')
6264
if os.path.isabs(dest):
63-
dest = u'//?/'+dest
65+
dest = '\\\\?\\'+dest.replace('/', '\\')
6466
shutil.copy(src, dest, **kwargs)
6567

6668
def move(src, dest, **kwargs):
6769
if is_windows():
6870
if os.path.isabs(src):
69-
src = u'//?/'+src
71+
src = '\\\\?\\'+src.replace('/', '\\')
7072
if os.path.isabs(dest):
71-
dest = u'//?/'+dest
73+
dest = '\\\\?\\'+dest.replace('/', '\\')
7274
shutil.move(src, dest, **kwargs)
7375

7476
def copytree(src, dest, **kwargs):
7577
if is_windows():
7678
if os.path.isabs(src):
77-
src = u'//?/'+src
79+
src = '\\\\?\\'+src.replace('/', '\\')
7880
if os.path.isabs(dest):
79-
dest = u'//?/'+dest
81+
dest = '\\\\?\\'+dest.replace('/', '\\')
8082
shutil.copytree(src, dest, **kwargs)
8183

8284

@@ -102,6 +104,8 @@ def zip_files(zip_file_name, *args, **kwargs):
102104
old_path = os.getcwd()
103105

104106
for arg in args:
107+
if is_windows():
108+
arg = '\\\\?\\'+os.path.abspath(arg).replace('/', '\\')
105109
if os.path.exists(arg):
106110
if os.path.isdir(arg):
107111
directory = os.path.abspath(arg)

0 commit comments

Comments
 (0)