summaryrefslogtreecommitdiff
path: root/src/PlatformUtils.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2014-02-13 05:15:35 (GMT)
committerMarius Kintel <marius@kintel.net>2014-02-13 05:15:35 (GMT)
commit78baae599b6c0fbe058071c98ebc541ed66fd030 (patch)
treece7bfa13ca4897a8bff68365a3c58a4433754db7 /src/PlatformUtils.cc
parentada0609b9cb338fc14f1822f9a94fe9e0af95d67 (diff)
Adapted wil1471's pull request #385 to master
Diffstat (limited to 'src/PlatformUtils.cc')
-rw-r--r--src/PlatformUtils.cc35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/PlatformUtils.cc b/src/PlatformUtils.cc
index 8b39f6d..c207651 100644
--- a/src/PlatformUtils.cc
+++ b/src/PlatformUtils.cc
@@ -41,6 +41,40 @@ std::string PlatformUtils::libraryPath()
return boosty::stringy( path );
}
+
+std::string PlatformUtils::backupPath()
+{
+ fs::path path;
+ try {
+ std::string pathstr = PlatformUtils::documentsPath();
+ if (pathstr=="") return "";
+ path = boosty::canonical(fs::path( pathstr ));
+ if (path.empty()) return "";
+ path /= "OpenSCAD";
+ path /= "backups";
+ } catch (const fs::filesystem_error& ex) {
+ PRINTB("ERROR: %s",ex.what());
+ }
+ return boosty::stringy( path );
+}
+
+bool PlatformUtils::createBackupPath()
+{
+ std::string path = PlatformUtils::backupPath();
+ bool OK = false;
+ try {
+ if (!fs::exists(fs::path(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;
+}
+
#include "version_check.h"
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
@@ -121,4 +155,3 @@ std::string PlatformUtils::info()
;
return s.str();
}
-
contact: Jan Huwald // Impressum