Skip to main content

FileOps

Struct FileOps 

Source
pub struct FileOps { /* private fields */ }
Expand description

All file operations of the panel.

Implementations§

Source§

impl FileOps

Source

pub fn new() -> Self

FileOps backed by the platform trash (GIO).

Source

pub fn with_trash(trash: Box<dyn TrashService>) -> Self

FileOps with an explicit trash backend (used in tests).

Source

pub fn create_file(&self, dir: &Path, name: &str) -> Result<PathBuf, OpsError>

Create a new, empty file named name inside dir.

Fails with OpsError::Conflict when the name already exists, so this is safe against accidental overwrites.

Source

pub fn create_dir(&self, dir: &Path, name: &str) -> Result<PathBuf, OpsError>

Create a new, empty directory named name inside dir.

Source

pub fn rename(&self, from: &Path, new_name: &str) -> Result<PathBuf, OpsError>

Rename from to a new name inside its current directory.

Uses renameat2(..., RENAME_NOREPLACE) where available so the “destination must not exist” check is atomic: the previous dest.exists() pre-check had a TOCTOU window in which a concurrently created file would be silently overwritten by rename(2). On filesystems or kernels that reject RENAME_NOREPLACE (e.g. some network filesystems), it falls back to the check-then-rename sequence, which is still correct in the common single-user case.

Source

pub fn copy(&self, from: &Path, dest_dir: &Path) -> Result<PathBuf, OpsError>

Copy from into dest_dir using from’s file name, resolving name conflicts by appending (n) before the extension.

Source

pub fn move_(&self, from: &Path, dest_dir: &Path) -> Result<PathBuf, OpsError>

Move from into dest_dir under its current file name (resolving conflicts the same way as Self::copy). Falls back to copy+delete when the move crosses a filesystem boundary.

Source

pub fn duplicate(&self, from: &Path) -> Result<PathBuf, OpsError>

Duplicate from in place (used by the Duplicate menu action).

Create a symlink to from next to it, named “Link to ” (with a unique suffix on collisions). The link is created with an absolute target so it keeps working from any directory.

Source

pub fn trash(&self, paths: &[PathBuf]) -> Result<(), OpsError>

Move each path to the trash. Stops at the first failure.

Source

pub fn delete_permanently(&self, paths: &[PathBuf]) -> Result<(), OpsError>

Permanently delete each path — unlinks files, recursively removes directories. Bypasses the trash entirely; there is no undo. Stops at the first failure (paths already removed stay removed).

Trait Implementations§

Source§

impl Debug for FileOps

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FileOps

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<C> AsyncPosition<()> for C

Source§

fn position(_index: usize)

Returns the position. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<C, I> Position<(), I> for C

Source§

fn position(&self, _index: &I)

Returns the position. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more