Updated project to properly link & use the custom built libunrar library.

Also initial code to handle rar extraction. No handling or errors like missing RAR files, or requiring a password.
This commit is contained in:
Robert McGovern 2009-11-14 23:12:16 +01:00
parent f4630a44be
commit b3188496c3
7 changed files with 1412 additions and 76 deletions

View File

@ -2,18 +2,16 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">10A324</string>
<string key="IBDocument.InterfaceBuilderVersion">719</string>
<string key="IBDocument.AppKitVersion">1015</string>
<string key="IBDocument.HIToolboxVersion">418.00</string>
<string key="IBDocument.SystemVersion">10C540</string>
<string key="IBDocument.InterfaceBuilderVersion">740</string>
<string key="IBDocument.AppKitVersion">1038.25</string>
<string key="IBDocument.HIToolboxVersion">458.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">719</string>
<string key="NS.object.0">740</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="371"/>
<integer value="29"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -1325,10 +1323,9 @@
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<object class="NSView" key="NSWindowView" id="439893737">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<string key="NSFrameSize">{480, 360}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
@ -3427,7 +3424,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{525, 802}, {197, 73}}</string>
<string>{{380, 836}, {512, 20}}</string>
<string>{{380, 736}, {444, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{74, 862}</string>
@ -3452,10 +3449,10 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{380, 496}, {480, 360}}</string>
<string>{{380, 396}, {480, 360}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{380, 496}, {480, 360}}</string>
<integer value="1"/>
<string>{{380, 396}, {480, 360}}</string>
<boolean value="NO"/>
<string>{{33, 99}, {480, 360}}</string>
<string>{3.40282e+38, 3.40282e+38}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>

View File

@ -142,7 +142,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>0.1</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>

View File

@ -10,19 +10,19 @@
256AC3DA0F4B6AC300CF3369 /* QuietUnrarAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF3369 /* QuietUnrarAppDelegate.m */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
D488B9B310AF206000B3451C /* libunrar.so in Frameworks */ = {isa = PBXBuildFile; fileRef = D488B9B210AF206000B3451C /* libunrar.so */; };
D488BA8110AF216100B3451C /* libunrar.so in Resources */ = {isa = PBXBuildFile; fileRef = D488B9B210AF206000B3451C /* libunrar.so */; };
D488BC6810AF437B00B3451C /* libunrar.so in Frameworks */ = {isa = PBXBuildFile; fileRef = D488BC6710AF437B00B3451C /* libunrar.so */; };
D488BCC110AF49C700B3451C /* libunrar.so in CopyFiles */ = {isa = PBXBuildFile; fileRef = D488BC6710AF437B00B3451C /* libunrar.so */; };
D4A49691105435BE00BE38AE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
D4A49692105435C100BE38AE /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; };
D4A96E2110545E9A0091ECB4 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4A96E2010545E9A0091ECB4 /* Carbon.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
D4A4964C10541CFF00BE38AE /* PBXContainerItemProxy */ = {
D488BC6310AF435500B3451C /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
proxyType = 1;
remoteGlobalIDString = D4A4962A105419AA00BE38AE;
remoteGlobalIDString = D4A4962A105419AA00BE38AE /* libunrar */;
remoteInfo = libunrar;
};
/* End PBXContainerItemProxy section */
@ -32,8 +32,9 @@
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 7;
dstSubfolderSpec = 10;
files = (
D488BCC110AF49C700B3451C /* libunrar.so in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -52,7 +53,7 @@
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
8D1107310486CEB800E47090 /* QuietUnrar-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "QuietUnrar-Info.plist"; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* QuietUnrar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QuietUnrar.app; sourceTree = BUILT_PRODUCTS_DIR; };
D488B9B210AF206000B3451C /* libunrar.so */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libunrar.so; path = libunrar/libunrar.so; sourceTree = "<group>"; };
D488BC6710AF437B00B3451C /* libunrar.so */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libunrar.so; path = libunrar/libunrar.so; sourceTree = "<group>"; };
D4A495741054177300BE38AE /* arccmt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = arccmt.cpp; path = libunrar/arccmt.cpp; sourceTree = "<group>"; };
D4A495751054177300BE38AE /* archive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = archive.cpp; path = libunrar/archive.cpp; sourceTree = "<group>"; };
D4A495761054177300BE38AE /* archive.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = archive.hpp; path = libunrar/archive.hpp; sourceTree = "<group>"; };
@ -175,9 +176,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D488BC6810AF437B00B3451C /* libunrar.so in Frameworks */,
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
D4A96E2110545E9A0091ECB4 /* Carbon.framework in Frameworks */,
D488B9B310AF206000B3451C /* libunrar.so in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -196,7 +197,6 @@
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
D488B9B210AF206000B3451C /* libunrar.so */,
D4A96E2010545E9A0091ECB4 /* Carbon.framework */,
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
);
@ -256,6 +256,7 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
D488BC6710AF437B00B3451C /* libunrar.so */,
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
);
@ -411,11 +412,12 @@
8D11072E0486CEB800E47090 /* Frameworks */,
D4A4965210541D2600BE38AE /* CopyFiles */,
D4A49697105435C700BE38AE /* Resources */,
D488BC8210AF470700B3451C /* ShellScript */,
);
buildRules = (
);
dependencies = (
D4A4964D10541CFF00BE38AE /* PBXTargetDependency */,
D488BC6410AF435500B3451C /* PBXTargetDependency */,
);
name = QuietUnrar;
productInstallPath = "$(HOME)/Applications";
@ -446,7 +448,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D488BA8110AF216100B3451C /* libunrar.so in Resources */,
D4A49692105435C100BE38AE /* MainMenu.xib in Resources */,
D4A49691105435BE00BE38AE /* InfoPlist.strings in Resources */,
);
@ -454,6 +455,22 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
D488BC8210AF470700B3451C /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 12;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#export NEWLIBPATH=\"@loader_path/../Frameworks\"\n#export PROJECT_PATH=\"/Users/rob/Programming/Projects - Mine/QuietUnrar\"\n#\n#mkdir \"$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks\"\n#cp -f \"$PROJECT_PATH/libunrar/libunrar.so\" \"$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libunrar.so\"\n\ninstall_name_tool -change libunrar.so @loader_path/../Frameworks/libunrar.so \"$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME\"";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
8D11072C0486CEB800E47090 /* Sources */ = {
isa = PBXSourcesBuildPhase;
@ -467,10 +484,10 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
D4A4964D10541CFF00BE38AE /* PBXTargetDependency */ = {
D488BC6410AF435500B3451C /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D4A4962A105419AA00BE38AE /* libunrar */;
targetProxy = D4A4964C10541CFF00BE38AE /* PBXContainerItemProxy */;
targetProxy = D488BC6310AF435500B3451C /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
@ -508,7 +525,9 @@
GCC_PREPROCESSOR_DEFINITIONS = _UNIX;
INFOPLIST_FILE = "QuietUnrar-Info.plist";
INSTALL_PATH = "$(HOME)/Applications";
LD_DYLIB_INSTALL_NAME = "";
LIBRARY_SEARCH_PATHS = (
"@executable_path/../Frameworks",
"$(inherited)",
"\"$(SRCROOT)/libunrar\"",
);
@ -527,7 +546,9 @@
GCC_PREPROCESSOR_DEFINITIONS = _UNIX;
INFOPLIST_FILE = "QuietUnrar-Info.plist";
INSTALL_PATH = "$(HOME)/Applications";
LD_DYLIB_INSTALL_NAME = "";
LIBRARY_SEARCH_PATHS = (
"@executable_path/../Frameworks",
"$(inherited)",
"\"$(SRCROOT)/libunrar\"",
);

View File

@ -216,7 +216,7 @@
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>D488BA8F10AF23CF00B3451C</string>
<string>D488BD6610AF625400B3451C</string>
<key>history</key>
<array>
<string>D4C9D7EB10A9B7A20005973D</string>
@ -312,12 +312,12 @@
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
<integer>1</integer>
<integer>0</integer>
<integer>7</integer>
<integer>6</integer>
</array>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
<string>{{0, 0}, {186, 658}}</string>
<string>{{0, 0}, {186, 664}}</string>
</dict>
<key>PBXTopSmartGroupGIDs</key>
<array/>
@ -329,14 +329,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {203, 676}}</string>
<string>{{0, 0}, {203, 682}}</string>
<key>GroupTreeTableConfiguration</key>
<array>
<string>MainColumn</string>
<real>186</real>
</array>
<key>RubberWindowFrame</key>
<string>89 61 1190 717 0 0 1280 778 </string>
<string>53 55 1227 723 0 0 1280 778 </string>
</dict>
<key>Module</key>
<string>PBXSmartGroupTreeModule</string>
@ -366,17 +366,20 @@
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>D488BA8E10AF23CF00B3451C</string>
<string>D488BD6510AF625400B3451C</string>
<key>history</key>
<array>
<string>D4A4963610541A1C00BE38AE</string>
<string>D4A4965D105433E000BE38AE</string>
<string>D4A496731054350F00BE38AE</string>
<string>D4A96E4C1054628D0091ECB4</string>
<string>D4A96E4D1054628D0091ECB4</string>
<string>D4A96E4E1054628D0091ECB4</string>
<string>D4A96E4F1054628D0091ECB4</string>
<string>D4C9D7E810A9B7A20005973D</string>
<string>D488BC5810AF432D00B3451C</string>
<string>D488BCD010AF4A1700B3451C</string>
<string>D488BCD110AF4A1700B3451C</string>
<string>D488BD0610AF568000B3451C</string>
<string>D488BD3010AF598C00B3451C</string>
<string>D488BD3110AF598C00B3451C</string>
</array>
</dict>
<key>SplitCount</key>
@ -388,14 +391,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {982, 514}}</string>
<string>{{0, 0}, {1019, 520}}</string>
<key>RubberWindowFrame</key>
<string>89 61 1190 717 0 0 1280 778 </string>
<string>53 55 1227 723 0 0 1280 778 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
<string>514pt</string>
<string>520pt</string>
</dict>
<dict>
<key>ContentConfiguration</key>
@ -408,9 +411,9 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 519}, {982, 157}}</string>
<string>{{0, 525}, {1019, 157}}</string>
<key>RubberWindowFrame</key>
<string>89 61 1190 717 0 0 1280 778 </string>
<string>53 55 1227 723 0 0 1280 778 </string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
@ -419,7 +422,7 @@
</dict>
</array>
<key>Proportion</key>
<string>982pt</string>
<string>1019pt</string>
</dict>
</array>
<key>Name</key>
@ -576,14 +579,14 @@
<array>
<string>D488B03D10AF1C2900B3451C</string>
<string>D488B03E10AF1C2900B3451C</string>
<string>1C78EAAD065D492600B07095</string>
<string>1CD10A99069EF8BA00B06720</string>
<string>D4A49630105419F700BE38AE</string>
<string>1C78EAAD065D492600B07095</string>
<string>D40FFE1D105828A50070BCAF</string>
<string>/Users/rob/Programming/Projects - Mine/QuietUnrar/QuietUnrar.xcodeproj</string>
</array>
<key>WindowString</key>
<string>89 61 1190 717 0 0 1280 778 </string>
<string>53 55 1227 723 0 0 1280 778 </string>
<key>WindowToolsV3</key>
<array>
<dict>
@ -604,7 +607,7 @@
<key>PBXProjectModuleGUID</key>
<string>1CD0528F0623707200166675</string>
<key>PBXProjectModuleLabel</key>
<string></string>
<string>QuietUnrarAppDelegate.m</string>
<key>StatusBarVisibility</key>
<true/>
</dict>
@ -621,6 +624,8 @@
<string>267pt</string>
</dict>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
@ -962,7 +967,7 @@
<key>WindowToolGUID</key>
<string>1C78EAAD065D492600B07095</string>
<key>WindowToolIsVisible</key>
<false/>
<true/>
</dict>
<dict>
<key>Identifier</key>

File diff suppressed because it is too large Load Diff

View File

@ -21,10 +21,14 @@ enum
#define KEYMAP_GET(m, index) ((((uint8_t*)(m))[(index) >> 3] & (1L << ((index) & 7))) ? 1 : 0)
#define BUF_LEN 64000
@interface QuietUnrarAppDelegate : NSObject <NSApplicationDelegate> {
NSWindow *window;
}
@property (assign) IBOutlet NSWindow *window;
- (BOOL) extractRarWith:(NSString *) filename;
@end

View File

@ -14,23 +14,27 @@
@synthesize window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
- (void) applicationWillFinishLaunching:(NSNotification *)notification {
KeyMap map;
GetKeys(map);
NSLog(@"Shift or Right Shift: %d", KEYMAP_GET(map, kVKC_Shift) || KEYMAP_GET(map, kVKC_rShift));
NSLog(@"Dll Version %d\n", RARGetDllVersion());
}
- (BOOL)application:(id)sender openFileWithoutUI:(NSString *)filename {
NSLog(@"openFileWithoutUI with file: %@", filename);
return YES;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
// NSLog(@"Dll Version %d\n", RARGetDllVersion());
}
//- (BOOL)application:(id)sender openFileWithoutUI:(NSString *)filename {
// NSLog(@"openFileWithoutUI with file: %@", filename);
// return YES;
//}
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename {
NSLog(@"openFile: %@", filename);
return YES;
return [self extractRarWith:filename];
}
//- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames {
@ -42,4 +46,47 @@
// [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
//}
- (BOOL) extractRarWith:(NSString *) filename {
char commentBuffer[BUF_LEN];
BOOL extractionSuccessful = YES;
//Determine the folder we should extract the archive to. This by default
//is the <folderContainingTheArchive>/<archiveNameWithPathExtension>
NSString * defaultFolderToExtractTo = [filename stringByDeletingPathExtension];
char * cstringFilename = (char *)[filename cStringUsingEncoding:NSISOLatin1StringEncoding];
// Open the Archive for extraction, we set the open result to 3 so we can see it has changed
struct RAROpenArchiveData arcData = { cstringFilename, RAR_OM_EXTRACT, 3, &commentBuffer[0], BUF_LEN, 0, 0};
HANDLE archive = RAROpenArchive(&arcData);
NSLog(@"Opening Archive %s with result %d", cstringFilename, arcData.OpenResult);
// set call backs for if password needed or need to change volume
//
struct RARHeaderData headerData;
while (RARReadHeader(archive, &headerData) != ERAR_END_ARCHIVE) {
NSLog(@"Attempting to extract %s to %@", headerData.FileName, defaultFolderToExtractTo);
int process_result = RARProcessFile(archive, RAR_EXTRACT, (char *) [defaultFolderToExtractTo cStringUsingEncoding:NSISOLatin1StringEncoding], NULL);
if (process_result != 0) {
NSLog(@"Process Result was %d", process_result);
extractionSuccessful = NO;
// DISPLAY ERROR DIALOG, ALERT THE USER
}
else {
NSLog(@"...Extracted");
}
}
int close_result = RARCloseArchive(archive);
return extractionSuccessful;
}
@end