phrohdoh / easage

A library that provides programmatic manipulation of BIG archives.
MIT License
9 stars 0 forks source link

Backslashes are not converted to directories on Unix-like systems #2

Closed Teteros closed 6 years ago

Teteros commented 6 years ago

BIG archives made on Windows currently do not retain directory trees on Unix-like machines. Backslashes \ are not converted to directories / (on e.g. linux) essentially.

Test case:

On Windows

mkdir foo & echo baz >foo\bar & easage pack --source foo --output foo.big

On Linux

easage list foo.big
Archive:
  kind: Big4
  size: 50
  len: 1
  data start: 0x2b
Entries:
  foo\bar
    offset: 0x2b
    len: 7
└> easage extract --output . --source foo.big
└> ls -la
total 8
drwxr-xr-x  2 tete tete  80 Oct 23 13:34  .
drwxrwxrwt 10 root root 320 Oct 23 13:33  ..
-rw-r--r--  1 tete tete   7 Oct 23 13:34 'foo\bar'
-rw-r--r--  1 tete tete  50 Oct 23 13:27  foo.big

Expected: foo/bar

i.e. bar in folder called foo

The opposite works however

BIG archives created on Linux with easage pack will extract on Windows machines with folder paths respected.

foo.big with \ paths attached below

(wrapped in .zip due to github attachment support) foo.big.zip

phrohdoh commented 6 years ago

Meta: I changed this from bug to enhancement because currently there is no code to try to handle this (that could be buggy) so this is technically an enhancement.

I believe we'll want to convert all \ to / before writing (and creating directories) because Windows will internally convert / to \ while *nixes expect / as path separators.

The above fix can be applied by calling str::replace on all entry paths/names before unpacking.

phrohdoh commented 6 years ago

This was fixed in 3035d194c3416089ff00bdb287174cffc78e8ca0.

Please re-open this ticket if you are able to reproduce this after the above commit.