14
14
// See the file "License.txt" for information on usage and redistribution of
15
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
17
// $Id: LauncherDialog.cxx 2356 2012-01-14 22:00:54Z stephena $
17
// $Id: LauncherDialog.cxx 2477 2012-05-16 20:52:33Z stephena $
19
19
// Based on code from ScummVM - Scumm Interpreter
20
20
// Copyright (C) 2002-2004 The ScummVM project
341
342
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
342
343
void LauncherDialog::loadDirListing()
344
if(!myCurrentNode.isDirectory())
345
if(!myCurrentNode.isDirectory() && !myCurrentNode.exists())
348
myCurrentNode.getChildren(files, FilesystemNode::kListAll);
351
if(myCurrentNode.isDirectory())
353
myCurrentNode.getChildren(files, FilesystemNode::kListAll);
358
if((tz = unzOpen(myCurrentNode.getPath().c_str())) != NULL)
360
if(unzGoToFirstFile(tz) == UNZ_OK)
364
for(;;) // Loop through all files for valid 2600 images
366
// Longer filenames might be possible, but I don't
367
// think people would name files that long in zip files...
370
unzGetCurrentFileInfo(tz, &ufo, filename, 1024, 0, 0, 0, 0);
371
filename[1023] = '\0';
373
if(strlen(filename) >= 4 &&
374
!BSPF_startsWithIgnoreCase(filename, "__MACOSX"))
376
// Grab 3-character extension
377
const char* ext = filename + strlen(filename) - 4;
379
if(BSPF_equalsIgnoreCase(ext, ".a26") || BSPF_equalsIgnoreCase(ext, ".bin") ||
380
BSPF_equalsIgnoreCase(ext, ".rom"))
382
FilesystemNode newFile(AbstractFilesystemNode::getAbsolutePath(
383
filename, myCurrentNode.getPath(), ""));
384
files.push_back(newFile);
388
// Scan the next file in the zip
389
if(unzGoToNextFile(tz) != UNZ_OK)
350
396
// Add '[..]' to indicate previous folder
351
397
if(myCurrentNode.hasParent())
363
409
// that we want - if there are no extensions, it implies show all files
364
410
// In this way, showing all files is on the 'fast code path'
366
413
name = " [" + name + "]";
367
415
else if(myRomExts.size() > 0)
369
417
// Skip over those names we've filtered out
480
528
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
529
int LauncherDialog::filesInArchive(const string& archive)
533
if((tz = unzOpen(archive.c_str())) != NULL)
536
if(unzGoToFirstFile(tz) == UNZ_OK)
540
for(;;) // Loop through all files for valid 2600 images
542
// Longer filenames might be possible, but I don't
543
// think people would name files that long in zip files...
546
unzGetCurrentFileInfo(tz, &ufo, filename, 1024, 0, 0, 0, 0);
547
filename[1023] = '\0';
549
if(strlen(filename) >= 4 &&
550
!BSPF_startsWithIgnoreCase(filename, "__MACOSX"))
552
// Grab 3-character extension
553
const char* ext = filename + strlen(filename) - 4;
555
if(BSPF_equalsIgnoreCase(ext, ".a26") || BSPF_equalsIgnoreCase(ext, ".bin") ||
556
BSPF_equalsIgnoreCase(ext, ".rom"))
560
// Scan the next file in the zip
561
if(unzGoToNextFile(tz) != UNZ_OK)
569
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
481
570
void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod, char ascii)
483
572
// Grab the key before passing it to the actual dialog and check for
518
607
const string& md5 = myGameList->md5(item);
519
608
string extension;
610
int numFilesInArchive = filesInArchive(rom);
611
bool isArchive = !myGameList->isDir(item) &&
612
BSPF_endsWithIgnoreCase(rom, ".zip");
521
614
// Directory's should be selected (ie, enter them and redisplay)
522
if(myGameList->isDir(item))
615
// Archives should be entered if they contain more than 1 file
616
if(isArchive && numFilesInArchive < 1)
618
instance().frameBuffer().showMessage("Archive does not contain any valid ROM files",
619
kMiddleCenter, true);
621
else if((isArchive && numFilesInArchive > 1) || myGameList->isDir(item))
524
623
string dirname = "";
525
624
if(myGameList->name(item) == " [..]")