From 1d10a63af68301247dcf44f2f508bd1eba15f4b4 Mon Sep 17 00:00:00 2001 From: stephena Date: Sun, 9 Mar 2008 17:52:40 +0000 Subject: [PATCH] Made Win32 port use %USERPROFILE%\Stella as the base folder for the various config files and the state folder. This is more in line with the Linux and OSX ports, which have a pre-defined basedir folder ($HOME/.stella). This also makes Stella behave better with limited accounts in Windows, since writes are no longer done to the app folder. Since the Win32 port didn't work this way before, many people may require the old behaviour. In this case, one may create a file named 'disable_profiles.txt' in the app folder to restore the old behaviour. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1424 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/Makefile | 4 ++-- stella/src/win32/OSystemWin32.cxx | 31 ++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/stella/Makefile b/stella/Makefile index 4578d3dfa..c79c9aff9 100644 --- a/stella/Makefile +++ b/stella/Makefile @@ -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: Makefile,v 1.34 2008-03-09 15:30:27 stephena Exp $ +## $Id: Makefile,v 1.35 2008-03-09 17:52:40 stephena Exp $ ## ## Based on code from ScummVM - Scumm Interpreter ## Copyright (C) 2002-2004 The ScummVM project @@ -196,7 +196,7 @@ src/win32/stella_icon.o: src/win32/stella.ico src/win32/stella.rc win32dist: stella$(EXEEXT) rm -rf $(DISTNAME) mkdir -p $(DISTNAME)/docs/graphics - $(STRIP) stella$(EXEEXT) -o $(DISTNAME)/stella$(EXEEXT) + $(STRIP) stella$(EXEEXT) -o $(DISTNAME)/Stella$(EXEEXT) cp Announce.txt Changes.txt Copyright.txt License.txt README-SDL.txt Readme.txt Todo.txt $(DISTNAME)/docs cp -r docs/*.html $(DISTNAME)/docs cp -r docs/graphics/*.png $(DISTNAME)/docs/graphics diff --git a/stella/src/win32/OSystemWin32.cxx b/stella/src/win32/OSystemWin32.cxx index 0e7ae2651..9f110b8c9 100644 --- a/stella/src/win32/OSystemWin32.cxx +++ b/stella/src/win32/OSystemWin32.cxx @@ -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.21 2008-02-06 13:45:24 stephena Exp $ +// $Id: OSystemWin32.cxx,v 1.22 2008-03-09 17:52:40 stephena Exp $ //============================================================================ #include @@ -21,6 +21,7 @@ #include #include "bspf.hxx" +#include "FSNode.hxx" #include "OSystem.hxx" #include "OSystemWin32.hxx" @@ -38,12 +39,28 @@ OSystemWin32::OSystemWin32() : OSystem() { - // TODO - there really should be code here to determine which version - // of Windows is being used. - // If using a version which supports multiple users (NT and above), - // the relevant directories should be created in per-user locations. - // For now, we just put it in the same directory as the executable. - const string& basedir = "."; + string basedir = "."; + + if(!FilesystemNode::fileExists("disable_profiles.txt")) + { + OSVERSIONINFO win32OsVersion; + ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO)); + win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&win32OsVersion); + + // Check for non-9X version of Windows; Win9x will use the app directory + if(win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) + { + // If this doesn't exist, we just fall back to the default (same directory as app) + char configFile[256]; + if(GetEnvironmentVariable("USERPROFILE", configFile, sizeof(configFile))) + { + strcat(configFile, "\\Stella"); + basedir = configFile; + } + } + } + setBaseDir(basedir); setConfigFile(basedir + "\\stella.ini"); }