pub struct FileOps { /* private fields */ }Expand description
All file operations of the panel.
Implementations§
Source§impl FileOps
impl FileOps
Sourcepub fn with_trash(trash: Box<dyn TrashService>) -> Self
pub fn with_trash(trash: Box<dyn TrashService>) -> Self
FileOps with an explicit trash backend (used in tests).
Sourcepub fn create_file(&self, dir: &Path, name: &str) -> Result<PathBuf, OpsError>
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.
Sourcepub fn create_dir(&self, dir: &Path, name: &str) -> Result<PathBuf, OpsError>
pub fn create_dir(&self, dir: &Path, name: &str) -> Result<PathBuf, OpsError>
Create a new, empty directory named name inside dir.
Sourcepub fn rename(&self, from: &Path, new_name: &str) -> Result<PathBuf, OpsError>
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.
Sourcepub fn copy(&self, from: &Path, dest_dir: &Path) -> Result<PathBuf, OpsError>
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.
Sourcepub fn move_(&self, from: &Path, dest_dir: &Path) -> Result<PathBuf, OpsError>
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.
Sourcepub fn duplicate(&self, from: &Path) -> Result<PathBuf, OpsError>
pub fn duplicate(&self, from: &Path) -> Result<PathBuf, OpsError>
Duplicate from in place (used by the Duplicate menu action).
Sourcepub fn create_link(&self, from: &Path) -> Result<PathBuf, OpsError>
pub fn create_link(&self, from: &Path) -> Result<PathBuf, OpsError>
Create a symlink to from next to it, named “Link to
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for FileOps
impl !UnwindSafe for FileOps
impl Freeze for FileOps
impl Send for FileOps
impl Sync for FileOps
impl Unpin for FileOps
impl UnsafeUnpin for FileOps
Blanket Implementations§
Source§impl<C> AsyncPosition<()> for C
impl<C> AsyncPosition<()> for C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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