mirror of https://github.com/stella-emu/stella.git
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:
parent
9190943534
commit
b7bf3b79b2
|
@ -955,20 +955,12 @@ string CartDebug::saveDisassembly()
|
||||||
if(myConsole.cartridge().bankCount() > 1)
|
if(myConsole.cartridge().bankCount() > 1)
|
||||||
return DebuggerParser::red("disassembly for multi-bank ROM not yet supported");
|
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 == "")
|
if(myDisasmFile == "")
|
||||||
{
|
{
|
||||||
const string& propsname =
|
const string& propsname =
|
||||||
myConsole.properties().get(Cartridge_Name) + ".asm";
|
myConsole.properties().get(Cartridge_Name) + ".asm";
|
||||||
|
|
||||||
FilesystemNode case0(myOSystem.romFile().getParent().getPath() + propsname);
|
myDisasmFile = FilesystemNode(myOSystem.defaultSaveDir() + propsname).getPath();
|
||||||
if(case0.getParent().isWritable())
|
|
||||||
myDisasmFile = case0.getPath();
|
|
||||||
else
|
|
||||||
return DebuggerParser::red("disassembly file not writable:\n " +
|
|
||||||
case0.getShortPath());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FilesystemNode node(myDisasmFile);
|
FilesystemNode node(myDisasmFile);
|
||||||
|
|
|
@ -190,8 +190,8 @@ void OSystem::setConfigPaths()
|
||||||
string s;
|
string s;
|
||||||
|
|
||||||
validatePath(myStateDir, "statedir", myBaseDir + "state");
|
validatePath(myStateDir, "statedir", myBaseDir + "state");
|
||||||
validatePath(mySnapshotSaveDir, "snapsavedir", defaultSnapSaveDir());
|
validatePath(mySnapshotSaveDir, "snapsavedir", defaultSaveDir());
|
||||||
validatePath(mySnapshotLoadDir, "snaploaddir", defaultSnapLoadDir());
|
validatePath(mySnapshotLoadDir, "snaploaddir", defaultLoadDir());
|
||||||
validatePath(myNVRamDir, "nvramdir", myBaseDir + "nvram");
|
validatePath(myNVRamDir, "nvramdir", myBaseDir + "nvram");
|
||||||
validatePath(myCfgDir, "cfgdir", myBaseDir + "cfg");
|
validatePath(myCfgDir, "cfgdir", myBaseDir + "cfg");
|
||||||
|
|
||||||
|
|
|
@ -403,14 +403,14 @@ class OSystem
|
||||||
virtual void stateChanged(EventHandler::State state) { }
|
virtual void stateChanged(EventHandler::State state) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the default save and load paths for the snapshot directory.
|
Returns the default save and load paths for various files
|
||||||
Since this varies greatly among different systems and is the one
|
(snapshots, disassembly, roms, etc). Since this varies greatly
|
||||||
directory that most end-users care about (vs. config file stuff
|
among different systems and is the one directory that most end-users
|
||||||
that usually isn't user-modifiable), we create a special method
|
care about (vs. config file stuff that usually isn't user-modifiable),
|
||||||
for it.
|
we create a special method for it.
|
||||||
*/
|
*/
|
||||||
virtual string defaultSnapSaveDir() { return string("~") + BSPF::PATH_SEPARATOR; }
|
virtual string defaultSaveDir() const { return string("~") + BSPF::PATH_SEPARATOR; }
|
||||||
virtual string defaultSnapLoadDir() { return string("~") + BSPF::PATH_SEPARATOR; }
|
virtual string defaultLoadDir() const { return string("~") + BSPF::PATH_SEPARATOR; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -156,8 +156,8 @@ void SnapshotDialog::saveConfig()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void SnapshotDialog::setDefaults()
|
void SnapshotDialog::setDefaults()
|
||||||
{
|
{
|
||||||
mySnapSavePath->setText(instance().defaultSnapSaveDir());
|
mySnapSavePath->setText(instance().defaultSaveDir());
|
||||||
mySnapLoadPath->setText(instance().defaultSnapLoadDir());
|
mySnapLoadPath->setText(instance().defaultLoadDir());
|
||||||
|
|
||||||
mySnapSingle->setState(false);
|
mySnapSingle->setState(false);
|
||||||
mySnap1x->setState(false);
|
mySnap1x->setState(false);
|
||||||
|
|
|
@ -32,21 +32,21 @@
|
||||||
OSystemMACOSX::OSystemMACOSX()
|
OSystemMACOSX::OSystemMACOSX()
|
||||||
: OSystem()
|
: OSystem()
|
||||||
{
|
{
|
||||||
setBaseDir("~/Library/Application Support/Stella");
|
setBaseDir("~/Library/Application Support/Stella/");
|
||||||
|
|
||||||
// This will be overridden, as OSX uses plist files for settings
|
// This will be overridden, as OSX uses plist files for settings
|
||||||
setConfigFile("~/Library/Application Support/Stella/stellarc");
|
setConfigFile("~/Library/Application Support/Stella/stellarc");
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string OSystemMACOSX::defaultSnapSaveDir()
|
string OSystemMACOSX::defaultSaveDir() const
|
||||||
{
|
{
|
||||||
FilesystemNode desktop("~/Desktop");
|
FilesystemNode desktop("~/Desktop/");
|
||||||
return desktop.isDirectory() ? desktop.getShortPath() : "~";
|
return desktop.isDirectory() ? desktop.getShortPath() : "~/";
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string OSystemMACOSX::defaultSnapLoadDir()
|
string OSystemMACOSX::defaultLoadDir() const
|
||||||
{
|
{
|
||||||
return defaultSnapSaveDir();
|
return defaultSaveDir();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,10 @@ class OSystemMACOSX : public OSystem
|
||||||
virtual ~OSystemMACOSX() = default;
|
virtual ~OSystemMACOSX() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the default paths for the snapshot directory.
|
Returns the default paths for loading/saving files.
|
||||||
*/
|
*/
|
||||||
string defaultSnapSaveDir() override;
|
string defaultSaveDir() const override;
|
||||||
string defaultSnapLoadDir() override;
|
string defaultLoadDir() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -56,21 +56,21 @@ class HomeFinder
|
||||||
return ourAppDataPath;
|
return ourAppDataPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the 'DESKTOPDIRECTORY' folder, or an empty string if the folder couldn't be determined.
|
// Return the 'My Documents' folder, or an empty string if the folder couldn't be determined.
|
||||||
const string& getDesktopPath() const
|
const string& getDocumentsPath() const
|
||||||
{
|
{
|
||||||
if(ourDesktopPath == "")
|
if(ourDocumentsPath == "")
|
||||||
{
|
{
|
||||||
char folder_path[MAX_PATH];
|
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);
|
NULL, 0, folder_path);
|
||||||
ourDesktopPath = (result == S_OK) ? folder_path : EmptyString;
|
ourDocumentsPath = (result == S_OK) ? folder_path : EmptyString;
|
||||||
}
|
}
|
||||||
return ourDesktopPath;
|
return ourDocumentsPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static string ourHomePath, ourAppDataPath, ourDesktopPath;
|
static string ourHomePath, ourAppDataPath, ourDocumentsPath;
|
||||||
|
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
HomeFinder(const HomeFinder&) = delete;
|
HomeFinder(const HomeFinder&) = delete;
|
||||||
|
@ -81,6 +81,6 @@ class HomeFinder
|
||||||
|
|
||||||
__declspec(selectany) string HomeFinder::ourHomePath = "";
|
__declspec(selectany) string HomeFinder::ourHomePath = "";
|
||||||
__declspec(selectany) string HomeFinder::ourAppDataPath = "";
|
__declspec(selectany) string HomeFinder::ourAppDataPath = "";
|
||||||
__declspec(selectany) string HomeFinder::ourDesktopPath = "";
|
__declspec(selectany) string HomeFinder::ourDocumentsPath = "";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -74,23 +74,23 @@ OSystemWINDOWS::OSystemWINDOWS()
|
||||||
basedir += "Stella";
|
basedir += "Stella";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
basedir = "."; // otherwise, default to current directory
|
basedir = ".\\"; // otherwise, default to current directory
|
||||||
}
|
}
|
||||||
|
|
||||||
setBaseDir(basedir);
|
setBaseDir(basedir);
|
||||||
setConfigFile(basedir + "\\stella.ini");
|
setConfigFile(basedir + "stella.ini");
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string OSystemWINDOWS::defaultSnapSaveDir()
|
string OSystemWINDOWS::defaultSaveDir() const
|
||||||
{
|
{
|
||||||
HomeFinder homefinder;
|
HomeFinder homefinder;
|
||||||
FilesystemNode desktop(homefinder.getDesktopPath());
|
FilesystemNode desktop(homefinder.getDesktopPath() + "\\Stella");
|
||||||
return desktop.isDirectory() ? desktop.getShortPath() : "~";
|
return desktop.isDirectory() ? desktop.getShortPath() : "~\\";
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string OSystemWINDOWS::defaultSnapLoadDir()
|
string OSystemWINDOWS::defaultLoadDir() const
|
||||||
{
|
{
|
||||||
return defaultSnapSaveDir();
|
return defaultSaveDir();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,10 @@ class OSystemWINDOWS : public OSystem
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
Returns the default paths for the snapshot directory.
|
Returns the default paths for loading/saving files.
|
||||||
*/
|
*/
|
||||||
string defaultSnapSaveDir() override;
|
string defaultSaveDir() const override;
|
||||||
string defaultSnapLoadDir() override;
|
string defaultLoadDir() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
Loading…
Reference in New Issue