From b5fbf004805f5f48b0c1cd83e47b29fe29d21b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sun, 28 Aug 2005 09:50:00 +0000 Subject: [PATCH] Fix rbuild compilation, by adding Path::RelativeFromDirectory method svn path=/trunk/; revision=17580 --- reactos/tools/rbuild/XML.cpp | 18 ++++++++++++------ reactos/tools/rbuild/XML.h | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/reactos/tools/rbuild/XML.cpp b/reactos/tools/rbuild/XML.cpp index a9723c3a9e4..96547562496 100644 --- a/reactos/tools/rbuild/XML.cpp +++ b/reactos/tools/rbuild/XML.cpp @@ -172,21 +172,27 @@ Path::RelativeFromWorkingDirectory () string Path::RelativeFromWorkingDirectory ( const string& path ) { - vector vwork, vpath, vout; - Path::Split ( vwork, working_directory, true ); + return Path::RelativeFromDirectory ( path, working_directory ); +} + +string +Path::RelativeFromDirectory ( const string& path, const string& base_directory ) +{ + vector vbase, vpath, vout; + Path::Split ( vbase, base_directory, true ); Path::Split ( vpath, path, true ); #ifdef WIN32 // this squirreliness is b/c win32 has drive letters and *nix doesn't... // not possible to do relative across different drive letters - if ( vwork[0] != vpath[0] ) + if ( vbase[0] != vpath[0] ) return path; #endif size_t i = 0; - while ( i < vwork.size() && i < vpath.size() && vwork[i] == vpath[i] ) + while ( i < vbase.size() && i < vpath.size() && vbase[i] == vpath[i] ) ++i; - if ( i < vwork.size() ) + if ( i < vbase.size() ) { - // path goes above our working directory, we will need some ..'s + // path goes above our base directory, we will need some ..'s for ( size_t j = 0; j < i; j++ ) vout.push_back ( ".." ); } diff --git a/reactos/tools/rbuild/XML.h b/reactos/tools/rbuild/XML.h index d22ab987161..38ad86c3a09 100644 --- a/reactos/tools/rbuild/XML.h +++ b/reactos/tools/rbuild/XML.h @@ -44,6 +44,7 @@ public: std::string RelativeFromWorkingDirectory (); static std::string RelativeFromWorkingDirectory ( const std::string& path ); + static std::string RelativeFromDirectory ( const std::string& path, const std::string& base_directory); static void Split ( std::vector& out, const std::string& path,