summaryrefslogtreecommitdiff
path: root/src/PlatformUtils.cc
diff options
context:
space:
mode:
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