cmSystemTools: copy file member functions accept std::string params
Cleaned up `c_str()`s. `cmSystemTools::CopyFileIfDifferent()` removed as redundant.
This commit is contained in:
parent
9620cb935a
commit
c31b6e616d
@ -288,8 +288,7 @@ protected:
|
|||||||
content = cmSystemTools::TrimWhitespace(content);
|
content = cmSystemTools::TrimWhitespace(content);
|
||||||
std::string source = this->basePath + "/" + content;
|
std::string source = this->basePath + "/" + content;
|
||||||
std::string destination = this->path + "/" + content;
|
std::string destination = this->path + "/" + content;
|
||||||
if (!cmSystemTools::CopyFileIfDifferent(source.data(),
|
if (!cmSystemTools::CopyFileIfDifferent(source, destination)) {
|
||||||
destination.data())) {
|
|
||||||
this->hasErrors = true;
|
this->hasErrors = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,8 +212,7 @@ int cmCPackDragNDropGenerator::PackageFiles()
|
|||||||
bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source,
|
bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source,
|
||||||
std::ostringstream& target)
|
std::ostringstream& target)
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::CopyFileIfDifferent(source.str().c_str(),
|
if (!cmSystemTools::CopyFileIfDifferent(source.str(), target.str())) {
|
||||||
target.str().c_str())) {
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
"Error copying " << source.str() << " to " << target.str()
|
"Error copying " << source.str() << " to " << target.str()
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
|
@ -392,8 +392,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
|
|||||||
std::move(inFileRelative));
|
std::move(inFileRelative));
|
||||||
}
|
}
|
||||||
/* If it is not a symlink then do a plain copy */
|
/* If it is not a symlink then do a plain copy */
|
||||||
else if (!(cmSystemTools::CopyFileIfDifferent(inFile.c_str(),
|
else if (!(cmSystemTools::CopyFileIfDifferent(inFile, filePath) &&
|
||||||
filePath.c_str()) &&
|
|
||||||
cmSystemTools::CopyFileTime(inFile.c_str(),
|
cmSystemTools::CopyFileTime(inFile.c_str(),
|
||||||
filePath.c_str()))) {
|
filePath.c_str()))) {
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
@ -1077,8 +1076,7 @@ int cmCPackGenerator::DoPackage()
|
|||||||
<< (tempPackageFileName ? tempPackageFileName : "(NULL)")
|
<< (tempPackageFileName ? tempPackageFileName : "(NULL)")
|
||||||
<< " to " << (packageFileName ? packageFileName : "(NULL)")
|
<< " to " << (packageFileName ? packageFileName : "(NULL)")
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
if (!cmSystemTools::CopyFileIfDifferent(tempPackageFileName,
|
if (!cmSystemTools::CopyFileIfDifferent(pkgFileName, tmpPF)) {
|
||||||
packageFileName)) {
|
|
||||||
cmCPackLogger(
|
cmCPackLogger(
|
||||||
cmCPackLog::LOG_ERROR,
|
cmCPackLog::LOG_ERROR,
|
||||||
"Problem copying the package: "
|
"Problem copying the package: "
|
||||||
|
@ -3759,8 +3759,7 @@ bool cmFileCommand::HandleCreateLinkCommand(
|
|||||||
|
|
||||||
// Check if copy-on-error is enabled in the arguments.
|
// Check if copy-on-error is enabled in the arguments.
|
||||||
if (!completed && copyOnErrorArg.IsEnabled()) {
|
if (!completed && copyOnErrorArg.IsEnabled()) {
|
||||||
completed =
|
completed = cmSystemTools::cmCopyFile(fileName, newFileName);
|
||||||
cmSystemTools::cmCopyFile(fileName.c_str(), newFileName.c_str());
|
|
||||||
if (!completed) {
|
if (!completed) {
|
||||||
result = "Copy failed: " + cmSystemTools::GetLastSystemError();
|
result = "Copy failed: " + cmSystemTools::GetLastSystemError();
|
||||||
}
|
}
|
||||||
|
@ -262,9 +262,8 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
|
|||||||
// purposes but newer versions distributed with CMake will replace
|
// purposes but newer versions distributed with CMake will replace
|
||||||
// older versions in user directories.
|
// older versions in user directories.
|
||||||
int res;
|
int res;
|
||||||
if (!cmSystemTools::FileTimeCompare(src.c_str(), dst.c_str(), &res) ||
|
if (!cmSystemTools::FileTimeCompare(src, dst, &res) || res > 0) {
|
||||||
res > 0) {
|
if (!cmSystemTools::CopyFileAlways(src, dst)) {
|
||||||
if (!cmSystemTools::CopyFileAlways(src.c_str(), dst.c_str())) {
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Could not copy from: " << src << std::endl;
|
oss << "Could not copy from: " << src << std::endl;
|
||||||
oss << " to: " << dst << std::endl;
|
oss << " to: " << dst << std::endl;
|
||||||
|
@ -3750,8 +3750,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (copyonly) {
|
if (copyonly) {
|
||||||
if (!cmSystemTools::CopyFileIfDifferent(sinfile.c_str(),
|
if (!cmSystemTools::CopyFileIfDifferent(sinfile, soutfile)) {
|
||||||
soutfile.c_str())) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -3802,8 +3801,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
|
|||||||
// close the files before attempting to copy
|
// close the files before attempting to copy
|
||||||
fin.close();
|
fin.close();
|
||||||
fout.close();
|
fout.close();
|
||||||
if (!cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(),
|
if (!cmSystemTools::CopyFileIfDifferent(tempOutputFile, soutfile)) {
|
||||||
soutfile.c_str())) {
|
|
||||||
res = 0;
|
res = 0;
|
||||||
} else {
|
} else {
|
||||||
cmSystemTools::SetPermissions(soutfile, perm);
|
cmSystemTools::SetPermissions(soutfile, perm);
|
||||||
|
@ -940,17 +940,12 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmSystemTools::cmCopyFile(const char* source, const char* destination)
|
bool cmSystemTools::cmCopyFile(const std::string& source,
|
||||||
|
const std::string& destination)
|
||||||
{
|
{
|
||||||
return Superclass::CopyFileAlways(source, destination);
|
return Superclass::CopyFileAlways(source, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmSystemTools::CopyFileIfDifferent(const char* source,
|
|
||||||
const char* destination)
|
|
||||||
{
|
|
||||||
return Superclass::CopyFileIfDifferent(source, destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsFileRetry()
|
cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsFileRetry()
|
||||||
{
|
{
|
||||||
|
@ -179,8 +179,8 @@ public:
|
|||||||
std::vector<std::string>& files, int type = 0);
|
std::vector<std::string>& files, int type = 0);
|
||||||
|
|
||||||
///! Copy a file.
|
///! Copy a file.
|
||||||
static bool cmCopyFile(const char* source, const char* destination);
|
static bool cmCopyFile(const std::string& source,
|
||||||
static bool CopyFileIfDifferent(const char* source, const char* destination);
|
const std::string& destination);
|
||||||
|
|
||||||
/** Rename a file or directory within a single disk volume (atomic
|
/** Rename a file or directory within a single disk volume (atomic
|
||||||
if possible). */
|
if possible). */
|
||||||
|
@ -100,6 +100,6 @@ void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(const char* source,
|
|||||||
// close the files before attempting to copy
|
// close the files before attempting to copy
|
||||||
fin.close();
|
fin.close();
|
||||||
fout.close();
|
fout.close();
|
||||||
cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(), outFile.c_str());
|
cmSystemTools::CopyFileIfDifferent(tempOutputFile, outFile);
|
||||||
cmSystemTools::RemoveFile(tempOutputFile);
|
cmSystemTools::RemoveFile(tempOutputFile);
|
||||||
}
|
}
|
||||||
|
@ -2358,7 +2358,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
|
|||||||
outFile += "/CMakeLists.txt";
|
outFile += "/CMakeLists.txt";
|
||||||
|
|
||||||
// Copy file
|
// Copy file
|
||||||
if (!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str())) {
|
if (!cmSystemTools::cmCopyFile(inFile, outFile)) {
|
||||||
std::cerr << "Error copying file \"" << inFile << "\" to \"" << outFile
|
std::cerr << "Error copying file \"" << inFile << "\" to \"" << outFile
|
||||||
<< "\".\n";
|
<< "\".\n";
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -482,8 +482,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
|||||||
// If error occurs we want to continue copying next files.
|
// If error occurs we want to continue copying next files.
|
||||||
bool return_value = false;
|
bool return_value = false;
|
||||||
for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
|
for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
|
||||||
if (!cmSystemTools::cmCopyFile(args[cc].c_str(),
|
if (!cmSystemTools::cmCopyFile(args[cc], args.back())) {
|
||||||
args.back().c_str())) {
|
|
||||||
std::cerr << "Error copying file \"" << args[cc] << "\" to \""
|
std::cerr << "Error copying file \"" << args[cc] << "\" to \""
|
||||||
<< args.back() << "\".\n";
|
<< args.back() << "\".\n";
|
||||||
return_value = true;
|
return_value = true;
|
||||||
@ -505,8 +504,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
|||||||
// If error occurs we want to continue copying next files.
|
// If error occurs we want to continue copying next files.
|
||||||
bool return_value = false;
|
bool return_value = false;
|
||||||
for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
|
for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
|
||||||
if (!cmSystemTools::CopyFileIfDifferent(args[cc].c_str(),
|
if (!cmSystemTools::CopyFileIfDifferent(args[cc], args.back())) {
|
||||||
args.back().c_str())) {
|
|
||||||
std::cerr << "Error copying file (if different) from \"" << args[cc]
|
std::cerr << "Error copying file (if different) from \"" << args[cc]
|
||||||
<< "\" to \"" << args.back() << "\".\n";
|
<< "\" to \"" << args.back() << "\".\n";
|
||||||
return_value = true;
|
return_value = true;
|
||||||
@ -1304,7 +1302,7 @@ bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link)
|
|||||||
cmSystemTools::RemoveFile(link);
|
cmSystemTools::RemoveFile(link);
|
||||||
}
|
}
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
return cmSystemTools::CopyFileAlways(file.c_str(), link.c_str());
|
return cmSystemTools::CopyFileAlways(file, link);
|
||||||
#else
|
#else
|
||||||
std::string linktext = cmSystemTools::GetFilenameName(file);
|
std::string linktext = cmSystemTools::GetFilenameName(file);
|
||||||
return cmSystemTools::CreateSymlink(linktext, link);
|
return cmSystemTools::CreateSymlink(linktext, link);
|
||||||
|
Loading…
Reference in New Issue
Block a user