LittleFileSystem
Loading...
Searching...
No Matches
ntdv::FileStream Class Reference

FileStream class inherits from Stream class. More...

#include <FileStream.h>

Inheritance diagram for ntdv::FileStream:

Public Member Functions

 FileStream (const FilePtr &ptr=FilePtr())
 
size_t write (uint8_t byte) override
 
size_t write (const uint8_t *buf, size_t size) override
 
int available () override
 
int read () override
 
int peek () override
 
void flush () override
 Flush the stream.
 
size_t Read (uint8_t *buf, size_t size) const
 
size_t ReadBytes (char *buffer, const size_t length) const
 
bool Seek (uint32_t pos, SeekMode mode) const
 
bool Seek (const uint32_t pos) const
 
size_t Position () const
 
size_t Size () const
 
bool SetBufferSize (size_t size) const
 
void Close ()
 Close the stream.
 
 operator bool () const
 
time_t GetLastWrite () const
 
const char * Path () const
 
const char * Name () const
 
boolean IsDirectory () const
 
boolean SeekDir (long position) const
 
FileStream OpenNextFile (const char *mode=FILE_READ) const
 
String GetNextFileName () const
 
String GetNextFileName (boolean *isDir) const
 
void RewindDirectory () const
 Go to the begining of the directory.
 

Protected Attributes

FilePtr _ptr
 Shared pointer to an IFile object.
 

Detailed Description

FileStream class inherits from Stream class.

Constructor & Destructor Documentation

◆ FileStream()

ntdv::FileStream::FileStream ( const FilePtr & ptr = FilePtr())
inline

Constructor

Parameters
ptr- shared pointer to an IFile object

Member Function Documentation

◆ available()

int FileStream::available ( )
override

Check the number of bytes available for reading

Returns
the number of bytes available

◆ Close()

void FileStream::Close ( )

Close the stream.

◆ flush()

void FileStream::flush ( )
override

Flush the stream.

◆ GetLastWrite()

time_t FileStream::GetLastWrite ( ) const

Get the last write time of the stream

Returns
the last write time

◆ GetNextFileName() [1/2]

String FileStream::GetNextFileName ( ) const

Get the name of the next file in the directory

Returns
the name of the next file

◆ GetNextFileName() [2/2]

String FileStream::GetNextFileName ( boolean * isDir) const

Get the name of the next file in the directory and whether it is a directory

Parameters
isDir- pointer to a boolean to store whether the file is a directory
Returns
the name of the next file

◆ IsDirectory()

boolean FileStream::IsDirectory ( ) const

Check if the stream is a directory

Returns
true if the stream is a directory, false otherwise

◆ Name()

const char * FileStream::Name ( ) const

Get the name of the stream

Returns
the stream name

◆ OpenNextFile()

FileStream FileStream::OpenNextFile ( const char * mode = FILE_READ) const

Open the next file in the directory

Parameters
mode- mode to open the file in
Returns
a FileStream object for the opened file

◆ operator bool()

FileStream::operator bool ( ) const

Check if the stream is valid

Returns
true if the stream is valid, false otherwise

◆ Path()

const char * FileStream::Path ( ) const

Get the path of the stream

Returns
the stream path

◆ peek()

int FileStream::peek ( )
override

Peek at the next byte in the stream

Returns
the next byte

◆ Position()

size_t FileStream::Position ( ) const

Get the current position in the stream

Returns
the current position

◆ read()

int FileStream::read ( )
override

Read a byte from the stream

Returns
the byte read

◆ Read()

size_t FileStream::Read ( uint8_t * buf,
size_t size ) const

Read data from the stream

Parameters
buf- buffer to store the data
size- size of the data to read
Returns
the number of bytes read

◆ ReadBytes()

size_t ntdv::FileStream::ReadBytes ( char * buffer,
const size_t length ) const
inline

Read data from the stream

Parameters
buffer- buffer to store the data
length- size of the data to read
Returns
the number of bytes read

◆ RewindDirectory()

void FileStream::RewindDirectory ( ) const

Go to the begining of the directory.

◆ Seek() [1/2]

bool ntdv::FileStream::Seek ( const uint32_t pos) const
inline

Seek to a position in the stream

Parameters
pos- position to seek to
Returns
true if successful, false otherwise

◆ Seek() [2/2]

bool FileStream::Seek ( uint32_t pos,
SeekMode mode ) const

Set a position in the stream

Parameters
pos- position to seek to
mode- mode of seeking
Returns
true if successful, false otherwise

◆ SeekDir()

boolean FileStream::SeekDir ( long position) const

Seek to a position in the directory

Parameters
position- position to seek to
Returns
true if successful, false otherwise

◆ SetBufferSize()

bool FileStream::SetBufferSize ( size_t size) const

Set the buffer size for the stream

Parameters
size- size of the buffer
Returns
true if successful, false otherwise

◆ Size()

size_t FileStream::Size ( ) const

Get the size of the stream

Returns
the size of the stream

◆ write() [1/2]

size_t FileStream::write ( const uint8_t * buf,
size_t size )
override

Write data to the stream

Parameters
buf- buffer containing the data
size- size of the data
Returns
the number of bytes written

◆ write() [2/2]

size_t FileStream::write ( uint8_t byte)
override

Write a byte to the stream

Parameters
byte- the byte to write
Returns
the number of bytes written

Member Data Documentation

◆ _ptr

FilePtr ntdv::FileStream::_ptr
protected

Shared pointer to an IFile object.


The documentation for this class was generated from the following files: