From 1c5ceaef15e7e6e6add666aaf0fdec36bac0bfd5 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 13 Oct 2012 05:07:46 +0200 Subject: [PATCH] Boost filesystem Ver 2/3 transition This is kind of a workaround to avoid having to maintain two variants. Explanation: between Boost 1.42 and 1.52 there was the transition to a reworked version of the filesystem library, itroducing some breaking changes The new version distinguishes much clearer between the native and the generic representation of paths -- which becomes relevant when porting to non-POXIX operating systems. Actually the intention was to use the generic path representation in all configuration; currently this distinction is moot, since we're caring only for POSIX systems. So the workaround is to use the fsys::path::string() function, which is available in both versions, but changed meaning to yield the native string. Later, when able to deprecate older Boost versions, we should switch to generic_string() Note: an alternative solution was found by Mike Fisher in 3b39f35 using the compiletime define BOOST_FILESYSTEM_VERSION=2 See also ticket #896 --- src/common/basic-setup.cpp | 5 ++--- src/lib/searchpath.cpp | 10 +++++----- src/lib/searchpath.hpp | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/common/basic-setup.cpp b/src/common/basic-setup.cpp index 030d76623..5ab319d0d 100644 --- a/src/common/basic-setup.cpp +++ b/src/common/basic-setup.cpp @@ -53,9 +53,8 @@ namespace lumiera { string resolve (fsys::path iniSpec) { - string file = iniSpec.leaf(); - string searchpath = iniSpec.branch_path().string(); - return resolveModulePath (file, searchpath); + string searchpath = iniSpec.parent_path().string(); ///////////TICKET #896 + return resolveModulePath (iniSpec.filename(), searchpath); } }//(End) implementation details diff --git a/src/lib/searchpath.cpp b/src/lib/searchpath.cpp index 4e4411ec3..86dccb015 100644 --- a/src/lib/searchpath.cpp +++ b/src/lib/searchpath.cpp @@ -71,7 +71,7 @@ namespace lib { { static const regex PICK_ORIGIN_TOKEN ("\\$?ORIGIN/?"); static const string expandedOriginDir - = fsys::path (findExePath()).remove_leaf().directory_string(); + = fsys::path (findExePath()).parent_path().string() + "/"; ///////////TICKET #896 return boost::regex_replace(src, PICK_ORIGIN_TOKEN, expandedOriginDir); } @@ -81,24 +81,24 @@ namespace lib { string - resolveModulePath (string moduleName, string searchPath) + resolveModulePath (fsys::path moduleName, string searchPath) { fsys::path modulePathName (moduleName); - SearchPathSplitter searchLocation(searchPath); + SearchPathSplitter searchLocation(searchPath); ///////////TICKET #896 while (true) { if (fsys::exists (modulePathName)) { INFO (config, "found module %s", modulePathName.string().c_str()); - return modulePathName.string(); + return modulePathName.string(); ///////////TICKET #896 } // try / continue search path if (searchLocation.isValid()) modulePathName = fsys::path() / searchLocation.next() / moduleName; else - throw error::Config ("Module \""+moduleName+"\" not found" + throw error::Config ("Module \""+moduleName.string()+"\" not found" /////TICKET #896 + (searchPath.empty()? ".":" in search path: "+searchPath)); } } diff --git a/src/lib/searchpath.hpp b/src/lib/searchpath.hpp index 66b985a5d..3505b9b69 100644 --- a/src/lib/searchpath.hpp +++ b/src/lib/searchpath.hpp @@ -111,7 +111,7 @@ namespace lib { * @return the absolute pathname of the module file found * @throws error::Config when the resolution fails */ - string resolveModulePath (string moduleName, string searchPath = ""); + string resolveModulePath (fsys::path moduleName, string searchPath = "");