ios - 是否允许在 App Store 中使用 ssziparchive 库?

标签 ios cryptography app-store ssziparchive

由于密码学导出法规,可以使用这个库吗?或者我可以使用哪一个来压缩/解压缩文件?

最佳答案

我不知道是否允许在分布式应用程序中使用 SSZipArchive,但我使用的库是 Objective-Zip .

它可以很容易地集成到任何项目中。

压缩示例代码:

// create a zip file for writing
ZipFile *zipFile= [[ZipFile alloc] initWithFileName:pathOfTheFileToBeZipped mode:ZipFileModeCreate];

// Add a file, write to its stream and close it
ZipWriteStream *stream1= [zipFile writeFileInZipWithName:@"abc.txt" fileDate:[NSDate dateWithTimeIntervalSinceNow:-86400.0] compressionLevel:ZipCompressionLevelBest];
NSString *text= @"abc";
[stream1 writeData:[text dataUsingEncoding:NSUTF8StringEncoding]];
[stream1 finishedWriting];

// Add another file, write to its stream and close it
ZipWriteStream *stream2= [zipFile writeFileInZipWithName:@"x/y/z/xyz.txt" compressionLevel:ZipCompressionLevelNone];
NSString *text2= @"XYZ";
[stream2 writeData:[text2 dataUsingEncoding:NSUTF8StringEncoding]];
[stream2 finishedWriting];

// Close the zip file
[zipFile close];

解压示例代码:

// open the zip file for reading
ZipFile *unzipFile = [[ZipFile alloc] initWithFileName:pathOfTheFileToBeUnzipped mode:ZipFileModeUnzip];

// retrieve the info of the files inside
NSArray *infos= [unzipFile listFileInZipInfos];

// iterate over files
for (FileInZipInfo *info in infos) {        
    // locate the file in the zip
    [unzipFile locateFileInZip:info.name];

    // expand the file in memory
    ZipReadStream *read= [unzipFile readCurrentFileInZip];
    NSData *data = [read readDataOfLength:info.length];
    [read finishedReading];

    // construct the folder/file path structure
    NSString *unzipPathFilename = [unzipPath stringByAppendingPathComponent:info.name];
    NSString *unzipPathFoldername = [[unzipPathFilename stringByDeletingLastPathComponent] copy];
    NSError *errorw;

    // write the unzipped files, with some consistency checks
    NSRange range = [unzipPathFoldername rangeOfString:@"__MACOSX"];

    if (range.location == NSNotFound) {
        if ([fileManager createDirectoryAtPath:unzipPathFoldername withIntermediateDirectories:YES attributes:nil error:&errorw]) {
            if (![[unzipPathFilename pathExtension] isEqualToString:@""] && ![[[unzipPathFilename lastPathComponent] substringToIndex:1] isEqualToString:@"." ]) {
                [data writeToFile:unzipPathFilename atomically:NO];
            }
        }
        else {
            NSLog(@"Directory Fail: %@", errorw);
        }
    }
}

// close the zip file
[unzipFile close];

关于ios - 是否允许在 App Store 中使用 ssziparchive 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15236198/

相关文章:

swift - iOS 10 发布后,我可以使用 Xcode 7.3 提交 Swift 2.2 应用程序吗?

swift3 - 如何解决 "Your app or its metadata still appears to contain misleading content."

ios - 使用 SWAPI 的 resultsarray 的结果填充表格单元格

ios - swift 3 中的 NSNumber 问题

encryption - AES-CTR 模式(流式加密)明文中的 1 位更改会更改密文中的 1 位?

android - Android 的 X.509 认证

iphone - 我的 iPhone 应用程序有 bug 已获批准,有办法回滚到以前的版本吗?

objective-c - 调用 sleep (5);并更新文本字段不起作用

ios - Swift - 在用户输入时获取键盘输入

c# - 为什么任何长度的 key 都适用于 RijndaelManaged?