|
Jameo Core Library
|
This class represents a resource, which comes with the app. More...
Public Member Functions | |
| Resource (const jm::String &path) | |
| Resource (const Resource &other) | |
| Resource & | operator= (const Resource &other) |
| ~Resource () override | |
| bool | exists () const |
| size_t | size () const override |
| Returns the length of the stream. | |
| jm::Status | open (jm::FileMode mode) override |
| Opens the stream for read or write operations. | |
| bool | isOpen () override |
| Returns whether the file is open or not. | |
| bool | canRead () const override |
| Checks if the file/stream can be read. | |
| void | close () override |
| Closes the stream if it was previously opened and releases any system resources. | |
| size_t | read (uint8 *buffer, size_t length) override |
| Reads a maximum of length bytes into the array. | |
| size_t | readFully (jm::ByteArray &buffer, size_t length) override |
| Reads a maximum of length bytes into the array. | |
| void | seek (size_t position) override |
| Moves the file cursor to the desired position, counted from the beginning of the file (0-based index). | |
| void | move (ssize_t offset) override |
| Moves the file cursor to the desired position, counted from the current position. | |
| size_t | position () override |
| Returns the current cursor position in the file. | |
| size_t | write (const uint8 *buffer, size_t length) override |
| Writes a buffer to the output file. | |
Public Member Functions inherited from jm::Stream | |
| Stream () | |
| Constructor. | |
| size_t | readFully (ByteArray &buffer) |
| Reads a maximum of length bytes into the array. | |
| size_t | write (const int8 *buffer, size_t length) |
| Writes a buffer to the output file. | |
| size_t | write (const String &string) |
| Writes a string to the output file. The encoding is the default encoding (UTF-8). NOT AS A C-STRING! | |
Public Member Functions inherited from jm::Object | |
| Object () noexcept | |
| Constructor. | |
| virtual | ~Object () noexcept |
| Destructor. | |
| void | release () noexcept |
| Decreases the reference counter and releases the object immediately when the reference counter becomes 0. | |
| Object * | retain () noexcept |
| Increases the reference counter of this object by 1. | |
| Object * | autorelease () noexcept |
| Same function as release(), but releases the object with a delay if the reference counter is 0. AutoreleasePool::drain() must be called in the to release the object. | |
| int32 | referenceCount () const noexcept |
| Returns the value of the reference counter. | |
| virtual bool | equals (const Object *other) const |
| Comparison of objects. | |
| virtual String | displayName () const |
| Returns the display name of the object intended to present to a user. | |
| virtual void | printDiffInfo (DiffOperation operation, Object *other) const |
| Output method for outputting the diff results for the diff algorithm. | |
| void | setHighBit (bool status) noexcept |
| bool | highBit () const noexcept |
This class represents a resource, which comes with the app.
Resources are files, that are packed with an application. Like images, fonts and other stuff to make the application work. On most systems, these are "plain" files in a defined resource directory. On Android for example, these are files packed into to apk of the app. So simple file access is not possible.
To handle all resources whether it is a file or a packed resource, we provide this unified interface.
|
explicit |
| jm::Resource::Resource | ( | const Resource & | other | ) |
|
override |
|
overridevirtual |
Checks if the file/stream can be read.
Implements jm::Stream.
|
overridevirtual |
Closes the stream if it was previously opened and releases any system resources.
This method closes the stream if it was previously opened and releases any system resources associated with it.
Implements jm::Stream.
| bool jm::Resource::exists | ( | ) | const |
|
overridevirtual |
Returns whether the file is open or not.
This method returns a boolean value indicating whether the file is currently open or not.
true if the file is open, false otherwise. Implements jm::Stream.
|
overridevirtual |
Moves the file cursor to the desired position, counted from the current position.
This method moves the file cursor to the specified position, counted from the current position.
Implements jm::Stream.
|
overridevirtual |
Opens the stream for read or write operations.
| mode | The mode to open the stream. |
This method opens the stream for read or write operations based on the specified mode.
Implements jm::Stream.
|
overridevirtual |
Returns the current cursor position in the file.
This method returns the current cursor position in the file.
Implements jm::Stream.
|
overridevirtual |
Reads a maximum of length bytes into the array.
For large blocks, it is possible that not all bytes are read because it is still waiting for data. In this case, only a portion may be returned. If you want to ensure that all data is read, you should call readFully().
Implements jm::Stream.
|
overridevirtual |
Reads a maximum of length bytes into the array.
For large blocks, it is possible that not all bytes are read because it is still waiting for data. In this case, only a portion may be returned. If you want to ensure that all data is read, you should call readFully().
| buffer | The buffer to read the data from. |
| length | The maximum number of bytes to read. |
Implements jm::Stream.
|
overridevirtual |
Moves the file cursor to the desired position, counted from the beginning of the file (0-based index).
This method moves the file cursor to the specified position, counted from the beginning of the file.
Implements jm::Stream.
|
overridevirtual |
Returns the length of the stream.
This method returns the length of the stream in bytes.
Implements jm::Stream.
|
overridevirtual |
Writes a buffer to the output file.
This method writes the contents of the buffer to the output file.
| buffer | The buffer containing the data to be written. |
| length | The number of bytes to write from the buffer. |
Implements jm::Stream.