(Objective-C) Split File into Chunks
Demonstrates how to split a file into chunks.
#import <CkoFileAccess.h>
#import <NSString.h>
CkoFileAccess *fac = [[CkoFileAccess alloc] init];
// Any type of file may be split. It doesn't matter if it's
// a binary file or a text file.
NSString *fileToSplit = @"qa_data/hamlet.xml";
NSString *partPrefix = @"hamlet";
NSString *partExtension = @"part";
int maxChunkSize = 50000;
NSString *destDirPath = @"qa_output";
// Splits hamlet.xml into hamlet1.part, hamlet2.part, ...
// Output files are written to the current working directory.
// Each chunk will be 50000 bytes except for the last which
// will be the remainder.
BOOL success = [fac SplitFile: fileToSplit partPrefix: partPrefix partExtension: partExtension partSize: [NSNumber numberWithInt: maxChunkSize] destDir: destDirPath];
if (success == YES) {
NSLog(@"%@",@"Success.");
}
else {
NSLog(@"%@",fac.LastErrorText);
}
|