mirror of
https://github.com/ksherlock/ProFUSE-Image-Opener.git
synced 2024-12-22 07:30:27 +00:00
remove old files.
This commit is contained in:
parent
37c28d539b
commit
9dd5ad0fb5
@ -9,7 +9,6 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
B61F50B11329D7040061B88D /* fuse_pascal in Copy Files */ = {isa = PBXBuildFile; fileRef = B61F50AD1329D6DD0061B88D /* fuse_pascal */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
B61F50B21329D7040061B88D /* profuse in Copy Files */ = {isa = PBXBuildFile; fileRef = B61F50AF1329D6E90061B88D /* profuse */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
B63BC07B1D654CEE00412B44 /* IODocumentController.m in Sources */ = {isa = PBXBuildFile; fileRef = B63BC07A1D654CEE00412B44 /* IODocumentController.m */; };
|
||||
B63BC07E1D6552EB00412B44 /* IODocument.m in Sources */ = {isa = PBXBuildFile; fileRef = B63BC07D1D6552EA00412B44 /* IODocument.m */; };
|
||||
B672604B131DF025002ABC91 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B672604A131DF025002ABC91 /* Cocoa.framework */; };
|
||||
B6726055131DF025002ABC91 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B6726053131DF025002ABC91 /* InfoPlist.strings */; };
|
||||
@ -18,7 +17,6 @@
|
||||
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 /* IODocument.xib in Resources */ = {isa = PBXBuildFile; fileRef = B6726067131DF054002ABC91 /* IODocument.xib */; };
|
||||
B672606D131DF78E002ABC91 /* WindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B672606C131DF78E002ABC91 /* WindowController.m */; };
|
||||
B672607D131F5570002ABC91 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = B672607C131F5570002ABC91 /* Icon.icns */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@ -40,8 +38,6 @@
|
||||
/* Begin PBXFileReference section */
|
||||
B61F50AD1329D6DD0061B88D /* fuse_pascal */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = fuse_pascal; sourceTree = "<group>"; };
|
||||
B61F50AF1329D6E90061B88D /* profuse */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = profuse; sourceTree = "<group>"; };
|
||||
B63BC0791D654CEE00412B44 /* IODocumentController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IODocumentController.h; sourceTree = "<group>"; };
|
||||
B63BC07A1D654CEE00412B44 /* IODocumentController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IODocumentController.m; sourceTree = "<group>"; };
|
||||
B63BC07C1D6552EA00412B44 /* IODocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IODocument.h; sourceTree = "<group>"; };
|
||||
B63BC07D1D6552EA00412B44 /* IODocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IODocument.m; sourceTree = "<group>"; };
|
||||
B63BC07F1D65DFF100412B44 /* Image Opener.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Image Opener.entitlements"; sourceTree = "<group>"; };
|
||||
@ -59,8 +55,6 @@
|
||||
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/IODocument.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>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@ -120,10 +114,6 @@
|
||||
B63BC07D1D6552EA00412B44 /* IODocument.m */,
|
||||
B672605C131DF025002ABC91 /* Image_OpenerAppDelegate.h */,
|
||||
B672605D131DF025002ABC91 /* Image_OpenerAppDelegate.m */,
|
||||
B63BC0791D654CEE00412B44 /* IODocumentController.h */,
|
||||
B63BC07A1D654CEE00412B44 /* IODocumentController.m */,
|
||||
B672606B131DF78E002ABC91 /* WindowController.h */,
|
||||
B672606C131DF78E002ABC91 /* WindowController.m */,
|
||||
B672606A131DF0CD002ABC91 /* Resources */,
|
||||
B6726051131DF025002ABC91 /* Supporting Files */,
|
||||
);
|
||||
@ -229,11 +219,9 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B63BC07B1D654CEE00412B44 /* IODocumentController.m in Sources */,
|
||||
B6726058131DF025002ABC91 /* main.m in Sources */,
|
||||
B63BC07E1D6552EB00412B44 /* IODocument.m in Sources */,
|
||||
B672605E131DF025002ABC91 /* Image_OpenerAppDelegate.m in Sources */,
|
||||
B672606D131DF78E002ABC91 /* WindowController.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -1,47 +0,0 @@
|
||||
//
|
||||
// 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
|
@ -1,363 +0,0 @@
|
||||
//
|
||||
// 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;
|
||||
|
||||
enum {
|
||||
kTagLucky = 1,
|
||||
kTag2MG,
|
||||
kTagDC42,
|
||||
kTagSDK,
|
||||
kTagDavex,
|
||||
kTagPO,
|
||||
kTagDO
|
||||
};
|
||||
|
||||
static const char *TagToFormat(NSInteger tag)
|
||||
{
|
||||
switch (tag)
|
||||
{
|
||||
|
||||
case kTagPO:
|
||||
default:
|
||||
return "po";
|
||||
case kTagDO:
|
||||
return "do";
|
||||
case kTag2MG:
|
||||
return "2img";
|
||||
case kTagDC42:
|
||||
return "dc42";
|
||||
case kTagDavex:
|
||||
return "davex";
|
||||
case kTagSDK:
|
||||
return "sdk";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned ExtToTag(NSString *ext)
|
||||
{
|
||||
ext = [ext lowercaseString];
|
||||
|
||||
if ([ext isEqualToString: @"po"] ||
|
||||
[ext isEqualToString: @"raw"])
|
||||
{
|
||||
return kTagPO;
|
||||
}
|
||||
else if ([ext isEqualToString: @"do"] ||
|
||||
[ext isEqualToString: @"dsk"])
|
||||
{
|
||||
return kTagDO;
|
||||
}
|
||||
else if ([ext isEqualToString: @"2mg"] ||
|
||||
[ext isEqualToString: @"2img"])
|
||||
{
|
||||
return kTag2MG;
|
||||
}
|
||||
else if ([ext isEqualToString: @"dc42"] ||
|
||||
[ext isEqualToString: @"dc"])
|
||||
{
|
||||
return kTagDC42;
|
||||
}
|
||||
else if ([ext isEqualToString: @"davex"] ||
|
||||
[ext isEqualToString: @"dvx"])
|
||||
{
|
||||
return kTagDavex;
|
||||
}
|
||||
|
||||
else if ([ext isEqualToString: @"sdk"] ||
|
||||
[ext isEqualToString: @"shk"])
|
||||
{
|
||||
return kTagDavex;
|
||||
}
|
||||
|
||||
return kTagPO;
|
||||
}
|
||||
|
||||
+(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];
|
||||
|
||||
// if auto-released, the window will close.
|
||||
return controller;
|
||||
//return [controller autorelease];
|
||||
}
|
||||
|
||||
|
||||
- (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 = @"";
|
||||
off_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];
|
||||
|
||||
//format = ExtToTag(ext);
|
||||
|
||||
|
||||
[_ifMatrix selectCellWithTag: kTagLucky];
|
||||
[_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
|
||||
{
|
||||
NSPipe *pipe = [NSPipe pipe];
|
||||
NSString *launchPath;
|
||||
NSMutableArray *argv;
|
||||
NSNotificationCenter *nc;
|
||||
NSString *exe;
|
||||
|
||||
NSInteger tag;
|
||||
|
||||
_task = [[NSTask alloc] init];
|
||||
|
||||
[_task setStandardError: pipe];
|
||||
[_task setStandardOutput: pipe];
|
||||
[_task setStandardInput: [NSFileHandle fileHandleWithNullDevice]];
|
||||
|
||||
_handle = [[pipe fileHandleForReading] retain];
|
||||
|
||||
|
||||
switch ([_fsMatrix selectedTag])
|
||||
{
|
||||
case 1:
|
||||
default:
|
||||
exe = @"profuse";
|
||||
break;
|
||||
case 2:
|
||||
exe = @"fuse_pascal";
|
||||
break;
|
||||
}
|
||||
|
||||
launchPath = [[NSBundle mainBundle] pathForAuxiliaryExecutable: exe];
|
||||
|
||||
|
||||
|
||||
argv = [NSMutableArray arrayWithCapacity: 4];
|
||||
|
||||
[argv addObject: @"-r"]; // read-only.
|
||||
|
||||
tag = [_ifMatrix selectedTag];
|
||||
if (tag != kTagLucky)
|
||||
{
|
||||
[argv addObject: [NSString stringWithFormat: @"--format=%s", TagToFormat(tag)]];
|
||||
}
|
||||
|
||||
[argv addObject: _filePath];
|
||||
|
||||
|
||||
[_task setLaunchPath: launchPath];
|
||||
[_task setArguments: argv];
|
||||
|
||||
[self appendString: launchPath];
|
||||
|
||||
for (NSString *string in argv)
|
||||
{
|
||||
[self appendString: @" "];
|
||||
[self appendString: string];
|
||||
}
|
||||
[self appendString: @"\n\n"];
|
||||
|
||||
|
||||
nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
[nc addObserver: self
|
||||
selector: @selector(taskComplete:)
|
||||
name: NSTaskDidTerminateNotification
|
||||
object: _task];
|
||||
[nc addObserver: self
|
||||
selector: @selector(readComplete:)
|
||||
name: NSFileHandleReadCompletionNotification
|
||||
object: _handle];
|
||||
|
||||
|
||||
[_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];
|
||||
[string release];
|
||||
|
||||
[_handle readInBackgroundAndNotify];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(void)taskComplete: (NSNotification *)notification
|
||||
{
|
||||
BOOL ok = NO;
|
||||
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";
|
||||
ok = YES;
|
||||
}
|
||||
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;
|
||||
|
||||
if (!ok) [_mountButton setEnabled: YES];
|
||||
|
||||
}
|
||||
#pragma mark -
|
||||
#pragma mark NSWindowDelegate
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification
|
||||
{
|
||||
if (_filePath)
|
||||
{
|
||||
NSURL *url = [NSURL fileURLWithPath: _filePath isDirectory: NO];
|
||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: url];
|
||||
}
|
||||
|
||||
[self release];
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue
Block a user