use abi::error::Error;
use alloc::string::String;

use crate::process;

pub fn current_exe<T, F: FnOnce(&str) -> T>(_mapper: F) -> Result<T, Error> {
    todo!()
}

pub fn home_directory<T, F: FnOnce(&str) -> T>(_mapper: F) -> Result<T, Error> {
    todo!()
}

pub fn current_directory<T, F: FnOnce(&str) -> T>(mapper: F) -> Result<T, Error> {
    let mut buffer = [0; 512];
    let path = process::get_process_option::<process::options::Directory>(None, &mut buffer)?;
    Ok(mapper(path))
}

pub fn current_directory_string() -> Result<String, Error> {
    current_directory(|s| s.into())
}

pub fn set_current_directory(path: &str) -> Result<(), Error> {
    let mut buffer = [0; 512];
    process::set_process_option_with::<process::options::Directory>(None, &mut buffer, &path)
}

pub fn make_temp_directory(_template: &mut [u8]) -> Result<(), Error> {
    todo!()
}

pub fn canonicalize<T, F: FnOnce(&str) -> T>(_path: &str, _mapper: F) -> Result<T, Error> {
    todo!()
}
