PLCnext API Documentation
22.9.0.33
|
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. More... | |
FileStream & | operator= (const FileStream &arg)=delete |
Assignment operator. More... | |
~FileStream (void) override | |
Destructs this instance and frees all resources. More... | |
boolean | CanRead (void) override |
Checks if the stream is opened for read-access. More... | |
boolean | CanWrite (void) override |
Checks if the stream is opened for write-access. More... | |
boolean | CanSeek (void) override |
Checks if seek operations are possible. More... | |
size_t | GetLength (void) override |
Returns the size of the opened file in bytes. More... | |
void | SetLength (size_t length) override |
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... | |
![]() | |
Stream (void) | |
Constructs an Stream instance. More... | |
Stream (const Stream &arg)=delete | |
Copy constructor. More... | |
Stream & | operator= (const Stream &arg)=delete |
Assignment operator. More... | |
virtual | ~Stream (void) |
Destructs this instance and frees all resources. More... | |
virtual byte | ReadByte (void) |
virtual void | WriteByte (byte value) |
virtual void | CopyTo (Stream &other) |
void | Dispose (void) |
void | Close (void) |
Protected Member Functions | |
void | InternalDispose (void) override |
![]() | |
boolean | IsDisposed (void) |
void | CheckDisposed (void) |
Additional Inherited Members | |
![]() | |
static NullStream | Empty |
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. |
|
inline |
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. |
|
inline |
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. |
|
delete |
Copy constructor.
|
override |
Destructs this instance and frees all resources.
|
overridevirtual |
Checks if the stream is opened for read-access.
Implements Arp::System::Commons::Io::Stream.
|
overridevirtual |
Checks if seek operations are possible.
Implements Arp::System::Commons::Io::Stream.
|
overridevirtual |
Checks if the stream is opened for write-access.
Implements Arp::System::Commons::Io::Stream.
|
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::System::Commons::Io::Stream.
|
overridevirtual |
Returns the size of the opened file in bytes.
Arp::System::Commons::ObjectDisposedException | if the stream was already disposed. |
Implements Arp::System::Commons::Io::Stream.
|
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. |
Implements Arp::System::Commons::Io::Stream.
|
delete |
Assignment operator.
|
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::System::Commons::Io::Stream.
|
overridevirtual |
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. |
Implements Arp::System::Commons::Io::Stream.
|
overridevirtual |
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. |
Implements Arp::System::Commons::Io::Stream.
|
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. |
Implements Arp::System::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::System::Commons::Io::Stream.