Skip to content

Commit

Permalink
Updated readme, adding code examples and explanations
Browse files Browse the repository at this point in the history
  • Loading branch information
abbeycode committed Jun 18, 2015
1 parent 0793f58 commit 5aa7763
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,38 @@ I'm always open to improvements, so please submit your pull requests, or [create

```Objective-C
URKArchive *archive = [URKArchive rarArchiveAtPath:@"An Archive.rar"];

NSError *error = nil;
```
## Listing the file names in an archive
```Objective-C
NSArray *filesInArchive = [archive listFilenames:&error];
for (NSString *name in filesInArchive) {
NSLog(@"Archived file: %@", name);
}
```

## Listing the file details in an archive
```Objective-C
NSArray *fileInfosInArchive = [archive listFileInfo:&error];
for (URKFileInfo *info in fileInfosInArchive) {
NSLog(@"Archive name: %@ | File name: %@ | Size: %lld", info.archiveName, info.filename, info.uncompressedSize);
}
```
## Extracting files to a directory
```Objective-C
BOOL extractFilesSuccessful = [archive extractFilesTo:@"some/directory"
overWrite:NO
progress:
^(URKFileInfo *currentFile, CGFloat percentArchiveDecompressed) {
NSLog(@"Extracting %@: %f%% complete", currentFile.filename, percentArchiveDecompressed);
}
error:&error];
```

## Extracting a file into memory
```Objective-C
NSData *extractedData = [archive extractDataFromFile:@"a file in the archive.jpg"
progress:^(CGFloat percentDecompressed) {
NSLog(@"Extracting, %f%% complete", percentDecompressed);
Expand Down

0 comments on commit 5aa7763

Please sign in to comment.