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

Merge topic 'SystemTools-public-copy-mechanisms'

dd703ac6

 SystemTools: make file copying mechanisms public
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !207
parents e359c1e4 dd703ac6
......@@ -2273,11 +2273,8 @@ bool SystemTools::TextFilesDiffer(const std::string& path1,
return false;
}
/**
* Blockwise copy source to destination file
*/
static bool CopyFileContentBlockwise(const std::string& source,
const std::string& destination)
bool SystemTools::CopyFileContentBlockwise(const std::string& source,
const std::string& destination)
{
// Open files
kwsys::ifstream fin(source.c_str(), std::ios::in | std::ios::binary);
......@@ -2341,8 +2338,8 @@ static bool CopyFileContentBlockwise(const std::string& source,
* - The underlying filesystem does not support file cloning
* - An unspecified error occurred
*/
static bool CloneFileContent(const std::string& source,
const std::string& destination)
bool SystemTools::CloneFileContent(const std::string& source,
const std::string& destination)
{
#if defined(__linux) && defined(FICLONE)
int in = open(source.c_str(), O_RDONLY);
......@@ -2410,9 +2407,9 @@ bool SystemTools::CopyFileAlways(const std::string& source,
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 (!CopyFileContentBlockwise(source, real_destination)) {
if (!SystemTools::CopyFileContentBlockwise(source, real_destination)) {
return false;
}
}
......
......@@ -577,6 +577,17 @@ public:
static bool TextFilesDiffer(const std::string& path1,
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
*/
......
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