2014-01-07 96 views
0

我正在寻找一种压缩和解压缩带有arm64支持的ios文件的方法。我在Github上看,但他们中没有一个支持arm64。是否已有一个用于压缩和解压缩文件的现成即用库? (我爱你,如果你知道一种方法如何整合7zip的,bzip2的,gzip的,RAR)如何压缩,解压缩目标C中的文件(arm64支持)

我使用SSZipArchive现在,但它不工作:

#import "SSZipArchive.h" 

NSArray *nameWithoutExtention = [[[[self files] objectAtIndex:indexPath.row] lastPathComponent] componentsSeparatedByString:@"."]; 
NSString *fileName = [nameWithoutExtention objectAtIndex:0]; 
NSString *destPath = [NSString stringWithFormat:@"%@/%@", self.directory, fileName]; 
[fileManager createDirectoryAtPath:destPath withIntermediateDirectories:YES attributes:nil error:nil]; 
[SSZipArchive unzipFileAtPath:[[self files] objectAtIndex:indexPath.row] toDestination:destPath]; 
+0

为什么很重要?如果他们是开源的,你可以自己编译64位。 – coneybeare

+0

但是,当我添加https://github.com/dive/ALZipArchive我得到了很多错误消息,我不能修复,所以我认为已经必须有一个固定的项目/库 –

+0

我使用GTMNSData + zlib。它是为我所要求的所有内容编译的。 – Putz1103

回答

1

你可以看看official SSZipArchive ObjectiveC example(适用于纯ARM64的iOS11)。

要ZIP:

NSString *sampleDataPath = [[NSBundle mainBundle].bundleURL 
          URLByAppendingPathComponent:@"Sample Data" 
          isDirectory:YES].path; 
NSString *zipPath = [self tempZipPath]; 
BOOL success = [SSZipArchive createZipFileAtPath:zipPath 
         withContentsOfDirectory:sampleDataPath]; 

要解压:

NSString *unzipPath = [self tempUnzipPath]; 
BOOL success = [SSZipArchive unzipFileAtPath:zipPath 
           toDestination:unzipPath]; 

tempZipPathtempUnzipPath被宣布为:

- (NSString *)tempZipPath { 
    NSString *path = [NSString stringWithFormat:@"%@/\%@.zip", 
        NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0], 
        [NSUUID UUID].UUIDString]; 
    return path; 
} 

- (NSString *)tempUnzipPath { 
    NSString *path = [NSString stringWithFormat:@"%@/\%@", 
        NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0], 
        [NSUUID UUID].UUIDString]; 
    NSURL *url = [NSURL fileURLWithPath:path]; 
    NSError *error = nil; 
    [[NSFileManager defaultManager] createDirectoryAtURL:url 
          withIntermediateDirectories:YES 
              attributes:nil 
               error:&error]; 
    if (error) { 
    return nil; 
    } 
    return url.path; 
}