sal/os
Mahmoud-Emad e125bb6511
Some checks failed
Rhai Tests / Run Rhai Tests (push) Has been cancelled
Rhai Tests / Run Rhai Tests (pull_request) Has been cancelled
feat: Migrate SAL to Cargo workspace
- Migrate individual modules to independent crates
- Refactor dependencies for improved modularity
- Update build system and testing infrastructure
- Update documentation to reflect new structure
2025-06-24 12:39:18 +03:00
..
src feat: Migrate SAL to Cargo workspace 2025-06-24 12:39:18 +03:00
tests feat: Migrate SAL to Cargo workspace 2025-06-24 12:39:18 +03:00
Cargo.toml feat: Migrate SAL to Cargo workspace 2025-06-24 12:39:18 +03:00
README.md feat: Add process package to monorepo 2025-06-22 11:41:10 +03:00

SAL OS Package (sal-os)

The sal-os package provides a comprehensive suite of operating system interaction utilities. It offers a cross-platform abstraction layer for common OS-level tasks, simplifying system programming in Rust.

Features

  • File System Operations: Comprehensive file and directory manipulation
  • Download Utilities: File downloading with automatic extraction support
  • Package Management: System package manager integration
  • Platform Detection: Cross-platform OS and architecture detection
  • Rhai Integration: Full scripting support for all OS operations

Modules

  • fs: File system operations (create, copy, delete, find, etc.)
  • download: File downloading and basic installation
  • package: System package management
  • platform: Platform and architecture detection

Usage

Add this to your Cargo.toml:

[dependencies]
sal-os = "0.1.0"

File System Operations

use sal_os::fs;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create directory
    fs::mkdir("my_dir")?;
    
    // Write and read files
    fs::file_write("my_dir/example.txt", "Hello from SAL!")?;
    let content = fs::file_read("my_dir/example.txt")?;
    
    // Find files
    let files = fs::find_files(".", "*.txt")?;
    
    Ok(())
}

Download Operations

use sal_os::download;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Download and extract archive
    let path = download::download("https://example.com/archive.tar.gz", "/tmp", 1024)?;
    
    // Download specific file
    download::download_file("https://example.com/script.sh", "/tmp/script.sh", 0)?;
    download::chmod_exec("/tmp/script.sh")?;
    
    Ok(())
}

Platform Detection

use sal_os::platform;

fn main() {
    if platform::is_linux() {
        println!("Running on Linux");
    }
    
    if platform::is_arm() {
        println!("ARM architecture detected");
    }
}

Rhai Integration

The package provides full Rhai scripting support:

// File operations
mkdir("test_dir");
file_write("test_dir/hello.txt", "Hello World!");
let content = file_read("test_dir/hello.txt");

// Download operations
download("https://example.com/file.zip", "/tmp", 0);
chmod_exec("/tmp/script.sh");

// Platform detection
if is_linux() {
    print("Running on Linux");
}