Remove install_check
This commit is contained in:
parent
00542f11d3
commit
8f46888688
@ -1,38 +0,0 @@
|
||||
/*
|
||||
Rust Arch Linux Updater
|
||||
Copyright (C) 2024 Luke Harding <luke@lukeh990.io>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
install_check.rs
|
||||
This module allows for checking if any file is present on the filesystem
|
||||
*/
|
||||
|
||||
use std::fmt;
|
||||
use std::fmt::Formatter;
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct NotInstalledError {
|
||||
file_name: String,
|
||||
}
|
||||
|
||||
impl fmt::Display for NotInstalledError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{} not found.", self.file_name)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run(path: impl Into<String>) -> Result<(), NotInstalledError> {
|
||||
let path = path.into();
|
||||
let exists = Path::new(&path).exists();
|
||||
|
||||
if exists {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(NotInstalledError { file_name: path })
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user