mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 21:00:17 -06:00
KWSys 2018-05-15 (5f757898)
Code extracted from:
https://gitlab.kitware.com/utils/kwsys.git
at commit 5f757898119974aa30f700d5c38928ee48407320 (master).
Upstream Shortlog
-----------------
Marian Klymov (1):
d06fcab7 SystemTools: Check source directory in CopyADirectory
This commit is contained in:
committed by
Brad King
parent
55efd14733
commit
1e0a2e9377
@@ -2282,7 +2282,9 @@ bool SystemTools::CopyADirectory(const std::string& source,
|
||||
const std::string& destination, bool always)
|
||||
{
|
||||
Directory dir;
|
||||
dir.Load(source);
|
||||
if (dir.Load(source) == 0) {
|
||||
return false;
|
||||
}
|
||||
size_t fileNum;
|
||||
if (!SystemTools::MakeDirectory(destination)) {
|
||||
return false;
|
||||
|
||||
@@ -73,7 +73,38 @@ int _doLongPathTest()
|
||||
return res;
|
||||
}
|
||||
|
||||
int _copyDirectoryTest()
|
||||
{
|
||||
using namespace kwsys;
|
||||
const std::string source(TEST_SYSTEMTOOLS_BINARY_DIR
|
||||
"/directory_testing/copyDirectoryTestSrc");
|
||||
if (SystemTools::PathExists(source)) {
|
||||
std::cerr << source << " shouldn't exist before test" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
const std::string destination(TEST_SYSTEMTOOLS_BINARY_DIR
|
||||
"/directory_testing/copyDirectoryTestDst");
|
||||
if (SystemTools::PathExists(destination)) {
|
||||
std::cerr << destination << " shouldn't exist before test" << std::endl;
|
||||
return 2;
|
||||
}
|
||||
const bool copysuccess = SystemTools::CopyADirectory(source, destination);
|
||||
const bool destinationexists = SystemTools::PathExists(destination);
|
||||
if (copysuccess) {
|
||||
std::cerr << "CopyADirectory should have returned false" << std::endl;
|
||||
SystemTools::RemoveADirectory(destination);
|
||||
return 3;
|
||||
}
|
||||
if (destinationexists) {
|
||||
std::cerr << "CopyADirectory returned false, but destination directory"
|
||||
<< " has been created" << std::endl;
|
||||
SystemTools::RemoveADirectory(destination);
|
||||
return 4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int testDirectory(int, char* [])
|
||||
{
|
||||
return _doLongPathTest();
|
||||
return _doLongPathTest() + _copyDirectoryTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user