summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2007-02-15 20:07:16 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2007-02-15 20:07:16 (GMT)
commitffc0b5e4de02873ee825f70f4c434c8cb3b7edde (patch)
tree98c63ec76ab733f9be25916e4c3e8c75d942b26e /Source/cmake.cxx
parent7c72e03c25505275e0a2c0b17ae53393f22b2763 (diff)
downloadCMake-ffc0b5e4de02873ee825f70f4c434c8cb3b7edde.zip
CMake-ffc0b5e4de02873ee825f70f4c434c8cb3b7edde.tar.gz
CMake-ffc0b5e4de02873ee825f70f4c434c8cb3b7edde.tar.bz2
BUG: Overwrite the symlink if it already exists. Close Bug #4418 - cmake -create-symlink doesn't overwrite existing symlinks
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 3f6143a..7edf2ea 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1072,6 +1072,22 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
// supporting them.
else if (args[1] == "create_symlink" && args.size() == 4)
{
+ const char* destinationFileName = args[3].c_str();
+ if ( cmSystemTools::FileExists(destinationFileName) )
+ {
+ if ( cmSystemTools::FileIsSymlink(destinationFileName) )
+ {
+ if ( !cmSystemTools::RemoveFile(destinationFileName) ||
+ cmSystemTools::FileExists(destinationFileName) )
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ return 0;
+ }
+ }
return cmSystemTools::CreateSymlink(args[2].c_str(),
args[3].c_str())? 0:1;
}