Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IS_DIRECTORY cannot deal with delimiter on windows('\\") #35

Closed
aijyo opened this issue Oct 31, 2018 · 4 comments
Closed

IS_DIRECTORY cannot deal with delimiter on windows('\\") #35

aijyo opened this issue Oct 31, 2018 · 4 comments

Comments

@aijyo
Copy link

aijyo commented Oct 31, 2018

Just like the title, because windows delimiter is '\', but the macro DIRECTORY_SEPARATOR is defined as '/'
Follow is the code:
#define DIRECTORY_SEPARATOR '/'
#define IS_DIRECTORY(str) ((str).length()>0 && (str)[(str).length()-1]==DIRECTORY_SEPARATOR)
#define DEFAULT_CHUNK_SIZE 524288

And why not provide a interface just lik addDir that add all the file&directory in a directory to an entry

And more ...
I cannot find a interface that can uncompress a compressed file( like test.zip) to a directory...

@ctabin
Copy link
Owner

ctabin commented Nov 1, 2018

Hi @aijyo,

In a ZIP file, all the entry paths are separated by a slash (/), even on windows. Hence, this macro should never be used to match "real" directory paths under windows. Maybe a better name would be "ENTRY_PATH_SEPARATOR".

And for your remark for a addDir API, the problem is the compatibility between linux and windows, because the file & folder API is platform dependant (or you need to include an API that provides a generic access, like Qt, but that would then be very heavy).

@aijyo
Copy link
Author

aijyo commented Nov 2, 2018

Hi @aijyo,

In a ZIP file, all the entry paths are separated by a slash (/), even on windows. Hence, this macro should never be used to match "real" directory paths under windows. Maybe a better name would be "ENTRY_PATH_SEPARATOR".

And for your remark for a addDir API, the problem is the compatibility between linux and windows, because the file & folder API is platform dependant (or you need to include an API that provides a generic access, like Qt, but that would then be very heavy).

For the DIRECTORY_SEPARATOR problem , I normalized the path with the slash (/) (just like the nodejs.path.normalize...,but not the same) before call the libzipp api;

Add the addDir, I found a solution that seems not too heavy, I use dirent.h(https://github.com/tronkko/dirent), so I can enum dir file on windows same as linux

@ctabin
Copy link
Owner

ctabin commented Nov 2, 2018

When you use the methods of libzippp, remember that you are giving an entry name, not a directory path. Hence, as an entry name, only slashes (/) are interpreted as separators. The methods are not intended to handle real file paths.

Thanks for the link to dirent.h. I'm not sure yet I will include it, but it can be very useful.

@ctabin ctabin closed this as completed Nov 2, 2018
@aijyo
Copy link
Author

aijyo commented Nov 2, 2018

When you use the methods of libzippp, remember that you are giving an entry name, not a directory path. Hence, as an entry name, only slashes (/) are interpreted as separators. The methods are not intended to handle real file paths.

Thanks for the link to dirent.h. I'm not sure yet I will include it, but it can be very useful.

Thanks, and got it ...."you are giving an entry name, not a directory path"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants