diff options
author | Marius Kintel <marius@kintel.net> | 2012-05-02 16:07:56 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2012-05-02 16:07:56 (GMT) |
commit | bd714c75a8f03257271dc8cba90d22b3730775cd (patch) | |
tree | 376180ce3414024bb77b79b79c7d1cf77b21b19f /tests/tests-common.cc | |
parent | 60ea4baa2c2521ab17bd6041c390d728460bb4cf (diff) |
Ported away from Qt
Diffstat (limited to 'tests/tests-common.cc')
-rw-r--r-- | tests/tests-common.cc | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/tests/tests-common.cc b/tests/tests-common.cc index 5b0cc3b..703e1c5 100644 --- a/tests/tests-common.cc +++ b/tests/tests-common.cc @@ -2,31 +2,25 @@ #include "openscad.h" #include "module.h" #include "handle_dep.h" +#include "boosty.h" -#include <QFile> -#include <QFileInfo> #include <sstream> +#include <fstream> Module *parsefile(const char *filename) { Module *root_module = NULL; - QFileInfo fileInfo(filename); handle_dep(filename); - FILE *fp = fopen(filename, "rt"); - if (!fp) { + std::ifstream ifs(filename); + if (!ifs.is_open()) { fprintf(stderr, "Can't open input file `%s'!\n", filename); - } else { - std::stringstream text; - char buffer[513]; - int ret; - while ((ret = fread(buffer, 1, 512, fp)) > 0) { - buffer[ret] = 0; - text << buffer; - } - fclose(fp); - text << "\n" << commandline_commands; - root_module = parse(text.str().c_str(), fileInfo.absolutePath().toLocal8Bit(), false); + } + else { + std::string text((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); + text += "\n" + commandline_commands; + std::string pathname = boosty::stringy(fs::path(filename).parent_path()); + root_module = parse(text.c_str(), pathname.c_str(), false); if (root_module) { root_module->handleDependencies(); } |