Various path and filenames can now be stored with the '~' character; it

will be expanded to your home directory (whatever that may mean for your
OS) when necessary.

A few more fixes for the Win32 filesystem code.

Bumped version number back a little; we're still not ready.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1631 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2009-01-16 16:38:06 +00:00
parent 473b640c75
commit fabae5f02f
11 changed files with 79 additions and 66 deletions

View File

@ -56,8 +56,9 @@
currently in use. currently in use.
* Various path textboxes in the UI now recognize './' (or '.\') to mean * Various path textboxes in the UI now recognize './' (or '.\') to mean
the current directory. In Linux/UNIX, '~/' is also recognized to the current directory and '~/' (or '~\') is also recognized to
mean your home directory. mean your home directory (for Windows, home directory will be your
'My Documents' folder).
* Large speedup in loading directories with many files in the ROM launcher. * Large speedup in loading directories with many files in the ROM launcher.

View File

@ -267,8 +267,9 @@
currently in use.</li> currently in use.</li>
<li>Various path textboxes in the UI now recognize './' (or '.\') to mean <li>Various path textboxes in the UI now recognize './' (or '.\') to mean
the current directory. In Linux/UNIX, '~/' is also recognized to the current directory and '~/' (or '~\') is also recognized to
mean your home directory.</li> mean your home directory (for Windows, home directory will be your
'My Documents' folder).</li>
<li>Large speedup in loading directories with many files in the ROM launcher.</li> <li>Large speedup in loading directories with many files in the ROM launcher.</li>

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Version.hxx,v 1.43 2009-01-15 19:05:27 stephena Exp $ // $Id: Version.hxx,v 1.44 2009-01-16 16:38:06 stephena Exp $
//============================================================================ //============================================================================
#ifndef VERSION_HXX #ifndef VERSION_HXX
#define VERSION_HXX #define VERSION_HXX
#define STELLA_BASE_VERSION "2.7" #define STELLA_BASE_VERSION "2.7_pre"
#ifdef NIGHTLY_BUILD #ifdef NIGHTLY_BUILD
#define STELLA_VERSION STELLA_BASE_VERSION "pre-" NIGHTLY_BUILD #define STELLA_VERSION STELLA_BASE_VERSION "pre-" NIGHTLY_BUILD

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EventHandler.cxx,v 1.238 2009-01-14 20:31:07 stephena Exp $ // $Id: EventHandler.cxx,v 1.239 2009-01-16 16:38:06 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -1769,7 +1769,7 @@ void EventHandler::takeSnapshot()
{ {
// Figure out the correct snapshot name // Figure out the correct snapshot name
string filename; string filename;
string sspath = myOSystem->settings().getString("ssdir"); string sspath = myOSystem->snapshotDir();
if(sspath.length() > 0) if(sspath.length() > 0)
if(sspath.substr(sspath.length()-1) != BSPF_PATH_SEPARATOR) if(sspath.substr(sspath.length()-1) != BSPF_PATH_SEPARATOR)
@ -1790,8 +1790,8 @@ void EventHandler::takeSnapshot()
{ {
buf.str(""); buf.str("");
buf << sspath << "_" << i << ".png"; buf << sspath << "_" << i << ".png";
FilesystemNode node(buf.str()); FilesystemNode next(buf.str());
if(!node.exists()) if(!next.exists())
break; break;
} }
filename = buf.str(); filename = buf.str();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystem.cxx,v 1.147 2009-01-14 20:31:07 stephena Exp $ // $Id: OSystem.cxx,v 1.148 2009-01-16 16:38:06 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -270,38 +270,45 @@ bool OSystem::create()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setConfigPaths() void OSystem::setConfigPaths()
{ {
// Paths are saved with special characters preserved ('~' or '.')
// Internally, we expand them so the rest of the codebase doesn't
// have to worry about it
FilesystemNode node; FilesystemNode node;
string s;
myStateDir = mySettings->getString("statedir"); s = mySettings->getString("statedir");
if(myStateDir == "") if(s == "") s = myBaseDir + BSPF_PATH_SEPARATOR + "state";
myStateDir = myBaseDir + BSPF_PATH_SEPARATOR + "state"; mySettings->setString("statedir", s);
node = FilesystemNode(myStateDir); node = FilesystemNode(s);
myStateDir = node.getPath();
if(!node.isDirectory()) if(!node.isDirectory())
AbstractFilesystemNode::makeDir(myStateDir); AbstractFilesystemNode::makeDir(myStateDir);
mySettings->setString("statedir", myStateDir);
mySnapshotDir = mySettings->getString("ssdir"); s = mySettings->getString("ssdir");
if(mySnapshotDir == "") if(s == "") s = myBaseDir + BSPF_PATH_SEPARATOR + "snapshots";
mySnapshotDir = myBaseDir + BSPF_PATH_SEPARATOR + "snapshots"; mySettings->setString("ssdir", s);
node = FilesystemNode(mySnapshotDir); node = FilesystemNode(s);
mySnapshotDir = node.getPath();
if(!node.isDirectory()) if(!node.isDirectory())
AbstractFilesystemNode::makeDir(mySnapshotDir); AbstractFilesystemNode::makeDir(mySnapshotDir);
mySettings->setString("ssdir", mySnapshotDir);
myCheatFile = mySettings->getString("cheatfile"); s = mySettings->getString("cheatfile");
if(myCheatFile == "") if(s == "") s = myBaseDir + BSPF_PATH_SEPARATOR + "stella.cht";
myCheatFile = myBaseDir + BSPF_PATH_SEPARATOR + "stella.cht"; mySettings->setString("cheatfile", s);
mySettings->setString("cheatfile", myCheatFile); node = FilesystemNode(s);
myCheatFile = node.getPath();
myPaletteFile = mySettings->getString("palettefile"); s = mySettings->getString("palettefile");
if(myPaletteFile == "") if(s == "") s = myBaseDir + BSPF_PATH_SEPARATOR + "stella.pal";
myPaletteFile = myBaseDir + BSPF_PATH_SEPARATOR + "stella.pal"; mySettings->setString("palettefile", s);
mySettings->setString("palettefile", myPaletteFile); node = FilesystemNode(s);
myPaletteFile = node.getPath();
myPropertiesFile = mySettings->getString("propsfile"); s = mySettings->getString("propsfile");
if(myPropertiesFile == "") if(s == "") s = myBaseDir + BSPF_PATH_SEPARATOR + "stella.pro";
myPropertiesFile = myBaseDir + BSPF_PATH_SEPARATOR + "stella.pro"; mySettings->setString("propsfile", s);
mySettings->setString("propsfile", myPropertiesFile); node = FilesystemNode(s);
myPropertiesFile = node.getPath();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -318,8 +325,16 @@ void OSystem::setBaseDir(const string& basedir)
{ {
myBaseDir = basedir; myBaseDir = basedir;
FilesystemNode node(myBaseDir); FilesystemNode node(myBaseDir);
myBaseDirExpanded = node.getPath();
if(!node.isDirectory()) if(!node.isDirectory())
AbstractFilesystemNode::makeDir(myBaseDir); AbstractFilesystemNode::makeDir(myBaseDirExpanded);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setConfigFile(const string& file)
{
FilesystemNode node(file);
myConfigFile = node.getPath();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystem.hxx,v 1.75 2009-01-15 01:31:26 stephena Exp $ // $Id: OSystem.hxx,v 1.76 2009-01-16 16:38:06 stephena Exp $
//============================================================================ //============================================================================
#ifndef OSYSTEM_HXX #ifndef OSYSTEM_HXX
@ -56,7 +56,7 @@ typedef Common::Array<Resolution> ResolutionList;
other objects belong. other objects belong.
@author Stephen Anthony @author Stephen Anthony
@version $Id: OSystem.hxx,v 1.75 2009-01-15 01:31:26 stephena Exp $ @version $Id: OSystem.hxx,v 1.76 2009-01-16 16:38:06 stephena Exp $
*/ */
class OSystem class OSystem
{ {
@ -249,17 +249,17 @@ class OSystem
const ResolutionList& supportedResolutions() const { return myResolutions; } const ResolutionList& supportedResolutions() const { return myResolutions; }
/** /**
Return the default directory for storing data. Return the default full/complete directory name for storing data.
*/ */
const string& baseDir() const { return myBaseDir; } const string& baseDir() const { return myBaseDirExpanded; }
/** /**
Return the directory for storing state files. Return the full/complete directory name for storing state files.
*/ */
const string& stateDir() const { return myStateDir; } const string& stateDir() const { return myStateDir; }
/** /**
Return the directory for storing PNG snapshots. Return the full/complete directory name for storing PNG snapshots.
*/ */
const string& snapshotDir() const { return mySnapshotDir; } const string& snapshotDir() const { return mySnapshotDir; }
@ -427,7 +427,7 @@ class OSystem
/** /**
Set the locations of config file Set the locations of config file
*/ */
void setConfigFile(const string& file) { myConfigFile = file; } void setConfigFile(const string& file);
protected: protected:
// Pointer to the EventHandler object // Pointer to the EventHandler object
@ -486,7 +486,7 @@ class OSystem
private: private:
enum { kNumUIPalettes = 2 }; enum { kNumUIPalettes = 2 };
string myBaseDir; string myBaseDir, myBaseDirExpanded;
string myStateDir; string myStateDir;
string mySnapshotDir; string mySnapshotDir;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FileSnapDialog.cxx,v 1.27 2009-01-15 18:45:23 stephena Exp $ // $Id: FileSnapDialog.cxx,v 1.28 2009-01-16 16:38:06 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -154,14 +154,15 @@ FileSnapDialog::~FileSnapDialog()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::loadConfig() void FileSnapDialog::loadConfig()
{ {
myRomPath->setEditString(instance().settings().getString("romdir")); const Settings& settings = instance().settings();
myStatePath->setEditString(instance().stateDir()); myRomPath->setEditString(settings.getString("romdir"));
myCheatFile->setEditString(instance().cheatFile()); myStatePath->setEditString(settings.getString("statedir"));
myPaletteFile->setEditString(instance().paletteFile()); myCheatFile->setEditString(settings.getString("cheatfile"));
myPropsFile->setEditString(instance().propertiesFile()); myPaletteFile->setEditString(settings.getString("palettefile"));
mySnapPath->setEditString(instance().settings().getString("ssdir")); myPropsFile->setEditString(settings.getString("propsfile"));
mySnapSingle->setState(!instance().settings().getBool("sssingle")); mySnapPath->setEditString(settings.getString("ssdir"));
mySnap1x->setState(instance().settings().getBool("ss1x")); mySnapSingle->setState(!settings.getBool("sssingle"));
mySnap1x->setState(settings.getBool("ss1x"));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: RomInfoWidget.cxx,v 1.16 2009-01-12 01:07:29 stephena Exp $ // $Id: RomInfoWidget.cxx,v 1.17 2009-01-16 16:38:06 stephena Exp $
//============================================================================ //============================================================================
#include <cstring> #include <cstring>
@ -120,8 +120,7 @@ void RomInfoWidget::parseProperties()
StringList textChucks; StringList textChucks;
// Get a valid filename representing a snapshot file for this rom // Get a valid filename representing a snapshot file for this rom
const string& filename = const string& filename = instance().snapshotDir() + BSPF_PATH_SEPARATOR +
instance().settings().getString("ssdir") + BSPF_PATH_SEPARATOR +
myProperties.get(Cartridge_Name) + ".png"; myProperties.get(Cartridge_Name) + ".png";
// Open the PNG and check for a valid signature // Open the PNG and check for a valid signature

View File

@ -13,14 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystemUNIX.cxx,v 1.31 2009-01-16 14:57:53 stephena Exp $ // $Id: OSystemUNIX.cxx,v 1.32 2009-01-16 16:38:06 stephena Exp $
//============================================================================ //============================================================================
#include <cstdlib> #include <cstdlib>
#include <unistd.h> #include <unistd.h>
#include "bspf.hxx" #include "bspf.hxx"
#include "FSNode.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
#include "OSystemUNIX.hxx" #include "OSystemUNIX.hxx"
@ -43,10 +42,8 @@
OSystemUNIX::OSystemUNIX() OSystemUNIX::OSystemUNIX()
: OSystem() : OSystem()
{ {
FilesystemNode home("~"); setBaseDir("~/.stella");
const string& basedir = home.getPath() + "/.stella"; setConfigFile("~/.stella/stellarc");
setBaseDir(basedir);
setConfigFile(basedir + "/stellarc");
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FSNodeWin32.cxx,v 1.18 2009-01-16 15:13:46 stephena Exp $ // $Id: FSNodeWin32.cxx,v 1.19 2009-01-16 16:38:06 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -82,11 +82,9 @@ class MyDocumentsFinder
{ {
myFolderModule = LoadLibrary("shfolder.dll"); myFolderModule = LoadLibrary("shfolder.dll");
if(myFolderModule) if(myFolderModule)
{
myFolderPathFunc = reinterpret_cast<function_pointer> myFolderPathFunc = reinterpret_cast<function_pointer>
(::GetProcAddress(myFolderModule, "SHGetFolderPathA")); (::GetProcAddress(myFolderModule, "SHGetFolderPathA"));
} }
}
~MyDocumentsFinder() { if(myFolderModule) FreeLibrary(myFolderModule); } ~MyDocumentsFinder() { if(myFolderModule) FreeLibrary(myFolderModule); }
@ -407,7 +405,7 @@ AbstractFilesystemNode* WindowsFilesystemNode::getParent() const
const char *start = _path.c_str(); const char *start = _path.c_str();
const char *end = lastPathComponent(_path); const char *end = lastPathComponent(_path);
p = new WindowsFilesystemNode(); //FIXME - this seems like a memory leak p = new WindowsFilesystemNode();
p->_path = string(start, end - start); p->_path = string(start, end - start);
p->_isValid = true; p->_isValid = true;
p->_isDirectory = true; p->_isDirectory = true;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystemWin32.cxx,v 1.28 2009-01-16 14:57:53 stephena Exp $ // $Id: OSystemWin32.cxx,v 1.29 2009-01-16 16:38:06 stephena Exp $
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -41,7 +41,8 @@ OSystemWin32::OSystemWin32()
if(!node.exists()) if(!node.exists())
{ {
FilesystemNode home("~"); FilesystemNode home("~");
basedir = home.getPath() + "\\Stella"; if(node.isDirectory())
basedir = "~\\Stella";
} }
setBaseDir(basedir); setBaseDir(basedir);