1

私はオーディオファイルをzipファイルに圧縮するためにobjective-zipを使用していますが、それを行うと、この例外が表示されます:

Terminating app due to uncaught exception 'ZipException', reason: 
'Error in opening '/Users/macuser/Library/Application 
Support/iPhoneSimulator/5.1/Applications/79E57C84-3B47-437C-BB44- 
89BAAB034DF5/Documents/ADDRecordFileForTest_0_07-05-2012 12:42:45.caf' in zipfile

また、最初にすべてのオーディオ ファイルを 1 つのディレクトリに配置してから、objective-zip を使用してこれらのディレクトリを圧縮しようとしましたが、以下の例外も発生します。

Terminating app due to uncaught exception 'ZipException', reason: 
'Can't open '/Users/macuser/Library/Application Support/iPhone Simulator/5.1/
Applications/79E57C84-3B47-437C-BB44-89BAAB034DF5/Documents/
CurrentMeeting_AudioFiles

Objective-Zip はテキスト ファイルのみをサポートしていますが、なぜ Objective-Zip は既存のフォルダを圧縮しないのですか? どんな助けでも歓迎します、ありがとう。

4

1 に答える 1

0

ファイル名にコロンが含まれていると、問題が発生する可能性があります。

ADDRecordFileForTest_0_07-05-2012 12:42:45.caf

ダッシュの使用を検討してください。スペースも使いません。少なくとも、ユーザーが作成したファイル名で作業する必要がない限り(利便性/ユーザーエクスペリエンスのために)。

さらに、通常、zip はディレクトリを保持しません。ただし、フォルダー内のファイルを圧縮する場合、ディレクトリはパスの一部です。私はまだ Objective-Zip を使用していませんでしたが、ZipArchive は現在、必要に応じて機能しないため、試してみます。基本的に次のように機能する ZipArchive の「zip -r」カテゴリを作成しました。

- (NSDictionary *)directoriesAndFilesAtPath:(NSString *)path error:(NSError * __autoreleasing *)error {
    NSFileManager *fileManager = [[NSFileManager alloc] init];
    NSError *fileManagerError = nil;
    NSArray *directoryContents = [fileManager contentsOfDirectoryAtPath:path error:&fileManagerError];
    if (!directoryContents) {
        *error = fileManagerError;
        return nil;
    }

    BOOL isDir;
    NSMutableArray *dirs = [NSMutableArray arrayWithCapacity:10];
    NSMutableArray *files = [NSMutableArray arrayWithCapacity:10];
    for (NSString *object in directoryContents) {
        if ([fileManager fileExistsAtPath:[path stringByAppendingPathComponent:object] isDirectory:&isDir]) {
            if (isDir) {
                [dirs addObject:[path stringByAppendingPathComponent:object]];
            } else {
                [files addObject:[path stringByAppendingPathComponent:object]];
            }
        }
    }

    return @{kDirectoriesKey: dirs, kFilesKey: files};
}

次に、ファイルを zip に追加する再帰的な方法を使用して、各ディレクトリに対してそれ自体を呼び出すことができます。

于 2014-02-04T13:42:14.027 に答える