Appearance
AnyFile
cpp
#include <Media/AnyFile.h>cpp
class AnyFileDefined in Media/AnyFile.h:24
Base class of all files that can be loaded or saved.
Public Attributes
| Return | Name | Description |
|---|---|---|
fs::path | path | The location of this file (may be empty). |
utl::Buffer< u8 > | data | The raw data of this file. |
path
cpp
fs::path pathDefined in Media/AnyFile.h:29
The location of this file (may be empty).
data
cpp
utl::Buffer< u8 > dataDefined in Media/AnyFile.h:32
The raw data of this file.
Public Methods
| Return | Name | Description |
|---|---|---|
void | init | Initializes the file with an empty buffer of the given capacity. |
void | init | Initializes the file with the contents of a memory region. |
void | init | Initializes the file with the contents of a buffer. |
void | init | Initializes the file with the contents of a string. |
void | init | Initializes the file with the contents of a file. |
u64 | hash const inline override | Returns a fingerprint (hash value) for this file. |
Dumpable::DataProvider | dataProvider const inline override | Returns a data provider for dumping the file contents. |
isize | getSize const inline | Returns the size of this file. |
u8 * | getData const inline | Returns a pointer to the file data. |
bool | empty const inline | Returns true if the file contains no data. |
std::vector< string > | describe virtual const inline | Returns meta-information about the file. |
utl::ByteView | byteView const | Returns a read-only view of the file contents, starting at an offset. |
utl::ByteView | byteView const | Returns a read-only view of a portion of the file contents. |
utl::MutableByteView | byteView | Returns a mutable view of the file contents, starting at an offset. |
utl::MutableByteView | byteView | Returns a mutable view of a portion of the file contents. |
void | copy virtual const | Copies a portion of the file contents into a buffer. |
void | copy virtual const | Copies the file contents (starting at an offset) into a buffer. |
bool | isCompatiblePath virtual const inline | Returns true if path points to a compatible file. |
isize | writeToStream const | Writes the file to a stream. |
isize | writeToStream const | Writes a portion of the file to a stream. |
isize | writeToFile const | Writes the file to a file on disk. |
isize | writeToFile const | Writes a portion of the file to a file on disk. |
init
cpp
void init(isize len)Defined in Media/AnyFile.h:44
Initializes the file with an empty buffer of the given capacity.
init
cpp
void init(const u8 * buf, isize len)Defined in Media/AnyFile.h:46
Initializes the file with the contents of a memory region.
init
cpp
void init(const utl::Buffer< u8 > & buffer)Defined in Media/AnyFile.h:48
Initializes the file with the contents of a buffer.
init
cpp
void init(const string & str)Defined in Media/AnyFile.h:50
Initializes the file with the contents of a string.
init
cpp
void init(const fs::path & path)Defined in Media/AnyFile.h:52
Initializes the file with the contents of a file.
hash
const inline override
cpp
inline u64 hash(HashAlgorithm algorithm) const overrideDefined in Media/AnyFile.h:62
Returns a fingerprint (hash value) for this file.
dataProvider
const inline override
cpp
inline Dumpable::DataProvider dataProvider() const overrideDefined in Media/AnyFile.h:74
Returns a data provider for dumping the file contents.
getSize
const inline
cpp
inline isize getSize() constDefined in Media/AnyFile.h:86
Returns the size of this file.
getData
const inline
cpp
inline u8 * getData() constDefined in Media/AnyFile.h:88
Returns a pointer to the file data.
empty
const inline
cpp
inline bool empty() constDefined in Media/AnyFile.h:90
Returns true if the file contains no data.
describe
virtual const inline
cpp
virtual inline std::vector< string > describe() constDefined in Media/AnyFile.h:93
Returns meta-information about the file.
byteView
const
cpp
utl::ByteView byteView(isize offset = 0) constDefined in Media/AnyFile.h:103
Returns a read-only view of the file contents, starting at an offset.
byteView
const
cpp
utl::ByteView byteView(isize offset, isize len) constDefined in Media/AnyFile.h:105
Returns a read-only view of a portion of the file contents.
byteView
cpp
utl::MutableByteView byteView(isize offset = 0)Defined in Media/AnyFile.h:107
Returns a mutable view of the file contents, starting at an offset.
byteView
cpp
utl::MutableByteView byteView(isize offset, isize len)Defined in Media/AnyFile.h:109
Returns a mutable view of a portion of the file contents.
copy
virtual const
cpp
virtual void copy(u8 * dst, isize offset, isize len) constDefined in Media/AnyFile.h:113
Copies a portion of the file contents into a buffer.
copy
virtual const
cpp
virtual void copy(u8 * dst, isize offset = 0) constDefined in Media/AnyFile.h:115
Copies the file contents (starting at an offset) into a buffer.
isCompatiblePath
virtual const inline
cpp
virtual inline bool isCompatiblePath(const fs::path & path) constDefined in Media/AnyFile.h:123
Returns true if path points to a compatible file.
Reimplemented by
writeToStream
const
cpp
isize writeToStream(std::ostream & stream) constDefined in Media/AnyFile.h:133
Writes the file to a stream.
writeToStream
const
cpp
isize writeToStream(std::ostream & stream, isize offset, isize len) constDefined in Media/AnyFile.h:138
Writes a portion of the file to a stream.
writeToFile
const
cpp
isize writeToFile(const fs::path & path) constDefined in Media/AnyFile.h:135
Writes the file to a file on disk.
writeToFile
const
cpp
isize writeToFile(const fs::path & path, isize offset, isize len) constDefined in Media/AnyFile.h:140
Writes a portion of the file to a file on disk.