mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-22 04:37:46 +00:00
Fold free-standing is_valid() function into BootData
This commit is contained in:
parent
8eee3ec331
commit
51e8749b2d
1 changed files with 11 additions and 11 deletions
|
@ -15,16 +15,6 @@ pub struct BootData {
|
||||||
pub version: String,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_valid(path: &str) -> bool {
|
|
||||||
let d = PathBuf::from(path);
|
|
||||||
|
|
||||||
if fs::metadata(d.as_path()).is_err() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BootData {
|
impl BootData {
|
||||||
/// Reads from an existing boot data location.
|
/// Reads from an existing boot data location.
|
||||||
///
|
///
|
||||||
|
@ -39,7 +29,7 @@ impl BootData {
|
||||||
/// # assert!(boot.is_none())
|
/// # assert!(boot.is_none())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn from_existing(directory: &str) -> Option<BootData> {
|
pub fn from_existing(directory: &str) -> Option<BootData> {
|
||||||
match is_valid(directory) {
|
match Self::is_valid(directory) {
|
||||||
true => Some(BootData {
|
true => Some(BootData {
|
||||||
path: directory.parse().unwrap(),
|
path: directory.parse().unwrap(),
|
||||||
version: fs::read_to_string(format!("{directory}/ffxivboot.ver")).unwrap(),
|
version: fs::read_to_string(format!("{directory}/ffxivboot.ver")).unwrap(),
|
||||||
|
@ -55,4 +45,14 @@ impl BootData {
|
||||||
pub fn apply_patch(&self, patch_path: &str) -> Result<(), PatchError> {
|
pub fn apply_patch(&self, patch_path: &str) -> Result<(), PatchError> {
|
||||||
apply_patch(&self.path, patch_path)
|
apply_patch(&self.path, patch_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_valid(path: &str) -> bool {
|
||||||
|
let d = PathBuf::from(path);
|
||||||
|
|
||||||
|
if fs::metadata(d.as_path()).is_err() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue