Skip to content

Commit

Permalink
Avoid fs::canonical on emscripten (incl. indirect through fs::relativ…
Browse files Browse the repository at this point in the history
…e!) (openscad#5531)
  • Loading branch information
ochafik authored Dec 26, 2024
1 parent 481186b commit 28c5405
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/io/fileutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ std::string lookup_file(const std::string& filename,
fs::path fs_uncomplete(fs::path const& p, fs::path const& base)
{
if (p == fs::path{}) return p;
#ifndef __EMSCRIPTEN__
return fs::relative(p, base == fs::path{} ? fs::path{"."} : base);
#else
return p;
#endif
}

int64_t fs_timestamp(fs::path const& path) {
Expand Down
6 changes: 3 additions & 3 deletions src/openscad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,10 @@ int main(int argc, char **argv)
PlatformUtils::ensureStdIO();
#endif

#ifdef __EMSCRIPTEN__
const auto applicationPath = boost::dll::fs::current_path();
#else
#ifndef __EMSCRIPTEN__
const auto applicationPath = weakly_canonical(boost::dll::program_location()).parent_path().generic_string();
#else
const auto applicationPath = boost::dll::fs::current_path();
#endif
PlatformUtils::registerApplicationPath(applicationPath);

Expand Down
4 changes: 4 additions & 0 deletions src/platform/PlatformUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ std::string PlatformUtils::userLibraryPath()
if (pathstr == "") return "";
path = fs::path(pathstr);
if (!fs::exists(path)) return "";
#ifndef __EMSCRIPTEN__
path = fs::canonical(path);
#endif
// LOG(message_group::NONE,,"path size %1$i",fs::stringy(path).size());
// LOG(message_group::NONE,,"lib path found: [%1$s]",path);
if (path.empty()) return "";
Expand All @@ -149,7 +151,9 @@ std::string PlatformUtils::backupPath()
if (pathstr == "") return "";
path = fs::path(pathstr);
if (!fs::exists(path)) return "";
#ifndef __EMSCRIPTEN__
path = fs::canonical(path);
#endif
if (path.empty()) return "";
path /= OPENSCAD_FOLDER_NAME;
path /= "backups";
Expand Down

0 comments on commit 28c5405

Please sign in to comment.