Skip to content

Commit 5ab27e0

Browse files
authored
Fix a few more fs::canonical on emscripten (openscad#5523)
1 parent 401f06e commit 5ab27e0

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/core/parsersettings.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,18 @@ inline fs::path find_valid_path_(const fs::path& sourcepath,
8787
const std::vector<std::string> *openfilenames)
8888
{
8989
if (localpath.is_absolute()) {
90-
if (check_valid(localpath, openfilenames)) return fs::canonical(localpath);
90+
if (check_valid(localpath, openfilenames)) {
91+
#ifndef __EMSCRIPTEN__
92+
return fs::canonical(localpath);
93+
#else
94+
return localpath;
95+
#endif
96+
}
9197
} else {
9298
fs::path fpath = sourcepath / localpath;
99+
#ifndef __EMSCRIPTEN__
93100
if (fs::exists(fpath)) fpath = fs::canonical(fpath);
101+
#endif
94102
if (check_valid(fpath, openfilenames)) return fpath;
95103
fpath = search_libs(localpath);
96104
if (!fpath.empty() && check_valid(fpath, openfilenames)) return fpath;

src/platform/PlatformUtils.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ static std::string lookupResourcesPath()
7777
}
7878

7979
// resourcedir defaults to applicationPath
80-
std::string result = fs::canonical(resourcedir).generic_string();
80+
#ifndef __EMSCRIPTEN__
81+
resourcedir = fs::canonical(resourcedir);
82+
#endif
83+
std::string result = resourcedir.generic_string();
8184
PRINTDB("Using resource folder '%s'", result);
8285
return result;
8386
}

tests/wasm-check.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515
instance.FS.writeFile("/fonts/LiberationSans-Regular.ttf",
1616
new Uint8Array(await (await fetch("../fonts/Liberation-2.00.1/ttf/LiberationSans-Regular.ttf")).arrayBuffer()));
1717

18+
instance.FS.writeFile("lib.scad", `
19+
test_text = "Hello";
20+
`);
1821
instance.FS.writeFile("input.scad", `
22+
include <lib.scad>;
1923
$fn=64;
2024
difference() {
2125
linear_extrude(height = 20, center=true)
22-
text("Hello", size=10, halign="center", valign="center", font="Liberation Sans");
26+
text(test_text, size=10, halign="center", valign="center", font="Liberation Sans");
2327
sphere(r=10);
2428
}
2529
`);

0 commit comments

Comments
 (0)