1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Identification of configuration and source files based on their names.
//!
//! This module is primarily used to determine whether specific
//! repository entries (PPAs) or software sources are stored on the system.
/**
* search_string_name.rs
*
* (C) Copyright 2026 AtlantisOS Project
* by @NachtsternBuild
*
* License: GNU GENERAL PUBLIC LICENSE Version 3
*/
use fs;
use Path;
/// Searches a directory for a file whose name contains a specific string.
///
/// This function is used within AtlantisOS to validate the installation source
/// of the application (e.g., searching for "fastboot-assistant" in the APT sources).
///
/// # How it works
/// 1. First checks whether the target directory exists. If not, `Ok(false)` is returned.
/// 2. Iterates over all entries in the directory.
/// 3. Compares the filename with the search term.
///
/// # Arguments
/// * `directory` - The path to the directory (e.g., `/etc/apt/sources.list.d`).
/// * `search` - The substring to search for in the filename.
///
/// # Return Value
/// * `Ok(true)` - A matching file was found.
/// * `Ok(false)` - No file matches the pattern, or the directory does not exist.
/// * `Err(std::io::Error)` - Access to the directory was denied or failed.
///
/// # Usage:
///
/// ```rust
/// match search_string_file(source_dir, search_string) {
/// Ok(true) => AppEnvironment::Ppa,
/// Ok(false) => {
/// println!("Running local DEB package.");
/// AppEnvironment::LocalDeb
/// },
/// Err(e) => {
/// eprintln!("Error check for PPA files: {}", e);
/// process::exit(1);
/// }
/// }
/// ```