Commit 8914d431 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'systools-stdstring2'

080a79ca cmSystemTools: More methods accept `std::string` params
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2952
parents 26412846 080a79ca
......@@ -388,8 +388,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
}
/* If it is not a symlink then do a plain copy */
else if (!(cmSystemTools::CopyFileIfDifferent(inFile, filePath) &&
cmSystemTools::CopyFileTime(inFile.c_str(),
filePath.c_str()))) {
cmSystemTools::CopyFileTime(inFile, filePath))) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem copying file: " << inFile << " -> "
<< filePath << std::endl);
......
......@@ -223,7 +223,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file,
checkDir = fBinDir;
}
std::string ndc = cmSystemTools::FileExistsInParentDirectories(
".NoDartCoverage", fFile.c_str(), checkDir.c_str());
".NoDartCoverage", fFile, checkDir);
if (!ndc.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Found: " << ndc << " so skip coverage of " << file
......@@ -254,8 +254,8 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file,
return true;
}
ndc = cmSystemTools::FileExistsInParentDirectories(
".NoDartCoverage", fFile.c_str(), checkDir.c_str());
ndc = cmSystemTools::FileExistsInParentDirectories(".NoDartCoverage", fFile,
checkDir);
if (!ndc.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Found: " << ndc << " so skip coverage of: " << file
......@@ -1058,8 +1058,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
this->Quiet);
std::vector<std::string> lines;
cmSystemTools::Split(output.c_str(), lines);
cmsys::SystemTools::Split(output, lines);
for (std::string const& line : lines) {
std::string sourceFile;
......@@ -1435,8 +1434,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
this->Quiet);
std::vector<std::string> lines;
cmSystemTools::Split(output.c_str(), lines);
cmsys::SystemTools::Split(output, lines);
for (std::string const& line : lines) {
std::string sourceFile;
......
......@@ -725,7 +725,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
cmsys::RegularExpression leakWarning("(Direct|Indirect) leak of .*");
int defects = 0;
std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines);
cmsys::SystemTools::Split(str, lines);
std::ostringstream ostr;
log.clear();
for (std::string const& l : lines) {
......@@ -755,7 +755,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
const std::string& str, std::string& log, std::vector<int>& results)
{
std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines);
cmsys::SystemTools::Split(str, lines);
std::ostringstream ostr;
log.clear();
......@@ -798,7 +798,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
const std::string& str, std::string& log, std::vector<int>& results)
{
std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines);
cmsys::SystemTools::Split(str, lines);
bool unlimitedOutput = false;
if (str.find("CTEST_FULL_OUTPUT") != std::string::npos ||
this->CustomMaximumFailedTestOutputSize == 0) {
......@@ -937,7 +937,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
log.clear();
auto sttime = std::chrono::steady_clock::now();
std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines);
cmsys::SystemTools::Split(str, lines);
cmCTestOptionalLog(this->CTest, DEBUG,
"Start test: " << lines.size() << std::endl, this->Quiet);
std::vector<std::string>::size_type cc;
......
This diff is collapsed.
......@@ -897,7 +897,7 @@ std::string cmSystemTools::PrintSingleCommand(
}
bool cmSystemTools::DoesFileExistWithExtensions(
const char* name, const std::vector<std::string>& headerExts)
const std::string& name, const std::vector<std::string>& headerExts)
{
std::string hname;
......@@ -912,9 +912,9 @@ bool cmSystemTools::DoesFileExistWithExtensions(
return false;
}
std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
const char* directory,
const char* toplevel)
std::string cmSystemTools::FileExistsInParentDirectories(
const std::string& fname, const std::string& directory,
const std::string& toplevel)
{
std::string file = fname;
cmSystemTools::ConvertToUnixSlashes(file);
......@@ -926,7 +926,7 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
if (cmSystemTools::FileExists(path)) {
return path;
}
if (dir.size() < strlen(toplevel)) {
if (dir.size() < toplevel.size()) {
break;
}
prevDir = dir;
......@@ -2081,7 +2081,8 @@ void cmSystemTools::DoNotInheritStdPipes()
#endif
}
bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile)
bool cmSystemTools::CopyFileTime(const std::string& fromFile,
const std::string& toFile)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
cmSystemToolsWindowsHandle hFrom = CreateFileW(
......@@ -2102,14 +2103,14 @@ bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile)
return SetFileTime(hTo, &timeCreation, &timeLastAccess, &timeLastWrite) != 0;
#else
struct stat fromStat;
if (stat(fromFile, &fromStat) < 0) {
if (stat(fromFile.c_str(), &fromStat) < 0) {
return false;
}
struct utimbuf buf;
buf.actime = fromStat.st_atime;
buf.modtime = fromStat.st_mtime;
return utime(toFile, &buf) >= 0;
return utime(toFile.c_str(), &buf) >= 0;
#endif
}
......@@ -2123,7 +2124,8 @@ void cmSystemTools::FileTimeDelete(cmSystemToolsFileTime* t)
delete t;
}
bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t)
bool cmSystemTools::FileTimeGet(const std::string& fname,
cmSystemToolsFileTime* t)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
cmSystemToolsWindowsHandle h = CreateFileW(
......@@ -2138,7 +2140,7 @@ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t)
}
#else
struct stat st;
if (stat(fname, &st) < 0) {
if (stat(fname.c_str(), &st) < 0) {
return false;
}
t->timeBuf.actime = st.st_atime;
......@@ -2147,7 +2149,8 @@ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t)
return true;
}
bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t)
bool cmSystemTools::FileTimeSet(const std::string& fname,
const cmSystemToolsFileTime* t)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
cmSystemToolsWindowsHandle h = CreateFileW(
......@@ -2159,7 +2162,7 @@ bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t)
return SetFileTime(h, &t->timeCreation, &t->timeLastAccess,
&t->timeLastWrite) != 0;
#else
return utime(fname, &t->timeBuf) >= 0;
return utime(fname.c_str(), &t->timeBuf) >= 0;
#endif
}
......
......@@ -144,16 +144,16 @@ public:
static bool IsPathToFramework(const char* value);
static bool DoesFileExistWithExtensions(
const char* name, const std::vector<std::string>& sourceExts);
const std::string& name, const std::vector<std::string>& sourceExts);
/**
* Check if the given file exists in one of the parent directory of the
* given file or directory and if it does, return the name of the file.
* Toplevel specifies the top-most directory to where it will look.
*/
static std::string FileExistsInParentDirectories(const char* fname,
const char* directory,
const char* toplevel);
static std::string FileExistsInParentDirectories(
const std::string& fname, const std::string& directory,
const std::string& toplevel);
static void Glob(const std::string& directory, const std::string& regexp,
std::vector<std::string>& files);
......@@ -443,13 +443,15 @@ public:
/** Copy the file create/access/modify times from the file named by
the first argument to that named by the second. */
static bool CopyFileTime(const char* fromFile, const char* toFile);
static bool CopyFileTime(const std::string& fromFile,
const std::string& toFile);
/** Save and restore file times. */
static cmSystemToolsFileTime* FileTimeNew();
static void FileTimeDelete(cmSystemToolsFileTime*);
static bool FileTimeGet(const char* fname, cmSystemToolsFileTime* t);
static bool FileTimeSet(const char* fname, cmSystemToolsFileTime* t);
static bool FileTimeGet(const std::string& fname, cmSystemToolsFileTime* t);
static bool FileTimeSet(const std::string& fname,
const cmSystemToolsFileTime* t);
/** Random seed generation. */
static unsigned int RandomSeed();
......
......@@ -1105,7 +1105,7 @@ std::string cmake::FindCacheFile(const std::string& binaryDir)
if (cmSystemTools::FileExists(cmakeFiles)) {
std::string cachePathFound =
cmSystemTools::FileExistsInParentDirectories("CMakeCache.txt",
cachePath.c_str(), "/");
cachePath, "/");
if (!cachePathFound.empty()) {
cachePath = cmSystemTools::GetFilenamePath(cachePathFound);
}
......
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