Base Framework
Public Member Functions | Protected Attributes | List of all members
FileInputStream Class Reference

File input stream. More...

#include <base/io/FileInputStream.h>

Inherits Object, and InputStream.

Public Member Functions

 FileInputStream (const String &name, bool exclusive=true)
 
bool atEnd () const
 
unsigned int available () const
 
void close ()
 
unsigned int skip (unsigned int count)
 
unsigned int read (uint8 *buffer, unsigned int size, bool nonblocking=false)
 
void wait () const
 
bool wait (unsigned int timeout) const
 
- Public Member Functions inherited from Stream
virtual ~Stream () noexcept(false)
 
- Public Member Functions inherited from ReferenceCountedObject
 ReferenceCountedObject () noexcept
 
 ReferenceCountedObject (const ReferenceCountedObject &copy) noexcept
 
 ReferenceCountedObject (ReferenceCountedObject &&move) noexcept
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &copy) noexcept
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&move) noexcept
 
MemorySize getNumberOfReferences_INTERNAL () const noexcept
 
virtual bool useGarbageCollector () const noexcept
 
- Public Member Functions inherited from DynamicObject
 DynamicObject () noexcept
 
bool isValidObject () const noexcept
 
virtual ~DynamicObject () noexcept(false)
 
 _COM_AZURE_DEV__BASE__OVERRIDE_ALLOC ()
 

Protected Attributes

File file
 
bool end = false
 

Detailed Description

File input stream.

File input stream.

Version
1.0
Examples
testsuite/digest.cpp.

Constructor & Destructor Documentation

◆ FileInputStream()

FileInputStream::FileInputStream ( const String name,
bool  exclusive = true 
)

Initializes the file input stream.

Parameters
pathThe path of the file.
exclusiveSpecifies that the file should be opened in exclusive mode.

Member Function Documentation

◆ available()

unsigned int FileInputStream::available ( ) const
virtual

Returns the number of bytes that can be read or skipped over without blocking.

Returns
Available number of bytes in stream.

Implements InputStream.

◆ close()

void FileInputStream::close ( )
virtual

Closes the stream and releases any system resources associated with the stream.

Implements Stream.

◆ read()

unsigned int FileInputStream::read ( uint8 *  buffer,
unsigned int  size,
bool  nonblocking = false 
)
inlinevirtual

Fills the specified buffer with bytes from the stream. In blocking mode the method does not return until all bytes have been read. In non-blocking mode the total bytes read may be any number below or equal to the requested number of bytes. Attempting to read beyond the end of a stream in blocking mode results in an EndOfFile exception.

Parameters
bufferThe buffer to receive the bytes.
sizeThe size of the buffer.
nonblockingSpecifies that the method may not block.
Returns
The actual number of bytes read from the stream.

Implements InputStream.

Examples
testsuite/digest.cpp.

◆ skip()

unsigned int FileInputStream::skip ( unsigned int  count)
virtual

Skips a specified number of bytes. Blocks if asked to skip more bytes than available.

Parameters
countThe number of bytes to skip.
Returns
The actual number of bytes skipped.

Implements InputStream.

◆ wait() [1/2]

void FileInputStream::wait ( ) const
virtual

Blocking wait for input to become available. This method does nothing for a file.

Implements InputStream.

◆ wait() [2/2]

bool FileInputStream::wait ( unsigned int  timeout) const
virtual

Blocking wait for input to become available. This method does nothing for a file.

Parameters
timeoutThe timeout periode in microseconds.
Returns
Always returns true.

Implements InputStream.

Member Data Documentation

◆ end

bool FileInputStream::end = false
protected

Specifies that the end of the file has been reached.

◆ file

File FileInputStream::file
protected

The file providing the stream.