From bd714c75a8f03257271dc8cba90d22b3730775cd Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 2 May 2012 12:07:56 -0400 Subject: Ported away from Qt 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 -#include #include +#include 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(ifs)), std::istreambuf_iterator()); + 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(); } -- cgit v0.10.1