diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2018-08-07 09:48:17 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2018-08-07 14:57:40 (GMT) |
commit | a688defcc6e0195eefedd2cbc70ec5e40534f597 (patch) | |
tree | c5938b3d2f232506d759f56f94e60c76077a52cc /Source | |
parent | d7a52f8c24a29ff7f64b00566b646f2d125d4ac0 (diff) | |
download | CMake-a688defcc6e0195eefedd2cbc70ec5e40534f597.zip CMake-a688defcc6e0195eefedd2cbc70ec5e40534f597.tar.gz CMake-a688defcc6e0195eefedd2cbc70ec5e40534f597.tar.bz2 |
cmGeneratedFileStream: Use ``std::string const&`` instead of ``const char*``
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratedFileStream.cxx | 25 | ||||
-rw-r--r-- | Source/cmGeneratedFileStream.h | 12 |
2 files changed, 19 insertions, 18 deletions
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 6bdf3a4..95132e7 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -24,8 +24,8 @@ cmGeneratedFileStream::cmGeneratedFileStream(Encoding encoding) #endif } -cmGeneratedFileStream::cmGeneratedFileStream(const char* name, bool quiet, - Encoding encoding) +cmGeneratedFileStream::cmGeneratedFileStream(std::string const& name, + bool quiet, Encoding encoding) : cmGeneratedFileStreamBase(name) , Stream(TempName.c_str()) { @@ -54,7 +54,7 @@ cmGeneratedFileStream::~cmGeneratedFileStream() this->Okay = !this->fail(); } -cmGeneratedFileStream& cmGeneratedFileStream::Open(const char* name, +cmGeneratedFileStream& cmGeneratedFileStream::Open(std::string const& name, bool quiet, bool binaryFlag) { // Store the file name and construct the temporary file name. @@ -114,7 +114,7 @@ cmGeneratedFileStreamBase::cmGeneratedFileStreamBase() { } -cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(const char* name) +cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(std::string const& name) : Name() , TempName() , CopyIfDifferent(false) @@ -130,7 +130,7 @@ cmGeneratedFileStreamBase::~cmGeneratedFileStreamBase() this->Close(); } -void cmGeneratedFileStreamBase::Open(const char* name) +void cmGeneratedFileStreamBase::Open(std::string const& name) { // Save the original name of the file. this->Name = name; @@ -188,10 +188,10 @@ bool cmGeneratedFileStreamBase::Close() } #ifdef CMAKE_BUILD_WITH_CMAKE -int cmGeneratedFileStreamBase::CompressFile(const char* oldname, - const char* newname) +int cmGeneratedFileStreamBase::CompressFile(std::string const& oldname, + std::string const& newname) { - gzFile gf = gzopen(newname, "w"); + gzFile gf = gzopen(newname.c_str(), "w"); if (!gf) { return 0; } @@ -214,16 +214,17 @@ int cmGeneratedFileStreamBase::CompressFile(const char* oldname, return 1; } #else -int cmGeneratedFileStreamBase::CompressFile(const char*, const char*) +int cmGeneratedFileStreamBase::CompressFile(std::string const&, + std::string const&) { return 0; } #endif -int cmGeneratedFileStreamBase::RenameFile(const char* oldname, - const char* newname) +int cmGeneratedFileStreamBase::RenameFile(std::string const& oldname, + std::string const& newname) { - return cmSystemTools::RenameFile(oldname, newname); + return cmSystemTools::RenameFile(oldname.c_str(), newname.c_str()); } void cmGeneratedFileStream::SetName(const std::string& fname) diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h index 48f93c5..dacd166 100644 --- a/Source/cmGeneratedFileStream.h +++ b/Source/cmGeneratedFileStream.h @@ -20,7 +20,7 @@ protected: cmGeneratedFileStreamBase(); // This constructor prepares the temporary output file. - cmGeneratedFileStreamBase(const char* name); + cmGeneratedFileStreamBase(std::string const& name); // The destructor renames the temporary output file to the real name. ~cmGeneratedFileStreamBase(); @@ -29,14 +29,14 @@ protected: // called before the real stream is opened. Close is always called // after the real stream is closed and Okay is set to whether the // real stream was still valid for writing when it was closed. - void Open(const char* name); + void Open(std::string const& name); bool Close(); // Internal file replacement implementation. - int RenameFile(const char* oldname, const char* newname); + int RenameFile(std::string const& oldname, std::string const& newname); // Internal file compression implementation. - int CompressFile(const char* oldname, const char* newname); + int CompressFile(std::string const& oldname, std::string const& newname); // The name of the final destination file for the output. std::string Name; @@ -87,7 +87,7 @@ public: * file cannot be opened an error message is produced unless the * second argument is set to true. */ - cmGeneratedFileStream(const char* name, bool quiet = false, + cmGeneratedFileStream(std::string const& name, bool quiet = false, Encoding encoding = codecvt::None); /** @@ -103,7 +103,7 @@ public: * temporary file. If the file cannot be opened an error message is * produced unless the second argument is set to true. */ - cmGeneratedFileStream& Open(const char* name, bool quiet = false, + cmGeneratedFileStream& Open(std::string const& name, bool quiet = false, bool binaryFlag = false); /** |