From 97b17caeeb8512e2af332d7095fca4cad160a980 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 9 Aug 2014 13:47:39 +0200 Subject: 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 --- src/support/filesystem_context.cc | 31 ++++++++++++++++++++++++++----- 1 file 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; } } -- cgit v1.2.3