WIN32: Add Portable Mode

Adds support for a self-contained portable mode in which the
executable's directory is used for application files instead
of directories in the user's profile.

Portable mode is activated by placing a scummvm.ini file in
the executable's directory. The directory must be outside of
the system's Program Files directory to comply with UAC.
This commit is contained in:
sluicebox 2021-11-07 02:34:42 -06:00 committed by Lothar Serra Mari
parent 84872f6b8d
commit 3d6524c9f4
6 changed files with 167 additions and 64 deletions

View file

@ -31,6 +31,29 @@ HRESULT SHGetFolderPathFunc(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags,
// Helper functions
namespace Win32 {
/**
* Gets the full path to the ScummVM application data directory
* in the user's profile and creates it if it doesn't exist.
*
* @param profileDirectory MAX_PATH sized output array
*
* @return True if the user's profile directory was found, false if
* it was not.
*
* @note if the user's profile directory is found but the "ScummVM"
* subdirectory can't be created then this function calls error().
*/
bool getApplicationDataDirectory(TCHAR *profileDirectory);
/**
* Gets the full path to the directory that the currently executing
* process resides in.
*
* @param processDirectory output array
* @param size size in characters of output array
*/
void getProcessDirectory(TCHAR *processDirectory, DWORD size);
/**
* Checks if the current running Windows version is greater or equal to the specified version.
* See: https://docs.microsoft.com/en-us/windows/desktop/sysinfo/operating-system-version
@ -115,6 +138,6 @@ char **getArgvUtf8(int *argc);
void freeArgvUtf8(int argc, char **argv);
#endif
}
} // End of namespace Win32
#endif