Skip to content

Commit

Permalink
Overhauled library, bringing a new naming scheme, and consolidating i…
Browse files Browse the repository at this point in the history
…nto a single Xcode Workspace, and implementing the standard CocoaPods project layout
  • Loading branch information
abbeycode committed Mar 22, 2014
1 parent d2869d9 commit b7a333f
Show file tree
Hide file tree
Showing 242 changed files with 1,657 additions and 5,021 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Unrar4iOS CHANGELOG

## 0.1.0

Initial release.
19 changes: 8 additions & 11 deletions Unrar4iOS/Unrar4iOS.h → Classes/URRArchive.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// Unrar4iOS.h
// URRArchive.h
// Unrar4iOS
//
// Created by Rogerio Pereira Araujo on 10/11/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
// Created by Dov Frankel on 03/21/2014.
// Copyright 2014 Abbey Code. All rights reserved.
//

#import <Foundation/Foundation.h>
Expand Down Expand Up @@ -31,7 +31,7 @@ typedef NS_ENUM(NSInteger, URRErrorCode) {

extern NSString *URRErrorDomain;

@interface Unrar4iOS : NSObject {
@interface URRArchive : NSObject {

HANDLE _rarFile;
struct RARHeaderDataEx *header;
Expand All @@ -41,13 +41,10 @@ extern NSString *URRErrorDomain;
@property(nonatomic, retain) NSString *filename;
@property(nonatomic, retain) NSString *password;

+ (Unrar4iOS *)unrarFileAtPath:(NSString *)filePath;
+ (Unrar4iOS *)unrarFileAtURL:(NSURL *)fileURL;
+ (Unrar4iOS *)unrarFileAtPath:(NSString *)filePath password:(NSString *)password;
+ (Unrar4iOS *)unrarFileAtURL:(NSURL *)fileURL password:(NSString *)password;

- (void)openFile:(NSString *)filePath;
- (void)openFile:(NSString *)filePath password:(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;
Expand Down
51 changes: 25 additions & 26 deletions Unrar4iOS/Unrar4iOS.mm → Classes/URRArchive.mm
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//
// Unrar4iOS.mm
// URRArchive.mm
// Unrar4iOS
//
// Created by Rogerio Pereira Araujo on 10/11/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
// Created by Dov Frankel on 03/21/14.
// Copyright 2014 Abbey Code. All rights reserved.
//

#import "Unrar4iOS.h"
#import "URRArchive.h"


NSString *URRErrorDomain = @"URRErrorDomain";

@implementation Unrar4iOS
@implementation URRArchive

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


+ (Unrar4iOS *)unrarFileAtPath:(NSString *)filePath;
+ (URRArchive *)rarArchiveAtPath:(NSString *)filePath;
{
Unrar4iOS *result = [[Unrar4iOS alloc] init];
[result openFile:filePath];

URRArchive *result = [[URRArchive alloc] initWithFile:filePath];
return [result autorelease];
}

+ (Unrar4iOS *)unrarFileAtURL:(NSURL *)fileURL;
+ (URRArchive *)rarArchiveAtURL:(NSURL *)fileURL;
{
Unrar4iOS *result = [[Unrar4iOS alloc] init];
[result openFile:fileURL.path];

URRArchive *result = [[URRArchive alloc] initWithFile:fileURL.path];
return [result autorelease];
}

+ (Unrar4iOS *)unrarFileAtPath:(NSString *)filePath password:(NSString *)password;
+ (URRArchive *)rarArchiveAtPath:(NSString *)filePath password:(NSString *)password;
{
Unrar4iOS *result = [[Unrar4iOS alloc] init];
[result openFile:filePath password:password];

URRArchive *result = [[URRArchive alloc] initWithFile:filePath password:password];
return [result autorelease];
}

+ (Unrar4iOS *)unrarFileAtURL:(NSURL *)fileURL password:(NSString *)password;
+ (URRArchive *)rarArchiveAtURL:(NSURL *)fileURL password:(NSString *)password;
{
Unrar4iOS *result = [[Unrar4iOS alloc] init];
[result openFile:fileURL.path password:password];

URRArchive *result = [[URRArchive alloc] initWithFile:fileURL.path password:password];
return [result autorelease];
}

Expand All @@ -74,15 +66,22 @@ + (Unrar4iOS *)unrarFileAtURL:(NSURL *)fileURL password:(NSString *)password;
#pragma mark - Public Methods


- (void)openFile:(NSString *)filePath;
- (id)initWithFile:(NSString *)filePath;
{
[self openFile:filePath password:nil];
if ((self = [super init])) {
self.filename = filePath;
}

return self;
}

- (void)openFile:(NSString *)filePath password:(NSString*)password;
- (id)initWithFile:(NSString *)filePath password:(NSString*)password;
{
self.filename = filePath;
self.password = password;
if ((self = [self initWithFile:filePath])) {
self.password = password;
}

return self;
}

- (NSArray *)listFiles:(NSError **)error;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

#import <UIKit/UIKit.h>
#import <Unrar4iOS/Unrar4iOS.h>

@interface UnrarExampleViewController : UIViewController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

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

@implementation UnrarExampleViewController

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

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

Expand All @@ -63,7 +64,7 @@ - (IBAction)decompress:(id)sender {
}

// Extract a file into memory
NSData *data = [unrar extractDataFromFile:[files objectAtIndex:0] error:&error];
NSData *data = [archive extractDataFromFile:[files objectAtIndex:0] error:&error];

if (error) {
if (error.code == ERAR_MISSING_PASSWORD) {
Expand Down
File renamed without changes
File renamed without changes.
24 changes: 24 additions & 0 deletions Example/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pod "Unrar4iOS", :path => "../Unrar4iOS.podspec"

target "Demo" do
end

target "DemoTests" do
end

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

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

installer_representation.project.targets.each do |target|
if target.name.end_with? 'Unrar4iOS'
files_to_remove = target.source_build_phase.files.find_all do |file|
excluded_files.include? file.display_name
end

files_to_remove.each{|file| target.source_build_phase.remove_file_reference(file.file_ref)}
end
end
end
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; };
28D7ACF80DDB3853001CB0EB /* UnrarExampleViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* UnrarExampleViewController.mm */; };
480F6005128A0C0B00A9B478 /* not_protected.cbr in Resources */ = {isa = PBXBuildFile; fileRef = 480F6002128A0C0B00A9B478 /* not_protected.cbr */; };
487556F4128B85E700080B71 /* Unrar4iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 487556F3128B85E700080B71 /* Unrar4iOS.framework */; };
48BB62E31621B98300B424E2 /* protected.cbr in Resources */ = {isa = PBXBuildFile; fileRef = 48BB62E21621B98300B424E2 /* protected.cbr */; };
9685416E18DBA2B500B5651B /* libUnrar4iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9685416D18DBA2B500B5651B /* libUnrar4iOS.a */; };
96CD2C1A18D4D823002D004A /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 96CD2C1918D4D823002D004A /* [email protected] */; };
/* End PBXBuildFile section */

Expand All @@ -35,9 +35,10 @@
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
32CA4F630368D1EE00C91783 /* UnrarExample_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnrarExample_Prefix.pch; sourceTree = "<group>"; };
480F6002128A0C0B00A9B478 /* not_protected.cbr */ = {isa = PBXFileReference; lastKnownFileType = file; path = not_protected.cbr; sourceTree = "<group>"; };
487556F3128B85E700080B71 /* Unrar4iOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Unrar4iOS.framework; path = Frameworks/Unrar4iOS.framework; 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>"; };
96CD2C1918D4D823002D004A /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -46,10 +47,10 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9685416E18DBA2B500B5651B /* libUnrar4iOS.a in Frameworks */,
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */,
288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */,
487556F4128B85E700080B71 /* Unrar4iOS.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -112,7 +113,8 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
487556F3128B85E700080B71 /* Unrar4iOS.framework */,
9685416D18DBA2B500B5651B /* libUnrar4iOS.a */,
9685410A18DB9C8100B5651B /* libUnrar4iOS.a */,
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
1D30AB110D05D00D00671497 /* Foundation.framework */,
288765A40DF7441C002DB57D /* CoreGraphics.framework */,
Expand Down Expand Up @@ -201,19 +203,21 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/Frameworks\"",
);
FRAMEWORK_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)";
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = UnrarExample_Prefix.pch;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(BUILT_PRODUCTS_DIR)/../../Headers",
);
INFOPLIST_FILE = "UnrarExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/Frameworks\"",
"$(BUILT_PRODUCTS_DIR)",
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/Unrar4iOS-hdcdklgxaspoqwaqzxrymrryirrr/Build/Products/Debug-iphoneos",
);
PRODUCT_NAME = UnrarExample;
};
Expand All @@ -224,17 +228,19 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/Frameworks\"",
);
FRAMEWORK_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = UnrarExample_Prefix.pch;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(BUILT_PRODUCTS_DIR)/../../Headers",
);
INFOPLIST_FILE = "UnrarExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/Frameworks\"",
"$(BUILT_PRODUCTS_DIR)",
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/Unrar4iOS-hdcdklgxaspoqwaqzxrymrryirrr/Build/Products/Debug-iphoneos",
);
PRODUCT_NAME = UnrarExample;
VALIDATE_PRODUCT = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "UnrarExample.app"
BlueprintName = "UnrarExample"
ReferencedContainer = "container:UnrarExample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "UnrarExample.app"
BlueprintName = "UnrarExample"
ReferencedContainer = "container:UnrarExample.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "UnrarExample.app"
BlueprintName = "UnrarExample"
ReferencedContainer = "container:UnrarExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "UnrarExample.app"
BlueprintName = "UnrarExample"
ReferencedContainer = "container:UnrarExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
© Vicent Scott, All rights reserved.
© Dov Frankel, All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit b7a333f

Please sign in to comment.