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
//! Utility tools for checking the availability of system commands.
//!
//! This module provides functions to determine whether a specific program
//! or executable file is installed on the system and accessible via the environment variables.
/**
* command_exists.c
*
* (C) Copyright 2026 AtlantisOS Project
* by @NachtsternBuild
*
* License: GNU GENERAL PUBLIC LICENSE Version 3
*/
use env;
use Path;
/// Checks whether a command is available on the system.
///
/// The function distinguishes between two scenarios:
/// 1. **Absolute path:** If the passed string is an absolute path,
/// it checks directly whether the file exists at that location.
/// 2. **Command name:** If only a name (e.g., "ls" or "git") is passed,
/// the function searches all directories defined in the environment variable
/// `PATH`.
///
/// # Arguments
/// * `command` - The name of the command or an absolute path to the file.
///
/// # Return Value
/// Returns `true` if the command was found and is an executable file,
/// otherwise `false`.
///
/// # Usage:
///
/// ```rust
/// if command_exists_native("cd") {
/// println!("cd exists");
/// }
/// ```