mirror of
https://github.com/jorio/Pomme.git
synced 2024-09-27 12:55:59 +00:00
Compare commits
3 Commits
c6a38eab19
...
83d8e04520
Author | SHA1 | Date | |
---|---|---|---|
|
83d8e04520 | ||
|
5358bfea27 | ||
|
60f1eeaf58 |
@ -11,6 +11,7 @@
|
||||
#include "CompilerSupport/filesystem.h"
|
||||
|
||||
#if _WIN32
|
||||
#include <SDL.h>
|
||||
#include "Platform/Windows/PommeWindows.h"
|
||||
#endif
|
||||
|
||||
@ -173,9 +174,25 @@ OSErr FindFolder(short vRefNum, OSType folderType, Boolean createFolder, short*
|
||||
{
|
||||
#ifdef _WIN32
|
||||
path = Pomme::Platform::Windows::GetPreferencesFolder();
|
||||
if (path.empty())
|
||||
{
|
||||
const char* fallback = SDL_GetPrefPath("", "PommeFallback");
|
||||
if (fallback)
|
||||
{
|
||||
TODOMINOR2("SDL fallback path is: " << fallback);
|
||||
path = fallback;
|
||||
SDL_free((void*) fallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
TODO2("SDL fallback path failure!");
|
||||
return fnfErr;
|
||||
}
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
const char *home = getenv("HOME");
|
||||
if (!home) {
|
||||
if (!home)
|
||||
{
|
||||
return fnfErr;
|
||||
}
|
||||
path = fs::path(home) / "Library" / "Preferences";
|
||||
|
@ -180,6 +180,18 @@ static bool CaseInsensitiveAppendToPath(
|
||||
return true;
|
||||
}
|
||||
|
||||
#if POMME_CASE_SENSITIVE_FSSPEC
|
||||
if (!skipFiles)
|
||||
{
|
||||
fs::path candidateResourcePath = naiveConcat;
|
||||
candidateResourcePath += ".rsrc";
|
||||
if (fs::is_regular_file(candidateResourcePath))
|
||||
{
|
||||
path = naiveConcat;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Convert path element to uppercase for case-insensitive comparisons
|
||||
const auto uppercaseElement = UppercaseCopy(element);
|
||||
|
||||
@ -211,6 +223,7 @@ static bool CaseInsensitiveAppendToPath(
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
path = naiveConcat;
|
||||
return false;
|
||||
|
@ -1,14 +1,35 @@
|
||||
#undef NOUSER
|
||||
|
||||
#include "PommeDebug.h"
|
||||
#include "Platform/Windows/PommeWindows.h"
|
||||
|
||||
#include <shlobj.h>
|
||||
|
||||
std::filesystem::path Pomme::Platform::Windows::GetPreferencesFolder()
|
||||
{
|
||||
wchar_t* wpath = nullptr;
|
||||
SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &wpath);
|
||||
auto path = std::filesystem::path(wpath);
|
||||
PWSTR wpath = nullptr;
|
||||
HRESULT result = SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &wpath);
|
||||
|
||||
std::filesystem::path path;
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
TODO2("SHGetKnownFolderPath returned " << result);
|
||||
path = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
path = std::filesystem::path(wpath);
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
TODO2("Conversion from wpath failed " << ex.what());
|
||||
path = "";
|
||||
}
|
||||
}
|
||||
|
||||
CoTaskMemFree(static_cast<void*>(wpath));
|
||||
return path;
|
||||
}
|
||||
|
@ -6,13 +6,33 @@
|
||||
#include <sstream>
|
||||
#include <cstdint>
|
||||
|
||||
#define POMME_DEBUG_MEMORY false
|
||||
#define POMME_DEBUG_SOUND false
|
||||
#define POMME_DEBUG_PICT false
|
||||
#define POMME_DEBUG_FILES false
|
||||
#define POMME_DEBUG_RESOURCES false
|
||||
#define POMME_DEBUG_INPUT false
|
||||
#define POMME_DEBUG_3DMF false
|
||||
#if !defined(POMME_DEBUG_MEMORY)
|
||||
#define POMME_DEBUG_MEMORY 0
|
||||
#endif
|
||||
|
||||
#if !defined(POMME_DEBUG_SOUND)
|
||||
#define POMME_DEBUG_SOUND 0
|
||||
#endif
|
||||
|
||||
#if !defined(POMME_DEBUG_PICT)
|
||||
#define POMME_DEBUG_PICT 0
|
||||
#endif
|
||||
|
||||
#if !defined(POMME_DEBUG_FILES)
|
||||
#define POMME_DEBUG_FILES 0
|
||||
#endif
|
||||
|
||||
#if !defined(POMME_DEBUG_RESOURCES)
|
||||
#define POMME_DEBUG_RESOURCES 0
|
||||
#endif
|
||||
|
||||
#if !defined(POMME_DEBUG_INPUT)
|
||||
#define POMME_DEBUG_INPUT 0
|
||||
#endif
|
||||
|
||||
#if !defined(POMME_DEBUG_3DMF)
|
||||
#define POMME_DEBUG_3DMF 0
|
||||
#endif
|
||||
|
||||
#define POMME_GENLOG(define, prefix) if (!define) {} else std::cout << "[" << prefix << "] " << __func__ << ":\t"
|
||||
#define POMME_GENLOG_NOPREFIX(define) if (!define) {} else std::cout
|
||||
|
Loading…
Reference in New Issue
Block a user