diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-07-19 20:52:59 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-07-19 20:56:52 +0300 |
commit | 2155eb58531f97fef7f5e60b612d6436d083ebff (patch) | |
tree | 17401c9a5118497d21890dc709d9d4a7cc42e1e9 | |
parent | 432787c87494a7d39720d928f97bbce91ea6ef29 (diff) |
Fix T48187: Packing files on MS-Windows fails
Using paths on different drives caused packing to fail
since its not possible to make one path relative to another.
-rwxr-xr-x | io_blend_utils/blendfile_pack.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/io_blend_utils/blendfile_pack.py b/io_blend_utils/blendfile_pack.py index 225a941d..dee2bfa1 100755 --- a/io_blend_utils/blendfile_pack.py +++ b/io_blend_utils/blendfile_pack.py @@ -55,7 +55,18 @@ def _relpath_remap( raise Exception("Internal error 'path_src' -> %r must be absolute" % path_src) path_src = os.path.normpath(path_src) - path_dst = os.path.relpath(path_src, base_dir_src) + if os.name != "nt": + path_dst = os.path.relpath(path_src, base_dir_src) + else: + # exception for windows, we need to support mapping between drives + try: + path_dst = os.path.relpath(path_src, base_dir_src) + except ValueError: + # include the absolute path when the file is on a different drive. + path_dst = os.path.relpath( + os.path.join(base_dir_src, b'__' + path_src.replace(b':', b'\\')), + base_dir_src, + ) if blendfile_src_dir_fakeroot is None: # /foo/../bar.png --> /foo/__/bar.png |