# HG changeset patch # User Sebastien Jodogne # Date 1368018781 -7200 # Node ID 09b3c6265a94ed241de4800bdad8030a7ca21dd8 # Parent 6f00823be12a3985743017876ac0f3986ac401a0 unit test for fedora 18 problem diff -r 6f00823be12a -r 09b3c6265a94 OrthancServer/OrthancInitialization.cpp --- a/OrthancServer/OrthancInitialization.cpp Wed May 08 13:06:04 2013 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Wed May 08 15:13:01 2013 +0200 @@ -280,32 +280,40 @@ } - std::string InterpretStringParameterAsPath(const std::string& parameter) + std::string InterpretRelativePath(const std::string& baseDirectory, + const std::string& relativePath) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::filesystem::path base(baseDirectory); + boost::filesystem::path relative(relativePath); + + return (base / relative).string(); /** The following lines should be equivalent to this one: - return (defaultDirectory_ / parameter).string(); + return (base / relative).string(); However, for some unknown reason, some versions of Boost do not - make the proper path resolution when "defaultDirectory_" is an + make the proper path resolution when "baseDirectory" is an absolute path. So, a hack is used below. **/ - boost::filesystem::path p(parameter); - - if (p.is_absolute()) + if (relative.is_absolute()) { - return p.string(); + return relative.string(); } else { - return (defaultDirectory_ / parameter).string(); + return (base / relative).string(); } } + std::string InterpretStringParameterAsPath(const std::string& parameter) + { + boost::mutex::scoped_lock lock(globalMutex_); + return InterpretRelativePath(defaultDirectory_.string(), parameter); + } + void GetGlobalListOfStringsParameter(std::list& target, const std::string& key) diff -r 6f00823be12a -r 09b3c6265a94 OrthancServer/OrthancInitialization.h --- a/OrthancServer/OrthancInitialization.h Wed May 08 13:06:04 2013 +0200 +++ b/OrthancServer/OrthancInitialization.h Wed May 08 15:13:01 2013 +0200 @@ -62,6 +62,9 @@ void SetupRegisteredUsers(MongooseServer& httpServer); + std::string InterpretRelativePath(const std::string& baseDirectory, + const std::string& relativePath); + std::string InterpretStringParameterAsPath(const std::string& parameter); void GetGlobalListOfStringsParameter(std::list& target, diff -r 6f00823be12a -r 09b3c6265a94 Resources/CMake/LuaConfiguration.cmake --- a/Resources/CMake/LuaConfiguration.cmake Wed May 08 13:06:04 2013 +0200 +++ b/Resources/CMake/LuaConfiguration.cmake Wed May 08 15:13:01 2013 +0200 @@ -56,15 +56,12 @@ source_group(ThirdParty\\Lua REGULAR_EXPRESSION ${LUA_SOURCES_DIR}/.*) else() - CHECK_INCLUDE_FILE_CXX(lua.h HAVE_LUA_H) - if (NOT HAVE_LUA_H) + include(FindLua51) + + if (NOT LUA51_FOUND) message(FATAL_ERROR "Please install the liblua-dev package") endif() - CHECK_LIBRARY_EXISTS(lua lua_pcall "" HAVE_LUA_LIB) - if (NOT HAVE_LUA_LIB) - message(FATAL_ERROR "Please install the liblua-dev package") - endif() - - link_libraries(lua) + include_directories(${LUA_INCLUDE_DIR}) + link_libraries(${LUA_LIBRARIES}) endif() diff -r 6f00823be12a -r 09b3c6265a94 UnitTests/main.cpp --- a/UnitTests/main.cpp Wed May 08 13:06:04 2013 +0200 +++ b/UnitTests/main.cpp Wed May 08 15:13:01 2013 +0200 @@ -335,6 +335,14 @@ } +#if defined(__linux) +TEST(OrthancInitialization, AbsoluteDirectory) +{ + ASSERT_EQ("/tmp/coucou", InterpretRelativePath("/tmp", "coucou")); +} +#endif + + int main(int argc, char **argv) { // Initialize Google's logging library.