diff options
author | Adrian Kummerländer | 2014-04-21 13:30:23 +0200 |
---|---|---|
committer | Adrian Kummerländer | 2014-04-21 13:30:23 +0200 |
commit | cdf4ad3486debe75fe89b2f04bb62541f3ac8405 (patch) | |
tree | b09b380ca22abe5678079f86420c748dcd82c70d /src/support | |
parent | 5f4f3f003e1f08e5495e0fe30fae18eb6029888d (diff) | |
download | InputXSLT-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/support')
-rw-r--r-- | src/support/filesystem_context.cc | 24 | ||||
-rw-r--r-- | src/support/filesystem_context.h | 28 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/support/filesystem_context.cc b/src/support/filesystem_context.cc new file mode 100644 index 0000000..d3f9614 --- /dev/null +++ b/src/support/filesystem_context.cc @@ -0,0 +1,24 @@ +#include "filesystem_context.h" + +namespace InputXSLT { + +FilesystemContext::FilesystemContext(const std::string& path): + path_(path) { } + +boost::filesystem::path FilesystemContext::resolve( + const std::string& path) const { + return boost::filesystem::path(this->path_ / path); +} + +boost::filesystem::path FilesystemContext::resolve( + const xalan::XalanDOMString& path) const { + xalan::CharVectorType castHelper; + path.transcode(castHelper); + + return this->resolve(std::string( + castHelper.begin(), + castHelper.end() + )); +} + +} diff --git a/src/support/filesystem_context.h b/src/support/filesystem_context.h new file mode 100644 index 0000000..d5836f1 --- /dev/null +++ b/src/support/filesystem_context.h @@ -0,0 +1,28 @@ +#ifndef INPUTXSLT_SRC_SUPPORT_FILESYSTEM_CONTEXT_H_ +#define INPUTXSLT_SRC_SUPPORT_FILESYSTEM_CONTEXT_H_ + +#include <xalanc/XalanDOM/XalanDOMString.hpp> + +#include "boost/filesystem.hpp" + +#include <string> + +#include "common.h" + +namespace InputXSLT { + +class FilesystemContext { + public: + explicit FilesystemContext(const std::string&); + + boost::filesystem::path resolve(const std::string&) const; + boost::filesystem::path resolve(const xalan::XalanDOMString&) const; + + private: + const boost::filesystem::path path_; + +}; + +} + +#endif // INPUTXSLT_SRC_SUPPORT_FILESYSTEM_CONTEXT_H_ |