Skip to content

Commit ada028f

Browse files
committed
Fixed extraction issue on Windows. Use os.path and abspath.
1 parent 77700f4 commit ada028f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/extractcode/libarchive2.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
# logging.basicConfig(level=logging.DEBUG)
5555

5656

57-
5857
"""
5958
libarchive2 is a minimal and specialized wrapper around a vendored libarchive
6059
archive extraction library. It is inspired from several libarchive bindings
@@ -284,7 +283,7 @@ def write(self, target_dir, transform_path=lambda x: x):
284283
# TODO: return some warning when original path has been transformed
285284
clean_path = transform_path(self.path)
286285
if self.isdir:
287-
dir_path = posixpath.join(abs_target_dir, clean_path)
286+
dir_path = os.path.join(abs_target_dir, clean_path)
288287
fileutils.create_dir(dir_path)
289288
return dir_path
290289

@@ -293,7 +292,7 @@ def write(self, target_dir, transform_path=lambda x: x):
293292
# create parent directories if needed
294293
# TODO: also rename directories, segment by segment?
295294
target_path = os.path.join(abs_target_dir, clean_path)
296-
parent_path = posixpath.dirname(target_path)
295+
parent_path = os.path.dirname(target_path)
297296
fileutils.create_dir(parent_path)
298297

299298
# TODO: return some warning when original path has been renamed?

tests/commoncode/test_fileutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def test_file_iter(self):
371371
def test_file_iter_can_iterate_a_single_file(self):
372372
test_file = self.get_test_loc('fileutils/walk/f')
373373
result = [as_posixpath(f) for f in fileutils.file_iter(test_file)]
374-
expected = [test_file]
374+
expected = [as_posixpath(test_file)]
375375
assert expected == result
376376

377377
def test_file_iter_can_walk_an_empty_dir(self):

0 commit comments

Comments
 (0)