2013-05-22 01:45:24 +04:00
|
|
|
#include "PlatformUtils.h"
|
2013-05-22 02:19:29 +04:00
|
|
|
#include "boosty.h"
|
2013-05-22 01:45:24 +04:00
|
|
|
|
2014-02-17 00:13:21 +04:00
|
|
|
std::string PlatformUtils::pathSeparatorChar()
|
|
|
|
{
|
|
|
|
return ":";
|
|
|
|
}
|
|
|
|
|
2013-05-22 01:45:24 +04:00
|
|
|
std::string PlatformUtils::documentsPath()
|
|
|
|
{
|
2014-01-23 06:27:25 +04:00
|
|
|
const char *home = getenv("HOME");
|
|
|
|
if (home) {
|
|
|
|
fs::path docpath(home);
|
|
|
|
docpath = docpath / ".local" / "share";
|
|
|
|
return boosty::stringy(docpath);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return "";
|
|
|
|
}
|
2013-05-22 01:45:24 +04:00
|
|
|
}
|
2014-05-17 09:02:44 +04:00
|
|
|
|
2014-11-02 01:06:36 +03:00
|
|
|
// see http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
|
|
std::string PlatformUtils::userConfigPath()
|
|
|
|
{
|
|
|
|
fs::path config_path;
|
|
|
|
|
|
|
|
const char *xdg_env = getenv("XDG_CONFIG_HOME");
|
|
|
|
if (xdg_env && fs::exists(fs::path(xdg_env))) {
|
|
|
|
config_path = fs::path(xdg_env) / "OpenSCAD";
|
|
|
|
} else {
|
|
|
|
const char *home = getenv("HOME");
|
|
|
|
if (home) {
|
|
|
|
config_path = fs::path(home) / ".config" / "OpenSCAD";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fs::is_directory(config_path)) {
|
|
|
|
return boosty::stringy(boosty::absolute(config_path));
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2014-05-17 09:02:44 +04:00
|
|
|
void PlatformUtils::ensureStdIO(void) {}
|
|
|
|
|