diff options
author | Don Bright <hugh.m.bright@gmail.com> | 2013-05-26 03:37:26 (GMT) |
---|---|---|
committer | Don Bright <hugh.m.bright@gmail.com> | 2013-05-26 03:37:26 (GMT) |
commit | 31c88a434b3201d88819b485f74da843c2728cb2 (patch) | |
tree | 6fc7bffe22a7b685aa2cf18143796ace29d4fb8b /src/PlatformUtils.cc | |
parent | 164902fa76efac9f88bbd9aa6cbd1eb8c3fa00fb (diff) |
merge branch to get windows "library path" working. tweak build system,
eliminate several compiler warnings.
Diffstat (limited to 'src/PlatformUtils.cc')
-rw-r--r-- | src/PlatformUtils.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/PlatformUtils.cc b/src/PlatformUtils.cc index cea449b..a7efe40 100644 --- a/src/PlatformUtils.cc +++ b/src/PlatformUtils.cc @@ -3,5 +3,26 @@ std::string PlatformUtils::libraryPath() { - return boosty::stringy(fs::path(PlatformUtils::documentsPath()) / "OpenSCAD" / "libraries"); + fs::path path; + bool OK = true; + try { + path = boosty::canonical(fs::path(PlatformUtils::documentsPath())); + if (path.empty()) return ""; + PRINTB("path size %i",boosty::stringy(path).size()); + path /= "OpenSCAD"; + path /= "libraries"; + PRINTB("Appended path %s", path ); + PRINTB("Exists: %i", fs::exists(path) ); + if (!fs::exists(path)) { + PRINTB("Creating library folder %s", boosty::stringy(path) ); + OK &= fs::create_directories( path ); + } + if (!OK) { + PRINTB("ERROR: Cannot find nor create %s", boosty::stringy(path) ); + path = fs::path(""); + } + } catch (const fs::filesystem_error& ex) { + PRINTB("ERROR: %s",ex.what()); + } + return boosty::stringy( path ); } |