Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354#include "Resources.h"#include "Assets.h"#include "UserData.h"
#include <SDL3/SDL.h>#include <filesystem>#include <fstream>
void Resources::Init() { Assets::Init(); UserData::Init(); CloneBrushesForUser();}
void Resources::CloneBrushesForUser() { std::string brushesDir = UserData::GetBrushesDir(); if (std::filesystem::is_empty(brushesDir)) { std::list<std::string> brushFiles = Assets::Enumerate("brushes"); for (const auto& filename : brushFiles) { std::string src = "brushes/" + filename; std::string dest = brushesDir + "/" + filename; CopyAsset(Assets::Path(src), dest); } }}
bool Resources::CopyAsset(const std::string& srcPath, const std::string& destPath) { SDL_IOStream* src = SDL_IOFromFile(srcPath.c_str(), "rb"); if (!src) { return false; }
size_t size = SDL_GetIOSize(src); void* buffer = SDL_malloc(size); if (!buffer) { SDL_CloseIO(src); return false; }
SDL_ReadIO(src, buffer, size); SDL_CloseIO(src);
std::ofstream dest(destPath, std::ios::binary); if (!dest) { SDL_free(buffer); return false; }
dest.write((char*)buffer, size); dest.close(); SDL_free(buffer); return true;}