mirror of
https://github.com/supleed2/sv-filelist-parser.git
synced 2024-11-10 01:35:49 +00:00
A simple try in main
This commit is contained in:
parent
17c4de3e5f
commit
3b6cb44627
|
@ -2,3 +2,6 @@ sample/file1.sv
|
||||||
sample/file2.sv
|
sample/file2.sv
|
||||||
sample/file3.sv
|
sample/file3.sv
|
||||||
sample/file4.sv
|
sample/file4.sv
|
||||||
|
+incdir+sample/
|
||||||
|
// Some comment
|
||||||
|
+define+a=b+c=d+e=f
|
29
src/main.rs
29
src/main.rs
|
@ -1,33 +1,12 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
use sv_filelist_parser;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
||||||
// get .f file
|
let filelist = sv_filelist_parser::parse(&args[1])
|
||||||
let dot_f_file = PathBuf::from(&args[1]);
|
.expect("Error parsing");
|
||||||
println!("pathbuf {:?}", dot_f_file);
|
println!("{:#?}", filelist);
|
||||||
|
|
||||||
// check if .f file exists
|
|
||||||
if dot_f_file.is_file() {
|
|
||||||
println!("File exists", )
|
|
||||||
} else {
|
|
||||||
println!("File does not exist", )
|
|
||||||
}
|
|
||||||
|
|
||||||
// read .f file
|
|
||||||
let contents = fs::read_to_string(&dot_f_file)
|
|
||||||
.expect("Error while reading file");
|
|
||||||
|
|
||||||
println!("contents:\n{}", contents);
|
|
||||||
// check if all the files exist
|
|
||||||
for line in contents.lines() {
|
|
||||||
if PathBuf::from(line).is_file() {
|
|
||||||
println!("{} exists", line)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
println!("{} does not exist", line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue