mirror of
https://github.com/QuasarApp/zip.git
synced 2025-04-28 13:24:33 +00:00
Revert "clang-format"
This reverts commit 046a374bf0f03ec9e00b7717409864cd610f7764.
This commit is contained in:
parent
046a374bf0
commit
ce1a404443
27
src/zip.c
27
src/zip.c
@ -833,8 +833,7 @@ int zip_create(const char *zipname, const char *filenames[], size_t len) {
|
||||
}
|
||||
|
||||
static inline int extract(mz_zip_archive *zip_archive, const char *dir,
|
||||
int (*on_extract)(const char *filename, void *arg),
|
||||
void *arg) {
|
||||
int (*on_extract)(const char *filename, void *arg), void *arg){
|
||||
int status = -1;
|
||||
mz_uint i, n;
|
||||
char path[MAX_PATH + 1];
|
||||
@ -940,13 +939,13 @@ out:
|
||||
status = -1;
|
||||
}
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
static inline mz_zip_archive *zip_archive_init_file(const char *zipname,
|
||||
mz_uint32 flags) {
|
||||
static inline mz_zip_archive * zip_archive_init_file(const char *zipname, mz_uint32 flags){
|
||||
mz_zip_archive *zip_archive = NULL;
|
||||
zip_archive = (mz_zip_archive *)malloc(sizeof(mz_zip_archive));
|
||||
if (!zip_archive) {
|
||||
if (!zip_archive){
|
||||
// malloc failed.
|
||||
return NULL;
|
||||
}
|
||||
@ -965,14 +964,14 @@ static inline mz_zip_archive *zip_archive_init_file(const char *zipname,
|
||||
}
|
||||
|
||||
int zip_extract(const char *zipname, const char *dir,
|
||||
int (*on_extract)(const char *filename, void *arg), void *arg) {
|
||||
int (*on_extract)(const char *filename, void *arg), void *arg) {
|
||||
if (!zipname || !dir) {
|
||||
// Cannot parse zip archive name
|
||||
return -1;
|
||||
}
|
||||
// init zip_archive and set reader
|
||||
mz_zip_archive *zip_archive = zip_archive_init_file(zipname, 0);
|
||||
if (!zip_archive) {
|
||||
if (!zip_archive){
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -983,11 +982,11 @@ int zip_extract(const char *zipname, const char *dir,
|
||||
return status;
|
||||
}
|
||||
|
||||
static inline mz_zip_archive *
|
||||
zip_archive_init_mem(const void *stream, size_t size, mz_uint32 flags) {
|
||||
static inline mz_zip_archive * zip_archive_init_mem(const void *stream,
|
||||
size_t size, mz_uint32 flags){
|
||||
mz_zip_archive *zip_archive = NULL;
|
||||
zip_archive = (mz_zip_archive *)malloc(sizeof(mz_zip_archive));
|
||||
if (!zip_archive) {
|
||||
if (!zip_archive){
|
||||
// malloc failed.
|
||||
return NULL;
|
||||
}
|
||||
@ -1006,15 +1005,14 @@ zip_archive_init_mem(const void *stream, size_t size, mz_uint32 flags) {
|
||||
}
|
||||
|
||||
int zip_extract_stream(const char *stream, size_t size, const char *dir,
|
||||
int (*on_extract)(const char *filename, void *arg),
|
||||
void *arg) {
|
||||
int (*on_extract)(const char *filename, void *arg), void *arg) {
|
||||
if (!stream || !dir) {
|
||||
// Cannot parse zip archive stream
|
||||
return -1;
|
||||
}
|
||||
// init zip_archive and set reader
|
||||
mz_zip_archive *zip_archive = zip_archive_init_mem(stream, size, 0);
|
||||
if (!zip_archive) {
|
||||
if (!zip_archive){
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1023,4 +1021,5 @@ int zip_extract_stream(const char *stream, size_t size, const char *dir,
|
||||
free(zip_archive);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
}
|
@ -331,9 +331,7 @@ extern int zip_extract(const char *zipname, const char *dir,
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
extern int zip_extract_stream(const char *stream, size_t size, const char *dir,
|
||||
int (*on_extract)(const char *filename,
|
||||
void *arg),
|
||||
void *arg);
|
||||
int (*on_extract)(const char *filename, void *arg), void *arg);
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -462,7 +462,7 @@ static void test_unix_permissions(void) {
|
||||
remove(RFILE);
|
||||
remove(ZIPNAME);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void test_extract_stream(void) {
|
||||
|
||||
@ -482,7 +482,7 @@ static void test_extract_stream(void) {
|
||||
FILE *fp = NULL;
|
||||
fp = fopen(ZIPNAME, "r+");
|
||||
assert(fp != NULL);
|
||||
|
||||
|
||||
fseek(fp, 0L, SEEK_END);
|
||||
size_t filesize = ftell(fp);
|
||||
fseek(fp, 0L, SEEK_SET);
|
||||
|
Loading…
x
Reference in New Issue
Block a user