DEVELOPMENT ENVIRONMENT

~liljamo/entamin

ref: e3e66074d013036e474749a5276702fb43996145 entamin/src/util.rs -rw-r--r-- 720 bytes
e3e66074Jonni Liljamo chore: clean flake.nix a bit a day ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * Copyright (C) 2024 Jonni Liljamo <jonni@liljamo.com>
 *
 * This file is licensed under GPL-3.0-or-later, see NOTICE and LICENSE for
 * more information.
 */

use std::{
    fs::{self, DirEntry},
    path::Path,
};

pub fn collect_files(dir: &Path, files: &mut Vec<DirEntry>) {
    for entry in fs::read_dir(dir).expect("could not read directory") {
        let entry = entry.expect("could not read directory entry");
        let path = entry.path();
        if path.is_dir() {
            collect_files(&path, files)
        } else if path.extension().unwrap() != "mkv" {
            panic!("file is not an mkv file: '{}'", path.to_string_lossy())
        } else {
            files.push(entry);
        }
    }
}