diff options
author | donbright <hugh.m.bright@gmail.com> | 2013-05-27 05:28:56 (GMT) |
---|---|---|
committer | donbright <hugh.m.bright@gmail.com> | 2013-05-27 05:28:56 (GMT) |
commit | ef7b80656fc39dc0fd4012231633cf858e6aa10b (patch) | |
tree | 17e5a57dfa154821918094cab47476189771ce00 /src/PlatformUtils.cc | |
parent | 0967a26bff45951d7b86fe628e8b1156e6e40ede (diff) | |
parent | 37dc9342a14206f5862447eb9d3d5049ec67f638 (diff) |
Merge pull request #368 from openscad/issue125
Issue125
Diffstat (limited to 'src/PlatformUtils.cc')
-rw-r--r-- | src/PlatformUtils.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/PlatformUtils.cc b/src/PlatformUtils.cc new file mode 100644 index 0000000..5dd007d --- /dev/null +++ b/src/PlatformUtils.cc @@ -0,0 +1,40 @@ +#include "PlatformUtils.h" +#include "boosty.h" + +bool PlatformUtils::createLibraryPath() +{ + std::string path = PlatformUtils::libraryPath(); + bool OK = false; + try { + if (!fs::exists(fs::path(path))) { + //PRINTB("Creating library folder %s", path ); + OK = fs::create_directories( path ); + } + if (!OK) { + PRINTB("ERROR: Cannot create %s", path ); + } + } catch (const fs::filesystem_error& ex) { + PRINTB("ERROR: %s",ex.what()); + } + return OK; +} + +std::string PlatformUtils::libraryPath() +{ + fs::path path; + try { + std::string pathstr = PlatformUtils::documentsPath(); + if (pathstr=="") return ""; + path = boosty::canonical(fs::path( pathstr )); + //PRINTB("path size %i",boosty::stringy(path).size()); + //PRINTB("lib path found: [%s]", path ); + if (path.empty()) return ""; + path /= "OpenSCAD"; + path /= "libraries"; + //PRINTB("Appended path %s", path ); + //PRINTB("Exists: %i", fs::exists(path) ); + } catch (const fs::filesystem_error& ex) { + PRINTB("ERROR: %s",ex.what()); + } + return boosty::stringy( path ); +} |