Skip to content

Commit 28c5405

Browse files
authored
Avoid fs::canonical on emscripten (incl. indirect through fs::relative!) (openscad#5531)
1 parent 481186b commit 28c5405

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/io/fileutils.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ std::string lookup_file(const std::string& filename,
3737
fs::path fs_uncomplete(fs::path const& p, fs::path const& base)
3838
{
3939
if (p == fs::path{}) return p;
40+
#ifndef __EMSCRIPTEN__
4041
return fs::relative(p, base == fs::path{} ? fs::path{"."} : base);
42+
#else
43+
return p;
44+
#endif
4145
}
4246

4347
int64_t fs_timestamp(fs::path const& path) {

src/openscad.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,10 @@ int main(int argc, char **argv)
708708
PlatformUtils::ensureStdIO();
709709
#endif
710710

711-
#ifdef __EMSCRIPTEN__
712-
const auto applicationPath = boost::dll::fs::current_path();
713-
#else
711+
#ifndef __EMSCRIPTEN__
714712
const auto applicationPath = weakly_canonical(boost::dll::program_location()).parent_path().generic_string();
713+
#else
714+
const auto applicationPath = boost::dll::fs::current_path();
715715
#endif
716716
PlatformUtils::registerApplicationPath(applicationPath);
717717

src/platform/PlatformUtils.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ std::string PlatformUtils::userLibraryPath()
126126
if (pathstr == "") return "";
127127
path = fs::path(pathstr);
128128
if (!fs::exists(path)) return "";
129+
#ifndef __EMSCRIPTEN__
129130
path = fs::canonical(path);
131+
#endif
130132
// LOG(message_group::NONE,,"path size %1$i",fs::stringy(path).size());
131133
// LOG(message_group::NONE,,"lib path found: [%1$s]",path);
132134
if (path.empty()) return "";
@@ -149,7 +151,9 @@ std::string PlatformUtils::backupPath()
149151
if (pathstr == "") return "";
150152
path = fs::path(pathstr);
151153
if (!fs::exists(path)) return "";
154+
#ifndef __EMSCRIPTEN__
152155
path = fs::canonical(path);
156+
#endif
153157
if (path.empty()) return "";
154158
path /= OPENSCAD_FOLDER_NAME;
155159
path /= "backups";

0 commit comments

Comments
 (0)