pub trait DirExt {
// Required methods
fn set_atime<P: AsRef<Path>>(
&self,
path: P,
atime: SystemTimeSpec,
) -> Result<()>;
fn set_mtime<P: AsRef<Path>>(
&self,
path: P,
mtime: SystemTimeSpec,
) -> Result<()>;
fn set_times<P: AsRef<Path>>(
&self,
path: P,
atime: Option<SystemTimeSpec>,
mtime: Option<SystemTimeSpec>,
) -> Result<()>;
fn set_symlink_times<P: AsRef<Path>>(
&self,
path: P,
atime: Option<SystemTimeSpec>,
mtime: Option<SystemTimeSpec>,
) -> Result<()>;
fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
src: P,
dst: Q,
) -> Result<()>;
fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
src: P,
dst: Q,
) -> Result<()>;
fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
src: P,
dst: Q,
) -> Result<()>;
fn open_dir_nofollow<P: AsRef<Path>>(&self, path: P) -> Result<Self>
where Self: Sized;
fn remove_file_or_symlink<P: AsRef<Path>>(&self, path: P) -> Result<()>;
fn access<P: AsRef<Path>>(&self, path: P, type_: AccessType) -> Result<()>;
fn access_symlink<P: AsRef<Path>>(
&self,
path: P,
type_: AccessType,
) -> Result<()>;
fn set_symlink_permissions<P: AsRef<Path>>(
&self,
path: P,
perm: Permissions,
) -> Result<()>;
}
Expand description
Extension trait for Dir
.
Required Methods§
Sourcefn set_atime<P: AsRef<Path>>(
&self,
path: P,
atime: SystemTimeSpec,
) -> Result<()>
fn set_atime<P: AsRef<Path>>( &self, path: P, atime: SystemTimeSpec, ) -> Result<()>
Set the last access time for a file on a filesystem.
This corresponds to filetime::set_file_atime
.
Sourcefn set_mtime<P: AsRef<Path>>(
&self,
path: P,
mtime: SystemTimeSpec,
) -> Result<()>
fn set_mtime<P: AsRef<Path>>( &self, path: P, mtime: SystemTimeSpec, ) -> Result<()>
Set the last modification time for a file on a filesystem.
This corresponds to filetime::set_file_mtime
.
Sourcefn set_times<P: AsRef<Path>>(
&self,
path: P,
atime: Option<SystemTimeSpec>,
mtime: Option<SystemTimeSpec>,
) -> Result<()>
fn set_times<P: AsRef<Path>>( &self, path: P, atime: Option<SystemTimeSpec>, mtime: Option<SystemTimeSpec>, ) -> Result<()>
Set the last access and modification times for a file on a filesystem.
This corresponds to filetime::set_file_times
.
Sourcefn set_symlink_times<P: AsRef<Path>>(
&self,
path: P,
atime: Option<SystemTimeSpec>,
mtime: Option<SystemTimeSpec>,
) -> Result<()>
fn set_symlink_times<P: AsRef<Path>>( &self, path: P, atime: Option<SystemTimeSpec>, mtime: Option<SystemTimeSpec>, ) -> Result<()>
Set the last access and modification times for a file on a filesystem. This function does not follow symlink.
This corresponds to filetime::set_symlink_file_times
.
Sourcefn symlink<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, dst: Q) -> Result<()>
fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, dst: Q) -> Result<()>
Creates a new symbolic link on a filesystem.
This corresponds to std::os::unix::fs::symlink
, except that it’s
supported on non-Unix platforms as well, and it’s not guaranteed to be
atomic.
Sourcefn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
src: P,
dst: Q,
) -> Result<()>
fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>( &self, src: P, dst: Q, ) -> Result<()>
Creates a new file symbolic link on a filesystem.
This corresponds to std::os::windows::fs::symlink_file
, except that
it’s supported on non-Windows platforms as well, and it’s not
guaranteed to fail if the target is not a file.
Sourcefn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
src: P,
dst: Q,
) -> Result<()>
fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>( &self, src: P, dst: Q, ) -> Result<()>
Creates a new directory symbolic link on a filesystem.
This corresponds to std::os::windows::fs::symlink_dir
, except that
it’s supported on non-Windows platforms as well, and it’s not
guaranteed to fail if the target is not a directory.
Sourcefn open_dir_nofollow<P: AsRef<Path>>(&self, path: P) -> Result<Self>where
Self: Sized,
fn open_dir_nofollow<P: AsRef<Path>>(&self, path: P) -> Result<Self>where
Self: Sized,
Similar to cap_std::fs::Dir::open_dir
, but fails if the path names a
symlink.
Sourcefn remove_file_or_symlink<P: AsRef<Path>>(&self, path: P) -> Result<()>
fn remove_file_or_symlink<P: AsRef<Path>>(&self, path: P) -> Result<()>
Removes a file or symlink from a filesystem.
Removal of symlinks has different behavior under Windows - if a symlink
points to a directory, it cannot be removed with the remove_file
operation. This method will remove files and all symlinks.
Sourcefn access<P: AsRef<Path>>(&self, path: P, type_: AccessType) -> Result<()>
fn access<P: AsRef<Path>>(&self, path: P, type_: AccessType) -> Result<()>
Test for accessibility or existence of a filesystem object.
Sourcefn access_symlink<P: AsRef<Path>>(
&self,
path: P,
type_: AccessType,
) -> Result<()>
fn access_symlink<P: AsRef<Path>>( &self, path: P, type_: AccessType, ) -> Result<()>
Test for accessibility or existence of a filesystem object, without following symbolic links.
Sourcefn set_symlink_permissions<P: AsRef<Path>>(
&self,
path: P,
perm: Permissions,
) -> Result<()>
fn set_symlink_permissions<P: AsRef<Path>>( &self, path: P, perm: Permissions, ) -> Result<()>
Changes the permissions found on a file or a directory, without following symbolic links.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl DirExt for Dir
impl DirExt for Dir
Source§fn access<P: AsRef<Path>>(&self, path: P, type_: AccessType) -> Result<()>
fn access<P: AsRef<Path>>(&self, path: P, type_: AccessType) -> Result<()>
Test for accessibility or existence of a filesystem object.
Source§fn access_symlink<P: AsRef<Path>>(
&self,
path: P,
type_: AccessType,
) -> Result<()>
fn access_symlink<P: AsRef<Path>>( &self, path: P, type_: AccessType, ) -> Result<()>
Test for accessibility or existence of a filesystem object.
Source§fn set_symlink_permissions<P: AsRef<Path>>(
&self,
path: P,
perm: Permissions,
) -> Result<()>
fn set_symlink_permissions<P: AsRef<Path>>( &self, path: P, perm: Permissions, ) -> Result<()>
Changes the permissions found on a file or a directory, without following symbolic links.