summaryrefslogtreecommitdiff
path: root/src/info.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/info.rs')
-rw-r--r--[-rwxr-xr-x]src/info.rs37
1 files changed, 1 insertions, 36 deletions
diff --git a/src/info.rs b/src/info.rs
index d827a53..eb258bb 100755..100644
--- a/src/info.rs
+++ b/src/info.rs
@@ -1,43 +1,8 @@
use serde::{Deserialize, Serialize};
use std::fs;
-use std::path::{Path, PathBuf};
use colored::Colorize;
-const REPO_ROOT: &str = "/var/ror/packages";
-
-fn find_case_insensitive_dir(parent: &Path, target: &str) -> Option<PathBuf> {
- let exact = parent.join(target);
- if exact.exists() && exact.is_dir() {
- return Some(exact);
- }
- let target_lower = target.to_lowercase();
- for entry in fs::read_dir(parent).ok()? {
- let entry = entry.ok()?;
- if entry.file_type().ok()?.is_dir() && entry.file_name().to_string_lossy().to_lowercase() == target_lower {
- return Some(entry.path());
- }
- }
- None
-}
-
-fn find_package_file(pkg_name: &str) -> Option<PathBuf> {
- let repo = Path::new(REPO_ROOT);
- for entry in fs::read_dir(repo).ok()? {
- let entry = entry.ok()?;
- let cat_path = entry.path();
- if !cat_path.is_dir() {
- continue;
- }
- if let Some(pkg_dir) = find_case_insensitive_dir(&cat_path, pkg_name) {
- let dir_name = pkg_dir.file_name()?.to_string_lossy();
- let pkg_path = pkg_dir.join(format!("{}.yaml", dir_name));
- if pkg_path.exists() && pkg_path.is_file() {
- return Some(pkg_path);
- }
- }
- }
- None
-}
+use crate::install::find_package_file;
#[derive(Debug, Serialize, Deserialize)]
struct Package {