summaryrefslogtreecommitdiff
path: root/src/PlatformUtils.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-06-18 05:46:48 (GMT)
committerMarius Kintel <marius@kintel.net>2013-06-18 05:46:48 (GMT)
commit6d91540e4cc3f9fe0caaea63ac64518a5626d28b (patch)
treeca7034453a1f55124e4b7378aaab22985aff6a21 /src/PlatformUtils.cc
parent95947a877b8e88521a7f00348d56c89e9b7c2a79 (diff)
parent6c7d386a3338039416ced323bf1aa75edbb43d19 (diff)
Merge branch 'master' into epec-kernel
Diffstat (limited to 'src/PlatformUtils.cc')
-rw-r--r--src/PlatformUtils.cc40
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 );
+}
contact: Jan Huwald // Impressum