[yabridgectl] Disallow adding individual files

This commit is contained in:
Robbert van der Helm
2022-01-12 13:56:09 +01:00
parent 8382384fc1
commit 1f16c2bf1a
2 changed files with 18 additions and 2 deletions
+14 -2
View File
@@ -60,8 +60,8 @@ fn main() -> Result<()> {
.display_order(1)
.arg(
Arg::new("path")
.help("Path to a directory containing Windows VST plugins")
.validator(validate_path)
.help("Path to a directory containing Windows VST2 or VST3 plugins")
.validator(validate_directory)
.takes_value(true)
.required(true),
),
@@ -301,6 +301,18 @@ fn main() -> Result<()> {
}
}
/// Verify that a path exists and that is is either a directory or a symlink to a directory.
fn validate_directory(path: &str) -> Result<(), String> {
validate_path(path)?;
let path = Path::new(path);
if path.is_dir() {
Ok(())
} else {
Err(format!("'{}' is not a directory", path.display()))
}
}
/// Verify that a path exists, used for validating arguments.
fn validate_path(path: &str) -> Result<(), String> {
let path = Path::new(path);