Ported from QFileInfo to boost::filesystem

felipesanches-svg
Marius Kintel 2011-12-06 04:09:39 +01:00
parent 0d6b87dd0e
commit ae30a79784
6 changed files with 24 additions and 26 deletions

View File

@ -15,14 +15,14 @@ boost {
DEFINES += BOOST_STATIC
DEFINES += BOOST_THREAD_USE_LIB
DEFINES += Boost_USE_STATIC_LIBS
LIBS += -lboost_thread_win32-mt -lboost_program_options-mt
LIBS += -lboost_thread_win32-mt -lboost_program_options-mt -lboost_filesystem-mt -lboost_system-mt
} else {
win32 {
LIBS += -llibboost_thread-vc90-mt-s-1_46_1 -llibboost_program_options-vc90-mt-s-1_46_1
LIBS += -llibboost_thread-vc90-mt-s-1_46_1 -llibboost_program_options-vc90-mt-s-1_46_1 -llibboost_filesystem-vc90-mt-s-1_46_1 -llibboost_system-vc90-mt-s-1_46_1
} else {
# some platforms have only '-mt' versions. uncomment if needed.
# LIBS += -lboost_thread-mt -lboost_program_options-mt
LIBS += -lboost_thread -lboost_program_options
LIBS += -lboost_thread -lboost_program_options -lboost_filesystem -lboost_system
}
}
}

View File

@ -140,12 +140,13 @@ build_boost()
tar xjf boost_$bversion.tar.bz2
cd boost_$bversion
# We only need the thread and program_options libraries
./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem
./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system
./bjam cflags="-mmacosx-version-min=10.5 -arch i386 -arch x86_64" linkflags="-mmacosx-version-min=10.5 -arch i386 -arch x86_64"
./bjam install
install_name_tool -id $DEPLOYDIR/lib/libboost_thread.dylib $DEPLOYDIR/lib/libboost_thread.dylib
install_name_tool -id $DEPLOYDIR/lib/libboost_program_options.dylib $DEPLOYDIR/lib/libboost_program_options.dylib
install_name_tool -id $DEPLOYDIR/lib/libboost_filesystem.dylib $DEPLOYDIR/lib/libboost_filesystem.dylib
install_name_tool -id $DEPLOYDIR/lib/libboost_system.dylib $DEPLOYDIR/lib/libboost_system.dylib
}
build_cgal()

View File

@ -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;

View File

@ -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())

View File

@ -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());
}
if (!QFile(QString::fromStdString(filename)).exists() && make_command) {
else {
dependencies.insert((current_path() / filepath).native());
}
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

View File

@ -79,7 +79,7 @@ if(BOOST_ROOT)
#set(Boost_DEBUG TRUE)
set(Boost_NO_SYSTEM_PATHS TRUE)
set(Boost_ADDITIONAL_VERSIONS "1.47.0")
find_package( Boost 1.35.0 COMPONENTS thread program_options )
find_package( Boost 1.35.0 COMPONENTS thread program_options filesystem system )
if(Boost_FOUND)
message(STATUS "Boost includes found: " ${Boost_INCLUDE_DIRS})
message(STATUS "Boost libraries found:")