Merge pull request #317 from Coeur/codeFormat

more consistent code format
This commit is contained in:
Joshua Hudson 2017-03-28 10:34:28 -07:00 committed by GitHub
commit 4aa70f4237

View File

@ -39,21 +39,20 @@
if (ret == UNZ_OK) {
do {
ret = unzOpenCurrentFile(zip);
if( ret!=UNZ_OK ) {
if (ret != UNZ_OK) {
return NO;
}
unz_file_info fileInfo ={0};
unz_file_info fileInfo = {0};
ret = unzGetCurrentFileInfo(zip, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
if (ret!= UNZ_OK) {
if (ret != UNZ_OK) {
return NO;
} else if((fileInfo.flag & 1) == 1) {
} else if ((fileInfo.flag & 1) == 1) {
return YES;
}
unzCloseCurrentFile(zip);
ret = unzGoToNextFile(zip);
} while( ret==UNZ_OK && UNZ_OK!=UNZ_END_OF_LIST_OF_FILE );
} while (ret == UNZ_OK && UNZ_OK != UNZ_END_OF_LIST_OF_FILE);
}
return NO;
@ -101,7 +100,7 @@
userInfo:@{NSLocalizedDescriptionKey: @"failed to retrieve info for file"}];
}
return NO;
} else if((fileInfo.flag & 1) == 1) {
} else if ((fileInfo.flag & 1) == 1) {
unsigned char buffer[10] = {0};
int readBytes = unzReadCurrentFile(zip, buffer, (unsigned)MIN(10UL,fileInfo.uncompressed_size));
if (readBytes < 0) {
@ -120,8 +119,7 @@
unzCloseCurrentFile(zip);
ret = unzGoToNextFile(zip);
} while (ret==UNZ_OK && UNZ_OK!=UNZ_END_OF_LIST_OF_FILE);
} while (ret == UNZ_OK && UNZ_OK != UNZ_END_OF_LIST_OF_FILE);
}
// No password required
@ -232,7 +230,7 @@
BOOL success = YES;
BOOL canceled = NO;
int ret = 0;
int crc_ret =0;
int crc_ret = 0;
unsigned char buffer[4096] = {0};
NSFileManager *fileManager = [NSFileManager defaultManager];
NSMutableArray *directoriesModificationDates = [[NSMutableArray alloc] init];
@ -379,7 +377,7 @@
FILE *fp = fopen((const char*)[fullPath UTF8String], "wb");
while (fp) {
if (readBytes > 0) {
fwrite(buffer, readBytes, 1, fp );
fwrite(buffer, readBytes, 1, fp);
} else {
break;
}
@ -389,7 +387,7 @@
if (fp) {
if ([[[fullPath pathExtension] lowercaseString] isEqualToString:@"zip"]) {
NSLog(@"Unzipping nested .zip file: %@", [fullPath lastPathComponent]);
if ([self unzipFileAtPath:fullPath toDestination:[fullPath stringByDeletingLastPathComponent] overwrite:overwrite password:password error:nil delegate:nil ]) {
if ([self unzipFileAtPath:fullPath toDestination:[fullPath stringByDeletingLastPathComponent] overwrite:overwrite password:password error:nil delegate:nil]) {
[[NSFileManager defaultManager] removeItemAtPath:fullPath error:nil];
}
}
@ -455,7 +453,7 @@
// Assemble the path for the symbolic link
NSMutableString* destinationPath = [NSMutableString string];
int bytesRead = 0;
while((bytesRead = unzReadCurrentFile(zip, buffer, 4096)) > 0)
while ((bytesRead = unzReadCurrentFile(zip, buffer, 4096)) > 0)
{
buffer[bytesRead] = (int)0;
[destinationPath appendString:@((const char*)buffer)];
@ -465,19 +463,19 @@
int symlinkError = symlink([destinationPath cStringUsingEncoding:NSUTF8StringEncoding],
[fullPath cStringUsingEncoding:NSUTF8StringEncoding]);
if(symlinkError != 0)
if (symlinkError != 0)
{
NSLog(@"Failed to create symbolic link at \"%@\" to \"%@\". symlink() error code: %d", fullPath, destinationPath, errno);
}
}
crc_ret = unzCloseCurrentFile( zip );
crc_ret = unzCloseCurrentFile(zip);
if (crc_ret == UNZ_CRCERROR) {
//CRC ERROR
success = NO;
break;
}
ret = unzGoToNextFile( zip );
ret = unzGoToNextFile(zip);
// Message delegate
if ([delegate respondsToSelector:@selector(zipArchiveDidUnzipFileAtIndex:totalFiles:archivePath:fileInfo:)]) {
@ -494,7 +492,7 @@
progressHandler(strPath, fileInfo, currentFileNumber, globalInfo.number_entry);
}
}
} while(ret == UNZ_OK && ret != UNZ_END_OF_LIST_OF_FILE);
} while (ret == UNZ_OK && ret != UNZ_END_OF_LIST_OF_FILE);
// Close
unzClose(zip);
@ -592,10 +590,10 @@
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password{
return [SSZipArchive createZipFileAtPath:path
withContentsOfDirectory:directoryPath
keepParentDirectory:keepParentDirectory
withPassword:password
andProgressHandler:nil
withContentsOfDirectory:directoryPath
keepParentDirectory:keepParentDirectory
withPassword:password
andProgressHandler:nil
];
}
@ -627,7 +625,7 @@
}
else
{
if([[NSFileManager defaultManager] subpathsOfDirectoryAtPath:fullFilePath error:nil].count == 0)
if ([[NSFileManager defaultManager] subpathsOfDirectoryAtPath:fullFilePath error:nil].count == 0)
{
NSString *tempFilePath = [self _temporaryPathForDiscardableFile];
NSString *tempFileFilename = [fileName stringByAppendingPathComponent:tempFilePath.lastPathComponent];
@ -701,12 +699,12 @@
zip_fileinfo zipInfo = {{0}};
NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:path error: nil];
if( attr )
if (attr)
{
NSDate *fileDate = (NSDate *)attr[NSFileModificationDate];
if( fileDate )
if (fileDate)
{
[self zipInfo:&zipInfo setDate: fileDate ];
[self zipInfo:&zipInfo setDate: fileDate];
}
// Write permissions into the external attributes, for details on this see here: http://unix.stackexchange.com/a/14727
@ -763,12 +761,12 @@
zip_fileinfo zipInfo = {{0}};
NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:path error: nil];
if( attr )
if (attr)
{
NSDate *fileDate = (NSDate *)attr[NSFileModificationDate];
if( fileDate )
if (fileDate)
{
[self zipInfo:&zipInfo setDate: fileDate ];
[self zipInfo:&zipInfo setDate: fileDate];
}
// Write permissions into the external attributes, for details on this see here: http://unix.stackexchange.com/a/14727
@ -798,7 +796,7 @@
zipOpenNewFileInZip3(_zip, afileName, &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION, 0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, [password UTF8String], 0);
unsigned int len = 0;
while(!feof(input) && !ferror(input))
while (!feof(input) && !ferror(input))
{
len = (unsigned int) fread(buffer, 1, CHUNK, input);
zipWriteInFileInZip(_zip, buffer, len);