[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx: [264] branches/fusegl/fuse/fusepb/controller
Brought to you by:
fredm
From: <fr...@us...> - 2006-12-25 04:27:23
|
Revision: 264 http://svn.sourceforge.net/fuse-for-macosx/?rev=264&view=rev Author: fredm Date: 2006-12-24 20:27:24 -0800 (Sun, 24 Dec 2006) Log Message: ----------- Restore support for drag-n-drop and double clicking files to start Fuse. Modified Paths: -------------- branches/fusegl/fuse/fusepb/controllers/FuseController.h branches/fusegl/fuse/fusepb/controllers/FuseController.m Modified: branches/fusegl/fuse/fusepb/controllers/FuseController.h =================================================================== --- branches/fusegl/fuse/fusepb/controllers/FuseController.h 2006-12-25 01:32:17 UTC (rev 263) +++ branches/fusegl/fuse/fusepb/controllers/FuseController.h 2006-12-25 04:27:24 UTC (rev 264) @@ -159,5 +159,6 @@ - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication; - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename; @end Modified: branches/fusegl/fuse/fusepb/controllers/FuseController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/FuseController.m 2006-12-25 01:32:17 UTC (rev 263) +++ branches/fusegl/fuse/fusepb/controllers/FuseController.m 2006-12-25 04:27:24 UTC (rev 264) @@ -1324,6 +1324,88 @@ return NSTerminateCancel; } +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename +{ + utils_file file; libspectrum_id_t type; + libspectrum_class_t lsclass; + char fsrep[PATH_MAX+1]; + + [filename getFileSystemRepresentation:fsrep maxLength:PATH_MAX]; + + if ( display_ui_initialised ) { + [self addRecentSnapshot:fsrep]; + [self openFile:fsrep]; + } else { + if( utils_read_file( fsrep, &file ) ) fuse_abort(); + + if( libspectrum_identify_file( &type, fsrep, file.buffer, file.length ) ) { + utils_close_file( &file ); + fuse_abort(); + } + + if( libspectrum_identify_class( &lsclass, type ) ) fuse_abort(); + + switch( lsclass ) { + + case LIBSPECTRUM_CLASS_UNKNOWN: + fprintf( stderr, "%s: couldn't identify `%s'\n", fuse_progname, fsrep ); + case LIBSPECTRUM_CLASS_SCREENSHOT: + utils_close_file( &file ); + return NO; + + case LIBSPECTRUM_CLASS_RECORDING: + settings_current.playback_file = strdup( fsrep ); + break; + + case LIBSPECTRUM_CLASS_SNAPSHOT: + settings_current.snapshot = strdup( fsrep ); + break; + + case LIBSPECTRUM_CLASS_TAPE: + settings_current.tape_file = strdup( fsrep ); + break; + + case LIBSPECTRUM_CLASS_DISK_PLUS3: + settings_current.plus3disk_file = strdup( fsrep ); + break; + + case LIBSPECTRUM_CLASS_DISK_TRDOS: + settings_current.trdosdisk_file = strdup( fsrep ); + break; + + case LIBSPECTRUM_CLASS_CARTRIDGE_TIMEX: + settings_current.dck_file = strdup( fsrep ); + break; + + case LIBSPECTRUM_CLASS_CARTRIDGE_IF2: + settings_current.if2_file = strdup( fsrep ); + break; + + case LIBSPECTRUM_CLASS_HARDDISK: + if( settings_current.zxcf_active ) { + settings_current.zxcf_pri_file = strdup( fsrep ); + } else if( settings_current.zxatasp_active ) { + settings_current.zxatasp_master_file = strdup( fsrep ); + } else if( settings_current.simpleide_active ) { + settings_current.simpleide_master_file = strdup( fsrep ); + } else { + /* No IDE interface active, so activate the ZXCF */ + settings_current.zxcf_active = 1; + settings_current.zxcf_pri_file = strdup( fsrep ); + } + break; + + default: + fprintf( stderr, "%s: loadFile: unknown class %d!\n", + fuse_progname, type ); + } + + if( utils_close_file( &file ) ) fuse_abort(); + } + + return YES; +} + @end static char* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |