Commit dd703ac6 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

SystemTools: make file copying mechanisms public

CMake will use these in its own file copying routines (which will
capture errors).
parent e359c1e4
...@@ -2273,10 +2273,7 @@ bool SystemTools::TextFilesDiffer(const std::string& path1, ...@@ -2273,10 +2273,7 @@ bool SystemTools::TextFilesDiffer(const std::string& path1,
return false; return false;
} }
/** bool SystemTools::CopyFileContentBlockwise(const std::string& source,
* Blockwise copy source to destination file
*/
static bool CopyFileContentBlockwise(const std::string& source,
const std::string& destination) const std::string& destination)
{ {
// Open files // Open files
...@@ -2341,7 +2338,7 @@ static bool CopyFileContentBlockwise(const std::string& source, ...@@ -2341,7 +2338,7 @@ static bool CopyFileContentBlockwise(const std::string& source,
* - The underlying filesystem does not support file cloning * - The underlying filesystem does not support file cloning
* - An unspecified error occurred * - An unspecified error occurred
*/ */
static bool CloneFileContent(const std::string& source, bool SystemTools::CloneFileContent(const std::string& source,
const std::string& destination) const std::string& destination)
{ {
#if defined(__linux) && defined(FICLONE) #if defined(__linux) && defined(FICLONE)
...@@ -2410,9 +2407,9 @@ bool SystemTools::CopyFileAlways(const std::string& source, ...@@ -2410,9 +2407,9 @@ bool SystemTools::CopyFileAlways(const std::string& source,
SystemTools::MakeDirectory(destination_dir); SystemTools::MakeDirectory(destination_dir);
if (!CloneFileContent(source, real_destination)) { if (!SystemTools::CloneFileContent(source, real_destination)) {
// if cloning did not succeed, fall back to blockwise copy // if cloning did not succeed, fall back to blockwise copy
if (!CopyFileContentBlockwise(source, real_destination)) { if (!SystemTools::CopyFileContentBlockwise(source, real_destination)) {
return false; return false;
} }
} }
......
...@@ -577,6 +577,17 @@ public: ...@@ -577,6 +577,17 @@ public:
static bool TextFilesDiffer(const std::string& path1, static bool TextFilesDiffer(const std::string& path1,
const std::string& path2); const std::string& path2);
/**
* Blockwise copy source to destination file
*/
static bool CopyFileContentBlockwise(const std::string& source,
const std::string& destination);
/**
* Clone the source file to the destination file
*/
static bool CloneFileContent(const std::string& source,
const std::string& destination);
/** /**
* Return true if the two files are the same file * Return true if the two files are the same file
*/ */
......
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