diff options
author | Adrian Kummerlaender | 2014-08-09 13:47:39 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2014-08-09 13:47:39 +0200 |
commit | 97b17caeeb8512e2af332d7095fca4cad160a980 (patch) | |
tree | 9c0b9741d647b36b29d3c4358769bb2eb8b1f5ce /src | |
parent | 5a38b9e11236c71245ca0609b54157630347e393 (diff) | |
download | InputXSLT-97b17caeeb8512e2af332d7095fca4cad160a980.tar InputXSLT-97b17caeeb8512e2af332d7095fca4cad160a980.tar.gz InputXSLT-97b17caeeb8512e2af332d7095fca4cad160a980.tar.bz2 InputXSLT-97b17caeeb8512e2af332d7095fca4cad160a980.tar.lz InputXSLT-97b17caeeb8512e2af332d7095fca4cad160a980.tar.xz InputXSLT-97b17caeeb8512e2af332d7095fca4cad160a980.tar.zst InputXSLT-97b17caeeb8512e2af332d7095fca4cad160a980.zip |
Reduced FilesystemContext's determination to resolve into absolute paths
* FilesystemContext was returning absolute paths in nearly every situation
** even when a path relative to the current working directory might be easier on the eyes
* new _soft_ base path resolution logic is implemented in a local "determineBasePath" method
Diffstat (limited to 'src')
-rw-r--r-- | src/support/filesystem_context.cc | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/support/filesystem_context.cc b/src/support/filesystem_context.cc index 183af13..be2cfb0 100644 --- a/src/support/filesystem_context.cc +++ b/src/support/filesystem_context.cc @@ -5,6 +5,29 @@ #include "support/xalan_string.h" +namespace { + +const std::string workingDirectory("."); + +inline boost::filesystem::path determineBasePath( + const boost::filesystem::path& path) { + const boost::filesystem::path basePath( + boost::filesystem::is_directory(path) ? path : path.parent_path() + ); + + if ( basePath == boost::filesystem::current_path() ) { + return workingDirectory; + } else { + if ( path.is_absolute() ) { + return path; + } else { + return workingDirectory / path; + } + } +} + +} + namespace InputXSLT { void FilesystemContext::iterate( @@ -36,12 +59,10 @@ void FilesystemContext::iterate( } FilesystemContext::FilesystemContext(const boost::filesystem::path& path): - path_(boost::filesystem::canonical( - path.parent_path() - )) { } + path_(determineBasePath(path)) { } FilesystemContext::FilesystemContext(const std::string& path): - path_(boost::filesystem::canonical(path)) { } + FilesystemContext(boost::filesystem::path(path)) { } boost::filesystem::path FilesystemContext::resolve( const xalan::XalanDOMString& path) const { @@ -53,7 +74,7 @@ boost::filesystem::path FilesystemContext::resolve( if ( path.is_absolute() ) { return path; } else { - return absolute(this->path_ / path); + return this->path_ / path; } } |