From cb0b5ae1ee54d9c279122e175b62f62ae435b6d1 Mon Sep 17 00:00:00 2001 From: stephena Date: Sun, 9 Mar 2008 20:38:44 +0000 Subject: [PATCH] Upon advice from Eckhard, changed the default location of the Stella config folder to "My Documents\Stella". Note that 'My Documents' will mean different locations in different versions of Windows. But the user shouldn't have to worry about that, since the 'Stella' folder will be in whatever 'My Documents' is on your system :) git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1425 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/win32/OSystemWin32.cxx | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/stella/src/win32/OSystemWin32.cxx b/stella/src/win32/OSystemWin32.cxx index 9f110b8c9..3f0b73ca4 100644 --- a/stella/src/win32/OSystemWin32.cxx +++ b/stella/src/win32/OSystemWin32.cxx @@ -13,12 +13,13 @@ // 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.22 2008-03-09 17:52:40 stephena Exp $ +// $Id: OSystemWin32.cxx,v 1.23 2008-03-09 20:38:44 stephena Exp $ //============================================================================ #include #include #include +#include #include "bspf.hxx" #include "FSNode.hxx" @@ -43,21 +44,23 @@ OSystemWin32::OSystemWin32() if(!FilesystemNode::fileExists("disable_profiles.txt")) { - OSVERSIONINFO win32OsVersion; - ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO)); - win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&win32OsVersion); + /* + Use 'My Documents' folder for the Stella folder, which can be in many + different places depending on the version of Windows, as follows: - // Check for non-9X version of Windows; Win9x will use the app directory - if(win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) + 98: C:\My Documents + XP: C:\Document and Settings\USERNAME\My Documents\ + Vista: C:\Users\USERNAME\Documents\ + + This function is guaranteed to return a valid 'My Documents' + folder (as much as Windows *can* make that guarantee) + */ + char configPath[256]; + if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, + NULL, 0, configPath))) { - // 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; - } + strcat(configPath, "\\Stella"); + basedir = configPath; } }