summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mainwin.cc2
-rw-r--r--src/openscad.cc31
-rw-r--r--src/openscad.h2
-rw-r--r--src/parser.y2
4 files changed, 17 insertions, 20 deletions
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 6ef7777..3567ddd 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -490,7 +490,7 @@ MainWindow::setFileName(const QString &filename)
{
if (filename.isEmpty()) {
this->fileName.clear();
- this->root_ctx.setDocumentPath(currentdir.toStdString());
+ this->root_ctx.setDocumentPath(currentdir);
setWindowTitle("OpenSCAD - New Document[*]");
}
else {
diff --git a/src/openscad.cc b/src/openscad.cc
index 8b81f48..f65b311 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -48,12 +48,7 @@
#endif
#include <QApplication>
-#include <QFile>
#include <QDir>
-#include <QSet>
-#include <QSettings>
-#include <QTextStream>
-#include <boost/program_options.hpp>
#include <sstream>
#ifdef Q_WS_MAC
@@ -61,11 +56,15 @@
#include "AppleEvents.h"
#endif
+#include <boost/program_options.hpp>
+#include <boost/filesystem.hpp>
+
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
namespace po = boost::program_options;
+namespace fs = boost::filesystem;
static void help(const char *progname)
{
@@ -84,7 +83,7 @@ static void version()
}
std::string commandline_commands;
-QString currentdir;
+std::string currentdir;
QString examplesdir;
using std::string;
@@ -115,7 +114,7 @@ int main(int argc, char **argv)
#ifdef Q_WS_MAC
app.installEventFilter(new EventFilter(&app));
#endif
- QDir original_path = QDir::current();
+ fs::path original_path = fs::current_path();
// set up groups for QSettings
QCoreApplication::setOrganizationName("OpenSCAD");
@@ -200,7 +199,7 @@ int main(int argc, char **argv)
}
#endif
- currentdir = QDir::currentPath();
+ currentdir = fs::current_path().generic_string();
QDir exdir(QApplication::instance()->applicationDirPath());
#ifdef Q_WS_MAC
@@ -259,7 +258,6 @@ int main(int argc, char **argv)
ModuleInstantiation root_inst;
AbstractNode *root_node;
- QFileInfo fileInfo(filename);
handle_dep(filename);
FILE *fp = fopen(filename, "rt");
if (!fp) {
@@ -275,18 +273,17 @@ int main(int argc, char **argv)
}
fclose(fp);
text << commandline_commands;
- root_module = parse(text.str().c_str(), fileInfo.absolutePath().toLocal8Bit(), false);
+ root_module = parse(text.str().c_str(), fs::absolute(filename).generic_string().c_str(), false);
if (!root_module) exit(1);
}
- QDir::setCurrent(fileInfo.absolutePath());
-
+ fs::current_path(fs::path(filename).parent_path());
AbstractNode::resetIndexCounter();
root_node = root_module->evaluate(&root_ctx, &root_inst);
tree.setRoot(root_node);
if (csg_output_file) {
- QDir::setCurrent(original_path.absolutePath());
+ fs::current_path(original_path);
std::ofstream fstream(csg_output_file);
if (!fstream.is_open()) {
PRINTF("Can't open file \"%s\" for export", csg_output_file);
@@ -299,7 +296,7 @@ int main(int argc, char **argv)
else {
CGAL_Nef_polyhedron root_N = cgalevaluator.evaluateCGALMesh(*tree.root());
- QDir::setCurrent(original_path.absolutePath());
+ fs::current_path(original_path);
if (deps_output_file) {
if (!write_deps(deps_output_file,
@@ -370,7 +367,7 @@ int main(int argc, char **argv)
#endif
QString qfilename;
- if (filename) qfilename = QFileInfo(original_path, filename).absoluteFilePath();
+ if (filename) qfilename = QString::fromStdString((original_path / filename).generic_string());
#if 0 /*** disabled by clifford wolf: adds rendering artefacts with OpenCSG ***/
// turn on anti-aliasing
@@ -384,8 +381,8 @@ int main(int argc, char **argv)
vector<string> inputFiles;
if (vm.count("input-file")) {
inputFiles = vm["input-file"].as<vector<string> >();
- for (vector<string>::const_iterator i = inputFiles.begin()+1; i != inputFiles.end(); i++) {
- new MainWindow(QFileInfo(original_path, i->c_str()).absoluteFilePath());
+ for (vector<string>::const_iterator infile = inputFiles.begin()+1; infile != inputFiles.end(); infile++) {
+ new MainWindow(QString::fromStdString((original_path / *infile).generic_string()));
}
}
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
diff --git a/src/openscad.h b/src/openscad.h
index 23ae4da..dab14cd 100644
--- a/src/openscad.h
+++ b/src/openscad.h
@@ -36,7 +36,7 @@ extern std::string commandline_commands;
#include <QString>
// The CWD when application started. We shouldn't change CWD, but until we stop
// doing this, use currentdir to get the original CWD.
-extern QString currentdir;
+extern std::string currentdir;
extern QString examplesdir;
diff --git a/src/parser.y b/src/parser.y
index 2fb0c3f..b8da50d 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -649,7 +649,7 @@ Module *Module::compile_library(const std::string &filename)
libs_cache[filename] = e;
Module *backup_mod = module;
- Module *lib_mod = dynamic_cast<Module*>(parse(text.str().c_str(), absolute(filename).generic_string().c_str(), 0));
+ Module *lib_mod = dynamic_cast<Module*>(parse(text.str().c_str(), path(filename).parent_path().generic_string().c_str(), 0));
module = backup_mod;
if (lib_mod) {
contact: Jan Huwald // Impressum