[yabridgectl] Allow setting up VST3 plugins

This is still missing checks for removing leftover files, symlinks for
resources and presets, and a way to differentiate between plugins with
the same name from different prefixes.
This commit is contained in:
Robbert van der Helm
2020-12-24 00:04:05 +01:00
parent bc9801c932
commit 55957ca798
4 changed files with 242 additions and 103 deletions
+26
View File
@@ -30,6 +30,7 @@ use std::process::{Command, Stdio};
use textwrap::Wrapper;
use crate::config::{self, Config, KnownConfig, YABRIDGE_HOST_EXE_NAME};
use crate::files::NativeFile;
/// (Part of) the expected output when running `yabridge-host.exe`. Used to verify that everything's
/// working correctly. We'll only match this prefix so we can modify the exact output at a later
@@ -47,6 +48,17 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64> {
})
}
/// Wrapper around [`std::fs::create_dir_all()`](std::fs::create_dir_all) with a human readable
/// error message.
pub fn create_dir_all<P: AsRef<Path>>(path: P) -> Result<()> {
fs::create_dir_all(&path).with_context(|| {
format!(
"Error creating directories for '{}'",
path.as_ref().display(),
)
})
}
/// Wrapper around [`std::fs::remove_file()`](std::fs::remove_file) with a human readable error
/// message.
pub fn remove_file<P: AsRef<Path>>(path: P) -> Result<()> {
@@ -66,6 +78,20 @@ pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> Result<()> {
})
}
/// Get the type of a file, if it exists.
pub fn get_file_type(path: &Path) -> Option<NativeFile> {
match path.metadata() {
Ok(metadata) if metadata.file_type().is_symlink() => {
Some(NativeFile::Symlink(path.to_owned()))
}
Ok(metadata) if metadata.file_type().is_dir() => {
Some(NativeFile::Directory(path.to_owned()))
}
Ok(_) => Some(NativeFile::Regular(path.to_owned())),
Err(_) => None,
}
}
/// Hash the conetnts of a file as an `i64` using Rust's built in hasher. Collisions are not a big
/// issue in our situation so we can get away with this.
///