diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2018-08-07 13:01:25 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2018-08-07 15:02:39 (GMT) |
commit | b6802cd506cd459f94fae7e4cadc8b94daa09d59 (patch) | |
tree | a74ed3696e442cdb1bb08ee4c0f09263b8d19a71 | |
parent | a688defcc6e0195eefedd2cbc70ec5e40534f597 (diff) | |
download | CMake-b6802cd506cd459f94fae7e4cadc8b94daa09d59.zip CMake-b6802cd506cd459f94fae7e4cadc8b94daa09d59.tar.gz CMake-b6802cd506cd459f94fae7e4cadc8b94daa09d59.tar.bz2 |
cmGeneratedFileStream: clang-tidy applied to remove redundant ``c_str`` calls
After changing the ``cmGeneratedFileStream`` methods to accept
``std::string const&`` instead of ``const char*`` we don't
need to call ``std::string::c_str`` anymore when passing
a ``std::string`` to a ``cmGeneratedFileStream`` method.
This patch removes all redundant ``std::string::c_str``
calls when passing a string to a ``cmGeneratedFileStream`` method.
It was generated by building CMake with clang-tidy enabled using
the following options:
-DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy-4.0;-checks=-*,readability-redundant-string-cstr;-fix;-fix-errors
37 files changed, 87 insertions, 93 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index cf8334a..180c92e 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -90,7 +90,7 @@ int cmCPackIFWGenerator::PackageFiles() ifwCmd.c_str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, cmDuration::zero()); if (!res || retVal) { - cmGeneratedFileStream ofs(ifwTmpFile.c_str()); + cmGeneratedFileStream ofs(ifwTmpFile); ofs << "# Run command: " << ifwCmd << std::endl << "# Output:" << std::endl << output << std::endl; @@ -203,7 +203,7 @@ int cmCPackIFWGenerator::PackageFiles() ifwCmd.c_str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, cmDuration::zero()); if (!res || retVal) { - cmGeneratedFileStream ofs(ifwTmpFile.c_str()); + cmGeneratedFileStream ofs(ifwTmpFile); ofs << "# Run command: " << ifwCmd << std::endl << "# Output:" << std::endl << output << std::endl; diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 36cf08c..8f492af 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -306,7 +306,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile() } // Output stream - cmGeneratedFileStream fout((this->Directory + "/config/config.xml").data()); + cmGeneratedFileStream fout(this->Directory + "/config/config.xml"); cmXMLWriter xout(fout); xout.StartDocument(); diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index f24ab69..67e279c 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -528,7 +528,7 @@ void cmCPackIFWPackage::GeneratePackageFile() } // Output stream - cmGeneratedFileStream fout((this->Directory + "/meta/package.xml").data()); + cmGeneratedFileStream fout(this->Directory + "/meta/package.xml"); cmXMLWriter xout(fout); xout.StartDocument(); diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx index a01fc4e..987cad8 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.cxx +++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx @@ -183,7 +183,7 @@ bool cmCPackIFWRepository::PatchUpdatesXml() this->Directory + "/repository/UpdatesPatch.xml"; // Output stream - cmGeneratedFileStream fout(updatesPatchXml.data()); + cmGeneratedFileStream fout(updatesPatchXml); cmXMLWriter xout(fout); xout.StartDocument(); diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 593b4bf..ee1070f 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -103,7 +103,7 @@ int cmCPackArchiveGenerator::addOneComponentToArchive( */ #define DECLARE_AND_OPEN_ARCHIVE(filename, archive) \ cmGeneratedFileStream gf; \ - gf.Open((filename).c_str(), false, true); \ + gf.Open((filename), false, true); \ if (!GenerateHeader(&gf)) { \ cmCPackLogger(cmCPackLog::LOG_ERROR, \ "Problem to generate Header for archive <" \ diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index c53dd32..972fe6f 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -238,7 +238,7 @@ int cmCPackDebGenerator::createDeb() const std::string strGenWDIR(this->GetOption("GEN_WDIR")); const std::string dbfilename = strGenWDIR + "/debian-binary"; { // the scope is needed for cmGeneratedFileStream - cmGeneratedFileStream out(dbfilename.c_str()); + cmGeneratedFileStream out(dbfilename); out << "2.0"; out << std::endl; // required for valid debian package } @@ -287,7 +287,7 @@ int cmCPackDebGenerator::createDeb() this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE"); { // the scope is needed for cmGeneratedFileStream - cmGeneratedFileStream out(ctlfilename.c_str()); + cmGeneratedFileStream out(ctlfilename); out << "Package: " << debian_pkg_name << "\n"; out << "Version: " << debian_pkg_version << "\n"; out << "Section: " << debian_pkg_section << "\n"; @@ -347,7 +347,7 @@ int cmCPackDebGenerator::createDeb() const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") && debian_pkg_shlibs && *debian_pkg_shlibs; if (gen_shibs) { - cmGeneratedFileStream out(shlibsfilename.c_str()); + cmGeneratedFileStream out(shlibsfilename); out << debian_pkg_shlibs; out << std::endl; } @@ -355,7 +355,7 @@ int cmCPackDebGenerator::createDeb() const std::string postinst = strGenWDIR + "/postinst"; const std::string postrm = strGenWDIR + "/postrm"; if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) { - cmGeneratedFileStream out(postinst.c_str()); + cmGeneratedFileStream out(postinst); out << "#!/bin/sh\n\n" "set -e\n\n" "if [ \"$1\" = \"configure\" ]; then\n" @@ -363,7 +363,7 @@ int cmCPackDebGenerator::createDeb() "fi\n"; } if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) { - cmGeneratedFileStream out(postrm.c_str()); + cmGeneratedFileStream out(postrm); out << "#!/bin/sh\n\n" "set -e\n\n" "if [ \"$1\" = \"remove\" ]; then\n" @@ -412,7 +412,7 @@ int cmCPackDebGenerator::createDeb() // atomic file generation for data.tar { cmGeneratedFileStream fileStream_data_tar; - fileStream_data_tar.Open(filename_data_tar.c_str(), false, true); + fileStream_data_tar.Open(filename_data_tar, false, true); if (!fileStream_data_tar) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \"" @@ -493,7 +493,7 @@ int cmCPackDebGenerator::createDeb() std::string md5filename = strGenWDIR + "/md5sums"; { // the scope is needed for cmGeneratedFileStream - cmGeneratedFileStream out(md5filename.c_str()); + cmGeneratedFileStream out(md5filename); std::string topLevelWithTrailingSlash = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); @@ -528,7 +528,7 @@ int cmCPackDebGenerator::createDeb() // atomic file generation for control.tar { cmGeneratedFileStream fileStream_control_tar; - fileStream_control_tar.Open(filename_control_tar.c_str(), false, true); + fileStream_control_tar.Open(filename_control_tar, false, true); if (!fileStream_control_tar) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \"" << filename_control_tar @@ -662,7 +662,7 @@ int cmCPackDebGenerator::createDeb() std::string const outputPath = outputDir + "/" + outputName; std::string const tlDir = strGenWDIR + "/"; cmGeneratedFileStream debStream; - debStream.Open(outputPath.c_str(), false, true); + debStream.Open(outputPath, false, true); cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd"); // uid/gid should be the one of the root user, and this root user has diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 7014676..78af622 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -288,7 +288,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( if (!resB || retVal) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/InstallOutput.log"; - cmGeneratedFileStream ofs(tmpFile.c_str()); + cmGeneratedFileStream ofs(tmpFile); ofs << "# Run command: " << ic << std::endl << "# Output:" << std::endl << output << std::endl; @@ -660,7 +660,7 @@ int cmCPackGenerator::RunPreinstallTarget( if (!resB || retVal) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/PreinstallOutput.log"; - cmGeneratedFileStream ofs(tmpFile.c_str()); + cmGeneratedFileStream ofs(tmpFile); ofs << "# Run command: " << buildCommand << std::endl << "# Directory: " << installDirectory << std::endl << "# Output:" << std::endl diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index e46b2cf..f75a750 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -305,7 +305,7 @@ int cmCPackNSISGenerator::PackageFiles() nsisCmd.c_str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose, cmDuration::zero()); if (!res || retVal) { - cmGeneratedFileStream ofs(tmpFile.c_str()); + cmGeneratedFileStream ofs(tmpFile); ofs << "# Run command: " << nsisCmd << std::endl << "# Output:" << std::endl << output << std::endl; @@ -416,7 +416,7 @@ int cmCPackNSISGenerator::InitializeInternal() const char* topDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); std::string tmpFile = topDir ? topDir : "."; tmpFile += "/NSISOutput.log"; - cmGeneratedFileStream ofs(tmpFile.c_str()); + cmGeneratedFileStream ofs(tmpFile); ofs << "# Run command: " << nsisCmd << std::endl << "# Output:" << std::endl << output << std::endl; @@ -726,7 +726,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES")); unsigned long totalSize = 0; { // the scope is needed for cmGeneratedFileStream - cmGeneratedFileStream out(zipListFileName.c_str()); + cmGeneratedFileStream out(zipListFileName); for (std::string const& file : component->Files) { if (needQuotesInFile) { out << "\""; @@ -754,7 +754,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( if (!res || retVal) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/CompressZip.log"; - cmGeneratedFileStream ofs(tmpFile.c_str()); + cmGeneratedFileStream ofs(tmpFile); ofs << "# Run command: " << cmd << std::endl << "# Output:" << std::endl << output << std::endl; diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 8527d54..65844bd 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -742,7 +742,7 @@ void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig() // Give some testing configuration information to the launcher. std::string fname = this->Handler->CTestLaunchDir; fname += "/CTestLaunchConfig.cmake"; - cmGeneratedFileStream fout(fname.c_str()); + cmGeneratedFileStream fout(fname); std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory"); fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n"; } @@ -757,7 +757,7 @@ void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers( fname += "/Custom"; fname += purpose; fname += ".txt"; - cmGeneratedFileStream fout(fname.c_str()); + cmGeneratedFileStream fout(fname); for (std::string const& m : matchers) { fout << m << "\n"; } diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 0bffde3..09addeb 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -345,7 +345,7 @@ void cmCTestLaunch::WriteXML() logXML += ".xml"; // Use cmGeneratedFileStream to atomically create the report file. - cmGeneratedFileStream fxml(logXML.c_str()); + cmGeneratedFileStream fxml(logXML); cmXMLWriter xml(fxml, 2); cmXMLElement e2(xml, "Failure"); e2.Attribute("type", this->IsError() ? "Error" : "Warning"); diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 333c899..6b62bb4 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -792,7 +792,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Write CMake output to file: " << cmakeOutputFile << std::endl); - cmGeneratedFileStream fout(cmakeOutputFile.c_str()); + cmGeneratedFileStream fout(cmakeOutputFile); if (fout) { fout << output.c_str(); } else { @@ -856,7 +856,7 @@ bool cmCTestScriptHandler::WriteInitialCache(const char* directory, { std::string cacheFile = directory; cacheFile += "/CMakeCache.txt"; - cmGeneratedFileStream fout(cacheFile.c_str()); + cmGeneratedFileStream fout(cacheFile); if (!fout) { return false; } diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 3911540..47006c1 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -121,7 +121,7 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args, // Log startup actions. std::string startLogFile = binaryDir + "/Testing/Temporary/LastStart.log"; - cmGeneratedFileStream ofs(startLogFile.c_str()); + cmGeneratedFileStream ofs(startLogFile); if (!ofs) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create log file: LastStart.log" << std::endl); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 95edd8b..3d3d526 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -818,7 +818,7 @@ bool cmCTest::OpenOutputFile(const std::string& path, const std::string& name, } } std::string filename = testingDir + "/" + name; - stream.Open(filename.c_str()); + stream.Open(filename); if (!stream) { cmCTestLog(this, ERROR_MESSAGE, "Problem opening file: " << filename << std::endl); diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index c6a1cff..5091c97 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -234,7 +234,7 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger) { std::string cacheFile = path; cacheFile += "/CMakeCache.txt"; - cmGeneratedFileStream fout(cacheFile.c_str()); + cmGeneratedFileStream fout(cacheFile); fout.SetCopyIfDifferent(true); if (!fout) { cmSystemTools::Error("Unable to open cache file for save. ", diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index dbea15a..a04cee7 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -178,7 +178,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, // Store the list of modules provided by this target. std::string fiName = this->TargetDirectory; fiName += "/fortran.internal"; - cmGeneratedFileStream fiStream(fiName.c_str()); + cmGeneratedFileStream fiStream(fiName); fiStream << "# The fortran modules provided by this target.\n"; fiStream << "provides\n"; std::set<std::string> const& provides = this->Internal->TargetProvides; @@ -190,7 +190,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, if (!provides.empty()) { std::string fcName = this->TargetDirectory; fcName += "/cmake_clean_Fortran.cmake"; - cmGeneratedFileStream fcStream(fcName.c_str()); + cmGeneratedFileStream fcStream(fcName); fcStream << "# Remove fortran modules provided by this target.\n"; fcStream << "FILE(REMOVE"; std::string currentBinDir = diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 4e1d771..7d5c4f8 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -339,7 +339,7 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package, fname += "/"; fname += hash; if (!cmSystemTools::FileExists(fname)) { - cmGeneratedFileStream entry(fname.c_str(), true); + cmGeneratedFileStream entry(fname, true); if (entry) { entry << content << "\n"; } else { diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index ec68fce..002fae6 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -75,7 +75,7 @@ bool cmExportFileGenerator::GenerateImportFile() } else { // Generate atomically and with copy-if-different. std::unique_ptr<cmGeneratedFileStream> ap( - new cmGeneratedFileStream(this->MainImportFile.c_str(), true)); + new cmGeneratedFileStream(this->MainImportFile, true)); ap->SetCopyIfDifferent(true); foutPtr = std::move(ap); } diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 3595708..bfb7a05 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -288,7 +288,7 @@ bool cmExportInstallFileGenerator::GenerateImportFileConfig( fileName += this->FileExt; // Open the output file to generate it. - cmGeneratedFileStream exportFileStream(fileName.c_str(), true); + cmGeneratedFileStream exportFileStream(fileName, true); if (!exportFileStream) { std::string se = cmSystemTools::GetLastSystemError(); std::ostringstream e; diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index 50f8cb0..b4b2962 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -54,7 +54,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), std::ios::app); } else { std::unique_ptr<cmGeneratedFileStream> ap( - new cmGeneratedFileStream(this->Filename.c_str(), true)); + new cmGeneratedFileStream(this->Filename, true)); ap->SetCopyIfDifferent(true); foutPtr = std::move(ap); } diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index b636c73..fbf6560 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -199,7 +199,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( const std::vector<cmLocalGenerator*>& lgs, const std::string& filename) { const cmMakefile* mf = lgs[0]->GetMakefile(); - cmGeneratedFileStream fout(filename.c_str()); + cmGeneratedFileStream fout(filename); if (!fout) { return; } @@ -476,7 +476,7 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile( filename += "/"; filename += target->GetName(); filename += ".objlib"; - cmGeneratedFileStream fout(filename.c_str()); + cmGeneratedFileStream fout(filename); if (fout) { /* clang-format off */ fout << "# This is a dummy file for the OBJECT library " diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index b76efb2..582a2e7 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -77,7 +77,7 @@ void cmExtraCodeLiteGenerator::Generate() } } - cmGeneratedFileStream fout(workspaceFileName.c_str()); + cmGeneratedFileStream fout(workspaceFileName); cmXMLWriter xml(fout); xml.StartDocument("utf-8"); @@ -249,7 +249,7 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile( const std::vector<cmLocalGenerator*>& lgs, const std::string& filename) { const cmMakefile* mf = lgs[0]->GetMakefile(); - cmGeneratedFileStream fout(filename.c_str()); + cmGeneratedFileStream fout(filename); if (!fout) { return; } @@ -547,7 +547,7 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile( const cmGeneratorTarget* gt, const std::string& filename) { const cmMakefile* mf = gt->Makefile; - cmGeneratedFileStream fout(filename.c_str()); + cmGeneratedFileStream fout(filename); if (!fout) { return; } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 14448f5..0958e99 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -176,7 +176,7 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() this->GetPathBasename(this->HomeDirectory)); const std::string filename = this->HomeDirectory + "/.project"; - cmGeneratedFileStream fout(filename.c_str()); + cmGeneratedFileStream fout(filename); if (!fout) { return; } @@ -261,7 +261,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() const std::string filename = this->HomeOutputDirectory + "/.project"; - cmGeneratedFileStream fout(filename.c_str()); + cmGeneratedFileStream fout(filename); if (!fout) { return; } @@ -582,7 +582,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const const std::string filename = this->HomeOutputDirectory + "/.cproject"; - cmGeneratedFileStream fout(filename.c_str()); + cmGeneratedFileStream fout(filename); if (!fout) { return; } diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index df18715..f5c4c93 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -58,7 +58,7 @@ void cmExtraKateGenerator::CreateKateProjectFile( { std::string filename = lg->GetBinaryDirectory(); filename += "/.kateproject"; - cmGeneratedFileStream fout(filename.c_str()); + cmGeneratedFileStream fout(filename); if (!fout) { return; } @@ -215,7 +215,7 @@ void cmExtraKateGenerator::CreateDummyKateProjectFile( filename += "/"; filename += this->ProjectName; filename += ".kateproject"; - cmGeneratedFileStream fout(filename.c_str()); + cmGeneratedFileStream fout(filename); if (!fout) { return; } diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index fb85a68..14e7927 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -91,7 +91,7 @@ void cmExtraSublimeTextGenerator::CreateNewProjectFile( { const cmMakefile* mf = lgs[0]->GetMakefile(); - cmGeneratedFileStream fout(filename.c_str()); + cmGeneratedFileStream fout(filename); if (!fout) { return; } diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 95132e7..186ec8c 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -168,12 +168,12 @@ bool cmGeneratedFileStreamBase::Close() // destination atomically. if (this->Compress) { std::string gzname = this->TempName + ".temp.gz"; - if (this->CompressFile(this->TempName.c_str(), gzname.c_str())) { - this->RenameFile(gzname.c_str(), resname.c_str()); + if (this->CompressFile(this->TempName, gzname)) { + this->RenameFile(gzname, resname); } cmSystemTools::RemoveFile(gzname); } else { - this->RenameFile(this->TempName.c_str(), resname.c_str()); + this->RenameFile(this->TempName, resname); } replaced = true; diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 99b9261..a094fa5 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -85,7 +85,7 @@ void cmGeneratorExpressionEvaluationFile::Generate( this->Files.push_back(outputFileName); outputFiles[outputFileName] = outputContent; - cmGeneratedFileStream fout(outputFileName.c_str()); + cmGeneratedFileStream fout(outputFileName); fout.SetCopyIfDifferent(true); fout << outputContent; if (fout.Close() && perm) { diff --git a/Source/cmGlobVerificationManager.cxx b/Source/cmGlobVerificationManager.cxx index e23b6ea..d8c854c 100644 --- a/Source/cmGlobVerificationManager.cxx +++ b/Source/cmGlobVerificationManager.cxx @@ -23,7 +23,7 @@ bool cmGlobVerificationManager::SaveVerificationScript(const std::string& path) cmSystemTools::MakeDirectory(scriptFile); scriptFile += "/VerifyGlobs.cmake"; stampFile += "/cmake.verify_globs"; - cmGeneratedFileStream verifyScriptFile(scriptFile.c_str()); + cmGeneratedFileStream verifyScriptFile(scriptFile); verifyScriptFile.SetCopyIfDifferent(true); if (!verifyScriptFile) { cmSystemTools::Error("Unable to open verification script file for save. ", diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 58821c2..324b56a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2904,7 +2904,7 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile) if (this->RuleHashes.empty()) { cmSystemTools::RemoveFile(pfile); } else { - cmGeneratedFileStream fout(pfile.c_str()); + cmGeneratedFileStream fout(pfile); fout << "# Hashes of file build rules.\n"; for (auto const& rh : this->RuleHashes) { fout.write(rh.second.Data, 32); @@ -2919,7 +2919,7 @@ void cmGlobalGenerator::WriteSummary() std::string fname = this->CMakeInstance->GetHomeOutputDirectory(); fname += cmake::GetCMakeFilesDirectory(); fname += "/TargetDirectories.txt"; - cmGeneratedFileStream fout(fname.c_str()); + cmGeneratedFileStream fout(fname); for (cmLocalGenerator* lg : this->LocalGenerators) { const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets(); @@ -2956,7 +2956,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) Json::Value& lj_sources = lj_root["sources"] = Json::arrayValue; cmSystemTools::MakeDirectory(dir); - cmGeneratedFileStream fout(file.c_str()); + cmGeneratedFileStream fout(file); std::vector<std::string> labels; @@ -3030,7 +3030,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) } } } - cmGeneratedFileStream json_fout(json_file.c_str()); + cmGeneratedFileStream json_fout(json_file); json_fout << lj_root; } else #endif @@ -3105,7 +3105,7 @@ bool cmGlobalGenerator::GenerateCPackPropertiesFile() return true; } - cmGeneratedFileStream file(path.c_str()); + cmGeneratedFileStream file(path); file << "# CPack properties\n"; for (auto const& i : installedFiles) { diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 6f7e82a..8ba38df 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -763,7 +763,7 @@ void cmGlobalNinjaGenerator::OpenBuildFileStream() // Get a stream where to generate things. if (!this->BuildFileStream) { this->BuildFileStream = new cmGeneratedFileStream( - buildFilePath.c_str(), false, this->GetMakefileEncoding()); + buildFilePath, false, this->GetMakefileEncoding()); if (!this->BuildFileStream) { // An error message is generated by the constructor if it cannot // open the file. @@ -801,7 +801,7 @@ void cmGlobalNinjaGenerator::OpenRulesFileStream() // Get a stream where to generate things. if (!this->RulesFileStream) { this->RulesFileStream = new cmGeneratedFileStream( - rulesFilePath.c_str(), false, this->GetMakefileEncoding()); + rulesFilePath, false, this->GetMakefileEncoding()); if (!this->RulesFileStream) { // An error message is generated by the constructor if it cannot // open the file. @@ -883,8 +883,7 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand( } // Get a stream where to generate things. - this->CompileCommandsStream = - new cmGeneratedFileStream(buildFilePath.c_str()); + this->CompileCommandsStream = new cmGeneratedFileStream(buildFilePath); *this->CompileCommandsStream << "["; } else { *this->CompileCommandsStream << "," << std::endl; @@ -1700,7 +1699,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg, } { - cmGeneratedFileStream depfile(arg_dep.c_str()); + cmGeneratedFileStream depfile(arg_dep); depfile << cmSystemTools::ConvertToUnixOutputPath(arg_pp) << ":"; for (std::string const& include : info.Includes) { depfile << " \\\n " << cmSystemTools::ConvertToUnixOutputPath(include); @@ -1723,7 +1722,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg, } } - cmGeneratedFileStream ddif(arg_ddi.c_str()); + cmGeneratedFileStream ddif(arg_ddi); ddif << ddi; if (!ddif) { cmSystemTools::Error("-E cmake_ninja_depends failed to write ", @@ -1827,7 +1826,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( } } - cmGeneratedFileStream ddf(arg_dd.c_str()); + cmGeneratedFileStream ddf(arg_dd); ddf << "ninja_dyndep_version = 1.0\n"; for (cmFortranObjectInfo const& object : objects) { @@ -1862,7 +1861,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( // use by dependents that reference this target in linked-target-dirs. std::string const target_mods_file = cmSystemTools::GetFilenamePath(arg_dd) + "/FortranModules.json"; - cmGeneratedFileStream tmf(target_mods_file.c_str()); + cmGeneratedFileStream tmf(target_mods_file); tmf << tm; return true; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 61c42be..db72353 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -147,7 +147,7 @@ void cmGlobalUnixMakefileGenerator3::Generate() markFileName += "/"; markFileName += cmake::GetCMakeFilesDirectory(); markFileName += "/progress.marks"; - cmGeneratedFileStream markFile(markFileName.c_str()); + cmGeneratedFileStream markFile(markFileName); markFile << this->CountProgressMarksInAll(lg) << "\n"; } @@ -170,8 +170,7 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand( std::string commandDatabaseName = std::string(this->GetCMakeInstance()->GetHomeOutputDirectory()) + "/compile_commands.json"; - this->CommandDatabase = - new cmGeneratedFileStream(commandDatabaseName.c_str()); + this->CommandDatabase = new cmGeneratedFileStream(commandDatabaseName); *this->CommandDatabase << "[" << std::endl; } else { *this->CommandDatabase << "," << std::endl; @@ -198,7 +197,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2() this->GetCMakeInstance()->GetHomeOutputDirectory(); makefileName += cmake::GetCMakeFilesDirectory(); makefileName += "/Makefile2"; - cmGeneratedFileStream makefileStream(makefileName.c_str(), false, + cmGeneratedFileStream makefileStream(makefileName, false, this->GetMakefileEncoding()); if (!makefileStream) { return; @@ -270,7 +269,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() this->GetCMakeInstance()->GetHomeOutputDirectory(); cmakefileName += cmake::GetCMakeFilesDirectory(); cmakefileName += "/Makefile.cmake"; - cmGeneratedFileStream cmakefileStream(cmakefileName.c_str()); + cmGeneratedFileStream cmakefileStream(cmakefileName); if (!cmakefileStream) { return; } @@ -876,7 +875,7 @@ void cmGlobalUnixMakefileGenerator3::RecordTargetProgress( void cmGlobalUnixMakefileGenerator3::TargetProgress::WriteProgressVariables( unsigned long total, unsigned long& current) { - cmGeneratedFileStream fout(this->VariableFile.c_str()); + cmGeneratedFileStream fout(this->VariableFile); for (unsigned long i = 1; i <= this->NumberOfActions; ++i) { fout << "CMAKE_PROGRESS_" << i << " = "; if (total <= 100) { diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 1bbfbe0..fcdf03f 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -257,7 +257,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName) currentFilename += ptr.first; currentFilename += ".dependers"; - cmGeneratedFileStream str(currentFilename.c_str()); + cmGeneratedFileStream str(currentFilename); if (!str) { return; } @@ -300,7 +300,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName) std::string currentFilename = fileName; currentFilename += "."; currentFilename += ptr.first; - cmGeneratedFileStream str(currentFilename.c_str()); + cmGeneratedFileStream str(currentFilename); if (!str) { return; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a669477..2660791 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -253,7 +253,7 @@ void cmLocalGenerator::GenerateTestFiles() file += "/"; file += "CTestTestfile.cmake"; - cmGeneratedFileStream fout(file.c_str()); + cmGeneratedFileStream fout(file); fout.SetCopyIfDifferent(true); fout << "# CMake generated Testfile for " << std::endl @@ -429,7 +429,7 @@ void cmLocalGenerator::GenerateInstallRules() toplevel_install = 1; } file += "/cmake_install.cmake"; - cmGeneratedFileStream fout(file.c_str()); + cmGeneratedFileStream fout(file); fout.SetCopyIfDifferent(true); // Write the header. diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 9fd2ddb..bc83ce2 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -211,8 +211,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() // rules may depend on this file itself. std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); cmGeneratedFileStream ruleFileStream( - ruleFileNameFull.c_str(), false, - this->GlobalGenerator->GetMakefileEncoding()); + ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding()); if (!ruleFileStream) { return; } @@ -433,7 +432,7 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() infoFileName += "/CMakeDirectoryInformation.cmake"; // Open the output file. - cmGeneratedFileStream infoFileStream(infoFileName.c_str()); + cmGeneratedFileStream infoFileStream(infoFileName); if (!infoFileStream) { return; } @@ -1403,8 +1402,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( std::string ruleFileNameFull = dir; ruleFileNameFull += "/depend.make"; cmGeneratedFileStream ruleFileStream( - ruleFileNameFull.c_str(), false, - this->GlobalGenerator->GetMakefileEncoding()); + ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding()); ruleFileStream.SetCopyIfDifferent(true); if (!ruleFileStream) { return false; @@ -1416,7 +1414,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( std::string internalRuleFileNameFull = dir; internalRuleFileNameFull += "/depend.internal"; cmGeneratedFileStream internalRuleFileStream( - internalRuleFileNameFull.c_str(), false, + internalRuleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding()); if (!internalRuleFileStream) { return false; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 7cae305..79baca6 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -124,7 +124,7 @@ void cmMakefileTargetGenerator::CreateRuleFile() // Open the rule file. This should be copy-if-different because the // rules may depend on this file itself. this->BuildFileStream = - new cmGeneratedFileStream(this->BuildFileNameFull.c_str(), false, + new cmGeneratedFileStream(this->BuildFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding()); this->BuildFileStream->SetCopyIfDifferent(true); if (!this->BuildFileStream) { @@ -237,8 +237,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() if (!cmSystemTools::FileExists(dependFileNameFull)) { // Write an empty dependency file. cmGeneratedFileStream depFileStream( - dependFileNameFull.c_str(), false, - this->GlobalGenerator->GetMakefileEncoding()); + dependFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding()); depFileStream << "# Empty dependencies file for " << this->GeneratorTarget->GetName() << ".\n" << "# This may be replaced when dependencies are built." @@ -250,7 +249,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() this->FlagFileNameFull = this->TargetBuildDirectoryFull; this->FlagFileNameFull += "/flags.make"; this->FlagFileStream = - new cmGeneratedFileStream(this->FlagFileNameFull.c_str(), false, + new cmGeneratedFileStream(this->FlagFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding()); this->FlagFileStream->SetCopyIfDifferent(true); if (!this->FlagFileStream) { @@ -974,8 +973,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() this->InfoFileNameFull += "/DependInfo.cmake"; this->InfoFileNameFull = this->LocalGenerator->ConvertToFullPath(this->InfoFileNameFull); - this->InfoFileStream = - new cmGeneratedFileStream(this->InfoFileNameFull.c_str()); + this->InfoFileStream = new cmGeneratedFileStream(this->InfoFileNameFull); this->InfoFileStream->SetCopyIfDifferent(true); if (!*this->InfoFileStream) { return; @@ -1446,7 +1444,7 @@ void cmMakefileTargetGenerator::CreateLinkScript( std::string linkScriptName = this->TargetBuildDirectoryFull; linkScriptName += "/"; linkScriptName += name; - cmGeneratedFileStream linkScriptStream(linkScriptName.c_str()); + cmGeneratedFileStream linkScriptStream(linkScriptName); linkScriptStream.SetCopyIfDifferent(true); for (std::string const& link_command : link_commands) { // Do not write out empty commands or commands beginning in the @@ -1530,7 +1528,7 @@ std::string cmMakefileTargetGenerator::CreateResponseFile( std::string responseFileNameFull = this->TargetBuildDirectoryFull; responseFileNameFull += "/"; responseFileNameFull += name; - cmGeneratedFileStream responseStream(responseFileNameFull.c_str()); + cmGeneratedFileStream responseStream(responseFileNameFull); responseStream.SetCopyIfDifferent(true); responseStream << options << "\n"; @@ -1718,7 +1716,7 @@ void cmMakefileTargetGenerator::GenDefFile( cmOutputConverter::SHELL); real_link_commands.insert(real_link_commands.begin(), cmd); // create a list of obj files for the -E __create_def to read - cmGeneratedFileStream fout(objlist_file.c_str()); + cmGeneratedFileStream fout(objlist_file); if (mdi->WindowsExportAllSymbols) { for (std::string const& obj : this->Objects) { diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index f94e5bc..b634b0a 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -956,7 +956,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() preLinkCmdLines.push_back(std::move(cmd)); // create a list of obj files for the -E __create_def to read - cmGeneratedFileStream fout(obj_list_file.c_str()); + cmGeneratedFileStream fout(obj_list_file); if (mdi->WindowsExportAllSymbols) { cmNinjaDeps objs = this->GetObjects(); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index df32f40..1cfaac5 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1133,7 +1133,7 @@ void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang) } std::string const tdin = this->GetTargetDependInfoPath(lang); - cmGeneratedFileStream tdif(tdin.c_str()); + cmGeneratedFileStream tdif(tdin); tdif << tdi; } diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 7cfdeba..72ae09a 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1076,7 +1076,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() cmGeneratedFileStream ofs; ofs.SetCopyIfDifferent(true); - ofs.Open(this->AutogenInfoFile.c_str(), false, true); + ofs.Open(this->AutogenInfoFile, false, true); if (ofs) { // Utility lambdas auto CWrite = [&ofs](const char* key, std::string const& value) { @@ -1183,7 +1183,7 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo() for (Qrc const& qrc : this->Rcc.Qrcs) { cmGeneratedFileStream ofs; ofs.SetCopyIfDifferent(true); - ofs.Open(qrc.InfoFile.c_str(), false, true); + ofs.Open(qrc.InfoFile, false, true); if (ofs) { // Utility lambdas auto CWrite = [&ofs](const char* key, std::string const& value) { |