mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-10 06:12:14 +02:00
Replace most uses of Boost.{Filesystem,Process}
With the `ghc::filesystem` dependency from the previous commit. If we can replace the rest of the Boost.Filesystem dependency then we can get rid the one nasty runtime dependency we have, and it will make implementing the chainloading simpler since can reuse more code without bringing in Boost.
This commit is contained in:
+24
-16
@@ -38,7 +38,7 @@
|
||||
#include "../common/utils.h"
|
||||
|
||||
namespace bp = boost::process;
|
||||
namespace fs = boost::filesystem;
|
||||
namespace fs = ghc::filesystem;
|
||||
|
||||
// These functions are used to populate the fields in `PluginInfo`. See the
|
||||
// docstrings for the corresponding fields for more information on what we're
|
||||
@@ -74,7 +74,7 @@ bp::environment PluginInfo::create_host_env() const {
|
||||
// just for clarity's sake)
|
||||
std::visit(overload{
|
||||
[](const OverridenWinePrefix&) {},
|
||||
[&](const boost::filesystem::path& prefix) {
|
||||
[&](const ghc::filesystem::path& prefix) {
|
||||
env["WINEPREFIX"] = prefix.string();
|
||||
},
|
||||
[](const DefaultWinePrefix&) {},
|
||||
@@ -84,11 +84,11 @@ bp::environment PluginInfo::create_host_env() const {
|
||||
return env;
|
||||
}
|
||||
|
||||
boost::filesystem::path PluginInfo::normalize_wine_prefix() const {
|
||||
ghc::filesystem::path PluginInfo::normalize_wine_prefix() const {
|
||||
return std::visit(
|
||||
overload{
|
||||
[](const OverridenWinePrefix& prefix) { return prefix.value; },
|
||||
[](const boost::filesystem::path& prefix) { return prefix; },
|
||||
[](const ghc::filesystem::path& prefix) { return prefix; },
|
||||
[](const DefaultWinePrefix&) {
|
||||
const bp::environment env = boost::this_process::environment();
|
||||
return fs::path(env.at("HOME").to_string()) / ".wine";
|
||||
@@ -101,7 +101,8 @@ std::string PluginInfo::wine_version() const {
|
||||
// The '*.exe' scripts generated by winegcc allow you to override the binary
|
||||
// used to run Wine, so will will handle this in the same way for our Wine
|
||||
// version detection
|
||||
fs::path wine_path;
|
||||
// FIXME: Replace Boost.Filesystem usage
|
||||
boost::filesystem::path wine_path;
|
||||
bp::environment env = create_host_env();
|
||||
if (const std::string wineloader_path = env["WINELOADER"].to_string();
|
||||
access(wineloader_path.c_str(), X_OK) == 0) {
|
||||
@@ -280,7 +281,8 @@ fs::path get_this_file_location() {
|
||||
// way to work around this if this happens is to just add another
|
||||
// leading slash and then normalize the path, since three or more
|
||||
// slashes will be coerced into a single slash.
|
||||
fs::path this_file = boost::dll::this_line_location();
|
||||
// FIXME: Replace Boost.Filesystem usage
|
||||
fs::path this_file = boost::dll::this_line_location().string();
|
||||
if (this_file.string().starts_with("//")) {
|
||||
this_file = ("/" / this_file).lexically_normal();
|
||||
}
|
||||
@@ -318,9 +320,10 @@ std::string create_logger_prefix(const fs::path& endpoint_base_dir) {
|
||||
return "[" + endpoint_name + "] ";
|
||||
}
|
||||
|
||||
fs::path find_vst_host(const boost::filesystem::path& this_plugin_path,
|
||||
fs::path find_vst_host(const ghc::filesystem::path& this_plugin_path,
|
||||
LibArchitecture plugin_arch,
|
||||
bool use_plugin_groups) {
|
||||
// FIXME: Anything using `this_plugin_path` and similar needs to be changed
|
||||
auto host_name = use_plugin_groups ? yabridge_group_host_name
|
||||
: yabridge_individual_host_name;
|
||||
if (plugin_arch == LibArchitecture::dll_32) {
|
||||
@@ -338,19 +341,20 @@ fs::path find_vst_host(const boost::filesystem::path& this_plugin_path,
|
||||
|
||||
// Boost will return an empty path if the file could not be found in the
|
||||
// search path
|
||||
const fs::path vst_host_path =
|
||||
const boost::filesystem::path vst_host_path =
|
||||
bp::search_path(host_name, get_augmented_search_path());
|
||||
if (vst_host_path == "") {
|
||||
throw std::runtime_error("Could not locate '" + std::string(host_name) +
|
||||
"'");
|
||||
}
|
||||
|
||||
return vst_host_path;
|
||||
// FIXME: Replace Boost.Filesystem usage requiring this conversion
|
||||
return vst_host_path.string();
|
||||
}
|
||||
|
||||
boost::filesystem::path generate_group_endpoint(
|
||||
ghc::filesystem::path generate_group_endpoint(
|
||||
const std::string& group_name,
|
||||
const boost::filesystem::path& wine_prefix,
|
||||
const ghc::filesystem::path& wine_prefix,
|
||||
const LibArchitecture architecture) {
|
||||
std::ostringstream socket_name;
|
||||
socket_name << "yabridge-group-" << group_name << "-"
|
||||
@@ -370,6 +374,7 @@ boost::filesystem::path generate_group_endpoint(
|
||||
return get_temporary_directory() / socket_name.str();
|
||||
}
|
||||
|
||||
// FIXME: Replace Boost.Filesystem
|
||||
std::vector<boost::filesystem::path> get_augmented_search_path() {
|
||||
// HACK: `std::locale("")` would return the current locale, but this
|
||||
// overload is implementation specific, and libstdc++ returns an error
|
||||
@@ -410,12 +415,13 @@ std::vector<boost::filesystem::path> get_augmented_search_path() {
|
||||
const bp::environment environment = boost::this_process::environment();
|
||||
if (auto xdg_data_home = environment.find("XDG_DATA_HOME");
|
||||
xdg_data_home != environment.end()) {
|
||||
search_path.push_back(fs::path(xdg_data_home->to_string()) /
|
||||
"yabridge");
|
||||
search_path.push_back(
|
||||
boost::filesystem::path(xdg_data_home->to_string()) / "yabridge");
|
||||
} else if (auto home_directory = environment.find("HOME");
|
||||
home_directory != environment.end()) {
|
||||
search_path.push_back(fs::path(home_directory->to_string()) / ".local" /
|
||||
"share" / "yabridge");
|
||||
search_path.push_back(
|
||||
boost::filesystem::path(home_directory->to_string()) / ".local" /
|
||||
"share" / "yabridge");
|
||||
}
|
||||
|
||||
return search_path;
|
||||
@@ -436,7 +442,9 @@ Configuration load_config_for(const fs::path& yabridge_path) {
|
||||
bool send_notification(const std::string& title,
|
||||
const std::string body,
|
||||
bool append_origin) {
|
||||
const fs::path notify_send_path = bp::search_path("notify-send");
|
||||
// FIXME: Replace Boost.Filesystem
|
||||
const boost::filesystem::path notify_send_path =
|
||||
bp::search_path("notify-send");
|
||||
if (notify_send_path.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user