pub struct Directory(/* private fields */);
Expand description
A FileHandle
that is also a directory.
Use File::into_type
or Directory::new
to create a Directory
. In
addition to supporting the normal File
operations, Directory
supports iterating over its contained files.
Implementations§
source§impl Directory
impl Directory
sourcepub unsafe fn new(handle: FileHandle) -> Self
pub unsafe fn new(handle: FileHandle) -> Self
Coverts a FileHandle
into a Directory
without checking the file type.
§Safety
This function should only be called on files which ARE directories, doing otherwise is unsafe.
sourcepub fn read_entry<'buf>(
&mut self,
buffer: &'buf mut [u8]
) -> Result<Option<&'buf mut FileInfo>, Option<usize>>
pub fn read_entry<'buf>( &mut self, buffer: &'buf mut [u8] ) -> Result<Option<&'buf mut FileInfo>, Option<usize>>
Read the next directory entry.
Try to read the next directory entry into buffer
. If the buffer is too small, report the
required buffer size as part of the error. If there are no more directory entries, return
an empty optional.
The input buffer must be correctly aligned for a FileInfo
. You can query the required
alignment through the Align
trait (<FileInfo as Align>::alignment()
).
§Arguments
buffer
The target buffer of the read operation
§Errors
All errors come from calls to RegularFile::read
.
sourcepub fn read_entry_boxed(&mut self) -> Result<Option<Box<FileInfo>>>
Available on crate feature alloc
only.
pub fn read_entry_boxed(&mut self) -> Result<Option<Box<FileInfo>>>
alloc
only.Wrapper around Self::read_entry
that returns an owned copy of the data. It has the same
implications and requirements. On failure, the payload of Err
is `()´.
sourcepub fn read_entry_boxed_in<A: Allocator>(
&mut self,
allocator: A
) -> Result<Option<Box<FileInfo>>>
Available on crate features unstable
and alloc
only.
pub fn read_entry_boxed_in<A: Allocator>( &mut self, allocator: A ) -> Result<Option<Box<FileInfo>>>
unstable
and alloc
only.Wrapper around Self::read_entry
that returns an owned copy of the data. It has the same
implications and requirements. On failure, the payload of Err
is `()´.
It allows to use a custom allocator via the allocator_api
feature.
sourcepub fn reset_entry_readout(&mut self) -> Result
pub fn reset_entry_readout(&mut self) -> Result
Start over the process of enumerating directory entries
§Errors
All errors come from calls to RegularFile::set_position
.
Trait Implementations§
source§impl File for Directory
impl File for Directory
source§fn is_regular_file(&self) -> Result<bool>
fn is_regular_file(&self) -> Result<bool>
source§fn is_directory(&self) -> Result<bool>
fn is_directory(&self) -> Result<bool>
source§fn open(
&mut self,
filename: &CStr16,
open_mode: FileMode,
attributes: FileAttribute
) -> Result<FileHandle>
fn open( &mut self, filename: &CStr16, open_mode: FileMode, attributes: FileAttribute ) -> Result<FileHandle>
source§fn get_info<'buf, Info: FileProtocolInfo + ?Sized>(
&mut self,
buffer: &'buf mut [u8]
) -> Result<&'buf mut Info, Option<usize>>
fn get_info<'buf, Info: FileProtocolInfo + ?Sized>( &mut self, buffer: &'buf mut [u8] ) -> Result<&'buf mut Info, Option<usize>>
source§fn set_info<Info: FileProtocolInfo + ?Sized>(&mut self, info: &Info) -> Result
fn set_info<Info: FileProtocolInfo + ?Sized>(&mut self, info: &Info) -> Result
source§fn flush(&mut self) -> Result
fn flush(&mut self) -> Result
source§fn get_boxed_info<Info: FileProtocolInfo + ?Sized + Debug>(
&mut self
) -> Result<Box<Info>>
fn get_boxed_info<Info: FileProtocolInfo + ?Sized + Debug>( &mut self ) -> Result<Box<Info>>
alloc
only.source§fn get_boxed_info_in<Info: FileProtocolInfo + ?Sized + Debug, A: Allocator>(
&mut self,
allocator: A
) -> Result<Box<Info>>
fn get_boxed_info_in<Info: FileProtocolInfo + ?Sized + Debug, A: Allocator>( &mut self, allocator: A ) -> Result<Box<Info>>
unstable
and alloc
only.