Просмотр исходного кода

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
Sebastian Holtermann 7 лет назад
Родитель
Сommit
b6802cd506
37 измененных файлов с 87 добавлено и 93 удалено
  1. 2 2
      Source/CPack/IFW/cmCPackIFWGenerator.cxx
  2. 1 1
      Source/CPack/IFW/cmCPackIFWInstaller.cxx
  3. 1 1
      Source/CPack/IFW/cmCPackIFWPackage.cxx
  4. 1 1
      Source/CPack/IFW/cmCPackIFWRepository.cxx
  5. 1 1
      Source/CPack/cmCPackArchiveGenerator.cxx
  6. 9 9
      Source/CPack/cmCPackDebGenerator.cxx
  7. 2 2
      Source/CPack/cmCPackGenerator.cxx
  8. 4 4
      Source/CPack/cmCPackNSISGenerator.cxx
  9. 2 2
      Source/CTest/cmCTestBuildHandler.cxx
  10. 1 1
      Source/CTest/cmCTestLaunch.cxx
  11. 2 2
      Source/CTest/cmCTestScriptHandler.cxx
  12. 1 1
      Source/CTest/cmCTestStartCommand.cxx
  13. 1 1
      Source/cmCTest.cxx
  14. 1 1
      Source/cmCacheManager.cxx
  15. 2 2
      Source/cmDependsFortran.cxx
  16. 1 1
      Source/cmExportCommand.cxx
  17. 1 1
      Source/cmExportFileGenerator.cxx
  18. 1 1
      Source/cmExportInstallFileGenerator.cxx
  19. 1 1
      Source/cmExportLibraryDependenciesCommand.cxx
  20. 2 2
      Source/cmExtraCodeBlocksGenerator.cxx
  21. 3 3
      Source/cmExtraCodeLiteGenerator.cxx
  22. 3 3
      Source/cmExtraEclipseCDT4Generator.cxx
  23. 2 2
      Source/cmExtraKateGenerator.cxx
  24. 1 1
      Source/cmExtraSublimeTextGenerator.cxx
  25. 3 3
      Source/cmGeneratedFileStream.cxx
  26. 1 1
      Source/cmGeneratorExpressionEvaluationFile.cxx
  27. 1 1
      Source/cmGlobVerificationManager.cxx
  28. 5 5
      Source/cmGlobalGenerator.cxx
  29. 7 8
      Source/cmGlobalNinjaGenerator.cxx
  30. 5 6
      Source/cmGlobalUnixMakefileGenerator3.cxx
  31. 2 2
      Source/cmGraphVizWriter.cxx
  32. 2 2
      Source/cmLocalGenerator.cxx
  33. 4 6
      Source/cmLocalUnixMakefileGenerator3.cxx
  34. 7 9
      Source/cmMakefileTargetGenerator.cxx
  35. 1 1
      Source/cmNinjaNormalTargetGenerator.cxx
  36. 1 1
      Source/cmNinjaTargetGenerator.cxx
  37. 2 2
      Source/cmQtAutoGenInitializer.cxx

+ 2 - 2
Source/CPack/IFW/cmCPackIFWGenerator.cxx

@@ -90,7 +90,7 @@ int cmCPackIFWGenerator::PackageFiles()
       ifwCmd.c_str(), &output, &output, &retVal, nullptr,
       ifwCmd.c_str(), &output, &output, &retVal, nullptr,
       this->GeneratorVerbose, cmDuration::zero());
       this->GeneratorVerbose, cmDuration::zero());
     if (!res || retVal) {
     if (!res || retVal) {
-      cmGeneratedFileStream ofs(ifwTmpFile.c_str());
+      cmGeneratedFileStream ofs(ifwTmpFile);
       ofs << "# Run command: " << ifwCmd << std::endl
       ofs << "# Run command: " << ifwCmd << std::endl
           << "# Output:" << std::endl
           << "# Output:" << std::endl
           << output << std::endl;
           << output << std::endl;
@@ -203,7 +203,7 @@ int cmCPackIFWGenerator::PackageFiles()
       ifwCmd.c_str(), &output, &output, &retVal, nullptr,
       ifwCmd.c_str(), &output, &output, &retVal, nullptr,
       this->GeneratorVerbose, cmDuration::zero());
       this->GeneratorVerbose, cmDuration::zero());
     if (!res || retVal) {
     if (!res || retVal) {
-      cmGeneratedFileStream ofs(ifwTmpFile.c_str());
+      cmGeneratedFileStream ofs(ifwTmpFile);
       ofs << "# Run command: " << ifwCmd << std::endl
       ofs << "# Run command: " << ifwCmd << std::endl
           << "# Output:" << std::endl
           << "# Output:" << std::endl
           << output << std::endl;
           << output << std::endl;

+ 1 - 1
Source/CPack/IFW/cmCPackIFWInstaller.cxx

@@ -306,7 +306,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
   }
   }
 
 
   // Output stream
   // Output stream
-  cmGeneratedFileStream fout((this->Directory + "/config/config.xml").data());
+  cmGeneratedFileStream fout(this->Directory + "/config/config.xml");
   cmXMLWriter xout(fout);
   cmXMLWriter xout(fout);
 
 
   xout.StartDocument();
   xout.StartDocument();

+ 1 - 1
Source/CPack/IFW/cmCPackIFWPackage.cxx

@@ -528,7 +528,7 @@ void cmCPackIFWPackage::GeneratePackageFile()
   }
   }
 
 
   // Output stream
   // Output stream
-  cmGeneratedFileStream fout((this->Directory + "/meta/package.xml").data());
+  cmGeneratedFileStream fout(this->Directory + "/meta/package.xml");
   cmXMLWriter xout(fout);
   cmXMLWriter xout(fout);
 
 
   xout.StartDocument();
   xout.StartDocument();

+ 1 - 1
Source/CPack/IFW/cmCPackIFWRepository.cxx

@@ -183,7 +183,7 @@ bool cmCPackIFWRepository::PatchUpdatesXml()
     this->Directory + "/repository/UpdatesPatch.xml";
     this->Directory + "/repository/UpdatesPatch.xml";
 
 
   // Output stream
   // Output stream
-  cmGeneratedFileStream fout(updatesPatchXml.data());
+  cmGeneratedFileStream fout(updatesPatchXml);
   cmXMLWriter xout(fout);
   cmXMLWriter xout(fout);
 
 
   xout.StartDocument();
   xout.StartDocument();

+ 1 - 1
Source/CPack/cmCPackArchiveGenerator.cxx

@@ -103,7 +103,7 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
  */
  */
 #define DECLARE_AND_OPEN_ARCHIVE(filename, archive)                           \
 #define DECLARE_AND_OPEN_ARCHIVE(filename, archive)                           \
   cmGeneratedFileStream gf;                                                   \
   cmGeneratedFileStream gf;                                                   \
-  gf.Open((filename).c_str(), false, true);                                   \
+  gf.Open((filename), false, true);                                           \
   if (!GenerateHeader(&gf)) {                                                 \
   if (!GenerateHeader(&gf)) {                                                 \
     cmCPackLogger(cmCPackLog::LOG_ERROR,                                      \
     cmCPackLogger(cmCPackLog::LOG_ERROR,                                      \
                   "Problem to generate Header for archive <"                  \
                   "Problem to generate Header for archive <"                  \

+ 9 - 9
Source/CPack/cmCPackDebGenerator.cxx

@@ -238,7 +238,7 @@ int cmCPackDebGenerator::createDeb()
   const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
   const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
   const std::string dbfilename = strGenWDIR + "/debian-binary";
   const std::string dbfilename = strGenWDIR + "/debian-binary";
   { // the scope is needed for cmGeneratedFileStream
   { // the scope is needed for cmGeneratedFileStream
-    cmGeneratedFileStream out(dbfilename.c_str());
+    cmGeneratedFileStream out(dbfilename);
     out << "2.0";
     out << "2.0";
     out << std::endl; // required for valid debian package
     out << std::endl; // required for valid debian package
   }
   }
@@ -287,7 +287,7 @@ int cmCPackDebGenerator::createDeb()
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
 
 
   { // the scope is needed for cmGeneratedFileStream
   { // the scope is needed for cmGeneratedFileStream
-    cmGeneratedFileStream out(ctlfilename.c_str());
+    cmGeneratedFileStream out(ctlfilename);
     out << "Package: " << debian_pkg_name << "\n";
     out << "Package: " << debian_pkg_name << "\n";
     out << "Version: " << debian_pkg_version << "\n";
     out << "Version: " << debian_pkg_version << "\n";
     out << "Section: " << debian_pkg_section << "\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") &&
   const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") &&
     debian_pkg_shlibs && *debian_pkg_shlibs;
     debian_pkg_shlibs && *debian_pkg_shlibs;
   if (gen_shibs) {
   if (gen_shibs) {
-    cmGeneratedFileStream out(shlibsfilename.c_str());
+    cmGeneratedFileStream out(shlibsfilename);
     out << debian_pkg_shlibs;
     out << debian_pkg_shlibs;
     out << std::endl;
     out << std::endl;
   }
   }
@@ -355,7 +355,7 @@ int cmCPackDebGenerator::createDeb()
   const std::string postinst = strGenWDIR + "/postinst";
   const std::string postinst = strGenWDIR + "/postinst";
   const std::string postrm = strGenWDIR + "/postrm";
   const std::string postrm = strGenWDIR + "/postrm";
   if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
   if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
-    cmGeneratedFileStream out(postinst.c_str());
+    cmGeneratedFileStream out(postinst);
     out << "#!/bin/sh\n\n"
     out << "#!/bin/sh\n\n"
            "set -e\n\n"
            "set -e\n\n"
            "if [ \"$1\" = \"configure\" ]; then\n"
            "if [ \"$1\" = \"configure\" ]; then\n"
@@ -363,7 +363,7 @@ int cmCPackDebGenerator::createDeb()
            "fi\n";
            "fi\n";
   }
   }
   if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
   if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
-    cmGeneratedFileStream out(postrm.c_str());
+    cmGeneratedFileStream out(postrm);
     out << "#!/bin/sh\n\n"
     out << "#!/bin/sh\n\n"
            "set -e\n\n"
            "set -e\n\n"
            "if [ \"$1\" = \"remove\" ]; then\n"
            "if [ \"$1\" = \"remove\" ]; then\n"
@@ -412,7 +412,7 @@ int cmCPackDebGenerator::createDeb()
   // atomic file generation for data.tar
   // atomic file generation for data.tar
   {
   {
     cmGeneratedFileStream fileStream_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) {
     if (!fileStream_data_tar) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
       cmCPackLogger(cmCPackLog::LOG_ERROR,
                     "Error opening the file \""
                     "Error opening the file \""
@@ -493,7 +493,7 @@ int cmCPackDebGenerator::createDeb()
   std::string md5filename = strGenWDIR + "/md5sums";
   std::string md5filename = strGenWDIR + "/md5sums";
   {
   {
     // the scope is needed for cmGeneratedFileStream
     // the scope is needed for cmGeneratedFileStream
-    cmGeneratedFileStream out(md5filename.c_str());
+    cmGeneratedFileStream out(md5filename);
 
 
     std::string topLevelWithTrailingSlash =
     std::string topLevelWithTrailingSlash =
       this->GetOption("CPACK_TEMPORARY_DIRECTORY");
       this->GetOption("CPACK_TEMPORARY_DIRECTORY");
@@ -528,7 +528,7 @@ int cmCPackDebGenerator::createDeb()
   // atomic file generation for control.tar
   // atomic file generation for control.tar
   {
   {
     cmGeneratedFileStream fileStream_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) {
     if (!fileStream_control_tar) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
       cmCPackLogger(cmCPackLog::LOG_ERROR,
                     "Error opening the file \"" << filename_control_tar
                     "Error opening the file \"" << filename_control_tar
@@ -662,7 +662,7 @@ int cmCPackDebGenerator::createDeb()
   std::string const outputPath = outputDir + "/" + outputName;
   std::string const outputPath = outputDir + "/" + outputName;
   std::string const tlDir = strGenWDIR + "/";
   std::string const tlDir = strGenWDIR + "/";
   cmGeneratedFileStream debStream;
   cmGeneratedFileStream debStream;
-  debStream.Open(outputPath.c_str(), false, true);
+  debStream.Open(outputPath, false, true);
   cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd");
   cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd");
 
 
   // uid/gid should be the one of the root user, and this root user has
   // uid/gid should be the one of the root user, and this root user has

+ 2 - 2
Source/CPack/cmCPackGenerator.cxx

@@ -288,7 +288,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
       if (!resB || retVal) {
       if (!resB || retVal) {
         std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
         std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
         tmpFile += "/InstallOutput.log";
         tmpFile += "/InstallOutput.log";
-        cmGeneratedFileStream ofs(tmpFile.c_str());
+        cmGeneratedFileStream ofs(tmpFile);
         ofs << "# Run command: " << ic << std::endl
         ofs << "# Run command: " << ic << std::endl
             << "# Output:" << std::endl
             << "# Output:" << std::endl
             << output << std::endl;
             << output << std::endl;
@@ -660,7 +660,7 @@ int cmCPackGenerator::RunPreinstallTarget(
     if (!resB || retVal) {
     if (!resB || retVal) {
       std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
       std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
       tmpFile += "/PreinstallOutput.log";
       tmpFile += "/PreinstallOutput.log";
-      cmGeneratedFileStream ofs(tmpFile.c_str());
+      cmGeneratedFileStream ofs(tmpFile);
       ofs << "# Run command: " << buildCommand << std::endl
       ofs << "# Run command: " << buildCommand << std::endl
           << "# Directory: " << installDirectory << std::endl
           << "# Directory: " << installDirectory << std::endl
           << "# Output:" << std::endl
           << "# Output:" << std::endl

+ 4 - 4
Source/CPack/cmCPackNSISGenerator.cxx

@@ -305,7 +305,7 @@ int cmCPackNSISGenerator::PackageFiles()
     nsisCmd.c_str(), &output, &output, &retVal, nullptr,
     nsisCmd.c_str(), &output, &output, &retVal, nullptr,
     this->GeneratorVerbose, cmDuration::zero());
     this->GeneratorVerbose, cmDuration::zero());
   if (!res || retVal) {
   if (!res || retVal) {
-    cmGeneratedFileStream ofs(tmpFile.c_str());
+    cmGeneratedFileStream ofs(tmpFile);
     ofs << "# Run command: " << nsisCmd << std::endl
     ofs << "# Run command: " << nsisCmd << std::endl
         << "# Output:" << std::endl
         << "# Output:" << std::endl
         << output << std::endl;
         << output << std::endl;
@@ -416,7 +416,7 @@ int cmCPackNSISGenerator::InitializeInternal()
     const char* topDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
     const char* topDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
     std::string tmpFile = topDir ? topDir : ".";
     std::string tmpFile = topDir ? topDir : ".";
     tmpFile += "/NSISOutput.log";
     tmpFile += "/NSISOutput.log";
-    cmGeneratedFileStream ofs(tmpFile.c_str());
+    cmGeneratedFileStream ofs(tmpFile);
     ofs << "# Run command: " << nsisCmd << std::endl
     ofs << "# Run command: " << nsisCmd << std::endl
         << "# Output:" << std::endl
         << "# Output:" << std::endl
         << output << std::endl;
         << output << std::endl;
@@ -726,7 +726,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
       cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES"));
       cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES"));
     unsigned long totalSize = 0;
     unsigned long totalSize = 0;
     { // the scope is needed for cmGeneratedFileStream
     { // the scope is needed for cmGeneratedFileStream
-      cmGeneratedFileStream out(zipListFileName.c_str());
+      cmGeneratedFileStream out(zipListFileName);
       for (std::string const& file : component->Files) {
       for (std::string const& file : component->Files) {
         if (needQuotesInFile) {
         if (needQuotesInFile) {
           out << "\"";
           out << "\"";
@@ -754,7 +754,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
     if (!res || retVal) {
     if (!res || retVal) {
       std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
       std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
       tmpFile += "/CompressZip.log";
       tmpFile += "/CompressZip.log";
-      cmGeneratedFileStream ofs(tmpFile.c_str());
+      cmGeneratedFileStream ofs(tmpFile);
       ofs << "# Run command: " << cmd << std::endl
       ofs << "# Run command: " << cmd << std::endl
           << "# Output:" << std::endl
           << "# Output:" << std::endl
           << output << std::endl;
           << output << std::endl;

+ 2 - 2
Source/CTest/cmCTestBuildHandler.cxx

@@ -742,7 +742,7 @@ void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig()
   // Give some testing configuration information to the launcher.
   // Give some testing configuration information to the launcher.
   std::string fname = this->Handler->CTestLaunchDir;
   std::string fname = this->Handler->CTestLaunchDir;
   fname += "/CTestLaunchConfig.cmake";
   fname += "/CTestLaunchConfig.cmake";
-  cmGeneratedFileStream fout(fname.c_str());
+  cmGeneratedFileStream fout(fname);
   std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
   std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
   fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n";
   fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n";
 }
 }
@@ -757,7 +757,7 @@ void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
   fname += "/Custom";
   fname += "/Custom";
   fname += purpose;
   fname += purpose;
   fname += ".txt";
   fname += ".txt";
-  cmGeneratedFileStream fout(fname.c_str());
+  cmGeneratedFileStream fout(fname);
   for (std::string const& m : matchers) {
   for (std::string const& m : matchers) {
     fout << m << "\n";
     fout << m << "\n";
   }
   }

+ 1 - 1
Source/CTest/cmCTestLaunch.cxx

@@ -345,7 +345,7 @@ void cmCTestLaunch::WriteXML()
   logXML += ".xml";
   logXML += ".xml";
 
 
   // Use cmGeneratedFileStream to atomically create the report file.
   // Use cmGeneratedFileStream to atomically create the report file.
-  cmGeneratedFileStream fxml(logXML.c_str());
+  cmGeneratedFileStream fxml(logXML);
   cmXMLWriter xml(fxml, 2);
   cmXMLWriter xml(fxml, 2);
   cmXMLElement e2(xml, "Failure");
   cmXMLElement e2(xml, "Failure");
   e2.Attribute("type", this->IsError() ? "Error" : "Warning");
   e2.Attribute("type", this->IsError() ? "Error" : "Warning");

+ 2 - 2
Source/CTest/cmCTestScriptHandler.cxx

@@ -792,7 +792,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                  "Write CMake output to file: " << cmakeOutputFile
                  "Write CMake output to file: " << cmakeOutputFile
                                                 << std::endl);
                                                 << std::endl);
-      cmGeneratedFileStream fout(cmakeOutputFile.c_str());
+      cmGeneratedFileStream fout(cmakeOutputFile);
       if (fout) {
       if (fout) {
         fout << output.c_str();
         fout << output.c_str();
       } else {
       } else {
@@ -856,7 +856,7 @@ bool cmCTestScriptHandler::WriteInitialCache(const char* directory,
 {
 {
   std::string cacheFile = directory;
   std::string cacheFile = directory;
   cacheFile += "/CMakeCache.txt";
   cacheFile += "/CMakeCache.txt";
-  cmGeneratedFileStream fout(cacheFile.c_str());
+  cmGeneratedFileStream fout(cacheFile);
   if (!fout) {
   if (!fout) {
     return false;
     return false;
   }
   }

+ 1 - 1
Source/CTest/cmCTestStartCommand.cxx

@@ -121,7 +121,7 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
 
 
   // Log startup actions.
   // Log startup actions.
   std::string startLogFile = binaryDir + "/Testing/Temporary/LastStart.log";
   std::string startLogFile = binaryDir + "/Testing/Temporary/LastStart.log";
-  cmGeneratedFileStream ofs(startLogFile.c_str());
+  cmGeneratedFileStream ofs(startLogFile);
   if (!ofs) {
   if (!ofs) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Cannot create log file: LastStart.log" << std::endl);
                "Cannot create log file: LastStart.log" << std::endl);

+ 1 - 1
Source/cmCTest.cxx

@@ -818,7 +818,7 @@ bool cmCTest::OpenOutputFile(const std::string& path, const std::string& name,
     }
     }
   }
   }
   std::string filename = testingDir + "/" + name;
   std::string filename = testingDir + "/" + name;
-  stream.Open(filename.c_str());
+  stream.Open(filename);
   if (!stream) {
   if (!stream) {
     cmCTestLog(this, ERROR_MESSAGE,
     cmCTestLog(this, ERROR_MESSAGE,
                "Problem opening file: " << filename << std::endl);
                "Problem opening file: " << filename << std::endl);

+ 1 - 1
Source/cmCacheManager.cxx

@@ -234,7 +234,7 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
 {
 {
   std::string cacheFile = path;
   std::string cacheFile = path;
   cacheFile += "/CMakeCache.txt";
   cacheFile += "/CMakeCache.txt";
-  cmGeneratedFileStream fout(cacheFile.c_str());
+  cmGeneratedFileStream fout(cacheFile);
   fout.SetCopyIfDifferent(true);
   fout.SetCopyIfDifferent(true);
   if (!fout) {
   if (!fout) {
     cmSystemTools::Error("Unable to open cache file for save. ",
     cmSystemTools::Error("Unable to open cache file for save. ",

+ 2 - 2
Source/cmDependsFortran.cxx

@@ -178,7 +178,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
   // Store the list of modules provided by this target.
   // Store the list of modules provided by this target.
   std::string fiName = this->TargetDirectory;
   std::string fiName = this->TargetDirectory;
   fiName += "/fortran.internal";
   fiName += "/fortran.internal";
-  cmGeneratedFileStream fiStream(fiName.c_str());
+  cmGeneratedFileStream fiStream(fiName);
   fiStream << "# The fortran modules provided by this target.\n";
   fiStream << "# The fortran modules provided by this target.\n";
   fiStream << "provides\n";
   fiStream << "provides\n";
   std::set<std::string> const& provides = this->Internal->TargetProvides;
   std::set<std::string> const& provides = this->Internal->TargetProvides;
@@ -190,7 +190,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
   if (!provides.empty()) {
   if (!provides.empty()) {
     std::string fcName = this->TargetDirectory;
     std::string fcName = this->TargetDirectory;
     fcName += "/cmake_clean_Fortran.cmake";
     fcName += "/cmake_clean_Fortran.cmake";
-    cmGeneratedFileStream fcStream(fcName.c_str());
+    cmGeneratedFileStream fcStream(fcName);
     fcStream << "# Remove fortran modules provided by this target.\n";
     fcStream << "# Remove fortran modules provided by this target.\n";
     fcStream << "FILE(REMOVE";
     fcStream << "FILE(REMOVE";
     std::string currentBinDir =
     std::string currentBinDir =

+ 1 - 1
Source/cmExportCommand.cxx

@@ -339,7 +339,7 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package,
   fname += "/";
   fname += "/";
   fname += hash;
   fname += hash;
   if (!cmSystemTools::FileExists(fname)) {
   if (!cmSystemTools::FileExists(fname)) {
-    cmGeneratedFileStream entry(fname.c_str(), true);
+    cmGeneratedFileStream entry(fname, true);
     if (entry) {
     if (entry) {
       entry << content << "\n";
       entry << content << "\n";
     } else {
     } else {

+ 1 - 1
Source/cmExportFileGenerator.cxx

@@ -75,7 +75,7 @@ bool cmExportFileGenerator::GenerateImportFile()
   } else {
   } else {
     // Generate atomically and with copy-if-different.
     // Generate atomically and with copy-if-different.
     std::unique_ptr<cmGeneratedFileStream> ap(
     std::unique_ptr<cmGeneratedFileStream> ap(
-      new cmGeneratedFileStream(this->MainImportFile.c_str(), true));
+      new cmGeneratedFileStream(this->MainImportFile, true));
     ap->SetCopyIfDifferent(true);
     ap->SetCopyIfDifferent(true);
     foutPtr = std::move(ap);
     foutPtr = std::move(ap);
   }
   }

+ 1 - 1
Source/cmExportInstallFileGenerator.cxx

@@ -288,7 +288,7 @@ bool cmExportInstallFileGenerator::GenerateImportFileConfig(
   fileName += this->FileExt;
   fileName += this->FileExt;
 
 
   // Open the output file to generate it.
   // Open the output file to generate it.
-  cmGeneratedFileStream exportFileStream(fileName.c_str(), true);
+  cmGeneratedFileStream exportFileStream(fileName, true);
   if (!exportFileStream) {
   if (!exportFileStream) {
     std::string se = cmSystemTools::GetLastSystemError();
     std::string se = cmSystemTools::GetLastSystemError();
     std::ostringstream e;
     std::ostringstream e;

+ 1 - 1
Source/cmExportLibraryDependenciesCommand.cxx

@@ -54,7 +54,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
       cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), std::ios::app);
       cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), std::ios::app);
   } else {
   } else {
     std::unique_ptr<cmGeneratedFileStream> ap(
     std::unique_ptr<cmGeneratedFileStream> ap(
-      new cmGeneratedFileStream(this->Filename.c_str(), true));
+      new cmGeneratedFileStream(this->Filename, true));
     ap->SetCopyIfDifferent(true);
     ap->SetCopyIfDifferent(true);
     foutPtr = std::move(ap);
     foutPtr = std::move(ap);
   }
   }

+ 2 - 2
Source/cmExtraCodeBlocksGenerator.cxx

@@ -199,7 +199,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
   const std::vector<cmLocalGenerator*>& lgs, const std::string& filename)
   const std::vector<cmLocalGenerator*>& lgs, const std::string& filename)
 {
 {
   const cmMakefile* mf = lgs[0]->GetMakefile();
   const cmMakefile* mf = lgs[0]->GetMakefile();
-  cmGeneratedFileStream fout(filename.c_str());
+  cmGeneratedFileStream fout(filename);
   if (!fout) {
   if (!fout) {
     return;
     return;
   }
   }
@@ -476,7 +476,7 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
   filename += "/";
   filename += "/";
   filename += target->GetName();
   filename += target->GetName();
   filename += ".objlib";
   filename += ".objlib";
-  cmGeneratedFileStream fout(filename.c_str());
+  cmGeneratedFileStream fout(filename);
   if (fout) {
   if (fout) {
     /* clang-format off */
     /* clang-format off */
     fout << "# This is a dummy file for the OBJECT library "
     fout << "# This is a dummy file for the OBJECT library "

+ 3 - 3
Source/cmExtraCodeLiteGenerator.cxx

@@ -77,7 +77,7 @@ void cmExtraCodeLiteGenerator::Generate()
     }
     }
   }
   }
 
 
-  cmGeneratedFileStream fout(workspaceFileName.c_str());
+  cmGeneratedFileStream fout(workspaceFileName);
   cmXMLWriter xml(fout);
   cmXMLWriter xml(fout);
 
 
   xml.StartDocument("utf-8");
   xml.StartDocument("utf-8");
@@ -249,7 +249,7 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile(
   const std::vector<cmLocalGenerator*>& lgs, const std::string& filename)
   const std::vector<cmLocalGenerator*>& lgs, const std::string& filename)
 {
 {
   const cmMakefile* mf = lgs[0]->GetMakefile();
   const cmMakefile* mf = lgs[0]->GetMakefile();
-  cmGeneratedFileStream fout(filename.c_str());
+  cmGeneratedFileStream fout(filename);
   if (!fout) {
   if (!fout) {
     return;
     return;
   }
   }
@@ -547,7 +547,7 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile(
   const cmGeneratorTarget* gt, const std::string& filename)
   const cmGeneratorTarget* gt, const std::string& filename)
 {
 {
   const cmMakefile* mf = gt->Makefile;
   const cmMakefile* mf = gt->Makefile;
-  cmGeneratedFileStream fout(filename.c_str());
+  cmGeneratedFileStream fout(filename);
   if (!fout) {
   if (!fout) {
     return;
     return;
   }
   }

+ 3 - 3
Source/cmExtraEclipseCDT4Generator.cxx

@@ -176,7 +176,7 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile()
                               this->GetPathBasename(this->HomeDirectory));
                               this->GetPathBasename(this->HomeDirectory));
 
 
   const std::string filename = this->HomeDirectory + "/.project";
   const std::string filename = this->HomeDirectory + "/.project";
-  cmGeneratedFileStream fout(filename.c_str());
+  cmGeneratedFileStream fout(filename);
   if (!fout) {
   if (!fout) {
     return;
     return;
   }
   }
@@ -261,7 +261,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
 
 
   const std::string filename = this->HomeOutputDirectory + "/.project";
   const std::string filename = this->HomeOutputDirectory + "/.project";
 
 
-  cmGeneratedFileStream fout(filename.c_str());
+  cmGeneratedFileStream fout(filename);
   if (!fout) {
   if (!fout) {
     return;
     return;
   }
   }
@@ -582,7 +582,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
 
 
   const std::string filename = this->HomeOutputDirectory + "/.cproject";
   const std::string filename = this->HomeOutputDirectory + "/.cproject";
 
 
-  cmGeneratedFileStream fout(filename.c_str());
+  cmGeneratedFileStream fout(filename);
   if (!fout) {
   if (!fout) {
     return;
     return;
   }
   }

+ 2 - 2
Source/cmExtraKateGenerator.cxx

@@ -58,7 +58,7 @@ void cmExtraKateGenerator::CreateKateProjectFile(
 {
 {
   std::string filename = lg->GetBinaryDirectory();
   std::string filename = lg->GetBinaryDirectory();
   filename += "/.kateproject";
   filename += "/.kateproject";
-  cmGeneratedFileStream fout(filename.c_str());
+  cmGeneratedFileStream fout(filename);
   if (!fout) {
   if (!fout) {
     return;
     return;
   }
   }
@@ -215,7 +215,7 @@ void cmExtraKateGenerator::CreateDummyKateProjectFile(
   filename += "/";
   filename += "/";
   filename += this->ProjectName;
   filename += this->ProjectName;
   filename += ".kateproject";
   filename += ".kateproject";
-  cmGeneratedFileStream fout(filename.c_str());
+  cmGeneratedFileStream fout(filename);
   if (!fout) {
   if (!fout) {
     return;
     return;
   }
   }

+ 1 - 1
Source/cmExtraSublimeTextGenerator.cxx

@@ -91,7 +91,7 @@ void cmExtraSublimeTextGenerator::CreateNewProjectFile(
 {
 {
   const cmMakefile* mf = lgs[0]->GetMakefile();
   const cmMakefile* mf = lgs[0]->GetMakefile();
 
 
-  cmGeneratedFileStream fout(filename.c_str());
+  cmGeneratedFileStream fout(filename);
   if (!fout) {
   if (!fout) {
     return;
     return;
   }
   }

+ 3 - 3
Source/cmGeneratedFileStream.cxx

@@ -168,12 +168,12 @@ bool cmGeneratedFileStreamBase::Close()
     // destination atomically.
     // destination atomically.
     if (this->Compress) {
     if (this->Compress) {
       std::string gzname = this->TempName + ".temp.gz";
       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);
       cmSystemTools::RemoveFile(gzname);
     } else {
     } else {
-      this->RenameFile(this->TempName.c_str(), resname.c_str());
+      this->RenameFile(this->TempName, resname);
     }
     }
 
 
     replaced = true;
     replaced = true;

+ 1 - 1
Source/cmGeneratorExpressionEvaluationFile.cxx

@@ -85,7 +85,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(
   this->Files.push_back(outputFileName);
   this->Files.push_back(outputFileName);
   outputFiles[outputFileName] = outputContent;
   outputFiles[outputFileName] = outputContent;
 
 
-  cmGeneratedFileStream fout(outputFileName.c_str());
+  cmGeneratedFileStream fout(outputFileName);
   fout.SetCopyIfDifferent(true);
   fout.SetCopyIfDifferent(true);
   fout << outputContent;
   fout << outputContent;
   if (fout.Close() && perm) {
   if (fout.Close() && perm) {

+ 1 - 1
Source/cmGlobVerificationManager.cxx

@@ -23,7 +23,7 @@ bool cmGlobVerificationManager::SaveVerificationScript(const std::string& path)
   cmSystemTools::MakeDirectory(scriptFile);
   cmSystemTools::MakeDirectory(scriptFile);
   scriptFile += "/VerifyGlobs.cmake";
   scriptFile += "/VerifyGlobs.cmake";
   stampFile += "/cmake.verify_globs";
   stampFile += "/cmake.verify_globs";
-  cmGeneratedFileStream verifyScriptFile(scriptFile.c_str());
+  cmGeneratedFileStream verifyScriptFile(scriptFile);
   verifyScriptFile.SetCopyIfDifferent(true);
   verifyScriptFile.SetCopyIfDifferent(true);
   if (!verifyScriptFile) {
   if (!verifyScriptFile) {
     cmSystemTools::Error("Unable to open verification script file for save. ",
     cmSystemTools::Error("Unable to open verification script file for save. ",

+ 5 - 5
Source/cmGlobalGenerator.cxx

@@ -2904,7 +2904,7 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile)
   if (this->RuleHashes.empty()) {
   if (this->RuleHashes.empty()) {
     cmSystemTools::RemoveFile(pfile);
     cmSystemTools::RemoveFile(pfile);
   } else {
   } else {
-    cmGeneratedFileStream fout(pfile.c_str());
+    cmGeneratedFileStream fout(pfile);
     fout << "# Hashes of file build rules.\n";
     fout << "# Hashes of file build rules.\n";
     for (auto const& rh : this->RuleHashes) {
     for (auto const& rh : this->RuleHashes) {
       fout.write(rh.second.Data, 32);
       fout.write(rh.second.Data, 32);
@@ -2919,7 +2919,7 @@ void cmGlobalGenerator::WriteSummary()
   std::string fname = this->CMakeInstance->GetHomeOutputDirectory();
   std::string fname = this->CMakeInstance->GetHomeOutputDirectory();
   fname += cmake::GetCMakeFilesDirectory();
   fname += cmake::GetCMakeFilesDirectory();
   fname += "/TargetDirectories.txt";
   fname += "/TargetDirectories.txt";
-  cmGeneratedFileStream fout(fname.c_str());
+  cmGeneratedFileStream fout(fname);
 
 
   for (cmLocalGenerator* lg : this->LocalGenerators) {
   for (cmLocalGenerator* lg : this->LocalGenerators) {
     const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets();
     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;
     Json::Value& lj_sources = lj_root["sources"] = Json::arrayValue;
 
 
     cmSystemTools::MakeDirectory(dir);
     cmSystemTools::MakeDirectory(dir);
-    cmGeneratedFileStream fout(file.c_str());
+    cmGeneratedFileStream fout(file);
 
 
     std::vector<std::string> labels;
     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;
     json_fout << lj_root;
   } else
   } else
 #endif
 #endif
@@ -3105,7 +3105,7 @@ bool cmGlobalGenerator::GenerateCPackPropertiesFile()
     return true;
     return true;
   }
   }
 
 
-  cmGeneratedFileStream file(path.c_str());
+  cmGeneratedFileStream file(path);
   file << "# CPack properties\n";
   file << "# CPack properties\n";
 
 
   for (auto const& i : installedFiles) {
   for (auto const& i : installedFiles) {

+ 7 - 8
Source/cmGlobalNinjaGenerator.cxx

@@ -763,7 +763,7 @@ void cmGlobalNinjaGenerator::OpenBuildFileStream()
   // Get a stream where to generate things.
   // Get a stream where to generate things.
   if (!this->BuildFileStream) {
   if (!this->BuildFileStream) {
     this->BuildFileStream = new cmGeneratedFileStream(
     this->BuildFileStream = new cmGeneratedFileStream(
-      buildFilePath.c_str(), false, this->GetMakefileEncoding());
+      buildFilePath, false, this->GetMakefileEncoding());
     if (!this->BuildFileStream) {
     if (!this->BuildFileStream) {
       // An error message is generated by the constructor if it cannot
       // An error message is generated by the constructor if it cannot
       // open the file.
       // open the file.
@@ -801,7 +801,7 @@ void cmGlobalNinjaGenerator::OpenRulesFileStream()
   // Get a stream where to generate things.
   // Get a stream where to generate things.
   if (!this->RulesFileStream) {
   if (!this->RulesFileStream) {
     this->RulesFileStream = new cmGeneratedFileStream(
     this->RulesFileStream = new cmGeneratedFileStream(
-      rulesFilePath.c_str(), false, this->GetMakefileEncoding());
+      rulesFilePath, false, this->GetMakefileEncoding());
     if (!this->RulesFileStream) {
     if (!this->RulesFileStream) {
       // An error message is generated by the constructor if it cannot
       // An error message is generated by the constructor if it cannot
       // open the file.
       // open the file.
@@ -883,8 +883,7 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand(
     }
     }
 
 
     // Get a stream where to generate things.
     // Get a stream where to generate things.
-    this->CompileCommandsStream =
-      new cmGeneratedFileStream(buildFilePath.c_str());
+    this->CompileCommandsStream = new cmGeneratedFileStream(buildFilePath);
     *this->CompileCommandsStream << "[";
     *this->CompileCommandsStream << "[";
   } else {
   } else {
     *this->CompileCommandsStream << "," << std::endl;
     *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) << ":";
     depfile << cmSystemTools::ConvertToUnixOutputPath(arg_pp) << ":";
     for (std::string const& include : info.Includes) {
     for (std::string const& include : info.Includes) {
       depfile << " \\\n " << cmSystemTools::ConvertToUnixOutputPath(include);
       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;
   ddif << ddi;
   if (!ddif) {
   if (!ddif) {
     cmSystemTools::Error("-E cmake_ninja_depends failed to write ",
     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";
   ddf << "ninja_dyndep_version = 1.0\n";
 
 
   for (cmFortranObjectInfo const& object : objects) {
   for (cmFortranObjectInfo const& object : objects) {
@@ -1862,7 +1861,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
   // use by dependents that reference this target in linked-target-dirs.
   // use by dependents that reference this target in linked-target-dirs.
   std::string const target_mods_file =
   std::string const target_mods_file =
     cmSystemTools::GetFilenamePath(arg_dd) + "/FortranModules.json";
     cmSystemTools::GetFilenamePath(arg_dd) + "/FortranModules.json";
-  cmGeneratedFileStream tmf(target_mods_file.c_str());
+  cmGeneratedFileStream tmf(target_mods_file);
   tmf << tm;
   tmf << tm;
 
 
   return true;
   return true;

+ 5 - 6
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -147,7 +147,7 @@ void cmGlobalUnixMakefileGenerator3::Generate()
     markFileName += "/";
     markFileName += "/";
     markFileName += cmake::GetCMakeFilesDirectory();
     markFileName += cmake::GetCMakeFilesDirectory();
     markFileName += "/progress.marks";
     markFileName += "/progress.marks";
-    cmGeneratedFileStream markFile(markFileName.c_str());
+    cmGeneratedFileStream markFile(markFileName);
     markFile << this->CountProgressMarksInAll(lg) << "\n";
     markFile << this->CountProgressMarksInAll(lg) << "\n";
   }
   }
 
 
@@ -170,8 +170,7 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand(
     std::string commandDatabaseName =
     std::string commandDatabaseName =
       std::string(this->GetCMakeInstance()->GetHomeOutputDirectory()) +
       std::string(this->GetCMakeInstance()->GetHomeOutputDirectory()) +
       "/compile_commands.json";
       "/compile_commands.json";
-    this->CommandDatabase =
-      new cmGeneratedFileStream(commandDatabaseName.c_str());
+    this->CommandDatabase = new cmGeneratedFileStream(commandDatabaseName);
     *this->CommandDatabase << "[" << std::endl;
     *this->CommandDatabase << "[" << std::endl;
   } else {
   } else {
     *this->CommandDatabase << "," << std::endl;
     *this->CommandDatabase << "," << std::endl;
@@ -198,7 +197,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
     this->GetCMakeInstance()->GetHomeOutputDirectory();
     this->GetCMakeInstance()->GetHomeOutputDirectory();
   makefileName += cmake::GetCMakeFilesDirectory();
   makefileName += cmake::GetCMakeFilesDirectory();
   makefileName += "/Makefile2";
   makefileName += "/Makefile2";
-  cmGeneratedFileStream makefileStream(makefileName.c_str(), false,
+  cmGeneratedFileStream makefileStream(makefileName, false,
                                        this->GetMakefileEncoding());
                                        this->GetMakefileEncoding());
   if (!makefileStream) {
   if (!makefileStream) {
     return;
     return;
@@ -270,7 +269,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
     this->GetCMakeInstance()->GetHomeOutputDirectory();
     this->GetCMakeInstance()->GetHomeOutputDirectory();
   cmakefileName += cmake::GetCMakeFilesDirectory();
   cmakefileName += cmake::GetCMakeFilesDirectory();
   cmakefileName += "/Makefile.cmake";
   cmakefileName += "/Makefile.cmake";
-  cmGeneratedFileStream cmakefileStream(cmakefileName.c_str());
+  cmGeneratedFileStream cmakefileStream(cmakefileName);
   if (!cmakefileStream) {
   if (!cmakefileStream) {
     return;
     return;
   }
   }
@@ -876,7 +875,7 @@ void cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
 void cmGlobalUnixMakefileGenerator3::TargetProgress::WriteProgressVariables(
 void cmGlobalUnixMakefileGenerator3::TargetProgress::WriteProgressVariables(
   unsigned long total, unsigned long& current)
   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) {
   for (unsigned long i = 1; i <= this->NumberOfActions; ++i) {
     fout << "CMAKE_PROGRESS_" << i << " = ";
     fout << "CMAKE_PROGRESS_" << i << " = ";
     if (total <= 100) {
     if (total <= 100) {

+ 2 - 2
Source/cmGraphVizWriter.cxx

@@ -257,7 +257,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
     currentFilename += ptr.first;
     currentFilename += ptr.first;
     currentFilename += ".dependers";
     currentFilename += ".dependers";
 
 
-    cmGeneratedFileStream str(currentFilename.c_str());
+    cmGeneratedFileStream str(currentFilename);
     if (!str) {
     if (!str) {
       return;
       return;
     }
     }
@@ -300,7 +300,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
     std::string currentFilename = fileName;
     std::string currentFilename = fileName;
     currentFilename += ".";
     currentFilename += ".";
     currentFilename += ptr.first;
     currentFilename += ptr.first;
-    cmGeneratedFileStream str(currentFilename.c_str());
+    cmGeneratedFileStream str(currentFilename);
     if (!str) {
     if (!str) {
       return;
       return;
     }
     }

+ 2 - 2
Source/cmLocalGenerator.cxx

@@ -253,7 +253,7 @@ void cmLocalGenerator::GenerateTestFiles()
   file += "/";
   file += "/";
   file += "CTestTestfile.cmake";
   file += "CTestTestfile.cmake";
 
 
-  cmGeneratedFileStream fout(file.c_str());
+  cmGeneratedFileStream fout(file);
   fout.SetCopyIfDifferent(true);
   fout.SetCopyIfDifferent(true);
 
 
   fout << "# CMake generated Testfile for " << std::endl
   fout << "# CMake generated Testfile for " << std::endl
@@ -429,7 +429,7 @@ void cmLocalGenerator::GenerateInstallRules()
     toplevel_install = 1;
     toplevel_install = 1;
   }
   }
   file += "/cmake_install.cmake";
   file += "/cmake_install.cmake";
-  cmGeneratedFileStream fout(file.c_str());
+  cmGeneratedFileStream fout(file);
   fout.SetCopyIfDifferent(true);
   fout.SetCopyIfDifferent(true);
 
 
   // Write the header.
   // Write the header.

+ 4 - 6
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -211,8 +211,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
   // rules may depend on this file itself.
   // rules may depend on this file itself.
   std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
   std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
   cmGeneratedFileStream ruleFileStream(
   cmGeneratedFileStream ruleFileStream(
-    ruleFileNameFull.c_str(), false,
-    this->GlobalGenerator->GetMakefileEncoding());
+    ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
   if (!ruleFileStream) {
   if (!ruleFileStream) {
     return;
     return;
   }
   }
@@ -433,7 +432,7 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
   infoFileName += "/CMakeDirectoryInformation.cmake";
   infoFileName += "/CMakeDirectoryInformation.cmake";
 
 
   // Open the output file.
   // Open the output file.
-  cmGeneratedFileStream infoFileStream(infoFileName.c_str());
+  cmGeneratedFileStream infoFileStream(infoFileName);
   if (!infoFileStream) {
   if (!infoFileStream) {
     return;
     return;
   }
   }
@@ -1403,8 +1402,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
   std::string ruleFileNameFull = dir;
   std::string ruleFileNameFull = dir;
   ruleFileNameFull += "/depend.make";
   ruleFileNameFull += "/depend.make";
   cmGeneratedFileStream ruleFileStream(
   cmGeneratedFileStream ruleFileStream(
-    ruleFileNameFull.c_str(), false,
-    this->GlobalGenerator->GetMakefileEncoding());
+    ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
   ruleFileStream.SetCopyIfDifferent(true);
   ruleFileStream.SetCopyIfDifferent(true);
   if (!ruleFileStream) {
   if (!ruleFileStream) {
     return false;
     return false;
@@ -1416,7 +1414,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
   std::string internalRuleFileNameFull = dir;
   std::string internalRuleFileNameFull = dir;
   internalRuleFileNameFull += "/depend.internal";
   internalRuleFileNameFull += "/depend.internal";
   cmGeneratedFileStream internalRuleFileStream(
   cmGeneratedFileStream internalRuleFileStream(
-    internalRuleFileNameFull.c_str(), false,
+    internalRuleFileNameFull, false,
     this->GlobalGenerator->GetMakefileEncoding());
     this->GlobalGenerator->GetMakefileEncoding());
   if (!internalRuleFileStream) {
   if (!internalRuleFileStream) {
     return false;
     return false;

+ 7 - 9
Source/cmMakefileTargetGenerator.cxx

@@ -124,7 +124,7 @@ void cmMakefileTargetGenerator::CreateRuleFile()
   // Open the rule file.  This should be copy-if-different because the
   // Open the rule file.  This should be copy-if-different because the
   // rules may depend on this file itself.
   // rules may depend on this file itself.
   this->BuildFileStream =
   this->BuildFileStream =
-    new cmGeneratedFileStream(this->BuildFileNameFull.c_str(), false,
+    new cmGeneratedFileStream(this->BuildFileNameFull, false,
                               this->GlobalGenerator->GetMakefileEncoding());
                               this->GlobalGenerator->GetMakefileEncoding());
   this->BuildFileStream->SetCopyIfDifferent(true);
   this->BuildFileStream->SetCopyIfDifferent(true);
   if (!this->BuildFileStream) {
   if (!this->BuildFileStream) {
@@ -237,8 +237,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
   if (!cmSystemTools::FileExists(dependFileNameFull)) {
   if (!cmSystemTools::FileExists(dependFileNameFull)) {
     // Write an empty dependency file.
     // Write an empty dependency file.
     cmGeneratedFileStream depFileStream(
     cmGeneratedFileStream depFileStream(
-      dependFileNameFull.c_str(), false,
-      this->GlobalGenerator->GetMakefileEncoding());
+      dependFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
     depFileStream << "# Empty dependencies file for "
     depFileStream << "# Empty dependencies file for "
                   << this->GeneratorTarget->GetName() << ".\n"
                   << this->GeneratorTarget->GetName() << ".\n"
                   << "# This may be replaced when dependencies are built."
                   << "# This may be replaced when dependencies are built."
@@ -250,7 +249,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
   this->FlagFileNameFull = this->TargetBuildDirectoryFull;
   this->FlagFileNameFull = this->TargetBuildDirectoryFull;
   this->FlagFileNameFull += "/flags.make";
   this->FlagFileNameFull += "/flags.make";
   this->FlagFileStream =
   this->FlagFileStream =
-    new cmGeneratedFileStream(this->FlagFileNameFull.c_str(), false,
+    new cmGeneratedFileStream(this->FlagFileNameFull, false,
                               this->GlobalGenerator->GetMakefileEncoding());
                               this->GlobalGenerator->GetMakefileEncoding());
   this->FlagFileStream->SetCopyIfDifferent(true);
   this->FlagFileStream->SetCopyIfDifferent(true);
   if (!this->FlagFileStream) {
   if (!this->FlagFileStream) {
@@ -974,8 +973,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
   this->InfoFileNameFull += "/DependInfo.cmake";
   this->InfoFileNameFull += "/DependInfo.cmake";
   this->InfoFileNameFull =
   this->InfoFileNameFull =
     this->LocalGenerator->ConvertToFullPath(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);
   this->InfoFileStream->SetCopyIfDifferent(true);
   if (!*this->InfoFileStream) {
   if (!*this->InfoFileStream) {
     return;
     return;
@@ -1446,7 +1444,7 @@ void cmMakefileTargetGenerator::CreateLinkScript(
   std::string linkScriptName = this->TargetBuildDirectoryFull;
   std::string linkScriptName = this->TargetBuildDirectoryFull;
   linkScriptName += "/";
   linkScriptName += "/";
   linkScriptName += name;
   linkScriptName += name;
-  cmGeneratedFileStream linkScriptStream(linkScriptName.c_str());
+  cmGeneratedFileStream linkScriptStream(linkScriptName);
   linkScriptStream.SetCopyIfDifferent(true);
   linkScriptStream.SetCopyIfDifferent(true);
   for (std::string const& link_command : link_commands) {
   for (std::string const& link_command : link_commands) {
     // Do not write out empty commands or commands beginning in the
     // Do not write out empty commands or commands beginning in the
@@ -1530,7 +1528,7 @@ std::string cmMakefileTargetGenerator::CreateResponseFile(
   std::string responseFileNameFull = this->TargetBuildDirectoryFull;
   std::string responseFileNameFull = this->TargetBuildDirectoryFull;
   responseFileNameFull += "/";
   responseFileNameFull += "/";
   responseFileNameFull += name;
   responseFileNameFull += name;
-  cmGeneratedFileStream responseStream(responseFileNameFull.c_str());
+  cmGeneratedFileStream responseStream(responseFileNameFull);
   responseStream.SetCopyIfDifferent(true);
   responseStream.SetCopyIfDifferent(true);
   responseStream << options << "\n";
   responseStream << options << "\n";
 
 
@@ -1718,7 +1716,7 @@ void cmMakefileTargetGenerator::GenDefFile(
     cmOutputConverter::SHELL);
     cmOutputConverter::SHELL);
   real_link_commands.insert(real_link_commands.begin(), cmd);
   real_link_commands.insert(real_link_commands.begin(), cmd);
   // create a list of obj files for the -E __create_def to read
   // 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) {
   if (mdi->WindowsExportAllSymbols) {
     for (std::string const& obj : this->Objects) {
     for (std::string const& obj : this->Objects) {

+ 1 - 1
Source/cmNinjaNormalTargetGenerator.cxx

@@ -956,7 +956,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
     preLinkCmdLines.push_back(std::move(cmd));
     preLinkCmdLines.push_back(std::move(cmd));
 
 
     // create a list of obj files for the -E __create_def to read
     // 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) {
     if (mdi->WindowsExportAllSymbols) {
       cmNinjaDeps objs = this->GetObjects();
       cmNinjaDeps objs = this->GetObjects();

+ 1 - 1
Source/cmNinjaTargetGenerator.cxx

@@ -1133,7 +1133,7 @@ void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang)
   }
   }
 
 
   std::string const tdin = this->GetTargetDependInfoPath(lang);
   std::string const tdin = this->GetTargetDependInfoPath(lang);
-  cmGeneratedFileStream tdif(tdin.c_str());
+  cmGeneratedFileStream tdif(tdin);
   tdif << tdi;
   tdif << tdi;
 }
 }
 
 

+ 2 - 2
Source/cmQtAutoGenInitializer.cxx

@@ -1076,7 +1076,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
 
 
   cmGeneratedFileStream ofs;
   cmGeneratedFileStream ofs;
   ofs.SetCopyIfDifferent(true);
   ofs.SetCopyIfDifferent(true);
-  ofs.Open(this->AutogenInfoFile.c_str(), false, true);
+  ofs.Open(this->AutogenInfoFile, false, true);
   if (ofs) {
   if (ofs) {
     // Utility lambdas
     // Utility lambdas
     auto CWrite = [&ofs](const char* key, std::string const& value) {
     auto CWrite = [&ofs](const char* key, std::string const& value) {
@@ -1183,7 +1183,7 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
   for (Qrc const& qrc : this->Rcc.Qrcs) {
   for (Qrc const& qrc : this->Rcc.Qrcs) {
     cmGeneratedFileStream ofs;
     cmGeneratedFileStream ofs;
     ofs.SetCopyIfDifferent(true);
     ofs.SetCopyIfDifferent(true);
-    ofs.Open(qrc.InfoFile.c_str(), false, true);
+    ofs.Open(qrc.InfoFile, false, true);
     if (ofs) {
     if (ofs) {
       // Utility lambdas
       // Utility lambdas
       auto CWrite = [&ofs](const char* key, std::string const& value) {
       auto CWrite = [&ofs](const char* key, std::string const& value) {