diff options
author | Marius Kintel <marius@kintel.net> | 2011-12-06 03:09:39 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-12-06 03:09:39 (GMT) |
commit | ae30a7978475f8e5bc8272fd1e073fae7f4bd3ed (patch) | |
tree | 35de3d04d39d9a767cf828f68713cdd82262213d /src | |
parent | 0d6b87dd0e28e53ec4601443c7d06dbb66628d47 (diff) |
Ported from QFileInfo to boost::filesystem
Diffstat (limited to 'src')
-rw-r--r-- | src/context.cc | 7 | ||||
-rw-r--r-- | src/dxfdim.cc | 17 | ||||
-rw-r--r-- | src/handle_dep.cc | 13 |
3 files changed, 17 insertions, 20 deletions
diff --git a/src/context.cc b/src/context.cc index bd97f8f..176bf8d 100644 --- a/src/context.cc +++ b/src/context.cc @@ -30,9 +30,9 @@ #include "module.h" #include "builtin.h" #include "printutils.h" -#include <QFileInfo> -#include <QDir> #include <boost/foreach.hpp> +#include <boost/filesystem.hpp> +using namespace boost::filesystem; std::vector<const Context*> Context::ctx_stack; @@ -175,8 +175,7 @@ AbstractNode *Context::evaluate_module(const ModuleInstantiation &inst) const std::string Context::getAbsolutePath(const std::string &filename) const { if (!filename.empty()) { - return QFileInfo(QDir(QString::fromStdString(this->document_path)), - QString::fromStdString(filename)).absoluteFilePath().toStdString(); + return absolute(path(this->document_path) / filename).native(); } else { return filename; diff --git a/src/dxfdim.cc b/src/dxfdim.cc index c696226..44b5d73 100644 --- a/src/dxfdim.cc +++ b/src/dxfdim.cc @@ -33,10 +33,11 @@ #include "context.h" #include "mathc99.h" -#include <QDateTime> -#include <QFileInfo> #include <sstream> +#include <boost/filesystem.hpp> +using namespace boost::filesystem; + boost::unordered_map<std::string,Value> dxf_dim_cache; boost::unordered_map<std::string,Value> dxf_cross_cache; @@ -62,12 +63,10 @@ Value builtin_dxf_dim(const Context *ctx, const std::vector<std::string> &argnam name = args[i].text; } - QFileInfo fileInfo(QString::fromStdString(filename)); - std::stringstream keystream; keystream << filename << "|" << layername << "|" << name << "|" << xorigin - << "|" << yorigin <<"|" << scale << "|" << fileInfo.lastModified().toTime_t() - << "|" << fileInfo.size(); + << "|" << yorigin <<"|" << scale << "|" << last_write_time(filename) + << "|" << file_size(filename); std::string key = keystream.str(); if (dxf_dim_cache.find(key) != dxf_dim_cache.end()) return dxf_dim_cache.find(key)->second; @@ -144,12 +143,10 @@ Value builtin_dxf_cross(const Context *ctx, const std::vector<std::string> &argn args[i].getnum(scale); } - QFileInfo fileInfo(QString::fromStdString(filename)); - std::stringstream keystream; keystream << filename << "|" << layername << "|" << xorigin << "|" << yorigin - << "|" << scale << "|" << fileInfo.lastModified().toTime_t() - << "|" << fileInfo.size(); + << "|" << scale << "|" << last_write_time(filename) + << "|" << file_size(filename); std::string key = keystream.str(); if (dxf_cross_cache.find(key) != dxf_cross_cache.end()) diff --git a/src/handle_dep.cc b/src/handle_dep.cc index d4380f5..99a0df7 100644 --- a/src/handle_dep.cc +++ b/src/handle_dep.cc @@ -2,24 +2,25 @@ #include <string> #include <sstream> #include <QString> -#include <QDir> -#include <QSet> #include <stdlib.h> // for system() #include <boost/unordered_set.hpp> #include <boost/foreach.hpp> +#include <boost/filesystem.hpp> +using namespace boost::filesystem; boost::unordered_set<std::string> dependencies; const char *make_command = NULL; void handle_dep(const std::string &filename) { - if (filename[0] == '/') + path filepath(filename); + if (filepath.is_absolute()) { dependencies.insert(filename); + } else { - QString dep = QDir::currentPath() + QString("/") + QString::fromStdString(filename); - dependencies.insert(dep.toStdString()); + dependencies.insert((current_path() / filepath).native()); } - if (!QFile(QString::fromStdString(filename)).exists() && make_command) { + if (!exists(filepath) && make_command) { std::stringstream buf; buf << make_command << " '" << QString::fromStdString(filename).replace("'", "'\\''").toUtf8().data() << "'"; system(buf.str().c_str()); // FIXME: Handle error |