mirror of https://github.com/vitalif/openscad
Added support for more paths in OPENSCADPATH, also search in HOME/Documents/OpenSCAD/libraries on Mac
parent
9c23c1e8b8
commit
4948c2457f
|
@ -1,10 +1,13 @@
|
|||
#ifndef COCOAUTILS_H_
|
||||
#define COCOAUTILS_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
class CocoaUtils
|
||||
{
|
||||
public:
|
||||
static void endApplication();
|
||||
static std::string documentsPath();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "CocoaUtils.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void CocoaUtils::endApplication()
|
||||
{
|
||||
|
@ -7,3 +8,8 @@ void CocoaUtils::endApplication()
|
|||
postNotificationName:@"NSApplicationWillTerminateNotification"
|
||||
object:nil];
|
||||
}
|
||||
|
||||
std::string CocoaUtils::documentsPath()
|
||||
{
|
||||
return std::string([[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] UTF8String]);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue