add: file extension validation

This commit is contained in:
2026-08-23 22:02:06 +05:30
parent c423f084ed
commit 4b2ecb367d
+7 -1
View File
@@ -23,7 +23,13 @@ fn main() -> std::io::Result<()>{
.expect("Failed to init the logger"); .expect("Failed to init the logger");
let args: Vec<String> = env::args().collect(); let args: Vec<String> = env::args().collect();
info!("File: {}", &args[1]); let file_path = &args[1];
let extension = &file_path[file_path.len()-2..file_path.len()];
if extension != "sr" {
error!("File is not in .sr");
std::process::exit(-1);
}
info!("File: {}", file_path);
let file = File::open(&args[1])?; let file = File::open(&args[1])?;
let reader = BufReader::new(file); let reader = BufReader::new(file);