More updoots
Sorry future ben this commit message sucks
This commit is contained in:
1 parent
4aaa6601c2
commit
0a0ca87243
8 files changed
+59
-13
No files matched your search
@@ -1,3 +1,4 @@
|
||||
use glob::glob;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
||||
@@ -14,3 +15,20 @@ pub fn load_file_contents(file_path: String) -> String {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn list_files(path: String, extension: String) -> Vec<String> {
|
||||
let mut tmp_path = path.clone();
|
||||
let mut files = Vec::<String>::new();
|
||||
let glob_path = format!("{}/*.{}", tmp_path, extension);
|
||||
// tmp_path.push_str(&glob_path);
|
||||
// println!("{}", glob_path);
|
||||
|
||||
for entry in glob(&glob_path).unwrap() {
|
||||
match entry {
|
||||
Ok(p) => files.push(String::from(p.display().to_string())),
|
||||
Err(e) => return vec![String::new()],
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
+10
-1
@@ -9,8 +9,17 @@ fn main() {
|
||||
let config = Config::load();
|
||||
|
||||
let pool = structs::BingoPool::load_from_file(String::from(
|
||||
"/home/ben/Documents/Projects/rust/BingoBongo/backend/workingdir/squares/testdata/testdata.toml",
|
||||
"/home/ben/Documents/Projects/rust/BingoBongo/backend/workingdir/pools/testdata.toml",
|
||||
));
|
||||
|
||||
// let pools = BingoPools::load_pools();
|
||||
|
||||
let files = files::list_files(
|
||||
String::from("/home/ben/Documents/Projects/rust/BingoBongo/backend/workingdir/pools"),
|
||||
String::from("toml"),
|
||||
);
|
||||
|
||||
println!("{:?}", files);
|
||||
|
||||
println!("{}", pool);
|
||||
}
|
||||
@@ -58,6 +58,18 @@ impl BingoPool {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BingoPools {
|
||||
pools: Vec<BingoPool>,
|
||||
}
|
||||
|
||||
impl BingoPools {
|
||||
pub fn load_pools() -> BingoPools {
|
||||
BingoPools {
|
||||
pools: Vec::<BingoPool>::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BingoBoard {
|
||||
size: i64,
|
||||
squares: Vec<BingoSquare>,
|
||||
|
||||
Reference in new issue
Block a user