mirror of
https://github.com/ksherlock/ProFUSE-Image-Opener.git
synced 2024-06-15 20:29:29 +00:00
a whole bunch of changes.
This commit is contained in:
parent
6fd52bf62f
commit
f128e33e45
|
@ -13,22 +13,48 @@
|
|||
B672605B131DF025002ABC91 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = B6726059131DF025002ABC91 /* Credits.rtf */; };
|
||||
B672605E131DF025002ABC91 /* Image_OpenerAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B672605D131DF025002ABC91 /* Image_OpenerAppDelegate.m */; };
|
||||
B6726061131DF025002ABC91 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = B672605F131DF025002ABC91 /* MainMenu.xib */; };
|
||||
B6726069131DF054002ABC91 /* Window.xib in Resources */ = {isa = PBXBuildFile; fileRef = B6726067131DF054002ABC91 /* Window.xib */; };
|
||||
B672606D131DF78E002ABC91 /* WindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B672606C131DF78E002ABC91 /* WindowController.m */; };
|
||||
B672607D131F5570002ABC91 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = B672607C131F5570002ABC91 /* Icon.icns */; };
|
||||
B68ACF7A1320906300B64522 /* profuse in Copy Files */ = {isa = PBXBuildFile; fileRef = B68ACF791320906300B64522 /* profuse */; };
|
||||
B68ACF7D1320906900B64522 /* fuse_pascal in Copy Files */ = {isa = PBXBuildFile; fileRef = B68ACF7C1320906900B64522 /* fuse_pascal */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
B68ACF7E1320918A00B64522 /* Copy Files */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 6;
|
||||
files = (
|
||||
B68ACF7A1320906300B64522 /* profuse in Copy Files */,
|
||||
B68ACF7D1320906900B64522 /* fuse_pascal in Copy Files */,
|
||||
);
|
||||
name = "Copy Files";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
B6726046131DF025002ABC91 /* Image Opener.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Image Opener.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B672604A131DF025002ABC91 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
|
||||
B672604D131DF025002ABC91 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
|
||||
B672604E131DF025002ABC91 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
|
||||
B672604F131DF025002ABC91 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
B6726052131DF025002ABC91 /* Image_Opener-Info.plist */ = {isa = PBXFileReference; path = "Image_Opener-Info.plist"; sourceTree = "<group>"; };
|
||||
B6726052131DF025002ABC91 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
B6726054131DF025002ABC91 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
B6726056131DF025002ABC91 /* Image_Opener-Prefix.pch */ = {isa = PBXFileReference; path = "Image_Opener-Prefix.pch"; sourceTree = "<group>"; };
|
||||
B6726056131DF025002ABC91 /* Image_Opener-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Image_Opener-Prefix.pch"; sourceTree = "<group>"; };
|
||||
B6726057131DF025002ABC91 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
B672605A131DF025002ABC91 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = "<group>"; };
|
||||
B672605C131DF025002ABC91 /* Image_OpenerAppDelegate.h */ = {isa = PBXFileReference; path = Image_OpenerAppDelegate.h; sourceTree = "<group>"; };
|
||||
B672605C131DF025002ABC91 /* Image_OpenerAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Image_OpenerAppDelegate.h; sourceTree = "<group>"; };
|
||||
B672605D131DF025002ABC91 /* Image_OpenerAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Image_OpenerAppDelegate.m; sourceTree = "<group>"; };
|
||||
B6726060131DF025002ABC91 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
|
||||
B6726068131DF054002ABC91 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/Window.xib; sourceTree = "<group>"; };
|
||||
B672606B131DF78E002ABC91 /* WindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowController.h; sourceTree = "<group>"; };
|
||||
B672606C131DF78E002ABC91 /* WindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WindowController.m; sourceTree = "<group>"; };
|
||||
B672607C131F5570002ABC91 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = "<group>"; };
|
||||
B68ACF791320906300B64522 /* profuse */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = profuse; path = "../../../Desktop/iPhone binaries/ProFUSE installer/2011-02-28/profuse"; sourceTree = "<group>"; };
|
||||
B68ACF7C1320906900B64522 /* fuse_pascal */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = fuse_pascal; path = "../../../Desktop/iPhone binaries/ProFUSE installer/2011-02-28/fuse_pascal"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -84,7 +110,9 @@
|
|||
children = (
|
||||
B672605C131DF025002ABC91 /* Image_OpenerAppDelegate.h */,
|
||||
B672605D131DF025002ABC91 /* Image_OpenerAppDelegate.m */,
|
||||
B672605F131DF025002ABC91 /* MainMenu.xib */,
|
||||
B672606B131DF78E002ABC91 /* WindowController.h */,
|
||||
B672606C131DF78E002ABC91 /* WindowController.m */,
|
||||
B672606A131DF0CD002ABC91 /* Resources */,
|
||||
B6726051131DF025002ABC91 /* Supporting Files */,
|
||||
);
|
||||
path = "Image Opener";
|
||||
|
@ -93,15 +121,27 @@
|
|||
B6726051131DF025002ABC91 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B6726052131DF025002ABC91 /* Image_Opener-Info.plist */,
|
||||
B6726052131DF025002ABC91 /* Info.plist */,
|
||||
B6726053131DF025002ABC91 /* InfoPlist.strings */,
|
||||
B6726056131DF025002ABC91 /* Image_Opener-Prefix.pch */,
|
||||
B6726057131DF025002ABC91 /* main.m */,
|
||||
B6726059131DF025002ABC91 /* Credits.rtf */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B672606A131DF0CD002ABC91 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B68ACF7C1320906900B64522 /* fuse_pascal */,
|
||||
B68ACF791320906300B64522 /* profuse */,
|
||||
B672607C131F5570002ABC91 /* Icon.icns */,
|
||||
B6726059131DF025002ABC91 /* Credits.rtf */,
|
||||
B672605F131DF025002ABC91 /* MainMenu.xib */,
|
||||
B6726067131DF054002ABC91 /* Window.xib */,
|
||||
);
|
||||
name = Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
|
@ -112,6 +152,7 @@
|
|||
B6726042131DF025002ABC91 /* Sources */,
|
||||
B6726043131DF025002ABC91 /* Frameworks */,
|
||||
B6726044131DF025002ABC91 /* Resources */,
|
||||
B68ACF7E1320918A00B64522 /* Copy Files */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
@ -152,6 +193,8 @@
|
|||
B6726055131DF025002ABC91 /* InfoPlist.strings in Resources */,
|
||||
B672605B131DF025002ABC91 /* Credits.rtf in Resources */,
|
||||
B6726061131DF025002ABC91 /* MainMenu.xib in Resources */,
|
||||
B6726069131DF054002ABC91 /* Window.xib in Resources */,
|
||||
B672607D131F5570002ABC91 /* Icon.icns in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -164,6 +207,7 @@
|
|||
files = (
|
||||
B6726058131DF025002ABC91 /* main.m in Sources */,
|
||||
B672605E131DF025002ABC91 /* Image_OpenerAppDelegate.m in Sources */,
|
||||
B672606D131DF78E002ABC91 /* WindowController.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -194,6 +238,14 @@
|
|||
name = MainMenu.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B6726067131DF054002ABC91 /* Window.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
B6726068131DF054002ABC91 /* en */,
|
||||
);
|
||||
name = Window.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
|
@ -237,7 +289,7 @@
|
|||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "Image Opener/Image_Opener-Prefix.pch";
|
||||
INFOPLIST_FILE = "Image Opener/Image_Opener-Info.plist";
|
||||
INFOPLIST_FILE = "Image Opener/Info.plist";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
|
@ -252,7 +304,7 @@
|
|||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "Image Opener/Image_Opener-Prefix.pch";
|
||||
INFOPLIST_FILE = "Image Opener/Image_Opener-Info.plist";
|
||||
INFOPLIST_FILE = "Image Opener/Info.plist";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
|
@ -277,6 +329,7 @@
|
|||
B6726066131DF025002ABC91 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
|
|
|
@ -15,4 +15,8 @@
|
|||
|
||||
@property (assign) IBOutlet NSWindow *window;
|
||||
|
||||
|
||||
-(IBAction)openDocument:(id)sender;
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
#import "Image_OpenerAppDelegate.h"
|
||||
#import "WindowController.h"
|
||||
|
||||
@implementation Image_OpenerAppDelegate
|
||||
|
||||
|
@ -17,4 +18,38 @@
|
|||
// Insert code here to initialize your application
|
||||
}
|
||||
|
||||
-(IBAction)openDocument:(id)sender
|
||||
{
|
||||
NSOpenPanel *panel;
|
||||
|
||||
panel = [NSOpenPanel openPanel];
|
||||
|
||||
[panel setCanChooseFiles: YES];
|
||||
[panel setCanCreateDirectories: NO];
|
||||
[panel setResolvesAliases: YES];
|
||||
[panel setAllowsMultipleSelection: NO];
|
||||
[panel setExtensionHidden: NO];
|
||||
|
||||
|
||||
[panel beginWithCompletionHandler: ^(NSInteger result){
|
||||
|
||||
if (result == 1)
|
||||
{
|
||||
WindowController *controller;
|
||||
NSURL *url = [[panel URLs] lastObject];
|
||||
NSString *path = [url isFileURL] ? [url path] : nil;
|
||||
|
||||
NSLog(@"%d %@", (int)result, path);
|
||||
|
||||
if (path)
|
||||
{
|
||||
controller = [WindowController controllerWithFilePath: path];
|
||||
}
|
||||
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<string>Icon.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.ksherlock.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
47
Image Opener/WindowController.h
Normal file
47
Image Opener/WindowController.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// WindowController.h
|
||||
// Image Opener
|
||||
//
|
||||
// Created by Kelvin Sherlock on 3/1/2011.
|
||||
// Copyright 2011 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
@interface WindowController : NSWindowController <NSWindowDelegate> {
|
||||
@private
|
||||
|
||||
IBOutlet NSMatrix *_fsMatrix;
|
||||
IBOutlet NSMatrix *_ifMatrix;
|
||||
|
||||
IBOutlet NSTextView *_textView;
|
||||
IBOutlet NSTextField *_nameView;
|
||||
IBOutlet NSTextField *_sizeView;
|
||||
|
||||
IBOutlet NSButton *_mountButton;
|
||||
|
||||
|
||||
NSTask *_task;
|
||||
NSFileHandle *_handle;
|
||||
|
||||
NSString *_filePath;
|
||||
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) NSString *filePath;
|
||||
|
||||
|
||||
+(id)controllerWithFilePath: (NSString *)filePath;
|
||||
|
||||
-(void)runTask;
|
||||
|
||||
-(IBAction)mountButton: (id)sender;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Notifications
|
||||
|
||||
-(void)readComplete:(NSNotification *)notification;
|
||||
-(void)taskComplete: (NSNotification *)notification;
|
||||
@end
|
311
Image Opener/WindowController.m
Normal file
311
Image Opener/WindowController.m
Normal file
|
@ -0,0 +1,311 @@
|
|||
//
|
||||
// WindowController.m
|
||||
// Image Opener
|
||||
//
|
||||
// Created by Kelvin Sherlock on 3/1/2011.
|
||||
// Copyright 2011 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WindowController.h"
|
||||
|
||||
|
||||
@implementation WindowController
|
||||
|
||||
@synthesize filePath = _filePath;
|
||||
|
||||
static const char *TagToFormat(NSInteger tag)
|
||||
{
|
||||
switch (tag)
|
||||
{
|
||||
|
||||
case 1:
|
||||
default:
|
||||
return "po";
|
||||
case 2:
|
||||
return "do";
|
||||
case 3:
|
||||
return "2img";
|
||||
case 4:
|
||||
return "dc42";
|
||||
case 5:
|
||||
return "davex";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+(id)new
|
||||
{
|
||||
return [[self alloc] initWithWindowNibName: @"Window"];
|
||||
|
||||
}
|
||||
|
||||
+(id)controllerWithFilePath: (NSString *)filePath
|
||||
{
|
||||
WindowController *controller = [[self alloc] initWithWindowNibName: @"Window"];
|
||||
NSWindow *window = [controller window]; // force a load...
|
||||
|
||||
[controller setFilePath: filePath];
|
||||
|
||||
[window makeKeyAndOrderFront: nil];
|
||||
[window makeFirstResponder: nil];
|
||||
|
||||
return controller;
|
||||
}
|
||||
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
NSLog(@"%s %@", sel_getName(_cmd), self);
|
||||
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
[nc removeObserver: self];
|
||||
|
||||
[_task release];
|
||||
[_handle release];
|
||||
|
||||
[_filePath release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
- (void)windowDidLoad
|
||||
{
|
||||
[super windowDidLoad];
|
||||
|
||||
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
||||
-(void)setFilePath:(NSString *)filePath
|
||||
{
|
||||
NSString *ext;
|
||||
NSFileManager *manager;
|
||||
NSDictionary *dict;
|
||||
NSError *error;
|
||||
unsigned format;
|
||||
|
||||
if (_filePath == filePath) return;
|
||||
|
||||
[_filePath release];
|
||||
_filePath = [filePath retain];
|
||||
|
||||
[[self window] setTitleWithRepresentedFilename: filePath];
|
||||
|
||||
[_nameView setStringValue: [_filePath lastPathComponent]];
|
||||
|
||||
|
||||
manager = [NSFileManager defaultManager];
|
||||
|
||||
error = nil;
|
||||
dict = [manager attributesOfItemAtPath: filePath error: &error];
|
||||
|
||||
if (error)
|
||||
{
|
||||
[_sizeView setStringValue: @""];
|
||||
[_mountButton setEnabled: NO];
|
||||
[_textView setString: [error localizedDescription]];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *ss = @"";
|
||||
size_t size = [(NSNumber *)[dict objectForKey: NSFileSize] unsignedLongLongValue];
|
||||
|
||||
if (size < 1024)
|
||||
ss = [NSString stringWithFormat: @"%u B", (unsigned)size];
|
||||
else if (size < 1024 * 1024)
|
||||
ss = [NSString stringWithFormat: @"%.1f KB", (double) size / 1024.0];
|
||||
|
||||
else ss = [NSString stringWithFormat: @"%.1f MB", (double) size / (1024.0 * 1024.0)];
|
||||
|
||||
[_sizeView setStringValue: ss];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// set the default image format.
|
||||
|
||||
|
||||
ext = [_filePath pathExtension];
|
||||
|
||||
ext = [ext lowercaseString];
|
||||
|
||||
format = 1;
|
||||
|
||||
if ([ext isEqualToString: @"po"] ||
|
||||
[ext isEqualToString: @"raw"])
|
||||
{
|
||||
format = 1;
|
||||
}
|
||||
else if ([ext isEqualToString: @"do"] ||
|
||||
[ext isEqualToString: @"dsk"])
|
||||
{
|
||||
format = 2;
|
||||
}
|
||||
else if ([ext isEqualToString: @"2mg"] ||
|
||||
[ext isEqualToString: @"2img"])
|
||||
{
|
||||
format = 3;
|
||||
}
|
||||
else if ([ext isEqualToString: @"dc42"])
|
||||
{
|
||||
format = 4;
|
||||
}
|
||||
else if ([ext isEqualToString: @"davex"] ||
|
||||
[ext isEqualToString: @"dvx"])
|
||||
{
|
||||
format = 5;
|
||||
}
|
||||
|
||||
[_ifMatrix selectCellWithTag: format];
|
||||
[_fsMatrix selectCellWithTag: 1]; // assume prodos.
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(IBAction)mountButton: (id)sender
|
||||
{
|
||||
[_mountButton setEnabled: NO];
|
||||
|
||||
[self runTask];
|
||||
}
|
||||
|
||||
-(void)appendString: (NSString *)string
|
||||
{
|
||||
if ([string length])
|
||||
{
|
||||
[[[_textView textStorage] mutableString] appendString: string];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void)runTask
|
||||
{
|
||||
NSTask *task;
|
||||
NSPipe *pipe = [NSPipe pipe];
|
||||
NSString *launchPath;
|
||||
NSArray *argv;
|
||||
NSFileHandle *handle;
|
||||
NSNotificationCenter *nc;
|
||||
|
||||
task = [[NSTask alloc] init];
|
||||
|
||||
[task setStandardError: pipe];
|
||||
[task setStandardOutput: pipe];
|
||||
[task setStandardInput: [NSFileHandle fileHandleWithNullDevice]];
|
||||
|
||||
handle = [pipe fileHandleForReading];
|
||||
|
||||
|
||||
launchPath = @"launch path...";
|
||||
|
||||
launchPath = [[NSBundle mainBundle] pathForAuxiliaryExecutable: @"profuse"];
|
||||
|
||||
argv = [NSArray arrayWithObjects:
|
||||
@"-r",
|
||||
[NSString stringWithFormat: @"--format=%s", TagToFormat([_ifMatrix selectedTag])],
|
||||
_filePath
|
||||
, nil];
|
||||
|
||||
|
||||
|
||||
[task setLaunchPath: launchPath];
|
||||
[task setArguments: argv];
|
||||
|
||||
[self appendString: launchPath];
|
||||
for (NSString *string in argv)
|
||||
{
|
||||
[self appendString: string];
|
||||
[self appendString: @" "];
|
||||
}
|
||||
[self appendString: @"\n\n"];
|
||||
|
||||
|
||||
return;
|
||||
|
||||
nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
[nc addObserver: self
|
||||
selector: @selector(taskComplete:)
|
||||
name: NSTaskDidTerminateNotification
|
||||
object: task];
|
||||
[nc addObserver: self
|
||||
selector: @selector(readComplete:)
|
||||
name: NSFileHandleReadCompletionNotification
|
||||
object: handle];
|
||||
|
||||
|
||||
_task = task;
|
||||
_handle = [handle retain];
|
||||
[task launch];
|
||||
[handle readInBackgroundAndNotify];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Notifications
|
||||
-(void)readComplete:(NSNotification *)notification
|
||||
{
|
||||
// read complete, queue up another.
|
||||
NSDictionary *dict = [notification userInfo];
|
||||
NSData *data = [dict objectForKey: NSFileHandleNotificationDataItem];
|
||||
|
||||
if ([data length])
|
||||
{
|
||||
|
||||
NSString *string = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
|
||||
|
||||
[self appendString: string];
|
||||
[_handle readInBackgroundAndNotify];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(void)taskComplete: (NSNotification *)notification
|
||||
{
|
||||
|
||||
NSTaskTerminationReason reason;
|
||||
int status;
|
||||
NSString *string = nil;
|
||||
|
||||
reason = [_task terminationReason];
|
||||
status = [_task terminationStatus];
|
||||
|
||||
if (reason == NSTaskTerminationReasonExit)
|
||||
{
|
||||
|
||||
if (status == 0) string = @"\n\n[Success]\n\n";
|
||||
else string = @"\n\n[An error occurred]\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
string = @"\n\n[Caught signal]\n\n";
|
||||
|
||||
}
|
||||
|
||||
[self appendString: string];
|
||||
|
||||
[_handle release];
|
||||
_handle = nil;
|
||||
|
||||
[_task release];
|
||||
_task = nil;
|
||||
|
||||
[_mountButton setEnabled: YES];
|
||||
|
||||
}
|
||||
#pragma mark -
|
||||
#pragma mark NSWindowDelegate
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification
|
||||
{
|
||||
[self release];
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,29 +1,15 @@
|
|||
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350
|
||||
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\paperw9840\paperh8400
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
|
||||
\vieww9600\viewh8400\viewkind0
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
|
||||
|
||||
\f0\b\fs24 \cf0 Engineering:
|
||||
\b0 \
|
||||
Some people\
|
||||
\f0\b\fs24 \cf0 Kelvin W Sherlock\
|
||||
\
|
||||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural
|
||||
|
||||
\b Human Interface Design:
|
||||
\b0 \
|
||||
Some other people\
|
||||
\
|
||||
\b0 \cf0 Verson 1.0
|
||||
\b \
|
||||
|
||||
\b Testing:
|
||||
\b0 \
|
||||
Hopefully not nobody\
|
||||
\
|
||||
|
||||
\b Documentation:
|
||||
\b0 \
|
||||
Whoever\
|
||||
\
|
||||
|
||||
\b With special thanks to:
|
||||
\b0 \
|
||||
Mom\
|
||||
\b0 2011-03-02\
|
||||
}
|
File diff suppressed because it is too large
Load Diff
1386
Image Opener/en.lproj/Window.xib
Normal file
1386
Image Opener/en.lproj/Window.xib
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user