diff options
author | Marius Kintel <marius@kintel.net> | 2012-07-15 01:57:55 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2012-07-15 01:57:55 (GMT) |
commit | 13557f1f9a44caccb0546717065ed72c27a210b3 (patch) | |
tree | d0ed7bd176d7c0b052431cb99efd358602d6b6bb /tests/tests-common.cc | |
parent | 38a4585d1a9abe9c779c5d0677bfc81c407db371 (diff) | |
parent | 2495df6bab07f14f0eed7062dec17d24599aa838 (diff) |
Merge branch 'timestamp-cache'
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(); } |