Skip to content

Commit

Permalink
More source tidies. Remove actual or potential local variable symbol …
Browse files Browse the repository at this point in the history
…shadows, plus a few other non-functionality impacting changes.
  • Loading branch information
johnezang committed Jul 22, 2011
1 parent 02417a4 commit f24f550
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 44 deletions.
7 changes: 3 additions & 4 deletions SSZipArchive.m
Expand Up @@ -65,7 +65,6 @@ + (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination o
}

// Reading data and write to file
int read;
unz_file_info fileInfo;
memset(&fileInfo, 0, sizeof(unz_file_info));

Expand Down Expand Up @@ -109,10 +108,10 @@ + (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination o

FILE *fp = fopen((const char*)[fullPath UTF8String], "wb");
while (fp) {
read = unzReadCurrentFile(zip, buffer, 4096);
int readBytes = unzReadCurrentFile(zip, buffer, 4096);

if (read > 0) {
fwrite(buffer, read, 1, fp );
if (readBytes > 0) {
fwrite(buffer, readBytes, 1, fp );
} else {
break;
}
Expand Down
72 changes: 37 additions & 35 deletions minizip/mztools.c
Expand Up @@ -137,28 +137,28 @@ uLong* bytesRecovered;

/* Central directory entry */
{
char header[46];
char* comment = "";
int comsize = (int) strlen(comment);
WRITE_32(header, 0x02014b50);
WRITE_16(header + 4, version);
WRITE_16(header + 6, version);
WRITE_16(header + 8, gpflag);
WRITE_16(header + 10, method);
WRITE_16(header + 12, filetime);
WRITE_16(header + 14, filedate);
WRITE_32(header + 16, crc);
WRITE_32(header + 20, cpsize);
WRITE_32(header + 24, uncpsize);
WRITE_16(header + 28, fnsize);
WRITE_16(header + 30, extsize);
WRITE_16(header + 32, comsize);
WRITE_16(header + 34, 0); /* disk # */
WRITE_16(header + 36, 0); /* int attrb */
WRITE_32(header + 38, 0); /* ext attrb */
WRITE_32(header + 42, currentOffset);
char centralDirectoryEntryHeader[46];
//char* comment = "";
//int comsize = (int) strlen(comment);
WRITE_32(centralDirectoryEntryHeader, 0x02014b50);
WRITE_16(centralDirectoryEntryHeader + 4, version);
WRITE_16(centralDirectoryEntryHeader + 6, version);
WRITE_16(centralDirectoryEntryHeader + 8, gpflag);
WRITE_16(centralDirectoryEntryHeader + 10, method);
WRITE_16(centralDirectoryEntryHeader + 12, filetime);
WRITE_16(centralDirectoryEntryHeader + 14, filedate);
WRITE_32(centralDirectoryEntryHeader + 16, crc);
WRITE_32(centralDirectoryEntryHeader + 20, cpsize);
WRITE_32(centralDirectoryEntryHeader + 24, uncpsize);
WRITE_16(centralDirectoryEntryHeader + 28, fnsize);
WRITE_16(centralDirectoryEntryHeader + 30, extsize);
WRITE_16(centralDirectoryEntryHeader + 32, 0 /*comsize*/);
WRITE_16(centralDirectoryEntryHeader + 34, 0); /* disk # */
WRITE_16(centralDirectoryEntryHeader + 36, 0); /* int attrb */
WRITE_32(centralDirectoryEntryHeader + 38, 0); /* ext attrb */
WRITE_32(centralDirectoryEntryHeader + 42, currentOffset);
/* Header */
if (fwrite(header, 1, 46, fpOutCD) == 46) {
if (fwrite(centralDirectoryEntryHeader, 1, 46, fpOutCD) == 46) {
offsetCD += 46;

/* Filename */
Expand All @@ -185,6 +185,7 @@ uLong* bytesRecovered;
}

/* Comment field */
/*
if (comsize > 0) {
if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) {
offsetCD += comsize;
Expand All @@ -193,7 +194,7 @@ uLong* bytesRecovered;
break;
}
}

*/

} else {
err = Z_ERRNO;
Expand All @@ -212,31 +213,32 @@ uLong* bytesRecovered;
/* Final central directory */
{
int entriesZip = entries;
char header[22];
char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
int comsize = (int) strlen(comment);
char finalCentralDirectoryHeader[22];
//char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
//int comsize = (int) strlen(comment);
if (entriesZip > 0xffff) {
entriesZip = 0xffff;
}
WRITE_32(header, 0x06054b50);
WRITE_16(header + 4, 0); /* disk # */
WRITE_16(header + 6, 0); /* disk # */
WRITE_16(header + 8, entriesZip); /* hack */
WRITE_16(header + 10, entriesZip); /* hack */
WRITE_32(header + 12, offsetCD); /* size of CD */
WRITE_32(header + 16, offset); /* offset to CD */
WRITE_16(header + 20, comsize); /* comment */
WRITE_32(finalCentralDirectoryHeader, 0x06054b50);
WRITE_16(finalCentralDirectoryHeader + 4, 0); /* disk # */
WRITE_16(finalCentralDirectoryHeader + 6, 0); /* disk # */
WRITE_16(finalCentralDirectoryHeader + 8, entriesZip); /* hack */
WRITE_16(finalCentralDirectoryHeader + 10, entriesZip); /* hack */
WRITE_32(finalCentralDirectoryHeader + 12, offsetCD); /* size of CD */
WRITE_32(finalCentralDirectoryHeader + 16, offset); /* offset to CD */
WRITE_16(finalCentralDirectoryHeader + 20, 0 /*comsize*/); /* comment */

/* Header */
if (fwrite(header, 1, 22, fpOutCD) == 22) {
if (fwrite(finalCentralDirectoryHeader, 1, 22, fpOutCD) == 22) {

/* Comment field */
/*
if (comsize > 0) {
if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) {
err = Z_ERRNO;
}
}

*/
} else {
err = Z_ERRNO;
}
Expand Down
10 changes: 5 additions & 5 deletions minizip/zip.c
Expand Up @@ -1070,10 +1070,10 @@ extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
return err;
}

extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32)
extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32ForFile)
zipFile file;
uLong uncompressed_size;
uLong crc32;
uLong crc32ForFile;
{
zip_internal* zi;
uLong compressed_size;
Expand Down Expand Up @@ -1124,15 +1124,15 @@ extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32)

if (!zi->ci.raw)
{
crc32 = (uLong)zi->ci.crc32;
crc32ForFile = (uLong)zi->ci.crc32;
uncompressed_size = (uLong)zi->ci.stream.total_in;
}
compressed_size = (uLong)zi->ci.stream.total_out;
# ifndef NOCRYPT
compressed_size += zi->ci.crypt_header_size;
# endif

ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/
ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32ForFile,4); /*crc*/
ziplocal_putValue_inmemory(zi->ci.central_header+20,
compressed_size,4); /*compr size*/
if (zi->ci.stream.data_type == Z_ASCII)
Expand All @@ -1153,7 +1153,7 @@ extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32)
err = ZIP_ERRNO;

if (err==ZIP_OK)
err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */
err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32ForFile,4); /* crc 32, unknown */

if (err==ZIP_OK) /* compressed size, unknown */
err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4);
Expand Down

0 comments on commit f24f550

Please sign in to comment.