mirror of https://github.com/stella-emu/stella.git
Finalized 'basedir' and 'baseinappdir' in Windows.
- This still needs some testing and doc updates, but it seems to be working great - Hopefully people will now stop asking for this feature
This commit is contained in:
parent
9c905bc53e
commit
0d34de269c
|
@ -179,12 +179,12 @@ void OSystem::loadConfig(const Settings::Options& options)
|
|||
FilesystemNode save(myDefaultSaveDir);
|
||||
if(!save.isDirectory())
|
||||
save.makeDir();
|
||||
myDefaultSaveDir = node.getPath();
|
||||
myDefaultSaveDir = save.getShortPath();
|
||||
|
||||
FilesystemNode load(myDefaultLoadDir);
|
||||
if(!load.isDirectory())
|
||||
load.makeDir();
|
||||
myDefaultLoadDir = node.getPath();
|
||||
myDefaultLoadDir = load.getShortPath();
|
||||
|
||||
logMessage("Loading config options ...", 2);
|
||||
mySettings->load(configFile(), options);
|
||||
|
|
|
@ -30,19 +30,6 @@ class HomeFinder
|
|||
HomeFinder() = default;
|
||||
~HomeFinder() = default;
|
||||
|
||||
// Return the 'HOME/User' folder, or an empty string if the folder couldn't be determined.
|
||||
const string& getHomePath() const
|
||||
{
|
||||
if(ourHomePath == "")
|
||||
{
|
||||
char folder_path[MAX_PATH];
|
||||
HRESULT const result = SHGetFolderPathA(NULL, CSIDL_PROFILE | CSIDL_FLAG_CREATE,
|
||||
NULL, 0, folder_path);
|
||||
ourHomePath = (result == S_OK) ? folder_path : EmptyString;
|
||||
}
|
||||
return ourHomePath;
|
||||
}
|
||||
|
||||
// Return the 'APPDATA' folder, or an empty string if the folder couldn't be determined.
|
||||
const string& getAppDataPath() const
|
||||
{
|
||||
|
@ -56,6 +43,19 @@ class HomeFinder
|
|||
return ourAppDataPath;
|
||||
}
|
||||
|
||||
// Return the 'Desktop' folder, or an empty string if the folder couldn't be determined.
|
||||
const string& getDesktopPath() const
|
||||
{
|
||||
if(ourDesktopPath == "")
|
||||
{
|
||||
char folder_path[MAX_PATH];
|
||||
HRESULT const result = SHGetFolderPathA(NULL, CSIDL_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE,
|
||||
NULL, 0, folder_path);
|
||||
ourDesktopPath = (result == S_OK) ? folder_path : EmptyString;
|
||||
}
|
||||
return ourDesktopPath;
|
||||
}
|
||||
|
||||
// Return the 'My Documents' folder, or an empty string if the folder couldn't be determined.
|
||||
const string& getDocumentsPath() const
|
||||
{
|
||||
|
@ -69,8 +69,21 @@ class HomeFinder
|
|||
return ourDocumentsPath;
|
||||
}
|
||||
|
||||
// Return the 'HOME/User' folder, or an empty string if the folder couldn't be determined.
|
||||
const string& getHomePath() const
|
||||
{
|
||||
if(ourHomePath == "")
|
||||
{
|
||||
char folder_path[MAX_PATH];
|
||||
HRESULT const result = SHGetFolderPathA(NULL, CSIDL_PROFILE | CSIDL_FLAG_CREATE,
|
||||
NULL, 0, folder_path);
|
||||
ourHomePath = (result == S_OK) ? folder_path : EmptyString;
|
||||
}
|
||||
return ourHomePath;
|
||||
}
|
||||
|
||||
private:
|
||||
static string ourHomePath, ourAppDataPath, ourDocumentsPath, ourDesktopPath;
|
||||
static string ourHomePath, ourAppDataPath, ourDesktopPath, ourDocumentsPath;
|
||||
|
||||
// Following constructors and assignment operators not supported
|
||||
HomeFinder(const HomeFinder&) = delete;
|
||||
|
|
|
@ -35,31 +35,21 @@ void OSystemWINDOWS::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
|||
basedir += '\\';
|
||||
basedir += "Stella\\";
|
||||
}
|
||||
savedir = loaddir = "~/"; // FIXME - change this to 'Desktop'
|
||||
FilesystemNode defaultLoadSaveDir(homefinder.getDesktopPath());
|
||||
savedir = loaddir = defaultLoadSaveDir.getShortPath();
|
||||
|
||||
// Check to see if basedir overrides are active
|
||||
if(useappdir)
|
||||
cout << "ERROR: base dir in app folder not supported" << endl;
|
||||
else if(usedir != "")
|
||||
{
|
||||
basedir = FilesystemNode(usedir).getPath();
|
||||
savedir = loaddir = basedir;
|
||||
char filename[MAX_PATH];
|
||||
GetModuleFileNameA(NULL, filename, sizeof(filename));
|
||||
FilesystemNode appdir(filename);
|
||||
appdir = appdir.getParent();
|
||||
if(appdir.isDirectory())
|
||||
savedir = loaddir = basedir = appdir.getPath();
|
||||
}
|
||||
else if(usedir != "")
|
||||
savedir = loaddir = basedir = FilesystemNode(usedir).getPath();
|
||||
|
||||
cfgfile = basedir + "stella.ini";
|
||||
}
|
||||
#if 0
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string OSystemWINDOWS::defaultSaveDir() const
|
||||
{
|
||||
HomeFinder homefinder;
|
||||
FilesystemNode documents(homefinder.getDocumentsPath());
|
||||
return documents.isDirectory() ? documents.getShortPath() + "\\Stella\\" : "~\\";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string OSystemWINDOWS::defaultLoadDir() const
|
||||
{
|
||||
return defaultSaveDir();
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue