zipper icon indicating copy to clipboard operation
zipper copied to clipboard

`add(path/to/folder/)` results in folder name to be incorrectly set to `/`

Open devnoname120 opened this issue 7 years ago • 4 comments

Test case:

Zipper zipper("ux0:data/testzipper/ziptest.zip");
zipper.add("ux0:data/testzipper/somefolder/");
zipper.close();

Result: ziptest.zip --> / --> some files Expected: ziptest.zip --> somefolder --> some files


The culprit is this line: https://github.com/sebastiandev/zipper/blob/787b97db8875c1c31789a8b82d96ed0191f6a0f7/zipper/CDirEntry.cpp#L97 Proposed fix: Trailing / should be ignored.

devnoname120 avatar Aug 30 '17 02:08 devnoname120

@devnoname120 have you tried that fixed? if it worked and every test is passing, would you submit a pull request?

Thanks!

sebastiandev avatar Aug 30 '17 15:08 sebastiandev

I will try to make a pull request when I get the chance to.

devnoname120 avatar Aug 31 '17 12:08 devnoname120

I think it's a bad idea to handle paths as std::string with a few helper functions. It leads to some unforeseen issues such as this one and the one described in this issue.

I suggest that we switch to C++17's std::filesystem::path with an optional fallback to boost::filesystem::path.

devnoname120 avatar Sep 23 '17 00:09 devnoname120

And with that we come full circle :) ... @sebastiandev originally was using of course C++17, which made the library available pretty much only on windows. I've tried with several fall back systems (using boost or Qt). But ultimately to have it working on most systems (and yes, even older linux kernel versions), for us it was necessary to revert to the solution with helper functions.

fbergmann avatar Sep 23 '17 08:09 fbergmann

Add unit tests inside the v2.x.y branch. Reopen this ticket if not fixed.

Lecrapouille avatar Sep 11 '22 01:09 Lecrapouille