From f7cf15e708fe39d3750b5259f2fba1e5c43319ec Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 2 Dec 2014 14:22:19 +0100 Subject: [PATCH] use multi-platform os.sep --- modules/blendfile_path_walker.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/blendfile_path_walker.py b/modules/blendfile_path_walker.py index ef3adc6..166857b 100644 --- a/modules/blendfile_path_walker.py +++ b/modules/blendfile_path_walker.py @@ -137,11 +137,10 @@ class FPElem_sequence_single(FPElem): def _set_cb(self, filepath): block, path, sub_block, sub_path = self.userdata - # TODO, os.sep - a, b = filepath.rsplit(b'/', 1) + head, sep, tail = utils.splitpath(filepath) - block[path] = a + b'/' - sub_block[sub_path] = b + block[path] = head + sep + sub_block[sub_path] = tail class FilePath: @@ -700,3 +699,16 @@ class utils: def compatpath(path): # keep '//' return path[:2] + path[2:].replace(b'/', b'\\') + + @staticmethod + def splitpath(path): + """ + Splits the path using either slashes + """ + split1 = path.rpartition(b'/') + split2 = path.rpartition(b'\\') + if len(split1[0]) > len(split2[0]): + return split1 + else: + return split2 +