add: file extension validation
This commit is contained in:
+7
-1
@@ -23,7 +23,13 @@ fn main() -> std::io::Result<()>{
|
||||
.expect("Failed to init the logger");
|
||||
|
||||
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 reader = BufReader::new(file);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user