mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-09 22:02:10 +02:00
Factor out directory finding from prefix detection
This will also be used to locate the `yabridge.tmol` configuration file.
This commit is contained in:
+9
-10
@@ -28,6 +28,8 @@
|
||||
// Generated inside of build directory
|
||||
#include <src/common/config/config.h>
|
||||
|
||||
#include <../common/configuration.h>
|
||||
|
||||
namespace bp = boost::process;
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
@@ -53,16 +55,13 @@ std::string create_logger_prefix(const fs::path& socket_path) {
|
||||
}
|
||||
|
||||
std::optional<fs::path> find_wineprefix() {
|
||||
// Try to locate the Wine prefix the plugin's .dll file is located in by
|
||||
// finding the first parent directory that contains a directory named
|
||||
// `dosdevices`
|
||||
fs::path wineprefix_path = find_vst_plugin();
|
||||
while (wineprefix_path != "") {
|
||||
if (fs::is_directory(wineprefix_path / "dosdevices")) {
|
||||
return wineprefix_path;
|
||||
}
|
||||
|
||||
wineprefix_path = wineprefix_path.parent_path();
|
||||
// We need these string conversions because Boost still doesn't use
|
||||
// std::filesystem paths
|
||||
std::optional<std::filesystem::path> 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();
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
|
||||
+2
-1
@@ -101,7 +101,8 @@ boost::filesystem::path find_vst_plugin();
|
||||
|
||||
/**
|
||||
* Locate the Wine prefix this file is located in, if it is inside of a wine
|
||||
* prefix.
|
||||
* prefix. This is done by locating the first parent directory that contains a
|
||||
* directory named `dosdevices`.
|
||||
*
|
||||
* @return Either the path to the Wine prefix (containing the `drive_c?`
|
||||
* directory), or `std::nullopt` if it is not inside of a wine prefix.
|
||||
|
||||
Reference in New Issue
Block a user