summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorVitaly Stakhovsky <vvs31415@gitlab.org>2019-01-29 10:34:18 -0500
committerVitaly Stakhovsky <vvs31415@gitlab.org>2019-01-29 10:34:18 -0500
commitc31b6e616d5c2d697696540ca2e8faf14160d2b0 (patch)
treebf4f82b41e5fd8a2d5f5fd76e80eb6f8e24e0e1b /Source
parent9620cb935a49e7b4955f5b1d0ffa2e93b4327591 (diff)
downloadcmake-c31b6e616d5c2d697696540ca2e8faf14160d2b0.tar.gz
cmSystemTools: copy file member functions accept std::string params
Cleaned up `c_str()`s. `cmSystemTools::CopyFileIfDifferent()` removed as redundant.
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/IFW/cmCPackIFWInstaller.cxx3
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.cxx3
-rw-r--r--Source/CPack/cmCPackGenerator.cxx6
-rw-r--r--Source/cmFileCommand.cxx3
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx5
-rw-r--r--Source/cmMakefile.cxx6
-rw-r--r--Source/cmSystemTools.cxx9
-rw-r--r--Source/cmSystemTools.h4
-rw-r--r--Source/cmUseMangledMesaCommand.cxx2
-rw-r--r--Source/cmake.cxx2
-rw-r--r--Source/cmcmd.cxx8
11 files changed, 18 insertions, 33 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
index 8f492afde9..f12a452424 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
@@ -288,8 +288,7 @@ protected:
content = cmSystemTools::TrimWhitespace(content);
std::string source = this->basePath + "/" + content;
std::string destination = this->path + "/" + content;
- if (!cmSystemTools::CopyFileIfDifferent(source.data(),
- destination.data())) {
+ if (!cmSystemTools::CopyFileIfDifferent(source, destination)) {
this->hasErrors = true;
}
}
diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index be4a18e09d..c55b1487ba 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -212,8 +212,7 @@ int cmCPackDragNDropGenerator::PackageFiles()
bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source,
std::ostringstream& target)
{
- if (!cmSystemTools::CopyFileIfDifferent(source.str().c_str(),
- target.str().c_str())) {
+ if (!cmSystemTools::CopyFileIfDifferent(source.str(), target.str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error copying " << source.str() << " to " << target.str()
<< std::endl);
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 4728f69577..90d38fc7d8 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -392,8 +392,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
std::move(inFileRelative));
}
/* If it is not a symlink then do a plain copy */
- else if (!(cmSystemTools::CopyFileIfDifferent(inFile.c_str(),
- filePath.c_str()) &&
+ else if (!(cmSystemTools::CopyFileIfDifferent(inFile, filePath) &&
cmSystemTools::CopyFileTime(inFile.c_str(),
filePath.c_str()))) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -1077,8 +1076,7 @@ int cmCPackGenerator::DoPackage()
<< (tempPackageFileName ? tempPackageFileName : "(NULL)")
<< " to " << (packageFileName ? packageFileName : "(NULL)")
<< std::endl);
- if (!cmSystemTools::CopyFileIfDifferent(tempPackageFileName,
- packageFileName)) {
+ if (!cmSystemTools::CopyFileIfDifferent(pkgFileName, tmpPF)) {
cmCPackLogger(
cmCPackLog::LOG_ERROR,
"Problem copying the package: "
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index afb0b2a908..76c5b9a2dd 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -3759,8 +3759,7 @@ bool cmFileCommand::HandleCreateLinkCommand(
// Check if copy-on-error is enabled in the arguments.
if (!completed && copyOnErrorArg.IsEnabled()) {
- completed =
- cmSystemTools::cmCopyFile(fileName.c_str(), newFileName.c_str());
+ completed = cmSystemTools::cmCopyFile(fileName, newFileName);
if (!completed) {
result = "Copy failed: " + cmSystemTools::GetLastSystemError();
}
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index e3dd2f987c..77be592e82 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -262,9 +262,8 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
// purposes but newer versions distributed with CMake will replace
// older versions in user directories.
int res;
- if (!cmSystemTools::FileTimeCompare(src.c_str(), dst.c_str(), &res) ||
- res > 0) {
- if (!cmSystemTools::CopyFileAlways(src.c_str(), dst.c_str())) {
+ if (!cmSystemTools::FileTimeCompare(src, dst, &res) || res > 0) {
+ if (!cmSystemTools::CopyFileAlways(src, dst)) {
std::ostringstream oss;
oss << "Could not copy from: " << src << std::endl;
oss << " to: " << dst << std::endl;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9bd3b01317..6b58f86351 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3750,8 +3750,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
}
if (copyonly) {
- if (!cmSystemTools::CopyFileIfDifferent(sinfile.c_str(),
- soutfile.c_str())) {
+ if (!cmSystemTools::CopyFileIfDifferent(sinfile, soutfile)) {
return 0;
}
} else {
@@ -3802,8 +3801,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
// close the files before attempting to copy
fin.close();
fout.close();
- if (!cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(),
- soutfile.c_str())) {
+ if (!cmSystemTools::CopyFileIfDifferent(tempOutputFile, soutfile)) {
res = 0;
} else {
cmSystemTools::SetPermissions(soutfile, perm);
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index f7de3aa71e..9c4afec827 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -940,17 +940,12 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
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);
}
-bool cmSystemTools::CopyFileIfDifferent(const char* source,
- const char* destination)
-{
- return Superclass::CopyFileIfDifferent(source, destination);
-}
-
#ifdef _WIN32
cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsFileRetry()
{
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index b1d57512da..98ada60850 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -179,8 +179,8 @@ public:
std::vector<std::string>& files, int type = 0);
///! Copy a file.
- static bool cmCopyFile(const char* source, const char* destination);
- static bool CopyFileIfDifferent(const char* source, const char* destination);
+ static bool cmCopyFile(const std::string& source,
+ const std::string& destination);
/** Rename a file or directory within a single disk volume (atomic
if possible). */
diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx
index 01ef5cbea4..9648b21d8f 100644
--- a/Source/cmUseMangledMesaCommand.cxx
+++ b/Source/cmUseMangledMesaCommand.cxx
@@ -100,6 +100,6 @@ void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(const char* source,
// close the files before attempting to copy
fin.close();
fout.close();
- cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(), outFile.c_str());
+ cmSystemTools::CopyFileIfDifferent(tempOutputFile, outFile);
cmSystemTools::RemoveFile(tempOutputFile);
}
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 70316f10bd..b03ffdb298 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2358,7 +2358,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
outFile += "/CMakeLists.txt";
// Copy file
- if (!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str())) {
+ if (!cmSystemTools::cmCopyFile(inFile, outFile)) {
std::cerr << "Error copying file \"" << inFile << "\" to \"" << outFile
<< "\".\n";
return 1;
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 2a3aedd647..d20c5d23a3 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -482,8 +482,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// If error occurs we want to continue copying next files.
bool return_value = false;
for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
- if (!cmSystemTools::cmCopyFile(args[cc].c_str(),
- args.back().c_str())) {
+ if (!cmSystemTools::cmCopyFile(args[cc], args.back())) {
std::cerr << "Error copying file \"" << args[cc] << "\" to \""
<< args.back() << "\".\n";
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.
bool return_value = false;
for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
- if (!cmSystemTools::CopyFileIfDifferent(args[cc].c_str(),
- args.back().c_str())) {
+ if (!cmSystemTools::CopyFileIfDifferent(args[cc], args.back())) {
std::cerr << "Error copying file (if different) from \"" << args[cc]
<< "\" to \"" << args.back() << "\".\n";
return_value = true;
@@ -1304,7 +1302,7 @@ bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link)
cmSystemTools::RemoveFile(link);
}
#if defined(_WIN32) && !defined(__CYGWIN__)
- return cmSystemTools::CopyFileAlways(file.c_str(), link.c_str());
+ return cmSystemTools::CopyFileAlways(file, link);
#else
std::string linktext = cmSystemTools::GetFilenameName(file);
return cmSystemTools::CreateSymlink(linktext, link);