First pass at a consistent default for load/saving files that don't have a

pre-defined location (ROM files and disassemblies, etc).
- Repurposed the snapshot load/save folders by changing OSystem::defaultSnapLoadDir to OSystem::defaultLoadDir, and similar for the save dir
- In Windows, this directory will now be 'Documents\Stella', while in Linux/OSX it will be $HOME
- Testing still required for Windows and OSX; only Linux is confirmed to work for now
This commit is contained in:
Stephen Anthony 2017-09-09 15:06:21 -02:30
parent 9190943534
commit b7bf3b79b2
9 changed files with 39 additions and 47 deletions

View File

@ -955,20 +955,12 @@ string CartDebug::saveDisassembly()
if(myConsole.cartridge().bankCount() > 1)
return DebuggerParser::red("disassembly for multi-bank ROM not yet supported");
// Currently, the default naming/location for disassembly files is:
// 1) ROM dir based on properties entry name
if(myDisasmFile == "")
{
const string& propsname =
myConsole.properties().get(Cartridge_Name) + ".asm";
FilesystemNode case0(myOSystem.romFile().getParent().getPath() + propsname);
if(case0.getParent().isWritable())
myDisasmFile = case0.getPath();
else
return DebuggerParser::red("disassembly file not writable:\n " +
case0.getShortPath());
myDisasmFile = FilesystemNode(myOSystem.defaultSaveDir() + propsname).getPath();
}
FilesystemNode node(myDisasmFile);

View File

@ -190,8 +190,8 @@ void OSystem::setConfigPaths()
string s;
validatePath(myStateDir, "statedir", myBaseDir + "state");
validatePath(mySnapshotSaveDir, "snapsavedir", defaultSnapSaveDir());
validatePath(mySnapshotLoadDir, "snaploaddir", defaultSnapLoadDir());
validatePath(mySnapshotSaveDir, "snapsavedir", defaultSaveDir());
validatePath(mySnapshotLoadDir, "snaploaddir", defaultLoadDir());
validatePath(myNVRamDir, "nvramdir", myBaseDir + "nvram");
validatePath(myCfgDir, "cfgdir", myBaseDir + "cfg");

View File

@ -403,14 +403,14 @@ class OSystem
virtual void stateChanged(EventHandler::State state) { }
/**
Returns the default save and load paths for the snapshot directory.
Since this varies greatly among different systems and is the one
directory that most end-users care about (vs. config file stuff
that usually isn't user-modifiable), we create a special method
for it.
Returns the default save and load paths for various files
(snapshots, disassembly, roms, etc). Since this varies greatly
among different systems and is the one directory that most end-users
care about (vs. config file stuff that usually isn't user-modifiable),
we create a special method for it.
*/
virtual string defaultSnapSaveDir() { return string("~") + BSPF::PATH_SEPARATOR; }
virtual string defaultSnapLoadDir() { return string("~") + BSPF::PATH_SEPARATOR; }
virtual string defaultSaveDir() const { return string("~") + BSPF::PATH_SEPARATOR; }
virtual string defaultLoadDir() const { return string("~") + BSPF::PATH_SEPARATOR; }
protected:
/**

View File

@ -156,8 +156,8 @@ void SnapshotDialog::saveConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SnapshotDialog::setDefaults()
{
mySnapSavePath->setText(instance().defaultSnapSaveDir());
mySnapLoadPath->setText(instance().defaultSnapLoadDir());
mySnapSavePath->setText(instance().defaultSaveDir());
mySnapLoadPath->setText(instance().defaultLoadDir());
mySnapSingle->setState(false);
mySnap1x->setState(false);

View File

@ -32,21 +32,21 @@
OSystemMACOSX::OSystemMACOSX()
: OSystem()
{
setBaseDir("~/Library/Application Support/Stella");
setBaseDir("~/Library/Application Support/Stella/");
// This will be overridden, as OSX uses plist files for settings
setConfigFile("~/Library/Application Support/Stella/stellarc");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string OSystemMACOSX::defaultSnapSaveDir()
string OSystemMACOSX::defaultSaveDir() const
{
FilesystemNode desktop("~/Desktop");
return desktop.isDirectory() ? desktop.getShortPath() : "~";
FilesystemNode desktop("~/Desktop/");
return desktop.isDirectory() ? desktop.getShortPath() : "~/";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string OSystemMACOSX::defaultSnapLoadDir()
string OSystemMACOSX::defaultLoadDir() const
{
return defaultSnapSaveDir();
return defaultSaveDir();
}

View File

@ -35,10 +35,10 @@ class OSystemMACOSX : public OSystem
virtual ~OSystemMACOSX() = default;
/**
Returns the default paths for the snapshot directory.
Returns the default paths for loading/saving files.
*/
string defaultSnapSaveDir() override;
string defaultSnapLoadDir() override;
string defaultSaveDir() const override;
string defaultLoadDir() const override;
private:
// Following constructors and assignment operators not supported

View File

@ -56,21 +56,21 @@ class HomeFinder
return ourAppDataPath;
}
// Return the 'DESKTOPDIRECTORY' folder, or an empty string if the folder couldn't be determined.
const string& getDesktopPath() const
// Return the 'My Documents' folder, or an empty string if the folder couldn't be determined.
const string& getDocumentsPath() const
{
if(ourDesktopPath == "")
if(ourDocumentsPath == "")
{
char folder_path[MAX_PATH];
HRESULT const result = SHGetFolderPathA(NULL, CSIDL_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE,
HRESULT const result = SHGetFolderPathA(NULL, CSIDL_MYDOCUMENTS | CSIDL_FLAG_CREATE,
NULL, 0, folder_path);
ourDesktopPath = (result == S_OK) ? folder_path : EmptyString;
ourDocumentsPath = (result == S_OK) ? folder_path : EmptyString;
}
return ourDesktopPath;
return ourDocumentsPath;
}
private:
static string ourHomePath, ourAppDataPath, ourDesktopPath;
static string ourHomePath, ourAppDataPath, ourDocumentsPath;
// Following constructors and assignment operators not supported
HomeFinder(const HomeFinder&) = delete;
@ -81,6 +81,6 @@ class HomeFinder
__declspec(selectany) string HomeFinder::ourHomePath = "";
__declspec(selectany) string HomeFinder::ourAppDataPath = "";
__declspec(selectany) string HomeFinder::ourDesktopPath = "";
__declspec(selectany) string HomeFinder::ourDocumentsPath = "";
#endif

View File

@ -74,23 +74,23 @@ OSystemWINDOWS::OSystemWINDOWS()
basedir += "Stella";
}
else
basedir = "."; // otherwise, default to current directory
basedir = ".\\"; // otherwise, default to current directory
}
setBaseDir(basedir);
setConfigFile(basedir + "\\stella.ini");
setConfigFile(basedir + "stella.ini");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string OSystemWINDOWS::defaultSnapSaveDir()
string OSystemWINDOWS::defaultSaveDir() const
{
HomeFinder homefinder;
FilesystemNode desktop(homefinder.getDesktopPath());
return desktop.isDirectory() ? desktop.getShortPath() : "~";
FilesystemNode desktop(homefinder.getDesktopPath() + "\\Stella");
return desktop.isDirectory() ? desktop.getShortPath() : "~\\";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string OSystemWINDOWS::defaultSnapLoadDir()
string OSystemWINDOWS::defaultLoadDir() const
{
return defaultSnapSaveDir();
return defaultSaveDir();
}

View File

@ -34,10 +34,10 @@ class OSystemWINDOWS : public OSystem
public:
/**
Returns the default paths for the snapshot directory.
Returns the default paths for loading/saving files.
*/
string defaultSnapSaveDir() override;
string defaultSnapLoadDir() override;
string defaultSaveDir() const override;
string defaultLoadDir() const override;
private:
// Following constructors and assignment operators not supported