pub struct File {
handle: Handle,
}
Fields§
§handle: Handle
Implementations§
source§impl File
impl File
pub fn open(path: &Path, opts: &OpenOptions) -> Result<File>
pub fn fsync(&self) -> Result<()>
pub fn datasync(&self) -> Result<()>
pub fn truncate(&self, size: u64) -> Result<()>
pub fn file_attr(&self) -> Result<FileAttr>
pub fn read(&self, buf: &mut [u8]) -> Result<usize>
pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
pub fn is_read_vectored(&self) -> bool
pub fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>
pub fn read_buf(&self, cursor: BorrowedCursor<'_>) -> Result<()>
pub fn write(&self, buf: &[u8]) -> Result<usize>
pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<usize>
pub fn is_write_vectored(&self) -> bool
pub fn write_at(&self, buf: &[u8], offset: u64) -> Result<usize>
pub fn flush(&self) -> Result<()>
pub fn seek(&self, pos: SeekFrom) -> Result<u64>
pub fn duplicate(&self) -> Result<File>
fn reparse_point( &self, space: &mut Align8<[MaybeUninit<u8>]> ) -> Result<(c_ulong, *mut REPARSE_DATA_BUFFER)>
fn readlink(&self) -> Result<PathBuf>
pub fn set_permissions(&self, perm: FilePermissions) -> Result<()>
pub fn set_times(&self, times: FileTimes) -> Result<()>
sourcefn basic_info(&self) -> Result<FILE_BASIC_INFO>
fn basic_info(&self) -> Result<FILE_BASIC_INFO>
Get only basic file information such as attributes and file times.
sourcefn posix_delete(&self) -> Result<()>
fn posix_delete(&self) -> Result<()>
Delete using POSIX semantics.
Files will be deleted as soon as the handle is closed. This is supported for Windows 10 1607 (aka RS1) and later. However some filesystem drivers will not support it even then, e.g. FAT32.
If the operation is not supported for this filesystem or OS version
then errors will be ERROR_NOT_SUPPORTED
or ERROR_INVALID_PARAMETER
.
sourcefn win32_delete(&self) -> Result<()>
fn win32_delete(&self) -> Result<()>
Delete a file using win32 semantics. The file won’t actually be deleted until all file handles are closed. However, marking a file for deletion will prevent anyone from opening a new handle to the file.
sourcefn fill_dir_buff(&self, buffer: &mut DirBuff, restart: bool) -> Result<bool>
fn fill_dir_buff(&self, buffer: &mut DirBuff, restart: bool) -> Result<bool>
Fill the given buffer with as many directory entries as will fit.
This will remember its position and continue from the last call unless
restart
is set to true
.
The returned bool indicates if there are more entries or not.
It is an error if self
is not a directory.
Symlinks and other reparse points
On Windows a file is either a directory or a non-directory. A symlink directory is simply an empty directory with some “reparse” metadata attached. So if you open a link (not its target) and iterate the directory, you will always iterate an empty directory regardless of the target.