Skip to content

Commit

Permalink
Renamed project from Unrar4iOS to UnrarKit
Browse files Browse the repository at this point in the history
  • Loading branch information
abbeycode committed Mar 23, 2014
1 parent b7a333f commit 152df9c
Show file tree
Hide file tree
Showing 25 changed files with 185 additions and 249 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build
.DS_Store
**/*.xcodeproj/project.xcworkspace/xcuserdata/*
**/*.xcodeproj/project.xcworkspace/xcshareddata/*.xccheckout
**/*.xcodeproj/xcuserdata/*

**/*.xccheckout
**/xcuserdata/*
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Unrar4iOS CHANGELOG
# UnrarKit CHANGELOG

## 0.1.0

Expand Down
53 changes: 53 additions & 0 deletions Classes/URKArchive.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// URKArchive.h
// UnrarKit
//
//

#import <Foundation/Foundation.h>
#import "raros.hpp"
#import "dll.hpp"

typedef NS_ENUM(NSInteger, URKErrorCode) {
URKErrorCodeEndOfArchive = ERAR_END_ARCHIVE,
URKErrorCodeNoMemory = ERAR_NO_MEMORY,
URKErrorCodeBadData = ERAR_BAD_DATA,
URKErrorCodeBadArchive = ERAR_BAD_ARCHIVE,
URKErrorCodeUnknownFormat = ERAR_UNKNOWN_FORMAT,
URKErrorCodeOpen = ERAR_EOPEN,
URKErrorCodeCreate = ERAR_ECREATE,
URKErrorCodeClose = ERAR_ECLOSE,
URKErrorCodeRead = ERAR_EREAD,
URKErrorCodeWrite = ERAR_EWRITE,
URKErrorCodeSmall = ERAR_SMALL_BUF,
URKErrorCodeUnknown = ERAR_UNKNOWN,
URKErrorCodeMissingPassword = ERAR_MISSING_PASSWORD,
URKErrorCodeArchiveNotFound = 101,
};

#define ERAR_ARCHIVE_NOT_FOUND 101

extern NSString *URKErrorDomain;

@interface URKArchive : NSObject {

HANDLE _rarFile;
struct RARHeaderDataEx *header;
struct RAROpenArchiveDataEx *flags;
}

@property(nonatomic, retain) NSString *filename;
@property(nonatomic, retain) NSString *password;

+ (instancetype)rarArchiveAtPath:(NSString *)filePath;
+ (instancetype)rarArchiveAtURL:(NSURL *)fileURL;
+ (instancetype)rarArchiveAtPath:(NSString *)filePath password:(NSString *)password;
+ (instancetype)rarArchiveAtURL:(NSURL *)fileURL password:(NSString *)password;

- (NSArray *)listFiles:(NSError **)error;
- (BOOL)extractFilesTo:(NSString *)filePath overWrite:(BOOL)overwrite error:(NSError **)error;
- (NSData *)extractDataFromFile:(NSString *)filePath error:(NSError **)error;

- (BOOL)closeFile;

@end
30 changes: 14 additions & 16 deletions Classes/URRArchive.mm → Classes/URKArchive.mm
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
//
// URRArchive.mm
// Unrar4iOS
// URKArchive.mm
// UnrarKit
//
// Created by Dov Frankel on 03/21/14.
// Copyright 2014 Abbey Code. All rights reserved.
//

#import "URRArchive.h"
#import "URKArchive.h"


NSString *URRErrorDomain = @"URRErrorDomain";
NSString *URKErrorDomain = @"URKErrorDomain";

@implementation URRArchive
@implementation URKArchive

int CALLBACK CallbackProc(UINT msg, long UserData, long P1, long P2) {
UInt8 **buffer;
Expand All @@ -37,27 +35,27 @@ int CALLBACK CallbackProc(UINT msg, long UserData, long P1, long P2) {
#pragma mark - Convenience Methods


+ (URRArchive *)rarArchiveAtPath:(NSString *)filePath;
+ (URKArchive *)rarArchiveAtPath:(NSString *)filePath;
{
URRArchive *result = [[URRArchive alloc] initWithFile:filePath];
URKArchive *result = [[URKArchive alloc] initWithFile:filePath];
return [result autorelease];
}

+ (URRArchive *)rarArchiveAtURL:(NSURL *)fileURL;
+ (URKArchive *)rarArchiveAtURL:(NSURL *)fileURL;
{
URRArchive *result = [[URRArchive alloc] initWithFile:fileURL.path];
URKArchive *result = [[URKArchive alloc] initWithFile:fileURL.path];
return [result autorelease];
}

+ (URRArchive *)rarArchiveAtPath:(NSString *)filePath password:(NSString *)password;
+ (URKArchive *)rarArchiveAtPath:(NSString *)filePath password:(NSString *)password;
{
URRArchive *result = [[URRArchive alloc] initWithFile:filePath password:password];
URKArchive *result = [[URKArchive alloc] initWithFile:filePath password:password];
return [result autorelease];
}

+ (URRArchive *)rarArchiveAtURL:(NSURL *)fileURL password:(NSString *)password;
+ (URKArchive *)rarArchiveAtURL:(NSURL *)fileURL password:(NSString *)password;
{
URRArchive *result = [[URRArchive alloc] initWithFile:fileURL.path password:password];
URKArchive *result = [[URKArchive alloc] initWithFile:fileURL.path password:password];
return [result autorelease];
}

Expand Down Expand Up @@ -328,7 +326,7 @@ - (BOOL)assignError:(NSError **)error code:(NSInteger)errorCode
if (error) {
NSString *errorName = [self errorNameForErrorCode:errorCode];

*error = [NSError errorWithDomain:URRErrorDomain
*error = [NSError errorWithDomain:URKErrorDomain
code:errorCode
userInfo:@{NSUnderlyingErrorKey: errorName}];
}
Expand Down
55 changes: 0 additions & 55 deletions Classes/URRArchive.h

This file was deleted.

2 changes: 0 additions & 2 deletions Example/Classes/UnrarExampleAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// UnrarExampleAppDelegate.h
// UnrarExample
//
// Created by Rogerio Pereira Araujo on 08/11/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
2 changes: 0 additions & 2 deletions Example/Classes/UnrarExampleAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// UnrarExampleAppDelegate.m
// UnrarExample
//
// Created by Rogerio Pereira Araujo on 08/11/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "UnrarExampleAppDelegate.h"
Expand Down
2 changes: 0 additions & 2 deletions Example/Classes/UnrarExampleViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// UnrarExampleViewController.h
// UnrarExample
//
// Created by Rogerio Pereira Araujo on 08/11/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
12 changes: 5 additions & 7 deletions Example/Classes/UnrarExampleViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
// UnrarExampleViewController.m
// UnrarExample
//
// Created by Rogerio Pereira Araujo on 08/11/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "UnrarExampleViewController.h"
#import <Unrar4iOS/URRArchive.h>
#import <UnrarKit/URKArchive.h>

@implementation UnrarExampleViewController

Expand Down Expand Up @@ -49,13 +47,13 @@ - (IBAction)decompress:(id)sender {
//NSString *filePath = [[NSBundle mainBundle] pathForResource:@"not_protected" ofType:@"cbr"];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"protected" ofType:@"cbr"];

URRArchive *archive = [URRArchive rarArchiveAtPath:filePath];
URKArchive *archive = [URKArchive rarArchiveAtPath:filePath];
NSError *error = nil;
NSArray *files = [unrar listFiles:&error];
NSArray *files = [archive listFiles:&error];

if (error) {
NSLog(@"Error reading archive: %@", error);
[unrar closeFile];
[archive closeFile];
return;
}

Expand All @@ -77,7 +75,7 @@ - (IBAction)decompress:(id)sender {
imageView.image = image;
}

[unrar closeFile];
[archive closeFile];
}

- (void)didReceiveMemoryWarning {
Expand Down
8 changes: 4 additions & 4 deletions Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pod "Unrar4iOS", :path => "../Unrar4iOS.podspec"
pod "UnrarKit", :path => "../UnrarKit.podspec"

target "Demo" do
end
Expand All @@ -7,13 +7,13 @@ target "DemoTests" do
end

post_install do |installer_representation|
puts 'Removing unwanted compilation sources from Unrar4iOS'
puts 'Removing unwanted compilation sources from UnrarKit'

excluded_files = File.readlines('Pods/Unrar4iOS/Resources/ExcludedBuildFiles.txt')
excluded_files = File.readlines('Pods/UnrarKit/Resources/ExcludedBuildFiles.txt')
excluded_files.each {|file| file.strip!}

installer_representation.project.targets.each do |target|
if target.name.end_with? 'Unrar4iOS'
if target.name.end_with? 'UnrarKit'
files_to_remove = target.source_build_phase.files.find_all do |file|
excluded_files.include? file.display_name
end
Expand Down
18 changes: 4 additions & 14 deletions Example/UnrarExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
28D7ACF80DDB3853001CB0EB /* UnrarExampleViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* UnrarExampleViewController.mm */; };
480F6005128A0C0B00A9B478 /* not_protected.cbr in Resources */ = {isa = PBXBuildFile; fileRef = 480F6002128A0C0B00A9B478 /* not_protected.cbr */; };
48BB62E31621B98300B424E2 /* protected.cbr in Resources */ = {isa = PBXBuildFile; fileRef = 48BB62E21621B98300B424E2 /* protected.cbr */; };
9685416E18DBA2B500B5651B /* libUnrar4iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9685416D18DBA2B500B5651B /* libUnrar4iOS.a */; };
96BBCACF18DE82D900BE9B86 /* libUnrarKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 96BBCACE18DE82D900BE9B86 /* libUnrarKit.a */; };
96CD2C1A18D4D823002D004A /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 96CD2C1918D4D823002D004A /* [email protected] */; };
/* End PBXBuildFile section */

Expand All @@ -37,8 +37,7 @@
480F6002128A0C0B00A9B478 /* not_protected.cbr */ = {isa = PBXFileReference; lastKnownFileType = file; path = not_protected.cbr; sourceTree = "<group>"; };
48BB62E21621B98300B424E2 /* protected.cbr */ = {isa = PBXFileReference; lastKnownFileType = file; path = protected.cbr; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* UnrarExample-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "UnrarExample-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
9685410A18DB9C8100B5651B /* libUnrar4iOS.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libUnrar4iOS.a; path = "../build/Debug-iphoneos/libUnrar4iOS.a"; sourceTree = "<group>"; };
9685416D18DBA2B500B5651B /* libUnrar4iOS.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libUnrar4iOS.a; path = "../../../Library/Developer/Xcode/DerivedData/Unrar4iOS-hdcdklgxaspoqwaqzxrymrryirrr/Build/Products/Debug-iphoneos/libUnrar4iOS.a"; sourceTree = "<group>"; };
96BBCACE18DE82D900BE9B86 /* libUnrarKit.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libUnrarKit.a; path = "../build/Debug-iphoneos/libUnrarKit.a"; sourceTree = "<group>"; };
96CD2C1918D4D823002D004A /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -47,7 +46,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9685416E18DBA2B500B5651B /* libUnrar4iOS.a in Frameworks */,
96BBCACF18DE82D900BE9B86 /* libUnrarKit.a in Frameworks */,
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */,
288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */,
Expand Down Expand Up @@ -113,8 +112,7 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
9685416D18DBA2B500B5651B /* libUnrar4iOS.a */,
9685410A18DB9C8100B5651B /* libUnrar4iOS.a */,
96BBCACE18DE82D900BE9B86 /* libUnrarKit.a */,
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
1D30AB110D05D00D00671497 /* Foundation.framework */,
288765A40DF7441C002DB57D /* CoreGraphics.framework */,
Expand Down Expand Up @@ -215,10 +213,6 @@
);
INFOPLIST_FILE = "UnrarExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LIBRARY_SEARCH_PATHS = (
"$(BUILT_PRODUCTS_DIR)",
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/Unrar4iOS-hdcdklgxaspoqwaqzxrymrryirrr/Build/Products/Debug-iphoneos",
);
PRODUCT_NAME = UnrarExample;
};
name = Debug;
Expand All @@ -238,10 +232,6 @@
);
INFOPLIST_FILE = "UnrarExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LIBRARY_SEARCH_PATHS = (
"$(BUILT_PRODUCTS_DIR)",
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/Unrar4iOS-hdcdklgxaspoqwaqzxrymrryirrr/Build/Products/Debug-iphoneos",
);
PRODUCT_NAME = UnrarExample;
VALIDATE_PRODUCT = YES;
};
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# About

Unrar4iOS is here to allow Mac and iOS apps to easily work with RAR files for read-only operations.
UnrarKit is here to enable Mac and iOS apps to easily work with RAR files for read-only operations.

There is a main project, with a static library target and a unit tests target, and an example project, which demonstrates how to use the library.

Expand All @@ -9,23 +9,23 @@ I'm always open to improvements, so please submit your pull requests.

# Installation

Unrar4iOS has been converted to a CocoaPods project. If you're not familiar with [CocoaPods](http://cocoapods.org), you can start with their [Getting Started guide](http://guides.cocoapods.org/using/getting-started.html).
UnrarKit has been converted to a CocoaPods project. If you're not familiar with [CocoaPods](http://cocoapods.org), you can start with their [Getting Started guide](http://guides.cocoapods.org/using/getting-started.html).

I've included a sample [`podfile`](Example/Podfile) in the Example directory along with the sample project. Because of the way the `unrar` library (which `Unrar4iOS` wraps) was written[1], the CocoaPods installation isn't as straightforward as it should be. As long as you include the `post_install` hook in your `podfile`, everything should still install with the single command:
I've included a sample [`podfile`](Example/Podfile) in the Example directory along with the sample project. Because of the way the `unrar` library (which `UnrarKit` wraps) was written[1], the CocoaPods installation isn't as straightforward as it should be. As long as you include the `post_install` hook in your `podfile`, everything should still install with the single command:

pod install


# Notes

Since this Unrar4iOS is cpp based library you will need to change the extension of classes that uses Unrar4iOS to .mm it will allow us to include libstdc++ on linking stage, otherwise you will need to add libstdc++ as linker flags in you application.
Since this UnrarKit is cpp based library you will need to change the extension of classes that uses UnrarKit to .mm it will allow us to include libstdc++ on linking stage, otherwise you will need to add libstdc++ as linker flags in you application.

To open in Xcode, use the [Unrar4iOS.xcworkspace](Unrar4iOS.xcworkspace) file, which includes the other projects.
To open in Xcode, use the [UnrarKit.xcworkspace](UnrarKit.xcworkspace) file, which includes the other projects.

# Credits

* Vicent Scott ([email protected])
* Rogerio Pereira Araujo ([email protected])
* Vicent Scott ([email protected])
* Dov Frankel ([email protected])

[1]: Some cpp files need to be downloaded, but can't be listed in the build phase. They have to be included in the build by includes in other files.
File renamed without changes.
Loading

0 comments on commit 152df9c

Please sign in to comment.