Latest | 2.9-beta8 |
---|---|
Homepage | https://github.com/abbeycode/UnrarKit |
License | BSD |
Platforms | ios 7.0, osx 10.9, requires ARC |
Authors |
About
UnrarKit is here to enable Mac and iOS apps to easily work with RAR files for read-only operations. It is currently based on version 5.2.1 of the UnRAR library.
There is a main project, with unit tests, and a basic iOS example project, which demonstrates how to use the library. To see all of these, open the main workspace file.
I’m always open to improvements, so please submit your pull requests, or create issues for someone else to implement.
Installation
UnrarKit supports both CocoaPods and Carthage. CocoaPods does not support dynamic framework targets (as of v0.39.0), so in that case, please use Carthage.
Cartfile:
github "abbeycode/UnrarKit"
Podfile:
pod "UnrarKit"
Example Usage
NSError *archiveError = nil;
URKArchive *archive = [[URKArchive alloc] initWithPath:@"An Archive.rar" error:&archiveError];
NSError *error = nil;
Listing the file names in an archive
NSArray<String*> *filesInArchive = [archive listFilenames:&error];
for (NSString *name in filesInArchive) {
NSLog(@"Archived file: %@", name);
}
Listing the file details in an archive
NSArray<URKFileInfo*> *fileInfosInArchive = [archive listFileInfo:&error];
for (URKFileInfo *info in fileInfosInArchive) {
NSLog(@"Archive name: %@ | File name: %@ | Size: %lld", info.archiveName, info.filename, info.uncompressedSize);
}
Working with passwords
NSArray<URKFileInfo*> *fileInfosInArchive = [archive listFileInfo:&error];
if (archive.isPasswordProtected) {
NSString *givenPassword = // prompt user
archive.password = givenPassword
}
// You can now extract the files
Extracting files to a directory
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
NSData *extractedData = [archive extractDataFromFile:@"a file in the archive.jpg"
progress:^(CGFloat percentDecompressed) {
NSLog(@"Extracting, %f%% complete", percentDecompressed);
}
error:&error];
Streaming a file
For large files, you may not want the whole contents in memory at once. You can handle it one "chunk" at a time, like so:
BOOL success = [archive extractBufferedDataFromFile:@"a file in the archive.jpg"
error:&error
action:
^(NSData *dataChunk, CGFloat percentDecompressed) {
NSLog(@"Decompressed: %f%%", percentDecompressed);
// Do something with the NSData chunk
}];
Notes
To open in Xcode, use the UnrarKit.xcworkspace file, which includes the other projects.
Documentation
Full documentation for the project is available on CocoaDocs.
Pushing a new CocoaPods version
New tagged builds (in any branch) get pushed to CocoaPods automatically, provided they meet the following criteria:
- All builds and tests succeed
- The library builds successfully for CocoaPods and for Carthage
- The build is tagged with something resembling a version number (
#.#.#(-beta#)
, e.g. 2.9 or 2.9-beta5) pod spec lint
passes, making sure the CocoaPod is 100% valid
Before pushing a build, you must:
- Add the release notes to the CHANGELOG.md, and commit
-
Run set-version, like so:
./Scripts/set-version.sh <version number>
This does the following:
-
Updates the UnrarKit-Info.plist file to indicate the new version number, and commits it
- Makes an annotated tag whose message contains the release notes entered in Step 1
-
Once that’s done, you can call git push --follow-tags
1, and let Travis CI take care of the rest.
Credits
- Dov Frankel ([email protected])
- Rogerio Pereira Araujo ([email protected])
- Vicent Scott ([email protected])
1: Or set followTags = true
in your git config to always get this behavior:
git config --global push.followTags true
Latest podspec
{ "name": "UnrarKit", "version": "2.9-beta8", "summary": "UnrarKit is here to enable Mac and iOS Cocoa apps to easily work with RAR files for read-only operations", "license": "BSD", "homepage": "https://github.com/abbeycode/UnrarKit", "authors": { "Dov Frankel": "[email protected]" }, "social_media_url": "https://twitter.com/dovfrankel", "source": { "git": "https://github.com/abbeycode/UnrarKit.git", "tag": "2.9-beta8" }, "platforms": { "ios": "7.0", "osx": "10.9" }, "requires_arc": "Classes/**/*", "source_files": "Classes/**/*.{mm,m,h}", "public_header_files": "Classes/*.h", "resource_bundles": { "UnrarKitResources": [ "Resources/**/*" ] }, "libraries": "z", "subspecs": [ { "name": "unrar-lib", "public_header_files": [ "Libraries/unrar/raros.hpp", "Libraries/unrar/dll.hpp" ], "source_files": [ "Libraries/unrar/*.hpp", "Libraries/unrar/rar.cpp", "Libraries/unrar/strlist.cpp", "Libraries/unrar/strfn.cpp", "Libraries/unrar/pathfn.cpp", "Libraries/unrar/smallfn.cpp", "Libraries/unrar/global.cpp", "Libraries/unrar/file.cpp", "Libraries/unrar/filefn.cpp", "Libraries/unrar/filcreat.cpp", "Libraries/unrar/archive.cpp", "Libraries/unrar/arcread.cpp", "Libraries/unrar/unicode.cpp", "Libraries/unrar/system.cpp", "Libraries/unrar/isnt.cpp", "Libraries/unrar/crypt.cpp", "Libraries/unrar/crc.cpp", "Libraries/unrar/rawread.cpp", "Libraries/unrar/encname.cpp", "Libraries/unrar/resource.cpp", "Libraries/unrar/match.cpp", "Libraries/unrar/timefn.cpp", "Libraries/unrar/rdwrfn.cpp", "Libraries/unrar/consio.cpp", "Libraries/unrar/options.cpp", "Libraries/unrar/errhnd.cpp", "Libraries/unrar/rarvm.cpp", "Libraries/unrar/secpassword.cpp", "Libraries/unrar/rijndael.cpp", "Libraries/unrar/getbits.cpp", "Libraries/unrar/sha1.cpp", "Libraries/unrar/sha256.cpp", "Libraries/unrar/blake2s.cpp", "Libraries/unrar/hash.cpp", "Libraries/unrar/extinfo.cpp", "Libraries/unrar/extract.cpp", "Libraries/unrar/volume.cpp", "Libraries/unrar/list.cpp", "Libraries/unrar/find.cpp", "Libraries/unrar/unpack.cpp", "Libraries/unrar/headers.cpp", "Libraries/unrar/threadpool.cpp", "Libraries/unrar/rs16.cpp", "Libraries/unrar/cmddata.cpp", "Libraries/unrar/ui.cpp", "Libraries/unrar/filestr.cpp", "Libraries/unrar/recvol.cpp", "Libraries/unrar/rs.cpp", "Libraries/unrar/scantree.cpp", "Libraries/unrar/qopen.cpp", "Libraries/unrar/dll.cpp" ], "preserve_paths": [ "Libraries/unrar/arccmt.cpp", "Libraries/unrar/blake2sp.cpp", "Libraries/unrar/coder.cpp", "Libraries/unrar/crypt1.cpp", "Libraries/unrar/crypt2.cpp", "Libraries/unrar/crypt3.cpp", "Libraries/unrar/crypt5.cpp", "Libraries/unrar/hardlinks.cpp", "Libraries/unrar/log.cpp", "Libraries/unrar/model.cpp", "Libraries/unrar/rarvmtbl.cpp", "Libraries/unrar/recvol3.cpp", "Libraries/unrar/recvol5.cpp", "Libraries/unrar/suballoc.cpp", "Libraries/unrar/uicommon.cpp", "Libraries/unrar/uisilent.cpp", "Libraries/unrar/ulinks.cpp", "Libraries/unrar/unpack15.cpp", "Libraries/unrar/unpack20.cpp", "Libraries/unrar/unpack30.cpp", "Libraries/unrar/unpack50.cpp", "Libraries/unrar/unpack50frag.cpp", "Libraries/unrar/unpackinline.cpp", "Libraries/unrar/uowners.cpp", "Libraries/unrar/win32stm.cpp" ], "pod_target_xcconfig": { "OTHER_LDFLAGS": "$(inherited) -lc++", "OTHER_CFLAGS": "$(inherited) -Wno-return-type -Wno-logical-op-parentheses -Wno-conversion -Wno-parentheses -Wno-unused-function -Wno-unused-variable -Wno-switch -Wno-unused-command-line-argument", "OTHER_CPLUSPLUSFLAGS": "$(inherited) -DSILENT -DRARDLL $(OTHER_CFLAGS)" }, "compiler_flags": "-Xanalyzer -analyzer-disable-all-checks" } ] }
Sat, 18 Nov 2017 15:20:16 +0000