mirror of https://github.com/stella-emu/stella.git
Completely remove 'cfgfile' functionality, since the SQL backend uses the same name on all ports.
This commit is contained in:
parent
7de2b7ba14
commit
162b13f3d1
|
@ -25,7 +25,8 @@ SettingsDb::SettingsDb(
|
|||
const string& databaseName
|
||||
) : myDatabaseDirectory(databaseDirectory),
|
||||
myDatabaseName(databaseName)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool SettingsDb::initialize()
|
||||
|
@ -38,7 +39,7 @@ bool SettingsDb::initialize()
|
|||
mySettingsRepository->initialize();
|
||||
}
|
||||
catch (const SqliteError& err) {
|
||||
Logger::info("sqlite DB " + myDb->fileName() + " failed to initialize: " + err.message);
|
||||
Logger::info("sqlite DB " + databaseFileName() + " failed to initialize: " + err.message);
|
||||
|
||||
myDb.reset();
|
||||
mySettingsRepository.reset();
|
||||
|
|
|
@ -32,6 +32,8 @@ class SettingsDb
|
|||
|
||||
KeyValueRepository& settingsRepository() const { return *mySettingsRepository; }
|
||||
|
||||
const string& databaseFileName() const { return myDb->fileName(); }
|
||||
|
||||
private:
|
||||
|
||||
string myDatabaseDirectory;
|
||||
|
|
|
@ -21,16 +21,10 @@
|
|||
#include "Logger.hxx"
|
||||
#include "SqliteError.hxx"
|
||||
|
||||
#ifdef BSPF_WINDOWS
|
||||
#define SEPARATOR "\""
|
||||
#else
|
||||
#define SEPARATOR "/"
|
||||
#endif
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
SqliteDatabase::SqliteDatabase(const string& databaseDirectory,
|
||||
const string& databaseName)
|
||||
: myDatabaseFile(databaseDirectory + SEPARATOR + databaseName + ".sqlite3")
|
||||
: myDatabaseFile(databaseDirectory + databaseName + ".sqlite3")
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -74,8 +68,6 @@ void SqliteDatabase::initialize()
|
|||
throw SqliteError("unable to initialize sqlite DB for unknown reason");
|
||||
};
|
||||
|
||||
Logger::debug("successfully opened " + myDatabaseFile);
|
||||
|
||||
exec("PRAGMA journal_mode=WAL");
|
||||
|
||||
switch (sqlite3_wal_checkpoint_v2(myHandle, nullptr, SQLITE_CHECKPOINT_TRUNCATE, nullptr, nullptr)) {
|
||||
|
|
|
@ -32,7 +32,7 @@ class SqliteDatabase
|
|||
|
||||
void initialize();
|
||||
|
||||
const string fileName() const { return myDatabaseFile; }
|
||||
const string& fileName() const { return myDatabaseFile; }
|
||||
|
||||
operator sqlite3*() const { return myHandle; }
|
||||
|
||||
|
|
|
@ -161,10 +161,6 @@ bool OSystem::create()
|
|||
myStateManager = make_unique<StateManager>(*this);
|
||||
myTimerManager = make_unique<TimerManager>();
|
||||
|
||||
#ifdef GUI_SUPPORT
|
||||
myHighScoresManager = make_unique<HighScoresManager>(*this);
|
||||
#endif
|
||||
|
||||
myAudioSettings = make_unique<AudioSettings>(*mySettings);
|
||||
|
||||
// Create the sound object; the sound subsystem isn't actually
|
||||
|
@ -184,6 +180,7 @@ bool OSystem::create()
|
|||
// Create various subsystems (menu and launcher GUI objects, etc)
|
||||
myMenu = make_unique<Menu>(*this);
|
||||
myCommandMenu = make_unique<CommandMenu>(*this);
|
||||
myHighScoresManager = make_unique<HighScoresManager>(*this);
|
||||
myHighScoresMenu = make_unique<HighScoresMenu>(*this);
|
||||
myMessageMenu = make_unique<MessageMenu>(*this);
|
||||
myTimeMachine = make_unique<TimeMachine>(*this);
|
||||
|
@ -214,16 +211,14 @@ void OSystem::loadConfig(const Settings::Options& options)
|
|||
{
|
||||
// Get base directory and config file from derived class
|
||||
// It will decide whether it can override its default location
|
||||
string baseDir, cfgFile, defSaveDir, defLoadDir;
|
||||
getBaseDirAndConfig(baseDir, cfgFile, defSaveDir, defLoadDir,
|
||||
string baseDir, defSaveDir, defLoadDir;
|
||||
getBaseDirAndConfig(baseDir, defSaveDir, defLoadDir,
|
||||
ourOverrideBaseDirWithApp, ourOverrideBaseDir);
|
||||
|
||||
// Get fully-qualified pathnames, and make directories when needed
|
||||
myBaseDir = FilesystemNode(baseDir);
|
||||
if(!myBaseDir.isDirectory())
|
||||
myBaseDir.makeDir();
|
||||
if(!cfgFile.empty())
|
||||
myConfigFile = FilesystemNode(cfgFile);
|
||||
|
||||
myDefaultSaveDir = FilesystemNode(defSaveDir);
|
||||
if(!myDefaultSaveDir.isDirectory())
|
||||
|
@ -236,6 +231,7 @@ void OSystem::loadConfig(const Settings::Options& options)
|
|||
mySettingsDb = make_shared<SettingsDb>(myBaseDir.getPath(), "settings");
|
||||
if(!mySettingsDb->initialize())
|
||||
mySettingsDb.reset();
|
||||
myConfigFile = FilesystemNode(mySettingsDb->databaseFileName());
|
||||
|
||||
mySettings->setRepository(createSettingsRepository());
|
||||
|
||||
|
|
|
@ -452,12 +452,10 @@ class OSystem
|
|||
// implemented in derived classes.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
Determine the base directory and main configuration file from the
|
||||
Determine the base directory and various other directories from the
|
||||
derived class. It can also use hints, as described below.
|
||||
|
||||
@param basedir The base directory for all configuration files
|
||||
@param cfgfile The fully qualified pathname of the config file
|
||||
(including the base directory)
|
||||
@param savedir The default directory to save various other files
|
||||
@param loaddir The default directory to load various other files
|
||||
@param useappdir A hint that the base dir should be set to the
|
||||
|
@ -467,7 +465,7 @@ class OSystem
|
|||
parameter; not all ports can do this, so
|
||||
they are free to ignore it
|
||||
*/
|
||||
virtual void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||
virtual void getBaseDirAndConfig(string& basedir,
|
||||
string& savedir, string& loaddir,
|
||||
bool useappdir, const string& usedir) = 0;
|
||||
|
||||
|
@ -551,8 +549,9 @@ class OSystem
|
|||
private:
|
||||
FilesystemNode myBaseDir, myStateDir, mySnapshotSaveDir, mySnapshotLoadDir,
|
||||
myNVRamDir, myCfgDir, myDefaultSaveDir, myDefaultLoadDir;
|
||||
FilesystemNode myCheatFile, myConfigFile, myPaletteFile, myPropertiesFile;
|
||||
FilesystemNode myRomFile; string myRomMD5;
|
||||
FilesystemNode myCheatFile, myConfigFile, myPaletteFile, myPropertiesFile;
|
||||
FilesystemNode myRomFile;
|
||||
string myRomMD5;
|
||||
|
||||
string myFeatures;
|
||||
string myBuildInfo;
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
#endif
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystemLIBRETRO::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||
void OSystemLIBRETRO::getBaseDirAndConfig(string& basedir,
|
||||
string& savedir, string& loaddir,
|
||||
bool useappdir, const string& usedir)
|
||||
{
|
||||
loaddir = savedir = cfgfile = basedir = "." + slash;
|
||||
loaddir = savedir = basedir = "." + slash;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
/**
|
||||
This class defines an OSystem object for libretro.
|
||||
It is responsible for completely implementing getBaseDirAndConfig(),
|
||||
to set the base directory, config file location, and various other
|
||||
save/load locations.
|
||||
to set the base directory and various other save/load locations.
|
||||
|
||||
@author Stephen Anthony
|
||||
*/
|
||||
|
@ -39,8 +38,6 @@ class OSystemLIBRETRO : public OSystem
|
|||
derived class. It can also use hints, as described below.
|
||||
|
||||
@param basedir The base directory for all configuration files
|
||||
@param cfgfile The fully qualified pathname of the config file
|
||||
(including the base directory)
|
||||
@param savedir The default directory to save various other files
|
||||
@param loaddir The default directory to load various other files
|
||||
@param useappdir A hint that the base dir should be set to the
|
||||
|
@ -50,7 +47,7 @@ class OSystemLIBRETRO : public OSystem
|
|||
parameter; not all ports can do this, so
|
||||
they are free to ignore it
|
||||
*/
|
||||
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||
void getBaseDirAndConfig(string& basedir,
|
||||
string& savedir, string& loaddir,
|
||||
bool useappdir, const string& usedir) override;
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "OSystemMACOS.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystemMACOS::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||
void OSystemMACOS::getBaseDirAndConfig(string& basedir,
|
||||
string& savedir, string& loaddir,
|
||||
bool useappdir, const string& usedir)
|
||||
{
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
/**
|
||||
This class defines an OSystem object for UNIX-like OS's (macOS).
|
||||
It is responsible for completely implementing getBaseDirAndConfig(),
|
||||
to set the base directory, config file location, and various other
|
||||
save/load locations.
|
||||
to set the base directory and various other save/load locations.
|
||||
|
||||
@author Stephen Anthony
|
||||
*/
|
||||
|
@ -39,8 +38,6 @@ class OSystemMACOS : public OSystem
|
|||
derived class. It can also use hints, as described below.
|
||||
|
||||
@param basedir The base directory for all configuration files
|
||||
@param cfgfile The fully qualified pathname of the config file
|
||||
(including the base directory)
|
||||
@param savedir The default directory to save various other files
|
||||
@param loaddir The default directory to load various other files
|
||||
@param useappdir A hint that the base dir should be set to the
|
||||
|
@ -50,7 +47,7 @@ class OSystemMACOS : public OSystem
|
|||
parameter; not all ports can do this, so
|
||||
they are free to ignore it
|
||||
*/
|
||||
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||
void getBaseDirAndConfig(string& basedir,
|
||||
string& savedir, string& loaddir,
|
||||
bool useappdir, const string& usedir) override;
|
||||
private:
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "OSystemUNIX.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystemUNIX::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||
void OSystemUNIX::getBaseDirAndConfig(string& basedir,
|
||||
string& savedir, string& loaddir,
|
||||
bool useappdir, const string& usedir)
|
||||
{
|
||||
|
@ -40,16 +40,4 @@ void OSystemUNIX::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
|||
basedir = FilesystemNode(usedir).getPath();
|
||||
savedir = loaddir = basedir;
|
||||
}
|
||||
|
||||
// (Currently) non-documented alternative for using version-specific
|
||||
// config file
|
||||
ostringstream buf;
|
||||
buf << basedir << "/stellarc" << "-" << STELLA_VERSION;
|
||||
|
||||
// Use version-specific config file only if it already exists
|
||||
FilesystemNode altConfigFile(buf.str());
|
||||
if(altConfigFile.exists() && altConfigFile.isWritable())
|
||||
cfgfile = altConfigFile.getPath();
|
||||
else
|
||||
cfgfile = basedir + "/stellarc";
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
/**
|
||||
This class defines an OSystem object for UNIX-like OS's (Linux).
|
||||
It is responsible for completely implementing getBaseDirAndConfig(),
|
||||
to set the base directory, config file location, and various other
|
||||
save/load locations.
|
||||
to set the base directory and various other save/load locations.
|
||||
|
||||
@author Stephen Anthony
|
||||
*/
|
||||
|
@ -39,8 +38,6 @@ class OSystemUNIX : public OSystem
|
|||
derived class. It can also use hints, as described below.
|
||||
|
||||
@param basedir The base directory for all configuration files
|
||||
@param cfgfile The fully qualified pathname of the config file
|
||||
(including the base directory)
|
||||
@param savedir The default directory to save various other files
|
||||
@param loaddir The default directory to load various other files
|
||||
@param useappdir A hint that the base dir should be set to the
|
||||
|
@ -50,7 +47,7 @@ class OSystemUNIX : public OSystem
|
|||
parameter; not all ports can do this, so
|
||||
they are free to ignore it
|
||||
*/
|
||||
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||
void getBaseDirAndConfig(string& basedir,
|
||||
string& savedir, string& loaddir,
|
||||
bool useappdir, const string& usedir) override;
|
||||
|
||||
|
|
|
@ -18,9 +18,8 @@
|
|||
#include "OSystemR77.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystemR77::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||
void OSystemR77::getBaseDirAndConfig(string& basedir,
|
||||
string& savedir, string& loaddir, bool, const string&)
|
||||
{
|
||||
basedir = savedir = loaddir = "/mnt/stella";
|
||||
cfgfile = "/mnt/stella/stellarc";
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
 The Retron77 system is based on an embedded Linux platform.
|
||||
|
||||
It is responsible for completely implementing getBaseDirAndConfig(),
|
||||
to set the base directory, config file location, and various other
|
||||
save/load locations.
|
||||
to set the base directory and various other save/load locations.
|
||||
|
||||
@author Stephen Anthony
|
||||
*/
|
||||
|
@ -41,8 +40,6 @@ class OSystemR77 : public OSystem
|
|||
derived class. It can also use hints, as described below.
|
||||
|
||||
@param basedir The base directory for all configuration files
|
||||
@param cfgfile The fully qualified pathname of the config file
|
||||
(including the base directory)
|
||||
@param savedir The default directory to save various other files
|
||||
@param loaddir The default directory to load various other files
|
||||
@param useappdir A hint that the base dir should be set to the
|
||||
|
@ -52,7 +49,7 @@ class OSystemR77 : public OSystem
|
|||
parameter; not all ports can do this, so
|
||||
they are free to ignore it
|
||||
*/
|
||||
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||
void getBaseDirAndConfig(string& basedir,
|
||||
string& savedir, string& loaddir,
|
||||
bool useappdir, const string& usedir) override;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "OSystemWINDOWS.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystemWINDOWS::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||
void OSystemWINDOWS::getBaseDirAndConfig(string& basedir,
|
||||
string& savedir, string& loaddir,
|
||||
bool useappdir, const string& usedir)
|
||||
{
|
||||
|
@ -50,6 +50,4 @@ void OSystemWINDOWS::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
|||
}
|
||||
else if(usedir != "")
|
||||
savedir = loaddir = basedir = FilesystemNode(usedir).getPath();
|
||||
|
||||
cfgfile = basedir + "stella.ini";
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
/**
|
||||
This class defines an OSystem object for Windows OS's.
|
||||
It is responsible for completely implementing getBaseDirAndConfig(),
|
||||
to set the base directory, config file location, and various other
|
||||
save/load locations.
|
||||
to set the base directory and various other save/load locations.
|
||||
|
||||
@author Stephen Anthony
|
||||
*/
|
||||
|
@ -39,8 +38,6 @@ class OSystemWINDOWS : public OSystem
|
|||
derived class. It can also use hints, as described below.
|
||||
|
||||
@param basedir The base directory for all configuration files
|
||||
@param cfgfile The fully qualified pathname of the config file
|
||||
(including the base directory)
|
||||
@param savedir The default directory to save various other files
|
||||
@param loaddir The default directory to load various other files
|
||||
@param useappdir A hint that the base dir should be set to the
|
||||
|
@ -50,7 +47,7 @@ class OSystemWINDOWS : public OSystem
|
|||
parameter; not all ports can do this, so
|
||||
they are free to ignore it
|
||||
*/
|
||||
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||
void getBaseDirAndConfig(string& basedir,
|
||||
string& savedir, string& loaddir,
|
||||
bool useappdir, const string& usedir) override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue