[][src]Struct quickcfg::FileSystem

pub struct FileSystem<'a> { /* fields omitted */ }

Helper and tracker of any filesystem modifications.

Methods

impl<'a> FileSystem<'a>[src]

pub fn new(
    opts: &'a Opts,
    state_dir: &Path,
    allocator: &'a UnitAllocator,
    data: &'a Data
) -> FileSystem<'a>
[src]

Create new, thread-safe file utilities.

pub fn validate(self) -> Result<(), Error>[src]

Validate that we haven't created any conflicting files. Logs details and errors in case duplicates are registered.

pub fn file_dependency(&self, path: &Path) -> Result<Dependency, Error>[src]

Access or allocate a file dependency of the given path.

pub fn dir_dependency(&self, path: &Path) -> Result<Dependency, Error>[src]

Access or allocate a directory dependency of the given path.

Try to create a symlink.

pub fn copy_file(
    &self,
    from: &Path,
    from_meta: Metadata,
    to: &Path,
    to_meta: Option<&Metadata>,
    template: bool
) -> Result<Option<SystemUnit>, Error>
[src]

Optionally set up if we should copy a file.

This is true if:

  • The destination file does not exist.
  • The destination file has a modified timestamp less than the source file.

pub fn create_dir_all(&self, dir: &Path) -> Result<Vec<SystemUnit>, Error>[src]

Recursively set up units with dependencies to create the given directories.

pub fn state_path(&self, id: &str) -> PathBuf[src]

Get the state path for the given ID.

pub fn try_open_meta(p: &Path) -> Result<Option<Metadata>, Error>[src]

Try to open metadata, unless the file does not exist.

If the file does not exist, returns None.

pub fn should_create_dir(
    path: &Path,
    meta: Option<&Metadata>
) -> Result<bool, Error>
[src]

Test if we should create the destination directory.

pub fn path_relative_from(path: &Path, base: &Path) -> Option<PathBuf>[src]

Construct a relative path from a provided base directory path to the provided path

use quickcfg::FileSystem;
use std::path::PathBuf;

let baz: PathBuf = "/foo/bar/baz".into();
let bar: PathBuf = "/foo/bar".into();
let quux: PathBuf = "/foo/bar/quux".into();
assert_eq!(FileSystem::path_relative_from(&bar, &baz), Some("../".into()));
assert_eq!(FileSystem::path_relative_from(&baz, &bar), Some("baz".into()));
assert_eq!(FileSystem::path_relative_from(&quux, &baz), Some("../quux".into()));
assert_eq!(FileSystem::path_relative_from(&baz, &quux), Some("../baz".into()));
assert_eq!(FileSystem::path_relative_from(&bar, &quux), Some("../".into()));

pub fn touch(path: &Path, timestamp: &SystemTime) -> Result<(), Error>[src]

Update timestamps for the given path.

Auto Trait Implementations

impl<'a> RefUnwindSafe for FileSystem<'a>

impl<'a> Send for FileSystem<'a>

impl<'a> Sync for FileSystem<'a>

impl<'a> Unpin for FileSystem<'a>

impl<'a> UnwindSafe for FileSystem<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.