Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

SF_USER_DATA_DIR set and read wide on Windows: a non-ASCII temp folder (benchmarks, agent runs on a user's machine) round-trips

islandmed2899aeffe986
diff --git a/src/app/UserData.h b/src/app/UserData.h
index b150825d..70f57a7e 100644
--- a/src/app/UserData.h
+++ b/src/app/UserData.h
@@ -17,9 +17,18 @@ namespace sf {
// Windows UI test shared the runner's real settings and read the ones an earlier test left (0.11.2: support_card
// found another test's "supporter").
inline std::string userDataDir() {
- if (const char* over = std::getenv("SF_USER_DATA_DIR"); over && *over) {
- const std::filesystem::path dir = std::filesystem::path(std::u8string(over, over + std::strlen(over))) /
- "SculptForge" / "SculptForge";
+#if defined(_WIN32)
+ const wchar_t* over = _wgetenv(L"SF_USER_DATA_DIR"); // (wide: getenv gives the ANSI code page, not UTF-8)
+#else
+ const char* over = std::getenv("SF_USER_DATA_DIR");
+#endif
+ if (over && *over) {
+#if defined(_WIN32)
+ const std::filesystem::path base(over);
+#else
+ const std::filesystem::path base(std::u8string(over, over + std::strlen(over)));
+#endif
+ const std::filesystem::path dir = base / "SculptForge" / "SculptForge";
std::error_code ec;
std::filesystem::create_directories(dir, ec);
if (ec) return std::string();
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 6f45a1c6..12701c6f 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -107,7 +107,7 @@ void isolateSettings() {
const std::string d = dir.string();
#if defined(_WIN32)
_putenv_s("APPDATA", d.c_str());
- _putenv_s("SF_USER_DATA_DIR", d.c_str()); // (SDL_GetPrefPath ignores APPDATA: app/UserData.h)
+ _wputenv_s(L"SF_USER_DATA_DIR", dir.c_str()); // (SDL_GetPrefPath ignores APPDATA: app/UserData.h; wide, any name)
#else
setenv("XDG_DATA_HOME", d.c_str(), 1);
setenv("XDG_CONFIG_HOME", d.c_str(), 1);