summaryrefslogtreecommitdiff
path: root/src/parsersettings.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-02-13 04:16:23 (GMT)
committerMarius Kintel <marius@kintel.net>2013-02-13 04:16:23 (GMT)
commit4948c2457f16110c10a2daa416e8fff84824ec69 (patch)
tree446e71bc5fd469c2d60288608a2ffe10fa67022a /src/parsersettings.cc
parent9c23c1e8b8d7828acba96d4b4985566701331249 (diff)
Added support for more paths in OPENSCADPATH, also search in HOME/Documents/OpenSCAD/libraries on Mac
Diffstat (limited to 'src/parsersettings.cc')
-rw-r--r--src/parsersettings.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/parsersettings.cc b/src/parsersettings.cc
index 3dda132..54f9713 100644
--- a/src/parsersettings.cc
+++ b/src/parsersettings.cc
@@ -2,7 +2,9 @@
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include "boosty.h"
+#include <boost/algorithm/string.hpp>
#include <qglobal.h> // Needed for Q_ defines - move the offending code somewhere else
+#include "CocoaUtils.h"
namespace fs = boost::filesystem;
@@ -28,15 +30,24 @@ std::string locate_file(const std::string &filename)
void parser_init(const std::string &applicationpath)
{
- // Add path from OPENSCADPATH before adding built-in paths
- const char *openscadpath = getenv("OPENSCADPATH");
- if (openscadpath) {
- add_librarydir(boosty::absolute(fs::path(openscadpath)).string());
+ // Add paths from OPENSCADPATH before adding built-in paths
+ const char *openscadpaths = getenv("OPENSCADPATH");
+ if (openscadpaths) {
+ std::string paths(openscadpaths);
+ typedef boost::split_iterator<std::string::iterator> string_split_iterator;
+ for (string_split_iterator it =
+ make_split_iterator(paths, first_finder(":", boost::is_iequal()));
+ it != string_split_iterator();
+ ++it) {
+ add_librarydir(boosty::absolute(fs::path(boost::copy_range<std::string>(*it))).string());
+ }
}
- // FIXME: Support specifying more than one path in OPENSCADPATH
// FIXME: Add ~/.openscad/libraries
- // FIXME: Add ~/Documents/OpenSCAD/libraries on Mac?
+#ifdef __APPLE__
+ fs::path docdir(CocoaUtils::documentsPath());
+ add_librarydir(boosty::stringy(docdir / "OpenSCAD" / "libraries"));
+#endif
std::string librarydir;
fs::path libdir(applicationpath);
contact: Jan Huwald // Impressum