KWSys: Remove "copyPermissions" parameters
The CopyFileIfDifferent, CopyFileAlways, CopyAFile and CopyADirectory methods should always copy permissions. The special cases in which a caller would pass copyPermissions=false should be handled at the call site. The parameter needlessly complicates the interface and semantics of these methods.
This commit is contained in:
parent
b180bad2c6
commit
ac17dc4a43
@ -1722,8 +1722,7 @@ kwsys_stl::string SystemTools::ConvertToWindowsOutputPath(const char* path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SystemTools::CopyFileIfDifferent(const char* source,
|
bool SystemTools::CopyFileIfDifferent(const char* source,
|
||||||
const char* destination,
|
const char* destination)
|
||||||
bool copyPermissions)
|
|
||||||
{
|
{
|
||||||
// special check for a destination that is a directory
|
// special check for a destination that is a directory
|
||||||
// FilesDiffer does not handle file to directory compare
|
// FilesDiffer does not handle file to directory compare
|
||||||
@ -1736,8 +1735,7 @@ bool SystemTools::CopyFileIfDifferent(const char* source,
|
|||||||
new_destination += SystemTools::GetFilenameName(source_name);
|
new_destination += SystemTools::GetFilenameName(source_name);
|
||||||
if(SystemTools::FilesDiffer(source, new_destination.c_str()))
|
if(SystemTools::FilesDiffer(source, new_destination.c_str()))
|
||||||
{
|
{
|
||||||
return SystemTools::CopyFileAlways(source, destination,
|
return SystemTools::CopyFileAlways(source, destination);
|
||||||
copyPermissions);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1750,7 +1748,7 @@ bool SystemTools::CopyFileIfDifferent(const char* source,
|
|||||||
// are different
|
// are different
|
||||||
if(SystemTools::FilesDiffer(source, destination))
|
if(SystemTools::FilesDiffer(source, destination))
|
||||||
{
|
{
|
||||||
return SystemTools::CopyFileAlways(source, destination, copyPermissions);
|
return SystemTools::CopyFileAlways(source, destination);
|
||||||
}
|
}
|
||||||
// at this point the files must be the same so return true
|
// at this point the files must be the same so return true
|
||||||
return true;
|
return true;
|
||||||
@ -1836,8 +1834,7 @@ bool SystemTools::FilesDiffer(const char* source,
|
|||||||
/**
|
/**
|
||||||
* Copy a file named by "source" to the file named by "destination".
|
* Copy a file named by "source" to the file named by "destination".
|
||||||
*/
|
*/
|
||||||
bool SystemTools::CopyFileAlways(const char* source, const char* destination,
|
bool SystemTools::CopyFileAlways(const char* source, const char* destination)
|
||||||
bool copyPermissions)
|
|
||||||
{
|
{
|
||||||
// If files are the same do not copy
|
// If files are the same do not copy
|
||||||
if ( SystemTools::SameFile(source, destination) )
|
if ( SystemTools::SameFile(source, destination) )
|
||||||
@ -1928,7 +1925,7 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination,
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( copyPermissions && perms )
|
if ( perms )
|
||||||
{
|
{
|
||||||
if ( !SystemTools::SetPermissions(destination, perm) )
|
if ( !SystemTools::SetPermissions(destination, perm) )
|
||||||
{
|
{
|
||||||
@ -1940,15 +1937,15 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination,
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool SystemTools::CopyAFile(const char* source, const char* destination,
|
bool SystemTools::CopyAFile(const char* source, const char* destination,
|
||||||
bool always, bool copyPermissions)
|
bool always)
|
||||||
{
|
{
|
||||||
if(always)
|
if(always)
|
||||||
{
|
{
|
||||||
return SystemTools::CopyFileAlways(source, destination, copyPermissions);
|
return SystemTools::CopyFileAlways(source, destination);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return SystemTools::CopyFileIfDifferent(source, destination, copyPermissions);
|
return SystemTools::CopyFileIfDifferent(source, destination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1957,7 +1954,7 @@ bool SystemTools::CopyAFile(const char* source, const char* destination,
|
|||||||
* "destination".
|
* "destination".
|
||||||
*/
|
*/
|
||||||
bool SystemTools::CopyADirectory(const char* source, const char* destination,
|
bool SystemTools::CopyADirectory(const char* source, const char* destination,
|
||||||
bool always, bool copyPermissions)
|
bool always)
|
||||||
{
|
{
|
||||||
Directory dir;
|
Directory dir;
|
||||||
dir.Load(source);
|
dir.Load(source);
|
||||||
@ -1981,16 +1978,14 @@ bool SystemTools::CopyADirectory(const char* source, const char* destination,
|
|||||||
fullDestPath += dir.GetFile(static_cast<unsigned long>(fileNum));
|
fullDestPath += dir.GetFile(static_cast<unsigned long>(fileNum));
|
||||||
if (!SystemTools::CopyADirectory(fullPath.c_str(),
|
if (!SystemTools::CopyADirectory(fullPath.c_str(),
|
||||||
fullDestPath.c_str(),
|
fullDestPath.c_str(),
|
||||||
always,
|
always))
|
||||||
copyPermissions))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!SystemTools::CopyAFile(fullPath.c_str(), destination, always,
|
if(!SystemTools::CopyAFile(fullPath.c_str(), destination, always))
|
||||||
copyPermissions))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -500,14 +500,10 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy the source file to the destination file only
|
* Copy the source file to the destination file only
|
||||||
* if the two files differ. If the "copyPermissions"
|
* if the two files differ.
|
||||||
* argument is true, the permissions of the copy are
|
|
||||||
* set to be the same as the permissions of the
|
|
||||||
* original.
|
|
||||||
*/
|
*/
|
||||||
static bool CopyFileIfDifferent(const char* source,
|
static bool CopyFileIfDifferent(const char* source,
|
||||||
const char* destination,
|
const char* destination);
|
||||||
bool copyPermissions = true);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare the contents of two files. Return true if different
|
* Compare the contents of two files. Return true if different
|
||||||
@ -520,22 +516,17 @@ public:
|
|||||||
static bool SameFile(const char* file1, const char* file2);
|
static bool SameFile(const char* file1, const char* file2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a file. If the "copyPermissions" argument is true, the
|
* Copy a file.
|
||||||
* permissions of the copy are set to be the same as the permissions
|
|
||||||
* of the original.
|
|
||||||
*/
|
*/
|
||||||
static bool CopyFileAlways(const char* source, const char* destination,
|
static bool CopyFileAlways(const char* source, const char* destination);
|
||||||
bool copyPermissions = true);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a file. If the "always" argument is true the file is always
|
* 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
|
* copied. If it is false, the file is copied only if it is new or
|
||||||
* has changed. If the "copyPermissions" argument is true, the
|
* has changed.
|
||||||
* permissions of the copy are set to be the same as the permissions
|
|
||||||
* of the original.
|
|
||||||
*/
|
*/
|
||||||
static bool CopyAFile(const char* source, const char* destination,
|
static bool CopyAFile(const char* source, const char* destination,
|
||||||
bool always = true, bool copyPermissions = true);
|
bool always = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy content directory to another directory with all files and
|
* Copy content directory to another directory with all files and
|
||||||
@ -544,7 +535,7 @@ public:
|
|||||||
* are new are copied.
|
* are new are copied.
|
||||||
*/
|
*/
|
||||||
static bool CopyADirectory(const char* source, const char* destination,
|
static bool CopyADirectory(const char* source, const char* destination,
|
||||||
bool always = true, bool copyPermissions = true);
|
bool always = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a file
|
* Remove a file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user