1
use std::ffi::OsStr;
2
use std::path::Path;
3

            
4
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
6
pub enum SymFormat {
7
    /// The mCRL2 symbolic format
8
    Sym,
9
    /// The Sylvan binary format
10
    Sylvan,
11
}
12

            
13
/// Guesses the symbolic LTS file format from the file extension. Returns None if it cannot be determined.
14
pub fn guess_format_from_extension(path: &Path, format: Option<SymFormat>) -> Option<SymFormat> {
15
    if let Some(format) = format {
16
        return Some(format);
17
    }
18

            
19
    if path.extension() == Some(OsStr::new("ldd")) {
20
        Some(SymFormat::Sylvan)
21
    } else if path.extension() == Some(OsStr::new("sym")) {
22
        Some(SymFormat::Sym)
23
    } else {
24
        None
25
    }
26
}