ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/MacOSX/Launcher/VMListController.mm
(Generate patch)

Comparing SheepShaver/src/MacOSX/Launcher/VMListController.mm (file contents):
Revision 1.9 by asvitkine, 2009-08-26T07:09:06Z vs.
Revision 1.10 by asvitkine, 2009-08-31T05:08:21Z

# Line 25 | Line 25
25  
26   TODO:
27  
28 Verify if VM exists
28   Drag VM from Finder to import
29   When choosing things like rom file and keycode files - have a checkbox to copy
30   selected file into the bundle.
# Line 86 | Line 85 | Copy path!
85          [vmList registerForDraggedTypes:[NSArray arrayWithObjects:VM_DRAG_TYPE, nil]];
86   }
87  
88 + - (void) _showNotFoundAlert
89 + {
90 +        NSAlert *alert = [[[NSAlert alloc] init] autorelease];
91 +        [alert setMessageText:@"The virtual machine cannot be found."];
92 +        [alert setAlertStyle:NSWarningAlertStyle];
93 +        [alert beginSheetModalForWindow:[self window]
94 +                    modalDelegate:self
95 +                   didEndSelector:nil
96 +                      contextInfo:nil];
97 + }
98 +
99   - (void) reloadDataAndSave
100   {
101          [vmList reloadData];
# Line 117 | Line 127 | Copy path!
127          NSString *currentPath = [vmArray objectAtIndex: r];
128          NSString *newPath = [[NSString stringWithFormat:@"%@/%@.sheepvm",
129                  [currentPath stringByDeletingLastPathComponent], value] retain];
130 <        NSFileManager *manager = [NSFileManager defaultManager];
131 <        if ([manager movePath: currentPath toPath: newPath handler:nil]) {
132 <                [vmArray replaceObjectAtIndex: r withObject: newPath];
133 <                [currentPath release];
130 >        if (![currentPath isEqual:newPath]) {
131 >                if ([[NSFileManager defaultManager] fileExistsAtPath:currentPath]) {
132 >                        NSFileManager *manager = [NSFileManager defaultManager];
133 >                        if ([manager movePath: currentPath toPath: newPath handler:nil]) {
134 >                                [vmArray replaceObjectAtIndex: r withObject: newPath];
135 >                                [currentPath release];
136 >                        }
137 >                } else {
138 >                        [self _showNotFoundAlert];
139 >                }
140          }
141   }
142  
# Line 271 | Line 287 | Copy path!
287                                      modalDelegate:self
288                                     didEndSelector:nil
289                                        contextInfo:nil];
290 <                } else {
290 >                } else if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
291                          [[VMSettingsController sharedInstance] editSettingsFor:path sender:sender];
292 +                } else {
293 +                        [self _showNotFoundAlert];
294                  }
295          }
296   }
# Line 290 | Line 308 | Copy path!
308                                      modalDelegate:self
309                                     didEndSelector:nil
310                                        contextInfo:nil];
311 <                } else {
311 >                } else if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
312                          NSTask *sheep = [[NSTask alloc] init];
313                          [sheep setLaunchPath:[[NSBundle mainBundle] pathForAuxiliaryExecutable:@"SheepShaver"]];
314                          [sheep setArguments:[NSArray arrayWithObject:path]];
315                          [sheep launch];
316                          [tasks setObject:sheep forKey:path];
317 +                } else {
318 +                        [self _showNotFoundAlert];
319                  }
320          }
321   }
# Line 327 | Line 347 | Copy path!
347                                    modalDelegate:self
348                                   didEndSelector:@selector(_deleteVirtualMachineDone: returnCode: contextInfo:)
349                                      contextInfo:nil];
330
350          }
351   }
352  
# Line 344 | Line 363 | Copy path!
363   {
364          int selectedRow = [vmList selectedRow];
365          if (selectedRow >= 0) {
366 <                [[NSWorkspace sharedWorkspace] selectFile: [vmArray objectAtIndex:selectedRow] inFileViewerRootedAtPath: @""];
366 >                NSString *path = [vmArray objectAtIndex:selectedRow];
367 >                if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
368 >                        [[NSWorkspace sharedWorkspace] selectFile: path inFileViewerRootedAtPath: @""];
369 >                } else {
370 >                        [self _showNotFoundAlert];
371 >                }
372          }
373   }
374  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines