aboutsummaryrefslogtreecommitdiff
path: root/src/function/read_file.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-04-21 13:30:23 +0200
committerAdrian Kummerländer2014-04-21 13:30:23 +0200
commitcdf4ad3486debe75fe89b2f04bb62541f3ac8405 (patch)
treeb09b380ca22abe5678079f86420c748dcd82c70d /src/function/read_file.cc
parent5f4f3f003e1f08e5495e0fe30fae18eb6029888d (diff)
downloadInputXSLT-cdf4ad3486debe75fe89b2f04bb62541f3ac8405.tar
InputXSLT-cdf4ad3486debe75fe89b2f04bb62541f3ac8405.tar.gz
InputXSLT-cdf4ad3486debe75fe89b2f04bb62541f3ac8405.tar.bz2
InputXSLT-cdf4ad3486debe75fe89b2f04bb62541f3ac8405.tar.lz
InputXSLT-cdf4ad3486debe75fe89b2f04bb62541f3ac8405.tar.xz
InputXSLT-cdf4ad3486debe75fe89b2f04bb62541f3ac8405.tar.zst
InputXSLT-cdf4ad3486debe75fe89b2f04bb62541f3ac8405.zip
Extracted filesystem path resolution into InputXSLT::FilesystemContext
* this class provides methods for resolving paths relative to the contained base path * other filesystem interaction methods will also be implemented in this class ** for instance directory traversal
Diffstat (limited to 'src/function/read_file.cc')
-rw-r--r--src/function/read_file.cc16
1 files changed, 5 insertions, 11 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>())