Commit c3054d90 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'SystemTools-Touch-broken-symlink'

22216d56

 SystemTools: Fix Touch() on broken symlink when create==false
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !194
parents 2a8b5d05 22216d56
......@@ -1453,7 +1453,7 @@ bool SystemTools::PathCygwinToWin32(const char* path, char* win32_path)
bool SystemTools::Touch(const std::string& filename, bool create)
{
if (!SystemTools::PathExists(filename)) {
if (!SystemTools::FileExists(filename)) {
if (create) {
FILE* file = Fopen(filename, "a+b");
if (file) {
......
......@@ -422,6 +422,28 @@ static bool CheckFileOperations()
res = false;
}
#if !defined(_WIN32)
std::string const testBadSymlink(testNewDir + "/badSymlink.txt");
std::string const testBadSymlinkTgt(testNewDir + "/missing/symlinkTgt.txt");
if (!kwsys::SystemTools::CreateSymlink(testBadSymlinkTgt, testBadSymlink)) {
std::cerr << "Problem with CreateSymlink for: " << testBadSymlink << " -> "
<< testBadSymlinkTgt << std::endl;
res = false;
}
if (!kwsys::SystemTools::Touch(testBadSymlink, false)) {
std::cerr << "Problem with Touch (no create) for: " << testBadSymlink
<< std::endl;
res = false;
}
#endif
if (!kwsys::SystemTools::Touch(testNewDir, false)) {
std::cerr << "Problem with Touch (no create) for: " << testNewDir
<< std::endl;
res = false;
}
kwsys::SystemTools::Touch(testNewFile, true);
if (!kwsys::SystemTools::RemoveADirectory(testNewDir)) {
std::cerr << "Problem with RemoveADirectory for: " << testNewDir
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment