summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/SystemTools.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2005-07-12 17:21:21 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2005-07-12 17:21:21 (GMT)
commiteee2d2b035295a04a8e00c2f187cfa786bffcdc0 (patch)
treebda9c5648e9bf4ffeab1362bf7e4ff5e6ca7cc24 /Source/kwsys/SystemTools.cxx
parent0e76ab6eb69786eb51a882b9c930636a5c0c7704 (diff)
downloadCMake-eee2d2b035295a04a8e00c2f187cfa786bffcdc0.zip
CMake-eee2d2b035295a04a8e00c2f187cfa786bffcdc0.tar.gz
CMake-eee2d2b035295a04a8e00c2f187cfa786bffcdc0.tar.bz2
BUG: Revert the change to FileIsDirectory. Add FileIsSymlink and treat symlinks as files when removing directory
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r--Source/kwsys/SystemTools.cxx24
1 files changed, 19 insertions, 5 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 157ea55..a9193bd 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -1827,7 +1827,8 @@ bool SystemTools::RemoveADirectory(const char* source)
kwsys_stl::string fullPath = source;
fullPath += "/";
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
- if(SystemTools::FileIsDirectory(fullPath.c_str()))
+ if(SystemTools::FileIsDirectory(fullPath.c_str()) &&
+ !SystemTools::FileIsSymlink(fullPath.c_str()))
{
if (!SystemTools::RemoveADirectory(fullPath.c_str()))
{
@@ -2044,11 +2045,7 @@ kwsys_stl::string SystemTools
bool SystemTools::FileIsDirectory(const char* name)
{
struct stat fs;
-#if _WIN32
if(stat(name, &fs) == 0)
-#else
- if(lstat(name, &fs) == 0)
-#endif
{
#if _WIN32
return ((fs.st_mode & _S_IFDIR) != 0);
@@ -2062,6 +2059,23 @@ bool SystemTools::FileIsDirectory(const char* name)
}
}
+bool SystemTools::FileIsSymlink(const char* name)
+{
+#if _WIN32
+ return false;
+#else
+ struct stat fs;
+ if(lstat(name, &fs) == 0)
+ {
+ return S_ISLNK(fs.st_mode);
+ }
+ else
+ {
+ return false;
+ }
+#endif
+}
+
int SystemTools::ChangeDirectory(const char *dir)
{
return Chdir(dir);