2013-05-22 02:02:16 +04:00
|
|
|
#include "PlatformUtils.h"
|
|
|
|
#include "boosty.h"
|
|
|
|
|
2013-05-27 05:24:53 +04:00
|
|
|
bool PlatformUtils::createLibraryPath()
|
|
|
|
{
|
|
|
|
std::string path = PlatformUtils::libraryPath();
|
|
|
|
bool OK = false;
|
|
|
|
try {
|
|
|
|
if (!fs::exists(fs::path(path))) {
|
2013-05-27 07:55:14 +04:00
|
|
|
//PRINTB("Creating library folder %s", path );
|
2013-05-27 05:24:53 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-05-22 02:02:16 +04:00
|
|
|
std::string PlatformUtils::libraryPath()
|
|
|
|
{
|
2013-05-26 07:37:26 +04:00
|
|
|
fs::path path;
|
|
|
|
try {
|
2013-05-27 07:55:14 +04:00
|
|
|
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 );
|
2013-05-26 07:37:26 +04:00
|
|
|
if (path.empty()) return "";
|
|
|
|
path /= "OpenSCAD";
|
|
|
|
path /= "libraries";
|
2013-05-27 05:24:53 +04:00
|
|
|
//PRINTB("Appended path %s", path );
|
|
|
|
//PRINTB("Exists: %i", fs::exists(path) );
|
2013-05-26 07:37:26 +04:00
|
|
|
} catch (const fs::filesystem_error& ex) {
|
|
|
|
PRINTB("ERROR: %s",ex.what());
|
|
|
|
}
|
|
|
|
return boosty::stringy( path );
|
2013-05-22 02:02:16 +04:00
|
|
|
}
|