From 5f4f3f003e1f08e5495e0fe30fae18eb6029888d Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Sun, 20 Apr 2014 23:30:25 +0200 Subject: Switched filesystem interaction code to boost::filesystem * while plain read access on files is doesn't require boost::filesystem it will greatly simplify the implementation of external directory traversal functions * it also improves the portability of relative path construction --- src/function/read_file.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/function/read_file.cc') diff --git a/src/function/read_file.cc b/src/function/read_file.cc index ea7a758..19ecfc8 100644 --- a/src/function/read_file.cc +++ b/src/function/read_file.cc @@ -1,5 +1,7 @@ #include "read_file.h" +#include "boost/filesystem/fstream.hpp" + #include namespace InputXSLT { @@ -24,24 +26,20 @@ xalan::XObjectPtr FunctionReadFile::execute( xalan::CharVectorType castHelper; arguments[0]->str().transcode(castHelper); - std::string fileName(this->path_); - fileName.reserve(fileName.size() + castHelper.size()); - - std::move( + const std::string fileName( castHelper.begin(), - castHelper.end(), - fileName.end() + castHelper.end() ); - std::ifstream file(fileName); + boost::filesystem::ifstream file(this->path_ / fileName); - std::string content( + const std::string fileContent( (std::istreambuf_iterator(file)), (std::istreambuf_iterator()) ); return executionContext.getXObjectFactory().createString( - xalan::XalanDOMString(content.data()) + xalan::XalanDOMString(fileContent.data()) ); } -- cgit v1.2.3