Skip to content

Commit

Permalink
CHANGE(client): Migrate boost::filesystem to std
Browse files Browse the repository at this point in the history
Since we are now using C++17, we can make use of the
std::filesystem::path API for use with our std::fstreams.

This commit replaces boost::filesystem::path introduced by
91f1177
with std::filesystem::path
  • Loading branch information
Hartmnt committed Dec 4, 2024
1 parent 91f1177 commit 42ef07b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/QtUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <QStringList>
#include <QUrl>

#include <boost/filesystem.hpp>
#include <filesystem>

namespace Mumble {
namespace QtUtils {
Expand All @@ -25,11 +25,11 @@ namespace QtUtils {
return QString();
}

boost::filesystem::path qstring_to_path(const QString &input) {
std::filesystem::path qstring_to_path(const QString &input) {
#ifdef _WIN32
return boost::filesystem::path(input.toStdWString());
return std::filesystem::path(input.toStdWString());
#else
return boost::filesystem::path(input.toUtf8());
return std::filesystem::path(input.toUtf8().data());
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions src/QtUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <QString>
#include <QStringList>

#include <boost/filesystem.hpp>
#include <filesystem>

#include <memory>

Expand Down Expand Up @@ -39,7 +39,7 @@ namespace QtUtils {
/**
* Creates a platform agnostic path from a QString
*/
boost::filesystem::path qstring_to_path(const QString &input);
std::filesystem::path qstring_to_path(const QString &input);

} // namespace QtUtils
} // namespace Mumble
Expand Down
6 changes: 2 additions & 4 deletions src/mumble/PluginInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
#include <QtGui/QIcon>

#include <exception>
#include <fstream>
#include <string>

#include <boost/filesystem/fstream.hpp>

#include <Poco/Exception.h>
#include <Poco/FileStream.h>
#include <Poco/StreamCopier.h>
Expand Down Expand Up @@ -129,8 +128,7 @@ void PluginInstaller::init() {

zipInput.clear();
Poco::Zip::ZipInputStream zipin(zipInput, pluginIt->second);
boost::filesystem::ofstream out(Mumble::QtUtils::qstring_to_path(tmpPluginPath),
std::ios::out | std::ios::binary);
std::ofstream out(Mumble::QtUtils::qstring_to_path(tmpPluginPath), std::ios::out | std::ios::binary);
Poco::StreamCopier::copyStream(zipin, out);

m_pluginSource = QFileInfo(tmpPluginPath);
Expand Down
10 changes: 5 additions & 5 deletions src/mumble/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
#include <QStandardPaths>
#include <QSystemTrayIcon>

#include <boost/filesystem/fstream.hpp>
#include <boost/typeof/typeof.hpp>

#include <algorithm>
#include <cassert>
#include <cstring>
#include <fstream>
#include <limits>
#include <memory>

Expand Down Expand Up @@ -156,7 +156,7 @@ void Settings::save(const QString &path) const {
QFile tmpFile(QString::fromLatin1("%1/mumble_settings.json.tmp")
.arg(QStandardPaths::writableLocation(QStandardPaths::TempLocation)));

boost::filesystem::ofstream stream(Mumble::QtUtils::qstring_to_path(tmpFile.fileName()));
std::ofstream stream(Mumble::QtUtils::qstring_to_path(tmpFile.fileName()));
stream << settingsJSON.dump(4) << std::endl;
stream.close();

Expand Down Expand Up @@ -224,7 +224,7 @@ void Settings::load(const QString &path) {
settingsLocation = path;
}

boost::filesystem::ifstream stream(Mumble::QtUtils::qstring_to_path(path));
std::ifstream stream(Mumble::QtUtils::qstring_to_path(path));

nlohmann::json settingsJSON;
try {
Expand Down Expand Up @@ -613,13 +613,13 @@ void OverlaySettings::savePresets(const QString &filename) {
settingsJSON.erase(SettingsKeys::OVERLAY_LAUNCHERS_KEY);
settingsJSON.erase(SettingsKeys::OVERLAY_LAUNCHERS_EXCLUDE_KEY);

boost::filesystem::ofstream stream(Mumble::QtUtils::qstring_to_path(filename));
std::ofstream stream(Mumble::QtUtils::qstring_to_path(filename));

stream << settingsJSON.dump(4) << std::endl;
}

void OverlaySettings::load(const QString &filename) {
boost::filesystem::ifstream stream(Mumble::QtUtils::qstring_to_path(filename));
std::ifstream stream(Mumble::QtUtils::qstring_to_path(filename));

nlohmann::json settingsJSON;
try {
Expand Down

0 comments on commit 42ef07b

Please sign in to comment.