mirror of
https://github.com/GerbilSoft/minizip-ng.git
synced 2025-06-18 11:35:34 -04:00
Adding MZ_PRESERVE_NATIVE_STRUCTURE to control the behavior.
This commit is contained in:
parent
1eb579d9bc
commit
f8941493a0
@ -37,6 +37,10 @@
|
|||||||
# include <stdlib.h> /* arc4random_buf */
|
# include <stdlib.h> /* arc4random_buf */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MZ_PRESERVE_NATIVE_STRUCTURE
|
||||||
|
# define MZ_PRESERVE_NATIVE_STRUCTURE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
|
||||||
#if defined(HAVE_ICONV)
|
#if defined(HAVE_ICONV)
|
||||||
@ -290,7 +294,15 @@ int32_t mz_os_close_dir(DIR *dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t mz_os_is_dir_separator(const char c) {
|
int32_t mz_os_is_dir_separator(const char c) {
|
||||||
|
#if MZ_PRESERVE_NATIVE_STRUCTURE
|
||||||
|
// While not strictly adhering to 4.4.17.1,
|
||||||
|
// this preserves UNIX filesystem structure.
|
||||||
return c == '/';
|
return c == '/';
|
||||||
|
#else
|
||||||
|
// While strictly adhering to 4.4.17.1,
|
||||||
|
// this corrupts UNIX filesystem structure (a filename with a '\\' will become a folder + a file).
|
||||||
|
return c == '\\' || c == '/';
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mz_os_is_dir(const char *path) {
|
int32_t mz_os_is_dir(const char *path) {
|
||||||
|
@ -57,12 +57,11 @@ TEST_P(path_resolve, os) {
|
|||||||
char output[256];
|
char output[256];
|
||||||
|
|
||||||
memset(output, 'z', sizeof(output));
|
memset(output, 'z', sizeof(output));
|
||||||
// The expectation is that archiving+unarchiving data on a system should preserve its structure.
|
// archiving and unarchiving data on a system should preserve its structure
|
||||||
// So on Windows backslash should be preserved, while on UNIX slash should be preserved.
|
if (!mz_os_is_dir_separator('\\')) {
|
||||||
#ifndef _WIN32
|
std::replace(path.begin(), path.end(), '\\', '/');
|
||||||
std::replace(path.begin(), path.end(), '\\', '/');
|
std::replace(expected_path.begin(), expected_path.end(), '\\', '/');
|
||||||
std::replace(expected_path.begin(), expected_path.end(), '\\', '/');
|
}
|
||||||
#endif
|
|
||||||
mz_path_resolve(path.c_str(), output, sizeof(output));
|
mz_path_resolve(path.c_str(), output, sizeof(output));
|
||||||
EXPECT_STREQ(output, expected_path.c_str());
|
EXPECT_STREQ(output, expected_path.c_str());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user