Route startup storage paths through platform services
This commit is contained in:
86
src/app.cpp
86
src/app.cpp
@@ -8,6 +8,7 @@
|
||||
#include "app_core/document_recording.h"
|
||||
#include "app_core/document_route.h"
|
||||
#include "app_core/document_session.h"
|
||||
#include "platform_api/platform_services.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
@@ -16,13 +17,6 @@
|
||||
#endif
|
||||
#include "settings.h"
|
||||
|
||||
#ifdef __LINUX__
|
||||
std::string linux_home_path();
|
||||
int mkpath(const std::string& dir, mode_t mode = DEFFILEMODE);
|
||||
#elif __WEB__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
App* App::I = nullptr; // singleton
|
||||
|
||||
std::deque<AppTask> App::render_tasklist;
|
||||
@@ -295,78 +289,16 @@ void App::initAssets()
|
||||
|
||||
void App::initLog()
|
||||
{
|
||||
#if defined(__IOS__)
|
||||
[ios_view init_dirs];
|
||||
#elif defined(__OSX__)
|
||||
[osx_app init_dirs];
|
||||
#elif defined(_WIN32)
|
||||
//CHAR my_documents[MAX_PATH];
|
||||
//HRESULT result = SHGetFolderPathA(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents);
|
||||
|
||||
//HMODULE hModule = GetModuleHandle(NULL);
|
||||
//CHAR path[MAX_PATH];
|
||||
//GetModuleFileNameA(hModule, path, MAX_PATH);
|
||||
//CHAR out_drive[MAX_PATH];
|
||||
//CHAR out_path[MAX_PATH];
|
||||
//_splitpath(path, out_drive, out_path, nullptr, nullptr);
|
||||
//sprintf_s(path, "%s%s", out_drive, out_path);
|
||||
//data_path = path;
|
||||
|
||||
|
||||
CHAR my_documents[MAX_PATH];
|
||||
HRESULT result = SHGetFolderPathA(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents);
|
||||
if (SUCCEEDED(result))
|
||||
{
|
||||
std::string path = std::string(my_documents) + "\\PanoPainter";
|
||||
if (!PathFileExistsA(path.c_str()))
|
||||
CreateDirectoryA(path.c_str(), NULL);
|
||||
data_path = path;
|
||||
}
|
||||
else
|
||||
{
|
||||
CHAR path[MAX_PATH];
|
||||
GetCurrentDirectoryA(sizeof(path), path);
|
||||
data_path = path;
|
||||
}
|
||||
|
||||
rec_path = data_path + "\\frames";
|
||||
if (!PathFileExistsA(rec_path.c_str()))
|
||||
CreateDirectoryA(rec_path.c_str(), NULL);
|
||||
|
||||
if (!PathFileExistsA((data_path + "\\brushes").c_str()))
|
||||
CreateDirectoryA((data_path + "\\brushes").c_str(), NULL);
|
||||
if (!PathFileExistsA((data_path + "\\brushes\\thumbs").c_str()))
|
||||
CreateDirectoryA((data_path + "\\brushes\\thumbs").c_str(), NULL);
|
||||
|
||||
if (!PathFileExistsA((data_path + "\\patterns").c_str()))
|
||||
CreateDirectoryA((data_path + "\\patterns").c_str(), NULL);
|
||||
if (!PathFileExistsA((data_path + "\\patterns\\thumbs").c_str()))
|
||||
CreateDirectoryA((data_path + "\\patterns\\thumbs").c_str(), NULL);
|
||||
|
||||
if (!PathFileExistsA((data_path + "\\settings").c_str()))
|
||||
CreateDirectoryA((data_path + "\\settings").c_str(), NULL);
|
||||
|
||||
#elif __LINUX__
|
||||
data_path = linux_home_path() + "/PanoPainter";
|
||||
mkpath(data_path + "/brushes");
|
||||
mkpath(data_path + "/brushes/thumbs");
|
||||
mkpath(data_path + "/patterns");
|
||||
mkpath(data_path + "/patterns/thumbs");
|
||||
mkpath(data_path + "/settings");
|
||||
mkpath(data_path + "/frames");
|
||||
#elif __WEB__
|
||||
data_path = "/PanoPainter";
|
||||
mkdir(data_path.c_str(), 0777);
|
||||
mkdir((data_path + "/brushes").c_str(), 0777);
|
||||
mkdir((data_path + "/brushes/thumbs").c_str(), 0777);
|
||||
mkdir((data_path + "/patterns").c_str(), 0777);
|
||||
mkdir((data_path + "/patterns/thumbs").c_str(), 0777);
|
||||
mkdir((data_path + "/settings").c_str(), 0777);
|
||||
mkdir((data_path + "/frames").c_str(), 0777);
|
||||
#endif
|
||||
const auto paths = prepare_storage_paths();
|
||||
if (!paths.data_path.empty())
|
||||
data_path = paths.data_path;
|
||||
if (!paths.recording_path.empty())
|
||||
rec_path = paths.recording_path;
|
||||
if (!paths.temporary_path.empty())
|
||||
tmp_path = paths.temporary_path;
|
||||
|
||||
// TODO: save this path somewhere in the settings, don't overwrite every start
|
||||
work_path = data_path;
|
||||
work_path = paths.work_path.empty() ? data_path : paths.work_path;
|
||||
|
||||
//LogRemote::I.start();
|
||||
LogRemote::I.file_init();
|
||||
|
||||
Reference in New Issue
Block a user