irid-std 0.1.2

A replacement for std when running without a filesystem on the irid kernel
Documentation
use alloc::{boxed::Box, string::{String, ToString}, vec::Vec};

use crate::{ffi::{OsStr, OsString}, io::Error, path::{Path, PathBuf}, sync::{Mutex, MutexGuard}};

static ARGS: Mutex<Vec<Box<str>>> = Mutex::new(Vec::new());

pub fn args() -> impl Iterator<Item = String> {
    ARGS.lock().expect("args lock poisoned").iter().map(|x| x.to_string()).collect::<Vec<_>>().into_iter()
}

pub fn args_os() -> impl Iterator<Item = OsString> {
    args().map(OsString::from)
}

pub fn current_dir() -> Result<PathBuf, Error> {
    todo!()
}

pub fn set_current_dir(path: impl AsRef<Path>) -> Result<(), Error> {
    todo!()
}

pub fn current_exe() -> Result<PathBuf, Error> {
    todo!()
}

pub fn home_dir() -> Option<PathBuf> {
    todo!()
}

pub fn temp_dir() -> PathBuf {
    todo!()
}

pub fn var(name: impl AsRef<OsStr>) -> Option<String> {
    todo!()
}

pub fn var_os(name: impl AsRef<OsStr>) -> Option<OsString> {
    var(name).map(OsString::from)
}

pub fn vars() -> impl Iterator<Item = (String, String)> {
    None.into_iter()
}

pub fn vars_os() -> impl Iterator<Item = (OsString, OsString)> {
    vars().map(|(a, b)| (OsString::from(a), OsString::from(b)))
}

pub(crate) fn arg_lock() -> MutexGuard<'static, Vec<Box<str>>> {
    ARGS.lock().expect("failed to lock args")
}