diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2006-02-07 15:23:17 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2006-02-07 15:23:17 (GMT) |
commit | e5a8e115bc26e6a7f6b25dc2450e9bb28fca6fa1 (patch) | |
tree | 3066579e9fc9477dc9dce981446a6fb30db91f19 /Source/kwsys/SystemTools.hxx.in | |
parent | f71a085f74e4b21f3b666c71557534b7603604dd (diff) | |
download | CMake-e5a8e115bc26e6a7f6b25dc2450e9bb28fca6fa1.zip CMake-e5a8e115bc26e6a7f6b25dc2450e9bb28fca6fa1.tar.gz CMake-e5a8e115bc26e6a7f6b25dc2450e9bb28fca6fa1.tar.bz2 |
ENH: Move relative path to kwsys
Diffstat (limited to 'Source/kwsys/SystemTools.hxx.in')
-rw-r--r-- | Source/kwsys/SystemTools.hxx.in | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 703f739..31bfa9a 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -20,6 +20,7 @@ #include <@KWSYS_NAMESPACE@/stl/map> #include <@KWSYS_NAMESPACE@/Configure.h> +#include <@KWSYS_NAMESPACE@/String.hxx> #include <sys/types.h> @@ -176,6 +177,13 @@ public: */ static kwsys_stl::string CropString(const kwsys_stl::string&,size_t max_len); + /** split a path by separator into an array of strings, default is /. + If isPath is true then the string is treated like a path and if + s starts with a / then the first element of the returned array will + be /, so /foo/bar will be [/, foo, bar] + */ + static std::vector<String> SplitString(const char* s, char separator = '/', + bool isPath = false); /** * Perform a case-independent string comparison */ @@ -574,6 +582,16 @@ public: static kwsys_stl::string FileExistsInParentDirectories(const char* fname, const char* directory, const char* toplevel); + /** compute the relative path from local to remote. local must + be a directory. remote can be a file or a directory. + Both remote and local must be full paths. Basically, if + you are in directory local and you want to access the file in remote + what is the relative path to do that. For example: + /a/b/c/d to /a/b/c1/d1 -> ../../c1/d1 + from /usr/src to /usr/src/test/blah/foo.cpp -> test/blah/foo.cpp + */ + static std::string RelativePath(const char* local, const char* remote); + /** * Return file's modified time */ |