Route startup storage paths through platform services

This commit is contained in:
2026-06-03 04:59:23 +02:00
parent beb7f717f1
commit 578b1f6082
10 changed files with 170 additions and 93 deletions

View File

@@ -134,6 +134,12 @@ void invoke_selected_path(
callback(path);
}
void ensure_directory(const std::string& path)
{
if (!PathFileExistsA(path.c_str()))
CreateDirectoryA(path.c_str(), NULL);
}
std::string build_supported_files_filter(const std::vector<std::string>& types)
{
std::string filter = "Supported Files (";
@@ -157,6 +163,38 @@ std::string build_supported_files_filter(const std::vector<std::string>& types)
class WindowsPlatformServices final : public pp::platform::PlatformServices {
public:
[[nodiscard]] pp::platform::PlatformStoragePaths prepare_storage_paths() override
{
std::string data_path;
CHAR my_documents[MAX_PATH];
HRESULT result = SHGetFolderPathA(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents);
if (SUCCEEDED(result))
{
data_path = std::string(my_documents) + "\\PanoPainter";
ensure_directory(data_path);
}
else
{
CHAR path[MAX_PATH];
GetCurrentDirectoryA(sizeof(path), path);
data_path = path;
}
ensure_directory(data_path + "\\frames");
ensure_directory(data_path + "\\brushes");
ensure_directory(data_path + "\\brushes\\thumbs");
ensure_directory(data_path + "\\patterns");
ensure_directory(data_path + "\\patterns\\thumbs");
ensure_directory(data_path + "\\settings");
return {
data_path,
data_path,
data_path + "\\frames",
{},
};
}
[[nodiscard]] std::string clipboard_text() override
{
return ::clipboard_text();