zipper
zipper copied to clipboard
`add(path/to/folder/)` results in folder name to be incorrectly set to `/`
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 have you tried that fixed? if it worked and every test is passing, would you submit a pull request?
Thanks!
I will try to make a pull request when I get the chance to.
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
.
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.
Add unit tests inside the v2.x.y branch. Reopen this ticket if not fixed.