Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
C++
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859#include "UserData.h"#include <SDL3/SDL.h>#include <filesystem>#include <stdexcept>
std::string UserData::projectsDir;std::string UserData::brushesDir;
void UserData::Init() { std::string writablePath;#ifdef __ANDROID__ // try public readable const char* prefPath = SDL_GetAndroidExternalStoragePath(); if (prefPath) { writablePath = prefPath; } else { // try /data/data by android api const char* internalPath = SDL_GetAndroidInternalStoragePath(); if (internalPath) { writablePath = internalPath; } else { // android fucked up, lets try anyway writablePath = "/data/data/io.tngl.hatlink.gradien/files"; } } if (!writablePath.empty() && (writablePath.back() == '/' || writablePath.back() == '\\')) { writablePath.pop_back(); }#else const char* xdgDataHome = std::getenv("XDG_DATA_HOME"); if (xdgDataHome != nullptr) { writablePath = xdgDataHome; } else { const char* homeEnv = std::getenv("HOME"); if (homeEnv != nullptr) { writablePath = homeEnv; writablePath += "/.local/share"; } else { throw std::runtime_error("Failed to find suitable location for user data"); } } writablePath += "/Gradien";#endif
projectsDir = writablePath + "/Projects"; brushesDir = writablePath + "/Brushes";
std::filesystem::create_directories(projectsDir); std::filesystem::create_directories(brushesDir);}
std::string UserData::GetProjectsDir() { return projectsDir;}
std::string UserData::GetBrushesDir() { return brushesDir;}