Use -fileSystemRepresentation for file names.
This commit is contained in:
+10
-10
@@ -30,7 +30,7 @@
|
||||
|
||||
+ (BOOL)isFilePasswordProtectedAtPath:(NSString *)path {
|
||||
// Begin opening
|
||||
zipFile zip = unzOpen((const char*)[path UTF8String]);
|
||||
zipFile zip = unzOpen((const char*)[path fileSystemRepresentation]);
|
||||
if (zip == NULL) {
|
||||
return NO;
|
||||
}
|
||||
@@ -64,7 +64,7 @@
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
zipFile zip = unzOpen((const char*)[path UTF8String]);
|
||||
zipFile zip = unzOpen((const char*)[path fileSystemRepresentation]);
|
||||
if (zip == NULL) {
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:@"SSZipArchiveErrorDomain"
|
||||
@@ -190,7 +190,7 @@
|
||||
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError * __nullable error))completionHandler
|
||||
{
|
||||
// Begin opening
|
||||
zipFile zip = unzOpen((const char*)[path UTF8String]);
|
||||
zipFile zip = unzOpen((const char*)[path fileSystemRepresentation]);
|
||||
if (zip == NULL)
|
||||
{
|
||||
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"failed to open zip file"};
|
||||
@@ -376,7 +376,7 @@
|
||||
// ensure we are not creating stale file entries
|
||||
int readBytes = unzReadCurrentFile(zip, buffer, 4096);
|
||||
if (readBytes >= 0) {
|
||||
FILE *fp = fopen((const char*)[fullPath UTF8String], "wb");
|
||||
FILE *fp = fopen((const char*)[fullPath fileSystemRepresentation], "wb");
|
||||
while (fp) {
|
||||
if (readBytes > 0) {
|
||||
fwrite(buffer, readBytes, 1, fp );
|
||||
@@ -672,7 +672,7 @@
|
||||
- (BOOL)open
|
||||
{
|
||||
NSAssert((_zip == NULL), @"Attempting open an archive which is already open");
|
||||
_zip = zipOpen([_path UTF8String], APPEND_STATUS_CREATE);
|
||||
_zip = zipOpen([_path fileSystemRepresentation], APPEND_STATUS_CREATE);
|
||||
return (NULL != _zip);
|
||||
}
|
||||
|
||||
@@ -728,7 +728,7 @@
|
||||
}
|
||||
|
||||
unsigned int len = 0;
|
||||
zipOpenNewFileInZip3(_zip, [[folderName stringByAppendingString:@"/"] UTF8String], &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_NO_COMPRESSION, 0, -MAX_WBITS, DEF_MEM_LEVEL,
|
||||
zipOpenNewFileInZip3(_zip, [[folderName stringByAppendingString:@"/"] fileSystemRepresentation], &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_NO_COMPRESSION, 0, -MAX_WBITS, DEF_MEM_LEVEL,
|
||||
Z_DEFAULT_STRATEGY, [password UTF8String], 0);
|
||||
zipWriteInFileInZip(_zip, &len, 0);
|
||||
zipCloseFileInZip(_zip);
|
||||
@@ -747,17 +747,17 @@
|
||||
{
|
||||
NSAssert((_zip != NULL), @"Attempting to write to an archive which was never opened");
|
||||
|
||||
FILE *input = fopen([path UTF8String], "r");
|
||||
FILE *input = fopen([path fileSystemRepresentation], "r");
|
||||
if (NULL == input) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
const char *afileName;
|
||||
if (!fileName) {
|
||||
afileName = [path.lastPathComponent UTF8String];
|
||||
afileName = [path.lastPathComponent fileSystemRepresentation];
|
||||
}
|
||||
else {
|
||||
afileName = [fileName UTF8String];
|
||||
afileName = [fileName fileSystemRepresentation];
|
||||
}
|
||||
|
||||
zip_fileinfo zipInfo = {{0}};
|
||||
@@ -821,7 +821,7 @@
|
||||
zip_fileinfo zipInfo = {{0,0,0,0,0,0},0,0,0};
|
||||
[self zipInfo:&zipInfo setDate:[NSDate date]];
|
||||
|
||||
zipOpenNewFileInZip3(_zip, [filename UTF8String], &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION, 0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, [password UTF8String], 0);
|
||||
zipOpenNewFileInZip3(_zip, [filename fileSystemRepresentation], &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION, 0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, [password UTF8String], 0);
|
||||
|
||||
zipWriteInFileInZip(_zip, data.bytes, (unsigned int)data.length);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user