From f5e6c67dafa40a0abe7a7d6dfbe171b520897692 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Tue, 31 Jan 2023 14:49:40 -0700 Subject: [PATCH] Remove unnecessary `std::string::c_str()` calls --- src/SFML/Audio/SoundFileWriterOgg.cpp | 2 +- src/SFML/Audio/SoundFileWriterWav.cpp | 2 +- src/SFML/Graphics/Shader.cpp | 2 +- src/SFML/Network/Ftp.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SFML/Audio/SoundFileWriterOgg.cpp b/src/SFML/Audio/SoundFileWriterOgg.cpp index feea52f5d..354f75e91 100644 --- a/src/SFML/Audio/SoundFileWriterOgg.cpp +++ b/src/SFML/Audio/SoundFileWriterOgg.cpp @@ -80,7 +80,7 @@ bool SoundFileWriterOgg::open(const std::filesystem::path& filename, unsigned in vorbis_analysis_init(&m_state, &m_vorbis); // Open the file after the vorbis setup is ok - m_file.open(filename.c_str(), std::ios::binary); + m_file.open(filename, std::ios::binary); if (!m_file) { err() << "Failed to write ogg/vorbis file (cannot open file)\n" << formatDebugPathInfo(filename) << std::endl; diff --git a/src/SFML/Audio/SoundFileWriterWav.cpp b/src/SFML/Audio/SoundFileWriterWav.cpp index 4d8102040..5ce7cc7ac 100644 --- a/src/SFML/Audio/SoundFileWriterWav.cpp +++ b/src/SFML/Audio/SoundFileWriterWav.cpp @@ -86,7 +86,7 @@ SoundFileWriterWav::~SoundFileWriterWav() bool SoundFileWriterWav::open(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount) { // Open the file - m_file.open(filename.c_str(), std::ios::binary); + m_file.open(filename, std::ios::binary); if (!m_file) { err() << "Failed to open WAV sound file for writing\n" << formatDebugPathInfo(filename) << std::endl; diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index 13abe6765..1698c40b3 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -79,7 +79,7 @@ std::size_t getMaxTextureUnits() // Read the contents of a file into an array of char bool getFileContents(const std::filesystem::path& filename, std::vector& buffer) { - std::ifstream file(filename.c_str(), std::ios_base::binary); + std::ifstream file(filename, std::ios_base::binary); if (file) { file.seekg(0, std::ios_base::end); diff --git a/src/SFML/Network/Ftp.cpp b/src/SFML/Network/Ftp.cpp index 92498314d..6b0a13a12 100644 --- a/src/SFML/Network/Ftp.cpp +++ b/src/SFML/Network/Ftp.cpp @@ -310,7 +310,7 @@ Ftp::Response Ftp::download(const std::filesystem::path& remoteFile, const std:: // If the download was unsuccessful, delete the partial file if (!response.isOk()) - std::remove(filepath.string().c_str()); + std::filesystem::remove(filepath); } } @@ -322,7 +322,7 @@ Ftp::Response Ftp::download(const std::filesystem::path& remoteFile, const std:: Ftp::Response Ftp::upload(const std::string& localFile, const std::string& remotePath, TransferMode mode, bool append) { // Get the contents of the file to send - std::ifstream file(localFile.c_str(), std::ios_base::binary); + std::ifstream file(localFile, std::ios_base::binary); if (!file) return Response(Response::Status::InvalidFile);