// // AppDelegate.m // RuntimeFS // // Created by Bill Bumgarner on 1/9/08. // Copyright 2008 Bill Bumgarner. All rights reserved. // #import #import "ClassFileSystem.h" #import "AppDelegate.h" @implementation AppDelegate - (void)didMount:(NSNotification *)notification { NSDictionary* userInfo = [notification userInfo]; NSString* mountPath = [userInfo objectForKey:@"mountPath"]; NSString* parentPath = [mountPath stringByDeletingLastPathComponent]; [[NSWorkspace sharedWorkspace] selectFile:mountPath inFileViewerRootedAtPath:parentPath]; } - (void)didUnmount:(NSNotification*)notification { [[NSApplication sharedApplication] terminate:nil]; } - (void)applicationDidFinishLaunching:(NSNotification *)notification { NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; [center addObserver:self selector:@selector(didMount:) name:kGMUserFileSystemDidMount object:nil]; [center addObserver:self selector:@selector(didUnmount:) name:kGMUserFileSystemDidUnmount object:nil]; NSString* mountPath = @"/Volumes/Objective-C Classes"; ClassFileSystem* classFS = [[ClassFileSystem alloc] init]; filesystem = [[GMUserFileSystem alloc] initWithDelegate:classFS isThreadSafe:YES]; NSMutableArray* options = [NSMutableArray array]; [options addObject:@"rdonly"]; [options addObject:@"local"]; [options addObject:@"volname=Classes"]; [options addObject:[NSString stringWithFormat:@"volicon=%@", [[NSBundle mainBundle] pathForResource:@"iCaramba" ofType:@"icns"]]]; [filesystem mountAtPath:mountPath withOptions:options]; } - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { [[NSNotificationCenter defaultCenter] removeObserver:self]; [filesystem unmount]; // Just in case we need to unmount; return NSTerminateNow; } @end