Windows support

This commit is contained in:
Gabrieal Jimmy
2026-10-02 16:04:30 -05:00
parent 34fa21139f
commit d31689cf86
14 changed files with 242 additions and 57 deletions

View File

@@ -28,34 +28,6 @@ namespace bs {
namespace fs = std::filesystem;
fs::path userDataDir() {
fs::path base;
#if defined(_WIN32)
if (const char* a = std::getenv("APPDATA"); a && *a) base = a;
#else
if (const char* x = std::getenv("XDG_DATA_HOME"); x && *x) base = x;
else if (const char* h = std::getenv("HOME"); h && *h) base = fs::path(h) / ".local/share";
#endif
if (base.empty()) base = ".";
fs::path d = base / "brandling-safari";
std::error_code ec;
fs::create_directories(d, ec);
return d;
}
fs::path executableDir() {
#if defined(_WIN32)
std::wstring buf(32768, L'\0');
DWORD n = GetModuleFileNameW(nullptr, buf.data(), DWORD(buf.size()));
buf.resize(n);
return fs::path(buf).parent_path();
#else
std::error_code ec;
fs::path exe = fs::read_symlink("/proc/self/exe", ec);
return ec ? fs::current_path() : exe.parent_path();
#endif
}
#if defined(_WIN32)
namespace {