aboutsummaryrefslogtreecommitdiff
path: root/src/function
diff options
context:
space:
mode:
Diffstat (limited to 'src/function')
-rw-r--r--src/function/read_file.cc16
-rw-r--r--src/function/read_file.h7
-rw-r--r--src/function/read_xml_file.cc18
-rw-r--r--src/function/read_xml_file.h7
4 files changed, 17 insertions, 31 deletions
diff --git a/src/function/read_file.cc b/src/function/read_file.cc
index 19ecfc8..9e32f04 100644
--- a/src/function/read_file.cc
+++ b/src/function/read_file.cc
@@ -6,8 +6,8 @@
namespace InputXSLT {
-FunctionReadFile::FunctionReadFile(const std::string& path):
- path_(path) { }
+FunctionReadFile::FunctionReadFile(const FilesystemContext& context):
+ fs_context_(context) { }
xalan::XObjectPtr FunctionReadFile::execute(
xalan::XPathExecutionContext& executionContext,
@@ -20,19 +20,13 @@ xalan::XObjectPtr FunctionReadFile::execute(
executionContext
);
- generalError(executionContext, context, locator);
+ this->generalError(executionContext, context, locator);
}
- xalan::CharVectorType castHelper;
- arguments[0]->str().transcode(castHelper);
-
- const std::string fileName(
- castHelper.begin(),
- castHelper.end()
+ boost::filesystem::ifstream file(
+ this->fs_context_.resolve(arguments[0]->str())
);
- boost::filesystem::ifstream file(this->path_ / fileName);
-
const std::string fileContent(
(std::istreambuf_iterator<char>(file)),
(std::istreambuf_iterator<char>())
diff --git a/src/function/read_file.h b/src/function/read_file.h
index f5bdb9d..b88336a 100644
--- a/src/function/read_file.h
+++ b/src/function/read_file.h
@@ -6,17 +6,16 @@
#include <xalanc/XPath/Function.hpp>
#include <xalanc/XPath/XObject.hpp>
-#include "boost/filesystem.hpp"
-
#include <string>
#include "common.h"
+#include "support/filesystem_context.h"
namespace InputXSLT {
class FunctionReadFile : public xalan::Function {
public:
- FunctionReadFile(const std::string&);
+ FunctionReadFile(const FilesystemContext&);
virtual xalan::XObjectPtr execute(
xalan::XPathExecutionContext&,
@@ -31,7 +30,7 @@ class FunctionReadFile : public xalan::Function {
bool operator==(const FunctionReadFile&) const = delete;
private:
- const boost::filesystem::path path_;
+ const FilesystemContext& fs_context_;
const xalan::XalanDOMString& getError(xalan::XalanDOMString&) const;
diff --git a/src/function/read_xml_file.cc b/src/function/read_xml_file.cc
index 78f81c4..ac42288 100644
--- a/src/function/read_xml_file.cc
+++ b/src/function/read_xml_file.cc
@@ -4,12 +4,12 @@
namespace InputXSLT {
-FunctionReadXmlFile::FunctionReadXmlFile(const std::string& path):
- path_(path),
+FunctionReadXmlFile::FunctionReadXmlFile(const FilesystemContext& context):
+ fs_context_(context),
parser_() { }
FunctionReadXmlFile::FunctionReadXmlFile(const FunctionReadXmlFile& src):
- path_(src.path_),
+ fs_context_(src.fs_context_),
parser_() { }
xalan::XObjectPtr FunctionReadXmlFile::execute(
@@ -23,19 +23,13 @@ xalan::XObjectPtr FunctionReadXmlFile::execute(
executionContext
);
- generalError(executionContext, context, locator);
+ this->generalError(executionContext, context, locator);
}
- xalan::CharVectorType castHelper;
- arguments[0]->str().transcode(castHelper);
-
- const std::string fileName(
- castHelper.begin(),
- castHelper.end()
+ boost::filesystem::ifstream file(
+ this->fs_context_.resolve(arguments[0]->str())
);
- boost::filesystem::ifstream file(this->path_ / fileName);
-
return executionContext.getXObjectFactory().createNodeSet(
this->parser_.parseXMLStream(
xalan::XSLTInputSource(file)
diff --git a/src/function/read_xml_file.h b/src/function/read_xml_file.h
index 6877feb..aa8590a 100644
--- a/src/function/read_xml_file.h
+++ b/src/function/read_xml_file.h
@@ -7,17 +7,16 @@
#include <xalanc/XPath/XObject.hpp>
#include <xalanc/XercesParserLiaison/XercesParserLiaison.hpp>
-#include "boost/filesystem.hpp"
-
#include <string>
#include "common.h"
+#include "support/filesystem_context.h"
namespace InputXSLT {
class FunctionReadXmlFile : public xalan::Function {
public:
- FunctionReadXmlFile(const std::string&);
+ FunctionReadXmlFile(const FilesystemContext&);
FunctionReadXmlFile(const FunctionReadXmlFile&);
virtual xalan::XObjectPtr execute(
@@ -33,7 +32,7 @@ class FunctionReadXmlFile : public xalan::Function {
bool operator==(const FunctionReadXmlFile&) const = delete;
private:
- const boost::filesystem::path path_;
+ const FilesystemContext& fs_context_;
mutable xalan::XercesParserLiaison parser_;
const xalan::XalanDOMString& getError(xalan::XalanDOMString& result) const;