summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--openscad.pro9
-rw-r--r--src/CocoaUtils.h3
-rw-r--r--src/CocoaUtils.mm5
-rw-r--r--src/PlatformUtils-posix.cc7
-rw-r--r--src/PlatformUtils-win32.cc15
-rw-r--r--src/PlatformUtils.h12
-rw-r--r--src/PlatformUtils.mm7
-rw-r--r--src/parsersettings.cc9
8 files changed, 52 insertions, 15 deletions
diff --git a/openscad.pro b/openscad.pro
index 542bcc3..c36c37b 100644
--- a/openscad.pro
+++ b/openscad.pro
@@ -384,7 +384,14 @@ macx {
src/EventFilter.h \
src/CocoaUtils.h
SOURCES += src/AppleEvents.cc
- OBJECTIVE_SOURCES += src/CocoaUtils.mm
+ OBJECTIVE_SOURCES += src/CocoaUtils.mm \
+ src/PlatformUtils.mm
+}
+unix:!macx {
+ SOURCES += src/PlatformUtils-posix.cc
+}
+win32* {
+ SOURCES += src/PlatformUtils-win32.cc
}
isEmpty(PREFIX):PREFIX = /usr/local
diff --git a/src/CocoaUtils.h b/src/CocoaUtils.h
index ad5518b..8543d84 100644
--- a/src/CocoaUtils.h
+++ b/src/CocoaUtils.h
@@ -1,13 +1,10 @@
#ifndef COCOAUTILS_H_
#define COCOAUTILS_H_
-#include <string>
-
class CocoaUtils
{
public:
static void endApplication();
- static std::string documentsPath();
};
#endif
diff --git a/src/CocoaUtils.mm b/src/CocoaUtils.mm
index 295ceb9..b72583c 100644
--- a/src/CocoaUtils.mm
+++ b/src/CocoaUtils.mm
@@ -1,6 +1,5 @@
#include "CocoaUtils.h"
#import <Foundation/Foundation.h>
-#include <stdio.h>
void CocoaUtils::endApplication()
{
@@ -9,7 +8,3 @@ void CocoaUtils::endApplication()
object:nil];
}
-std::string CocoaUtils::documentsPath()
-{
- return std::string([[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] UTF8String]);
-}
diff --git a/src/PlatformUtils-posix.cc b/src/PlatformUtils-posix.cc
new file mode 100644
index 0000000..7ed6735
--- /dev/null
+++ b/src/PlatformUtils-posix.cc
@@ -0,0 +1,7 @@
+#include "PlatformUtils.h"
+
+std::string PlatformUtils::documentsPath()
+{
+ // FIXME: Implement
+ return "";
+}
diff --git a/src/PlatformUtils-win32.cc b/src/PlatformUtils-win32.cc
new file mode 100644
index 0000000..61382dd
--- /dev/null
+++ b/src/PlatformUtils-win32.cc
@@ -0,0 +1,15 @@
+#include "PlatformUtils.h"
+#include <windows.h>
+#include <shlobj.h>
+
+std::string PlatformUtils::documentsPath()
+{
+ std::string retval;
+ CHAR my_documents[MAX_PATH];
+ HRESULT result = SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL,
+ SHGFP_TYPE_CURRENT, my_documents);
+
+ if (result != S_OK) retval = "";
+ else retval = my_documents;
+ return retval;
+}
diff --git a/src/PlatformUtils.h b/src/PlatformUtils.h
new file mode 100644
index 0000000..6448427
--- /dev/null
+++ b/src/PlatformUtils.h
@@ -0,0 +1,12 @@
+#ifndef PLATFORMUTILS_H_
+#define PLATFORMUTILS_H_
+
+#include <string>
+
+namespace PlatformUtils {
+
+ std::string documentsPath();
+
+}
+
+#endif
diff --git a/src/PlatformUtils.mm b/src/PlatformUtils.mm
new file mode 100644
index 0000000..1e2ba43
--- /dev/null
+++ b/src/PlatformUtils.mm
@@ -0,0 +1,7 @@
+#include "PlatformUtils.h"
+#import <Foundation/Foundation.h>
+
+std::string PlatformUtils::documentsPath()
+{
+ return std::string([[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] UTF8String]);
+}
diff --git a/src/parsersettings.cc b/src/parsersettings.cc
index 8d82744..b2ef1fa 100644
--- a/src/parsersettings.cc
+++ b/src/parsersettings.cc
@@ -3,9 +3,7 @@
#include <boost/foreach.hpp>
#include "boosty.h"
#include <boost/algorithm/string.hpp>
-#ifdef __APPLE__
-#include "CocoaUtils.h"
-#endif
+#include "PlatformUtils.h"
namespace fs = boost::filesystem;
@@ -44,9 +42,8 @@ void parser_init(const std::string &applicationpath)
}
}
- // FIXME: Add ~/.openscad/libraries
-#if defined(__APPLE__) && !defined(OPENSCAD_TESTING)
- fs::path docdir(CocoaUtils::documentsPath());
+#ifndef OPENSCAD_TESTING
+ fs::path docdir(PlatformUtils::documentsPath());
add_librarydir(boosty::stringy(docdir / "OpenSCAD" / "libraries"));
#endif
contact: Jan Huwald // Impressum