From f96c08775ab13479228f382b39375723c8f491d1 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 15 May 2020 14:54:42 +0200 Subject: [PATCH] Use Boost.Filesystem for the configuration I'd much rather just use std::filesystem, but since all of Boost.Process, Boost.DLL Boost.Asio uses its own filesystem library we need to use it anyways. --- src/plugin/configuration.h | 12 ++++++------ src/plugin/utils.cpp | 13 +++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/plugin/configuration.h b/src/plugin/configuration.h index 0f31fd01..d9e96ccf 100644 --- a/src/plugin/configuration.h +++ b/src/plugin/configuration.h @@ -16,7 +16,7 @@ #pragma once -#include +#include #include /** @@ -34,13 +34,13 @@ * @return The path to the *file* found, or `std::nullopt` if the file could not * be found. */ -template -std::optional find_dominating_file( +template +std::optional find_dominating_file( const std::string& filename, - std::filesystem::path starting_dir, - F predicate = std::filesystem::exists) { + boost::filesystem::path starting_dir, + F predicate = boost::filesystem::exists) { while (starting_dir != "") { - const std::filesystem::path candidate = starting_dir / filename; + const boost::filesystem::path candidate = starting_dir / filename; if (predicate(candidate)) { return candidate; } diff --git a/src/plugin/utils.cpp b/src/plugin/utils.cpp index 61885c94..061be195 100644 --- a/src/plugin/utils.cpp +++ b/src/plugin/utils.cpp @@ -55,16 +55,13 @@ std::string create_logger_prefix(const fs::path& socket_path) { } std::optional find_wineprefix() { - // We need these string conversions because Boost still doesn't use - // std::filesystem paths - std::optional dosdevices_dir = - find_dominating_file("dosdevices", find_vst_plugin().string(), - std::filesystem::is_directory); - if (dosdevices_dir.has_value()) { - return dosdevices_dir->parent_path().string(); + std::optional dosdevices_dir = + find_dominating_file("dosdevices", find_vst_plugin(), fs::is_directory); + if (!dosdevices_dir.has_value()) { + return std::nullopt; } - return std::nullopt; + return dosdevices_dir->parent_path(); } PluginArchitecture find_vst_architecture(fs::path plugin_path) {