Objective-C
Objective-C
Change a Filename before Unzipping
See more Zip Examples
How to open a zip and modify the filename of one or more files within the zip before unzipping.Chilkat Objective-C Downloads
#import <CkoZip.h>
#import <CkoZipEntry.h>
BOOL success = NO;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoZip *zip = [[CkoZip alloc] init];
success = [zip OpenZip: @"test.zip"];
if (success == NO) {
NSLog(@"%@",zip.LastErrorText);
return;
}
CkoZipEntry *entry = [[CkoZipEntry alloc] init];
success = [zip EntryOf: @"hamlet.xml" entry: entry];
if (success == NO) {
NSLog(@"%@",zip.LastErrorText);
return;
}
entry.FileName = @"hamlet2.xml";
success = [zip EntryOf: @"helloWorld.pl" entry: entry];
if (success == NO) {
NSLog(@"%@",zip.LastErrorText);
return;
}
entry.FileName = @"hw.pl";
// Now unzip to the "test" subdirectory, under our current
// working directory:
int numFilesUnzipped = [[zip Unzip: @"test"] intValue];
if (numFilesUnzipped < 0) {
NSLog(@"%@",zip.LastErrorText);
return;
}
// The filenames within the .zip are unchanged, but it unzipped
// test/hw.pl and test/hamlet2.xm