From 0d3a25c7795795c4590e496bf7f58fe9ede2b4af Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 14 Sep 2023 06:57:40 +0200 Subject: [PATCH] videoplayer: ignore directories passed as input names --- videoplayer/src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/videoplayer/src/main.rs b/videoplayer/src/main.rs index 56c3112..e695280 100644 --- a/videoplayer/src/main.rs +++ b/videoplayer/src/main.rs @@ -545,6 +545,11 @@ impl Player { // prepare data source let path = Path::new(name); let mut file = if let Ok(handle) = File::open(path) { + if let Ok(meta) = handle.metadata() { + if meta.is_dir() { + return window; + } + } handle } else { println!("failed to open {}", name); -- 2.39.5