videoplayer: ignore directories passed as input names
authorKostya Shishkov <kostya.shiskov@gmail.com>
Thu, 14 Sep 2023 04:57:40 +0000 (06:57 +0200)
committerKostya Shishkov <kostya.shiskov@gmail.com>
Thu, 14 Sep 2023 04:57:40 +0000 (06:57 +0200)
videoplayer/src/main.rs

index 56c311237ff6cf06aeb0ec6171bb4907d9f5b81a..e6952807130b28630fbb62d1ebf3217ce5ddc348 100644 (file)
@@ -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);