2009-06-18 17:08:09 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
2009-06-18 17:08:09 +00:00
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// Copyright (c) 1995-2017 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2009-06-18 17:08:09 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2009-06-18 17:08:09 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//============================================================================
|
|
|
|
|
2009-06-18 17:38:42 +00:00
|
|
|
#ifndef __HOME_FINDER_
|
|
|
|
#define __HOME_FINDER_
|
|
|
|
|
2016-04-02 20:46:02 +00:00
|
|
|
#pragma warning( disable : 4091 )
|
2009-06-18 17:08:09 +00:00
|
|
|
#include <shlobj.h>
|
|
|
|
|
|
|
|
/*
|
2011-11-25 14:17:05 +00:00
|
|
|
* Used to determine the location of the various Win32 user/system folders.
|
2009-06-18 17:08:09 +00:00
|
|
|
*/
|
|
|
|
class HomeFinder
|
|
|
|
{
|
|
|
|
public:
|
2016-04-02 20:46:02 +00:00
|
|
|
HomeFinder() = default;
|
|
|
|
~HomeFinder() = default;
|
2009-06-18 17:08:09 +00:00
|
|
|
|
2016-04-02 20:46:02 +00:00
|
|
|
// Return the 'HOME/User' folder, or an empty string if the folder couldn't be determined.
|
2011-12-22 21:29:24 +00:00
|
|
|
const string& getHomePath() const
|
2009-06-18 17:08:09 +00:00
|
|
|
{
|
2011-12-22 21:29:24 +00:00
|
|
|
if(ourHomePath == "")
|
|
|
|
{
|
2016-04-02 20:46:02 +00:00
|
|
|
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;
|
2011-12-22 21:29:24 +00:00
|
|
|
}
|
|
|
|
return ourHomePath;
|
2009-06-18 17:08:09 +00:00
|
|
|
}
|
|
|
|
|
2016-04-02 20:46:02 +00:00
|
|
|
// Return the 'APPDATA' folder, or an empty string if the folder couldn't be determined.
|
2011-12-22 21:29:24 +00:00
|
|
|
const string& getAppDataPath() const
|
2009-06-18 17:08:09 +00:00
|
|
|
{
|
2011-12-22 21:29:24 +00:00
|
|
|
if(ourAppDataPath == "")
|
|
|
|
{
|
2016-04-02 20:46:02 +00:00
|
|
|
char folder_path[MAX_PATH];
|
|
|
|
HRESULT const result = SHGetFolderPathA(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
|
|
|
|
NULL, 0, folder_path);
|
|
|
|
ourAppDataPath = (result == S_OK) ? folder_path : EmptyString;
|
2011-12-22 21:29:24 +00:00
|
|
|
}
|
|
|
|
return ourAppDataPath;
|
2009-06-18 17:08:09 +00:00
|
|
|
}
|
|
|
|
|
2016-04-02 20:46:02 +00:00
|
|
|
// Return the 'DESKTOPDIRECTORY' folder, or an empty string if the folder couldn't be determined.
|
2011-12-22 21:29:24 +00:00
|
|
|
const string& getDesktopPath() const
|
2011-11-25 14:17:05 +00:00
|
|
|
{
|
2011-12-22 21:29:24 +00:00
|
|
|
if(ourDesktopPath == "")
|
|
|
|
{
|
2016-04-02 20:46:02 +00:00
|
|
|
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;
|
2011-12-22 21:29:24 +00:00
|
|
|
}
|
|
|
|
return ourDesktopPath;
|
2011-11-25 14:17:05 +00:00
|
|
|
}
|
|
|
|
|
2015-04-26 19:02:42 +00:00
|
|
|
private:
|
|
|
|
static string ourHomePath, ourAppDataPath, ourDesktopPath;
|
|
|
|
|
|
|
|
// Following constructors and assignment operators not supported
|
|
|
|
HomeFinder(const HomeFinder&) = delete;
|
|
|
|
HomeFinder(HomeFinder&&) = delete;
|
|
|
|
HomeFinder& operator=(const HomeFinder&) = delete;
|
|
|
|
HomeFinder& operator=(HomeFinder&&) = delete;
|
2009-06-18 17:08:09 +00:00
|
|
|
};
|
2009-06-18 17:38:42 +00:00
|
|
|
|
2011-12-22 21:29:24 +00:00
|
|
|
__declspec(selectany) string HomeFinder::ourHomePath = "";
|
|
|
|
__declspec(selectany) string HomeFinder::ourAppDataPath = "";
|
|
|
|
__declspec(selectany) string HomeFinder::ourDesktopPath = "";
|
|
|
|
|
2009-06-18 17:38:42 +00:00
|
|
|
#endif
|