use std::io;
use std::path::Path;
use crate::fs::file::File;
pub async fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
let mut file = File::open(path).await?;
file.read_to_string().await
}
pub async fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
let mut file = File::open(path).await?;
file.read_to_end().await
}
pub async fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> {
moirai_pal::fs::write(path, contents).await
}
pub async fn write_str<P: AsRef<Path>>(path: P, contents: &str) -> io::Result<()> {
write(path, contents.as_bytes()).await
}
pub async fn append<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> {
moirai_pal::fs::append(path, contents).await
}
pub async fn append_str<P: AsRef<Path>>(path: P, contents: &str) -> io::Result<()> {
append(path, contents.as_bytes()).await
}
pub async fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<u64> {
moirai_pal::fs::copy(from, to).await
}
pub async fn metadata<P: AsRef<Path>>(path: P) -> io::Result<std::fs::Metadata> {
moirai_pal::fs::metadata(path).await
}
pub async fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()> {
moirai_pal::fs::rename(from, to).await
}
pub async fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
moirai_pal::fs::remove_file(path).await
}
pub async fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
moirai_pal::fs::create_dir(path).await
}
pub async fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
moirai_pal::fs::create_dir_all(path).await
}
pub async fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
moirai_pal::fs::remove_dir(path).await
}
pub async fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
moirai_pal::fs::remove_dir_all(path).await
}