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.
* Various path textboxes in the UI now recognize './' (or '.\') to mean
the current directory. In Linux/UNIX, '~/' is also recognized to
mean your home directory.
the current directory and '~/' (or '~\') is also recognized to
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.

View File

@ -267,8 +267,9 @@
currently in use.</li>
<li>Various path textboxes in the UI now recognize './' (or '.\') to mean
the current directory. In Linux/UNIX, '~/' is also recognized to
mean your home directory.</li>
the current directory and '~/' (or '~\') is also recognized to
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>

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of
// 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
#define VERSION_HXX
#define STELLA_BASE_VERSION "2.7"
#define STELLA_BASE_VERSION "2.7_pre"
#ifdef 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
// 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>
@ -1769,7 +1769,7 @@ void EventHandler::takeSnapshot()
{
// Figure out the correct snapshot name
string filename;
string sspath = myOSystem->settings().getString("ssdir");
string sspath = myOSystem->snapshotDir();
if(sspath.length() > 0)
if(sspath.substr(sspath.length()-1) != BSPF_PATH_SEPARATOR)
@ -1790,8 +1790,8 @@ void EventHandler::takeSnapshot()
{
buf.str("");
buf << sspath << "_" << i << ".png";
FilesystemNode node(buf.str());
if(!node.exists())
FilesystemNode next(buf.str());
if(!next.exists())
break;
}
filename = buf.str();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// 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>
@ -270,38 +270,45 @@ bool OSystem::create()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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;
string s;
myStateDir = mySettings->getString("statedir");
if(myStateDir == "")
myStateDir = myBaseDir + BSPF_PATH_SEPARATOR + "state";
node = FilesystemNode(myStateDir);
s = mySettings->getString("statedir");
if(s == "") s = myBaseDir + BSPF_PATH_SEPARATOR + "state";
mySettings->setString("statedir", s);
node = FilesystemNode(s);
myStateDir = node.getPath();
if(!node.isDirectory())
AbstractFilesystemNode::makeDir(myStateDir);
mySettings->setString("statedir", myStateDir);
mySnapshotDir = mySettings->getString("ssdir");
if(mySnapshotDir == "")
mySnapshotDir = myBaseDir + BSPF_PATH_SEPARATOR + "snapshots";
node = FilesystemNode(mySnapshotDir);
s = mySettings->getString("ssdir");
if(s == "") s = myBaseDir + BSPF_PATH_SEPARATOR + "snapshots";
mySettings->setString("ssdir", s);
node = FilesystemNode(s);
mySnapshotDir = node.getPath();
if(!node.isDirectory())
AbstractFilesystemNode::makeDir(mySnapshotDir);
mySettings->setString("ssdir", mySnapshotDir);
myCheatFile = mySettings->getString("cheatfile");
if(myCheatFile == "")
myCheatFile = myBaseDir + BSPF_PATH_SEPARATOR + "stella.cht";
mySettings->setString("cheatfile", myCheatFile);
s = mySettings->getString("cheatfile");
if(s == "") s = myBaseDir + BSPF_PATH_SEPARATOR + "stella.cht";
mySettings->setString("cheatfile", s);
node = FilesystemNode(s);
myCheatFile = node.getPath();
myPaletteFile = mySettings->getString("palettefile");
if(myPaletteFile == "")
myPaletteFile = myBaseDir + BSPF_PATH_SEPARATOR + "stella.pal";
mySettings->setString("palettefile", myPaletteFile);
s = mySettings->getString("palettefile");
if(s == "") s = myBaseDir + BSPF_PATH_SEPARATOR + "stella.pal";
mySettings->setString("palettefile", s);
node = FilesystemNode(s);
myPaletteFile = node.getPath();
myPropertiesFile = mySettings->getString("propsfile");
if(myPropertiesFile == "")
myPropertiesFile = myBaseDir + BSPF_PATH_SEPARATOR + "stella.pro";
mySettings->setString("propsfile", myPropertiesFile);
s = mySettings->getString("propsfile");
if(s == "") s = myBaseDir + BSPF_PATH_SEPARATOR + "stella.pro";
mySettings->setString("propsfile", s);
node = FilesystemNode(s);
myPropertiesFile = node.getPath();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -318,8 +325,16 @@ void OSystem::setBaseDir(const string& basedir)
{
myBaseDir = basedir;
FilesystemNode node(myBaseDir);
myBaseDirExpanded = node.getPath();
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
// 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
@ -56,7 +56,7 @@ typedef Common::Array<Resolution> ResolutionList;
other objects belong.
@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
{
@ -249,17 +249,17 @@ class OSystem
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; }
/**
Return the directory for storing PNG snapshots.
Return the full/complete directory name for storing PNG snapshots.
*/
const string& snapshotDir() const { return mySnapshotDir; }
@ -427,7 +427,7 @@ class OSystem
/**
Set the locations of config file
*/
void setConfigFile(const string& file) { myConfigFile = file; }
void setConfigFile(const string& file);
protected:
// Pointer to the EventHandler object
@ -486,7 +486,7 @@ class OSystem
private:
enum { kNumUIPalettes = 2 };
string myBaseDir;
string myBaseDir, myBaseDirExpanded;
string myStateDir;
string mySnapshotDir;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// 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
// Copyright (C) 2002-2004 The ScummVM project
@ -154,14 +154,15 @@ FileSnapDialog::~FileSnapDialog()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::loadConfig()
{
myRomPath->setEditString(instance().settings().getString("romdir"));
myStatePath->setEditString(instance().stateDir());
myCheatFile->setEditString(instance().cheatFile());
myPaletteFile->setEditString(instance().paletteFile());
myPropsFile->setEditString(instance().propertiesFile());
mySnapPath->setEditString(instance().settings().getString("ssdir"));
mySnapSingle->setState(!instance().settings().getBool("sssingle"));
mySnap1x->setState(instance().settings().getBool("ss1x"));
const Settings& settings = instance().settings();
myRomPath->setEditString(settings.getString("romdir"));
myStatePath->setEditString(settings.getString("statedir"));
myCheatFile->setEditString(settings.getString("cheatfile"));
myPaletteFile->setEditString(settings.getString("palettefile"));
myPropsFile->setEditString(settings.getString("propsfile"));
mySnapPath->setEditString(settings.getString("ssdir"));
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
// 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>
@ -120,8 +120,7 @@ void RomInfoWidget::parseProperties()
StringList textChucks;
// Get a valid filename representing a snapshot file for this rom
const string& filename =
instance().settings().getString("ssdir") + BSPF_PATH_SEPARATOR +
const string& filename = instance().snapshotDir() + BSPF_PATH_SEPARATOR +
myProperties.get(Cartridge_Name) + ".png";
// 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
// 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 <unistd.h>
#include "bspf.hxx"
#include "FSNode.hxx"
#include "OSystem.hxx"
#include "OSystemUNIX.hxx"
@ -43,10 +42,8 @@
OSystemUNIX::OSystemUNIX()
: OSystem()
{
FilesystemNode home("~");
const string& basedir = home.getPath() + "/.stella";
setBaseDir(basedir);
setConfigFile(basedir + "/stellarc");
setBaseDir("~/.stella");
setConfigFile("~/.stella/stellarc");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// 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
// Copyright (C) 2002-2004 The ScummVM project
@ -82,10 +82,8 @@ class MyDocumentsFinder
{
myFolderModule = LoadLibrary("shfolder.dll");
if(myFolderModule)
{
myFolderPathFunc = reinterpret_cast<function_pointer>
(::GetProcAddress(myFolderModule, "SHGetFolderPathA"));
}
}
~MyDocumentsFinder() { if(myFolderModule) FreeLibrary(myFolderModule); }
@ -407,7 +405,7 @@ AbstractFilesystemNode* WindowsFilesystemNode::getParent() const
const char *start = _path.c_str();
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->_isValid = true;
p->_isDirectory = true;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// 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"
@ -41,7 +41,8 @@ OSystemWin32::OSystemWin32()
if(!node.exists())
{
FilesystemNode home("~");
basedir = home.getPath() + "\\Stella";
if(node.isDirectory())
basedir = "~\\Stella";
}
setBaseDir(basedir);