Added ability to override the base directory for storing all

config-related files for the Win32 port.  To use this, simply create a
file named 'basedir.txt' in the application directory (ie, where-ever
Stella was installed) containing a full pathname representing the base
directory.

This should finally satisfy those who wish to place config files
directly in the app folder, although it really isn't a good idea to do
so.  But who am I to make that decision? ...


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1667 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2009-01-30 23:31:41 +00:00
parent 383be21071
commit 1a67bd9995
2 changed files with 59 additions and 10 deletions

View File

@ -2214,7 +2214,13 @@
<tr>
<td><b>Windows</b></td>
<td><i>%MY_DOCUMENTS%\Stella\atarivox_eeprom.dat<br>
%MY_DOCUMENTS%\Stella\savekey_eeprom.dat</i></td>
%MY_DOCUMENTS%\Stella\savekey_eeprom.dat</i>&nbsp;&nbsp;&nbsp;
<b>OR</b><br>
<i>_BASEDIR_\atarivox_eeprom.dat<br>
_BASEDIR_\savekey_eeprom.dat<br></i>
(if a file named 'basedir.txt' exists in the application
directory containing the full pathname for _BASEDIR_)
</td>
</tr>
</table>
@ -2328,7 +2334,12 @@
</tr>
<tr>
<td><b>Windows</b></td>
<td><i>%MY_DOCUMENTS%\Stella\stella.ini</i></td>
<td><i>%MY_DOCUMENTS%\Stella\stella.ini</i>&nbsp;&nbsp;&nbsp;
<b>OR</b><br>
<i>_BASEDIR_\stella.ini</i>&nbsp;&nbsp;&nbsp;
(if a file named 'basedir.txt' exists in the application
directory containing the full pathname for _BASEDIR_)
</td>
</tr>
</table>
@ -2425,7 +2436,12 @@ Ms Pac-Man (Stella extended codes):
</tr>
<tr>
<td><b>Windows</b></td>
<td><i>%MY_DOCUMENTS%\Stella\stella.cht</i></td>
<td><i>%MY_DOCUMENTS%\Stella\stella.cht</i>&nbsp;&nbsp;&nbsp;
<b>OR</b><br>
<i>_BASEDIR_\stella.cht</i>&nbsp;&nbsp;&nbsp;
(if a file named 'basedir.txt' exists in the application
directory containing the full pathname for _BASEDIR_)
</td>
</tr>
</table>
<p>Stella will require a restart for changes to this file to take effect.</p>
@ -2670,7 +2686,13 @@ Ms Pac-Man (Stella extended codes):
</tr>
<tr>
<td><b>Windows</b></td>
<td><i>%MY_DOCUMENTS%\Stella\stella.pro</i></td>
<td><i>%MY_DOCUMENTS%\Stella\stella.pro</i>&nbsp;&nbsp;&nbsp;
<b>OR</b><br>
<i>_BASEDIR_\stella.pro</i>&nbsp;&nbsp;&nbsp;
(if a file named 'basedir.txt' exists in the application
directory containing the full pathname for _BASEDIR_)
</td>
</tr>
</table>
<p>Stella will require a restart for changes to this file to take effect.</p>
@ -2733,7 +2755,12 @@ Ms Pac-Man (Stella extended codes):
</tr>
<tr>
<td><b>Windows</b></td>
<td><i>%MY_DOCUMENTS%\Stella\stella.pal</i></td>
<td><i>%MY_DOCUMENTS%\Stella\stella.pal</i>&nbsp;&nbsp;&nbsp;
<b>OR</b><br>
<i>_BASEDIR_\stella.pal</i>&nbsp;&nbsp;&nbsp;
(if a file named 'basedir.txt' exists in the application
directory containing the full pathname for _BASEDIR_)
</td>
</tr>
</table>
<p>Note that to actually use the external palette, the palette file must

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.31 2009-01-16 21:46:31 stephena Exp $
// $Id: OSystemWin32.cxx,v 1.32 2009-01-30 23:31:41 stephena Exp $
//============================================================================
#include "bspf.hxx"
@ -35,11 +35,33 @@
OSystemWin32::OSystemWin32()
: OSystem()
{
string basedir = ".";
string basedir = "";
FilesystemNode home("~\\");
if(home.isDirectory())
basedir = "~\\Stella";
// Check if the base directory should be overridden
// Shouldn't normally be necessary, but is useful for those people that
// don't want to clutter their 'My Documents' folder
bool overrideBasedir = false;
FilesystemNode basedirfile("basedir.txt");
if(basedirfile.exists())
{
ifstream in(basedirfile.getPath().c_str());
if(in && in.is_open())
{
in >> basedir;
in.close();
if(basedir != "") overrideBasedir = true;
}
}
// If basedir hasn't been specified, use the 'home' directory
if(!overrideBasedir)
{
FilesystemNode home("~\\");
if(home.isDirectory())
basedir = "~\\Stella";
else
basedir = "."; // otherwise, default to current directory
}
setBaseDir(basedir);
setConfigFile(basedir + "\\stella.ini");