PLCnext API Documentation 25.0.2.69
|
Exposes a Stream around a file, supporting read and write operations. More...
#include <FileStream.hpp>
Public Types | |
using | IFileService = Arp::System::Ve::IFileService |
Public Member Functions | |
FileStream (const String &path, FileMode mode) | |
Initializes a new instance of the FileStream class. More... | |
FileStream (const String &path, FileMode mode, FileAccess access) | |
Initializes a new instance of the FileStream class. After close operation, the synchronization of the file system will be enforced for this file. More... | |
FileStream (const String &path, FileMode mode, FileAccess access, bool sync) | |
Initializes a new instance of the FileStream class. More... | |
FileStream (const FileStream &arg)=delete | |
Copy constructor. | |
FileStream & | operator= (const FileStream &arg)=delete |
Assignment operator. | |
~FileStream (void) override | |
Destructs this instance and frees all resources. | |
size_t | GetLength (void) |
Returns the size of the opened file in bytes. More... | |
void | SetLength (size_t length) |
Reserves a specific amount of bytes for the opened file. More... | |
size_t | GetPosition (void) override |
Returns the byte offset of the internal stream pointer from the beginning of the file. More... | |
void | SetPosition (size_t position) override |
Sets a new position of the internal stream pointer. More... | |
void | Flush (void) override |
Forces a write of all possibly buffered data (input stream) or discards any buffered not yet read by the user (output stream). More... | |
size_t | Seek (size_t offset, SeekOrigin origin) override |
Sets a new position if the internal stream pointer relative to a specific position. More... | |
size_t | Read (byte *pBuffer, size_t bufferSize, size_t offset, size_t count) override |
Reads data from stream into assigned buffer at a specific offset. More... | |
void | Write (const byte *pBuffer, size_t bufferSize, size_t offset, size_t count) override |
Writes data from assigned buffer to stream. More... | |
void | Close (void) |
![]() | |
Stream (bool canRead=false, bool canWrite=false, bool canSeek=false) | |
This constructor is used to constructs a base stream instance. More... | |
Stream (const Stream &arg) | |
Default copy constructor. More... | |
Stream (Stream &&arg) noexcept | |
Default move constructor. More... | |
Stream & | operator= (const Stream &arg) |
Default copy-assignment operator. More... | |
Stream & | operator= (Stream &&arg) noexcept |
Default move-assignment operator. More... | |
virtual | ~Stream (void) |
Default destructor. | |
virtual bool | CanRead (void) |
Determines if the derived stream can read. More... | |
virtual bool | CanWrite (void) |
Determines if the derived stream can write. More... | |
virtual bool | CanSeek (void) |
Determines if the derived stream can seek. More... | |
virtual void | SetPosition (size_t value) |
Sets the position of the stream, if it can seek. More... | |
virtual size_t | GetPosition (void) |
Gets the position of the stream, if it can seek. More... | |
virtual size_t | Seek (size_t offset, SeekOrigin origin)=0 |
virtual size_t | Read (byte *pBuffer, size_t bufferSize, size_t bufferOffset, size_t count)=0 |
virtual void | Write (const byte *pBuffer, size_t bufferSize, size_t bufferOffset, size_t count)=0 |
virtual void | Flush (void)=0 |
virtual byte | ReadByte (void) |
Reads a single byte from the stream. More... | |
virtual void | WriteByte (byte value) |
Writes a single byte to the stream. More... | |
virtual void | WriteTo (Stream &other) |
Writes the data this stream to another stream entirely. More... | |
virtual void | ReadFrom (Stream &other) |
Reads the entire data from another stream into this stream. More... | |
Additional Inherited Members | |
![]() | |
static Stream & | GetEmpty (void) |
Gets an empty stream. More... | |
Exposes a Stream around a file, supporting read and write operations.
Initializes a new instance of the FileStream class.
The file is opened or created with read-write permissions.
path | The path of the file to open.. |
mode | The open mode. |
Arp::System::Commons::ArgumentException | if path is an empty string. |
Arp::System::Commons::Io::AlreadyExistsException | if #Arp::Syste::Commons::Io::FileMode::CreateNew is chosen and the file does already exists. |
Arp::System::Commons::Io::NotExistException | if a file should be opened that does not exist. |
Arp::System::Commons::Io::InvalidPathException | in case an error occured that is not already handled by the other exceptions. |
Arp::System::Commons::Io::FileStream::FileStream | ( | const String & | path, |
FileMode | mode, | ||
FileAccess | access | ||
) |
Initializes a new instance of the FileStream class. After close operation, the synchronization of the file system will be enforced for this file.
path | The path of the file to open.. |
mode | The open mode. |
access | The access mode. |
Arp::System::Commons::ArgumentException | if path is an empty string. |
Arp::System::Commons::Io::AlreadyExistsException | if #Arp::Syste::Commons::Io::FileMode::CreateNew is chosen and the file does already exists. |
Arp::System::Commons::Io::NotExistException | if a file should be opened that does not exist. |
Arp::System::Commons::Io::InvalidPathException | in case an error occured that is not already handled by the other exceptions. |
Arp::System::Commons::Io::FileStream::FileStream | ( | const String & | path, |
FileMode | mode, | ||
FileAccess | access, | ||
bool | sync | ||
) |
Initializes a new instance of the FileStream class.
path | The path of the file to open.. |
mode | The open mode. |
access | The access mode. |
sync | If set to true , the synchronization of the file system is enforced after close operation for this file. |
Arp::System::Commons::ArgumentException | if path is an empty string. |
Arp::System::Commons::Io::AlreadyExistsException | if #Arp::Syste::Commons::Io::FileMode::CreateNew is chosen and the file does already exists. |
Arp::System::Commons::Io::NotExistException | if a file should be opened that does not exist. |
Arp::System::Commons::Io::InvalidPathException | in case an error occured that is not already handled by the other exceptions. |
|
overridevirtual |
Forces a write of all possibly buffered data (input stream) or discards any buffered not yet read by the user (output stream).
Arp::System::Commons::ObjectDisposedException | if the stream was already disposed. |
Implements Arp::Base::Commons::Io::Stream.
size_t Arp::System::Commons::Io::FileStream::GetLength | ( | void | ) |
Returns the size of the opened file in bytes.
Arp::System::Commons::ObjectDisposedException | if the stream was already disposed. |
|
overridevirtual |
Returns the byte offset of the internal stream pointer from the beginning of the file.
The next read or write operation will be performed from this byte offset on.
Arp::System::Commons::ObjectDisposedException | if the stream was already disposed. |
Reimplemented from Arp::Base::Commons::Io::Stream.
|
overridevirtual |
Reads data from stream into assigned buffer at a specific offset.
pBuffer | Buffer where read data can be stored. |
bufferSize | Maximal capacity of buffer pBuffer. |
offset | Offset in pBuffer where read data should be stored. |
count | Amount of bytes to read from stream. |
Arp::System::Commons::ArgumentNullException | if pBuffer is nullptr. |
Arp::System::Commons::ObjectDisposedException | if the stream was already disposed. |
Arp::System::Commons::ArgumentOutOfRangeException | if offset plus count is greater than bufferSize . |
Arp::System::Commons::NotSupportedException | if this stream is not readable. |
Implements Arp::Base::Commons::Io::Stream.
|
override |
Sets a new position if the internal stream pointer relative to a specific position.
offset | Offset in byte from the reference position, can also be negativ. |
origin | Reference from where the offset is added to calculate the new position of the file stream pointer. |
Arp::System::Commons::ObjectDisposedException | if the stream was already disposed. |
void Arp::System::Commons::Io::FileStream::SetLength | ( | size_t | length | ) |
Reserves a specific amount of bytes for the opened file.
This method is not supported for FileStream class instances.
Arp::System::Commons::NotSupportedException |
length | Desired byte-size of opened file. |
|
overridevirtual |
Sets a new position of the internal stream pointer.
The assigned position value is interpreted as a byte offset from the beginning of the opened file.
Arp::System::Commons::ObjectDisposedException | if the stream was already disposed. |
position | Byte-offset for the internal stream pointer from the beginning of the file. |
Reimplemented from Arp::Base::Commons::Io::Stream.
|
overridevirtual |
Writes data from assigned buffer to stream.
pBuffer | Pointer to data-location. |
bufferSize | Amount of bytes stored inpBuffer |
offset | Byte offset from location pBuffer where storing of data starts. |
count | Amount of bytes to be store via FileStream. Data from offset to offset + count will be stored. |
Arp::System::Commons::ArgumentNullException | if pBuffer is nullptr. |
Arp::System::Commons::ObjectDisposedException | if the stream was already disposed. |
Arp::System::Commons::ArgumentOutOfRangeException | if offset plus count is greater than bufferSize . |
Arp::System::Commons::NotSupportedException | if this stream is not writeable. |
Implements Arp::Base::Commons::Io::Stream.