add load_accounts
This commit is contained in:
parent
4e583530cd
commit
d7b952b40f
1 changed files with 26 additions and 1 deletions
|
@ -37,7 +37,9 @@ impl Manifest {
|
|||
Ok(file) => {
|
||||
let reader = BufReader::new(file);
|
||||
match serde_json::from_reader(reader) {
|
||||
Ok(manifest) => {
|
||||
Ok(m) => {
|
||||
let mut manifest: Manifest = m;
|
||||
manifest.folder = String::from(path.parent().unwrap().to_str().unwrap());
|
||||
return Ok(manifest);
|
||||
}
|
||||
Err(e) => {
|
||||
|
@ -50,4 +52,27 @@ impl Manifest {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_accounts(&mut self) {
|
||||
for entry in &self.entries {
|
||||
let path = Path::new(&self.folder).join(&entry.filename);
|
||||
match File::open(path) {
|
||||
Ok(f) => {
|
||||
let reader = BufReader::new(f);
|
||||
match serde_json::from_reader(reader) {
|
||||
Ok(a) => {
|
||||
let account: SteamGuardAccount = a;
|
||||
self.accounts.push(account);
|
||||
}
|
||||
Err(e) => {
|
||||
panic!("invalid json")
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
panic!(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue