4 releases (2 breaking)

0.3.1 Apr 8, 2024
0.3.0 Nov 1, 2023
0.2.0 Aug 5, 2023
0.1.0 Jul 15, 2023

#11 in #file-permissions

Download history 3/week @ 2024-02-16 12/week @ 2024-02-23 6/week @ 2024-03-01 2/week @ 2024-03-08 4/week @ 2024-03-15 1/week @ 2024-03-22 47/week @ 2024-03-29 120/week @ 2024-04-05 14/week @ 2024-04-12

182 downloads per month
Used in 2 crates (via media_info)

MIT license

10KB
185 lines

FS Metadata

A cross-platform simple wrapper to get metadata of a file.

  1. Access SystemTime as readable dates.
  2. Get the permissions of a file.
  3. Get human readable file sizes.

Functions

Favor the Struct version instead.

pub fn file_created(path_str: &str) -> Result<String, String>

pub fn file_modified(path_str: &str) -> Result<String, String>

pub fn last_accessed(path_str: &str) -> Result<String, String>

Struct

struct FileMetadata {
    pub created: String,
    pub modified: String,
    pub accessed: String,
    pub is_file_read_only: bool,
    pub is_dir: bool,
    pub is_file: bool,
    pub is_readable: bool,
    pub is_writable: bool,
    pub is_executable: bool,
}

FileMetadata {
    fn new(path_str: &'static str) -> Result<Self, String>;
    fn readable(&self) -> bool;
    fn writable(&self) -> bool;
    fn executable(&self) -> bool;
    fn get_file_in_kilobytes(&self) -> f32;
    fn get_file_in_megabytes(&self) -> f32;
    fn get_file_in_gigabytes(&self) -> f32;
    fn get_file_in_terabytes(&self) -> f32;
}

Run Tests

To activate the tests, run cargo test -p fs_metadata.

Dependencies

~1–1.5MB
~22K SLoC