dumpling 0.1.0

A fast JavaScript runtime and bundler in Rust
Documentation
use std::path::Path;
use std::fs;
use std::io;
use anyhow::Result;

pub async fn read_file(path: &Path) -> Result<String> {
    Ok(fs::read_to_string(path)?)
}

pub async fn write_file(path: &Path, content: &str) -> Result<()> {
    Ok(fs::write(path, content)?)
}

pub async fn exists(path: &Path) -> bool {
    path.exists()
}

pub async fn is_file(path: &Path) -> bool {
    path.is_file()
}

pub async fn is_dir(path: &Path) -> bool {
    path.is_dir()
}

pub async fn create_dir_all(path: &Path) -> Result<()> {
    Ok(fs::create_dir_all(path)?)
}

pub async fn read_dir(path: &Path) -> Result<Vec<String>> {
    let mut entries = Vec::new();
    
    for entry in fs::read_dir(path)? {
        let entry = entry?;
        let path = entry.path();
        if let Some(name) = path.file_name() {
            if let Some(name_str) = name.to_str() {
                entries.push(name_str.to_string());
            }
        }
    }
    
    Ok(entries)
}

pub async fn remove_file(path: &Path) -> Result<()> {
    Ok(fs::remove_file(path)?)
}

pub async fn remove_dir_all(path: &Path) -> Result<()> {
    Ok(fs::remove_dir_all(path)?)
}

pub async fn copy_file(from: &Path, to: &Path) -> Result<()> {
    Ok(fs::copy(from, to)?);
    Ok(())
}

pub async fn metadata(path: &Path) -> Result<fs::Metadata> {
    Ok(fs::metadata(path)?)
}