1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! # filey
//! 'filey' is a collection of utilities to make file operations more convenient.
//!
//! This library is made up of three main components:
//!
//! - [`Filey`]: the main struct.
//! - [`FileTypes`]: make treating file types easier.
//!
//! # A Basic example
//! ```
//! use filey::Filey;
//! # use std::error::Error;
//! #
//! # fn examples() -> Result<(), Box<Error>> {
//! use filey::{Filey, FileTypes};
//!
//! let mut file = Filey::new(".great_app.conf").create(FileTypes::File)?;
//! let file_size = file.size()?;
//! println!("{}", file_size); // 0
//!
//! let dotfile = file.move_to("dotfiles/")?;
//!
//! dotfile.symlink(".great_app.conf")?;
//! # Ok(())
//! # }
//! # fn main() {
//! # examples().unwrap();
//! # }
//! ```

mod file_types;
mod filey;
mod macros;
#[cfg(target_family = "unix")]
mod permissions;
mod test;
pub mod units;

pub use crate::{file_types::FileTypes, filey::Filey, permissions::Permissions};

#[derive(Debug, thiserror::Error)]
#[error(transparent)]
pub enum Error {
    FileyError(anyhow::Error),
    #[error("'{}' already exists", path)]
    AlreadyExists {
        path: String,
    },
    #[error("Could not get the name of '{}'", path)]
    GetFileNameError {
        path: String,
    },
}

pub type Result<T> = std::result::Result<T, crate::Error>;