use std::path::Path;
use std::path::PathBuf;
#[cfg(feature = "enhanced-errors")]
pub use crate::deps::enhanced_errors::ReadDir;
#[cfg(not(feature = "enhanced-errors"))]
pub use std::fs::ReadDir;
pub use std::fs::Metadata;
pub fn create_file<P: Into<PathBuf> + std::convert::AsRef<std::path::Path>>(
path: P,
) -> std::io::Result<()> {
#[cfg(feature = "enhanced-errors")]
crate::deps::enhanced_errors::File::create(path)?;
#[cfg(not(feature = "enhanced-errors"))]
::std::fs::File::create(path)?;
Ok(())
}
pub fn rename<From: AsRef<Path>, To: AsRef<Path>>(from: From, to: To) -> std::io::Result<()> {
#[cfg(feature = "enhanced-errors")]
crate::deps::enhanced_errors::rename(from, to)?;
#[cfg(not(feature = "enhanced-errors"))]
::std::fs::rename(from, to)?;
Ok(())
}
pub fn set_permissions<P: AsRef<Path>>(
path: P,
perms: std::fs::Permissions,
) -> std::io::Result<()> {
#[cfg(feature = "enhanced-errors")]
crate::deps::enhanced_errors::set_permissions(path, perms)?;
#[cfg(not(feature = "enhanced-errors"))]
std::fs::set_permissions(path, perms)?;
Ok(())
}
pub fn create_dir<P: AsRef<Path>>(path: P) -> std::io::Result<()> {
#[cfg(feature = "enhanced-errors")]
{
crate::deps::enhanced_errors::create_dir(path)
}
#[cfg(not(feature = "enhanced-errors"))]
{
std::fs::create_dir(path)
}
}
pub fn create_dir_all<P: AsRef<Path>>(path: P) -> std::io::Result<()> {
#[cfg(feature = "enhanced-errors")]
{
crate::deps::enhanced_errors::create_dir_all(path)
}
#[cfg(not(feature = "enhanced-errors"))]
{
std::fs::create_dir_all(path)
}
}
pub fn remove_dir<P: AsRef<Path>>(path: P) -> std::io::Result<()> {
#[cfg(feature = "enhanced-errors")]
{
crate::deps::enhanced_errors::remove_dir(path)
}
#[cfg(not(feature = "enhanced-errors"))]
{
std::fs::remove_dir(path)
}
}
pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> std::io::Result<()> {
#[cfg(feature = "enhanced-errors")]
{
crate::deps::enhanced_errors::remove_dir_all(path)
}
#[cfg(not(feature = "enhanced-errors"))]
{
std::fs::remove_dir_all(path)
}
}
#[cfg(feature = "enhanced-errors")]
pub fn read_dir<P: AsRef<Path>>(path: P) -> std::io::Result<crate::deps::enhanced_errors::ReadDir> {
crate::deps::enhanced_errors::read_dir(path.as_ref())
}
#[cfg(not(feature = "enhanced-errors"))]
pub fn read_dir<P: AsRef<Path>>(path: P) -> std::io::Result<std::fs::ReadDir> {
std::fs::read_dir(path)
}
pub fn metadata<P: AsRef<Path>>(path: P) -> std::io::Result<std::fs::Metadata> {
#[cfg(feature = "enhanced-errors")]
{
crate::deps::enhanced_errors::metadata(path)
}
#[cfg(not(feature = "enhanced-errors"))]
{
std::fs::metadata(path)
}
}
pub fn read<P: AsRef<Path>>(path: P) -> std::io::Result<Vec<u8>> {
#[cfg(feature = "enhanced-errors")]
{
crate::deps::enhanced_errors::read(path)
}
#[cfg(not(feature = "enhanced-errors"))]
{
std::fs::read(path)
}
}
pub fn read_to_string<P: AsRef<Path>>(path: P) -> std::io::Result<String> {
#[cfg(feature = "enhanced-errors")]
{
crate::deps::enhanced_errors::read_to_string(path)
}
#[cfg(not(feature = "enhanced-errors"))]
{
std::fs::read_to_string(path)
}
}
pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> std::io::Result<()> {
#[cfg(feature = "enhanced-errors")]
{
crate::deps::enhanced_errors::write(path, contents)
}
#[cfg(not(feature = "enhanced-errors"))]
{
std::fs::write(path, contents)
}
}
pub fn remove_file<P: AsRef<Path>>(path: P) -> std::io::Result<()> {
#[cfg(feature = "enhanced-errors")]
{
crate::deps::enhanced_errors::remove_file(path)
}
#[cfg(not(feature = "enhanced-errors"))]
{
std::fs::remove_file(path)
}
}