diff options
author | Brad King <brad.king@kitware.com> | 2007-03-12 17:50:28 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2007-03-12 17:50:28 (GMT) |
commit | e01cdf2065d93cdbb873999b45414133978860b2 (patch) | |
tree | f50fd8e9ba30e1bd19faf827952058a311ae2dbe /Source/kwsys/SystemTools.cxx | |
parent | 558dbc84adab239ab3043d0efd0891f9a995161e (diff) | |
download | CMake-e01cdf2065d93cdbb873999b45414133978860b2.zip CMake-e01cdf2065d93cdbb873999b45414133978860b2.tar.gz CMake-e01cdf2065d93cdbb873999b45414133978860b2.tar.bz2 |
ENH: Added kwsys SystemTools::CreateSymlink and SystemTools::ReadSymlink.
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 9892d73..9212b45 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -2356,6 +2356,44 @@ bool SystemTools::FileIsSymlink(const char* name) #endif } +#if defined(_WIN32) && !defined(__CYGWIN__) +bool SystemTools::CreateSymlink(const char*, const char*) +{ + return false; +} +#else +bool SystemTools::CreateSymlink(const char* origName, const char* newName) +{ + return symlink(origName, newName) >= 0; +} +#endif + +#if defined(_WIN32) && !defined(__CYGWIN__) +bool SystemTools::ReadSymlink(const char*, kwsys_stl::string&) +{ + return false; +} +#else +bool SystemTools::ReadSymlink(const char* newName, + kwsys_stl::string& origName) +{ + char buf[KWSYS_SYSTEMTOOLS_MAXPATH+1]; + int count = + static_cast<int>(readlink(newName, buf, KWSYS_SYSTEMTOOLS_MAXPATH)); + if(count >= 0) + { + // Add null-terminator. + buf[count] = 0; + origName = buf; + return true; + } + else + { + return false; + } +} +#endif + int SystemTools::ChangeDirectory(const char *dir) { return Chdir(dir); |