RLib  5.7
RLib - an opensource, lightweight and multi-platform framework for cpp programming
System::IO::FileStream Class Reference

Provides a Stream for a file, supporting both synchronous and asynchronous read and write operations More...

Inheritance diagram for System::IO::FileStream:
System::IO::Stream

Public Member Functions

 FileStream (HANDLE)
 Initializes a new instance of the FileStream class for the specified file handle More...
 
bool GetFullAttributes (OUT FileFullAttributes *lpFileInformation) const
 Supplies network open information for the file More...
 
virtual intptr_t GetLength () const override
 Gets the length in bytes of the associated file More...
 
LARGE_INTEGER GetLength64 () const
 Gets the length in bytes of the associated file More...
 
virtual void SetLength (intptr_t) override
 Sets the length in bytes of the associated file More...
 
void SetLength64 (LONGLONG)
 Sets the length in bytes of the associated file More...
 
 RLIB_PROPERTY_GET_SET (intptr_t Length, GetLength, SetLength)
 Gets or sets the length in bytes of the associated file More...
 
virtual intptr_t GetPos () const override
 Gets the current position of this file stream More...
 
LARGE_INTEGER GetPos64 () const
 Gets the current position of this large file stream More...
 
virtual void SetPos (intptr_t pos) override
 Sets the current position of this file stream More...
 
void SetPos64 (LONGLONG pos)
 Sets the current position of this large file stream More...
 
 RLIB_PROPERTY_GET_SET (intptr_t Position, GetPos, SetPos)
 Gets or sets the current position of this file stream More...
 
virtual intptr_t Read (LPVOID buffer, intptr_t count) const override
 Reads a sequence of bytes from the file and advances the position within the stream by the number of bytes read More...
 
virtual intptr_t Write (const void *buffer, intptr_t count) override
 Writes a sequence of bytes to the file and advances the position within the stream by the number of bytes read More...
 
virtual void Flush () override
 Clears buffers for this stream and causes any buffered data to be written to the file More...
 
virtual void Close () override
 Closes the associated native file handle More...
 
virtual bool InheritFromMemoryStream () const overridefinal
 Identifies whether current class is a derived class of (or the same class as) MemoryStream More...
 
virtual bool InheritFromBufferedStream () const overridefinal
 Identifies whether current class is a derived class of (or the same class as) BufferedStream More...
 
LARGE_INTEGER GetAllocationSize () const
 Gets the physical length in bytes of the associated file More...
 
bool Delete ()
 Deletes the associated file. The method does not close the file handle, and any attempt to refer it is undefined More...
 
bool Move (const String &path, bool bReplaceIfExists=true)
 Moves the associated file to another path, and a value indicating whether to replace if the target path already exist More...
 
void Append (void *buffer, intptr_t count)
 Advances the position to the end of the file, and calls Write More...
 
 operator HANDLE ()
 Gets a Handle object that represents the operating system file handle for the file that the current FileStream object encapsulates More...
 
HANDLE GetSafeFileHandle ()
 Gets a Handle object that represents the operating system file handle for the file that the current FileStream object encapsulates More...
 
 RLIB_PROPERTY_GET (HANDLE SafeFileHandle, GetSafeFileHandle)
 Gets a Handle object that represents the operating system file handle for the file that the current FileStream object encapsulates More...
 
IOException * GetLastException () const
 Gets the last exception. The method will never return a nullptr pointer unless 'this' pointer is invalid More...
 
- Public Member Functions inherited from System::IO::Stream
 RLIB_PROPERTY_GET_SET (intptr_t Position, GetPos, SetPos)
 When overridden in a derived class, gets or sets the position within the current stream More...
 
 RLIB_PROPERTY_GET_SET (intptr_t Size, GetSize, SetSize)
 When overridden in a derived class, gets or sets the capacity in bytes of the stream More...
 
 RLIB_PROPERTY_GET_SET (intptr_t Length, GetLength, SetLength)
 When overridden in a derived class, gets or sets the length in bytes of the stream More...
 
virtual intptr_t Write (LPCVOID buffer, intptr_t count)=0
 When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written More...
 
intptr_t GetMaxReadSize () const
 Gets the maximum bytes of readable data from current position More...
 
 RLIB_PROPERTY_GET (intptr_t MaxReadSize, GetMaxReadSize)
 Gets the maximum bytes of readable data from current position More...
 
intptr_t GetMaxWriteSize () const
 Gets the maximum writeable bytes from current position, based on current capacity More...
 
 RLIB_PROPERTY_GET (intptr_t MaxWriteSize, GetMaxWriteSize)
 Gets the maximum writeable bytes from current position, based on current capacity More...
 
void CopyTo (Stream *destination, intptr_t bufferSize=RLIB_DEFAULT_BUFFER_SIZE) const
 Reads the bytes from the current stream and writes them to another stream, using a specified buffer size More...
 

Public Attributes

 RLIB_DECLARE_DYNCREATE
 

Protected Member Functions

void setException (NTSTATUS status) const
 

Protected Attributes

HANDLE m_native_handle
 
IOException m_error
 
LARGE_INTEGER m_file_pos
 

Friends

class File
 

Detailed Description

Provides a Stream for a file, supporting both synchronous and asynchronous read and write operations

Constructor & Destructor Documentation

FileStream::FileStream ( HANDLE  hFile)

Initializes a new instance of the FileStream class for the specified file handle

Member Function Documentation

void FileStream::Append ( void *  buffer,
intptr_t  count 
)

Advances the position to the end of the file, and calls Write

void FileStream::Close ( )
overridevirtual

Closes the associated native file handle

Implements System::IO::Stream.

bool FileStream::Delete ( )

Deletes the associated file. The method does not close the file handle, and any attempt to refer it is undefined

void FileStream::Flush ( )
overridevirtual

Clears buffers for this stream and causes any buffered data to be written to the file

Implements System::IO::Stream.

LARGE_INTEGER FileStream::GetAllocationSize ( ) const

Gets the physical length in bytes of the associated file

bool FileStream::GetFullAttributes ( OUT FileFullAttributes lpFileInformation) const

Supplies network open information for the file

IOException * FileStream::GetLastException ( ) const

Gets the last exception. The method will never return a nullptr pointer unless 'this' pointer is invalid

intptr_t FileStream::GetLength ( ) const
overridevirtual

Gets the length in bytes of the associated file

Implements System::IO::Stream.

LARGE_INTEGER FileStream::GetLength64 ( ) const

Gets the length in bytes of the associated file

intptr_t FileStream::GetPos ( ) const
overridevirtual

Gets the current position of this file stream

Implements System::IO::Stream.

LARGE_INTEGER FileStream::GetPos64 ( ) const

Gets the current position of this large file stream

HANDLE FileStream::GetSafeFileHandle ( )

Gets a Handle object that represents the operating system file handle for the file that the current FileStream object encapsulates

virtual bool System::IO::FileStream::InheritFromBufferedStream ( ) const
inlinefinaloverridevirtual

Identifies whether current class is a derived class of (or the same class as) BufferedStream

Implements System::IO::Stream.

virtual bool System::IO::FileStream::InheritFromMemoryStream ( ) const
inlinefinaloverridevirtual

Identifies whether current class is a derived class of (or the same class as) MemoryStream

Implements System::IO::Stream.

bool FileStream::Move ( const String path,
bool  bReplaceIfExists = true 
)

Moves the associated file to another path, and a value indicating whether to replace if the target path already exist

System::IO::FileStream::operator HANDLE ( )
inline

Gets a Handle object that represents the operating system file handle for the file that the current FileStream object encapsulates

intptr_t FileStream::Read ( LPVOID  buffer,
intptr_t  count 
) const
overridevirtual

Reads a sequence of bytes from the file and advances the position within the stream by the number of bytes read

Implements System::IO::Stream.

System::IO::FileStream::RLIB_PROPERTY_GET ( HANDLE  SafeFileHandle,
GetSafeFileHandle   
)

Gets a Handle object that represents the operating system file handle for the file that the current FileStream object encapsulates

System::IO::FileStream::RLIB_PROPERTY_GET_SET ( intptr_t  Length,
GetLength  ,
SetLength   
)

Gets or sets the length in bytes of the associated file

System::IO::FileStream::RLIB_PROPERTY_GET_SET ( intptr_t  Position,
GetPos  ,
SetPos   
)

Gets or sets the current position of this file stream

void FileStream::SetLength ( intptr_t  length)
overridevirtual

Sets the length in bytes of the associated file

Implements System::IO::Stream.

void FileStream::SetLength64 ( LONGLONG  length)

Sets the length in bytes of the associated file

void FileStream::SetPos ( intptr_t  pos)
overridevirtual

Sets the current position of this file stream

Implements System::IO::Stream.

void FileStream::SetPos64 ( LONGLONG  pos)

Sets the current position of this large file stream

intptr_t FileStream::Write ( const void *  buffer,
intptr_t  count 
)
overridevirtual

Writes a sequence of bytes to the file and advances the position within the stream by the number of bytes read


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