summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-05-13 14:30:33 (GMT)
committerBrad King <brad.king@kitware.com>2009-05-13 14:30:33 (GMT)
commitcecfce23a5138a0f44a9231d158c1d8541233a36 (patch)
tree27764943faaffda52cf42737f129896daabfbba2 /Source
parent33a1076b84c883f527f9817b51bdc2573841522e (diff)
downloadCMake-cecfce23a5138a0f44a9231d158c1d8541233a36.zip
CMake-cecfce23a5138a0f44a9231d158c1d8541233a36.tar.gz
CMake-cecfce23a5138a0f44a9231d158c1d8541233a36.tar.bz2
BUG: Fix removal of read-only directories
Read-only directories must be given write permission before we can remove files and subdirectories from them.
Diffstat (limited to 'Source')
-rw-r--r--Source/kwsys/SystemTools.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index a6512db..2d90de2 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2103,6 +2103,19 @@ bool SystemTools::RemoveFile(const char* source)
bool SystemTools::RemoveADirectory(const char* source)
{
+ // Add write permission to the directory so we can modify its
+ // content to remove files and directories from it.
+ mode_t mode;
+ if(SystemTools::GetPermissions(source, mode))
+ {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ mode |= S_IWRITE;
+#else
+ mode |= S_IWUSR;
+#endif
+ SystemTools::SetPermissions(source, mode);
+ }
+
Directory dir;
dir.Load(source);
size_t fileNum;