diff --git a/SystemTools.cxx b/SystemTools.cxx index 7d088b19210b6cf1b391d16ba9686c9bc0c11b16..37cecb097fa166748c74a2fe18da373dd0210b09 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -1637,11 +1637,26 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) return true; } +//---------------------------------------------------------------------------- +bool SystemTools::CopyAFile(const char* source, const char* destination, + bool always) +{ + if(always) + { + return SystemTools::CopyFileAlways(source, destination); + } + else + { + return SystemTools::CopyFileIfDifferent(source, destination); + } +} + /** * Copy a directory content from "source" directory to the directory named by * "destination". */ -bool SystemTools::CopyADirectory(const char* source, const char* destination) +bool SystemTools::CopyADirectory(const char* source, const char* destination, + bool always) { Directory dir; dir.Load(source); @@ -1663,14 +1678,16 @@ bool SystemTools::CopyADirectory(const char* source, const char* destination) kwsys_stl::string fullDestPath = destination; fullDestPath += "/"; fullDestPath += dir.GetFile(static_cast<unsigned long>(fileNum)); - if (!SystemTools::CopyADirectory(fullPath.c_str(), fullDestPath.c_str())) + if (!SystemTools::CopyADirectory(fullPath.c_str(), + fullDestPath.c_str(), + always)) { return false; } } else { - if(!SystemTools::CopyFileAlways(fullPath.c_str(), destination)) + if(!SystemTools::CopyAFile(fullPath.c_str(), destination, always)) { return false; } diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index 646c6cb82dd6a54ca2a952ba27fdda3bed870f28..35421155e5642404c6f908802fa5596c2f0c7805 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -469,10 +469,21 @@ public: static bool CopyFileAlways(const char* source, const char* destination); /** - * Copy content directory to another directory with all files and - * subdirectories + * Copy a file. If the "always" argument is true the file is always + * copied. If it is false, the file is copied only if it is new or + * has changed. */ - static bool CopyADirectory(const char* source, const char* destination); + static bool CopyAFile(const char* source, const char* destination, + bool always = true); + + /** + * Copy content directory to another directory with all files and + * subdirectories. If the "always" argument is true all files are + * always copied. If it is false, only files that have changed or + * are new are copied. + */ + static bool CopyADirectory(const char* source, const char* destination, + bool always = true); /** * Remove a file