summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorAmitha Perera <perera@cs.rpi.edu>2002-01-06 19:59:16 (GMT)
committerAmitha Perera <perera@cs.rpi.edu>2002-01-06 19:59:16 (GMT)
commit2fa6a0eb44a8032982c2ff09b56c3c7bc170ff3c (patch)
treeae63123167de44380ff91acc6b5f13f83d870dfc /Source/cmSystemTools.cxx
parent0e7e1c110c5cb6c0c79804e6d2654331b19db3d0 (diff)
downloadCMake-2fa6a0eb44a8032982c2ff09b56c3c7bc170ff3c.zip
CMake-2fa6a0eb44a8032982c2ff09b56c3c7bc170ff3c.tar.gz
CMake-2fa6a0eb44a8032982c2ff09b56c3c7bc170ff3c.tar.bz2
ENH: Add an invocation that maintains symbolic paths to the source and binary trees, mainly for systems with automounted network drives.
ENH: CollapseFullPath() no longer adds a trailing "/" to directory paths.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx34
1 files changed, 31 insertions, 3 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 962cfe5..02b0274 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -94,6 +94,7 @@ inline int Chdir(const char* dir)
bool cmSystemTools::s_DisableRunCommandOutput = false;
bool cmSystemTools::s_ErrorOccured = false;
bool cmSystemTools::s_DisableMessages = false;
+cmSystemTools::PathMap cmSystemTools::s_PathMap;
void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, bool&);
@@ -1176,6 +1177,7 @@ std::string cmSystemTools::GetCurrentWorkingDirectory()
{
char buf[2048];
std::string path = Getcwd(buf, 2048);
+ ApplyPathTranslation( path );
return path;
}
@@ -1237,6 +1239,7 @@ void cmSystemTools::SplitProgramPath(const char* in_name,
std::string cmSystemTools::CollapseFullPath(const char* in_name)
{
std::string dir, file;
+ std::string return_value;
cmSystemTools::SplitProgramPath(in_name, dir, file);
#ifdef _WIN32
// Ultra-hack warning:
@@ -1248,8 +1251,7 @@ std::string cmSystemTools::CollapseFullPath(const char* in_name)
Chdir(cwd.c_str());
cmSystemTools::ConvertToUnixSlashes(newDir);
- std::string newPath = newDir+"/"+file;
- return newPath;
+ return_value = newDir;
#else
# ifdef MAXPATHLEN
char resolved_name[MAXPATHLEN];
@@ -1269,8 +1271,13 @@ std::string cmSystemTools::CollapseFullPath(const char* in_name)
{
dir = cmSystemTools::GetCurrentWorkingDirectory();
}
- return dir + "/" + file;
+ return_value = dir;
#endif
+ if(file != "")
+ return_value += "/" + file;
+
+ ApplyPathTranslation( return_value );
+ return return_value;
}
/**
@@ -1424,3 +1431,24 @@ void cmSystemTools::GlobDirs(const char *fullPath,
}
}
}
+
+
+void cmSystemTools::AddPathTranslation( const std::string& from, const std::string& to )
+{
+ s_PathMap[from] = to;
+}
+
+void cmSystemTools::ApplyPathTranslation( std::string& path )
+{
+ PathMap::iterator i;
+
+ // For each key in the map, see if path starts with it. If so, perform the substitution.
+ for( i = s_PathMap.begin(); i != s_PathMap.end(); ++i )
+ {
+ if( path.substr( 0, i->first.length() ) == i->first )
+ {
+ path.replace( 0, i->first.length(), i->second );
+ return;
+ }
+ }
+}