Skip to content

AnyFile ​

cpp
#include <Media/AnyFile.h>
cpp
class AnyFile

Defined in Media/AnyFile.h:24

Base class of all files that can be loaded or saved.

Public Attributes ​

ReturnNameDescription
fs::pathpathThe location of this file (may be empty).
utl::Buffer< u8 >dataThe raw data of this file.

path ​

cpp
fs::path path

Defined in Media/AnyFile.h:29

The location of this file (may be empty).


data ​

cpp
utl::Buffer< u8 > data

Defined in Media/AnyFile.h:32

The raw data of this file.

Public Methods ​

ReturnNameDescription
voidinitInitializes the file with an empty buffer of the given capacity.
voidinitInitializes the file with the contents of a memory region.
voidinitInitializes the file with the contents of a buffer.
voidinitInitializes the file with the contents of a string.
voidinitInitializes the file with the contents of a file.
u64hash const inline overrideReturns a fingerprint (hash value) for this file.
Dumpable::DataProviderdataProvider const inline overrideReturns a data provider for dumping the file contents.
isizegetSize const inlineReturns the size of this file.
u8 *getData const inlineReturns a pointer to the file data.
boolempty const inlineReturns true if the file contains no data.
std::vector< string >describe virtual const inlineReturns meta-information about the file.
utl::ByteViewbyteView constReturns a read-only view of the file contents, starting at an offset.
utl::ByteViewbyteView constReturns a read-only view of a portion of the file contents.
utl::MutableByteViewbyteViewReturns a mutable view of the file contents, starting at an offset.
utl::MutableByteViewbyteViewReturns a mutable view of a portion of the file contents.
voidcopy virtual constCopies a portion of the file contents into a buffer.
voidcopy virtual constCopies the file contents (starting at an offset) into a buffer.
boolisCompatiblePath virtual const inlineReturns true if path points to a compatible file.
isizewriteToStream constWrites the file to a stream.
isizewriteToStream constWrites a portion of the file to a stream.
isizewriteToFile constWrites the file to a file on disk.
isizewriteToFile constWrites 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 override

Defined in Media/AnyFile.h:62

Returns a fingerprint (hash value) for this file.


dataProvider ​

const inline override

cpp
inline Dumpable::DataProvider dataProvider() const override

Defined in Media/AnyFile.h:74

Returns a data provider for dumping the file contents.


getSize ​

const inline

cpp
inline isize getSize() const

Defined in Media/AnyFile.h:86

Returns the size of this file.


getData ​

const inline

cpp
inline u8 * getData() const

Defined in Media/AnyFile.h:88

Returns a pointer to the file data.


empty ​

const inline

cpp
inline bool empty() const

Defined in Media/AnyFile.h:90

Returns true if the file contains no data.


describe ​

virtual const inline

cpp
virtual inline std::vector< string > describe() const

Defined in Media/AnyFile.h:93

Returns meta-information about the file.


byteView ​

const

cpp
utl::ByteView byteView(isize offset = 0) const

Defined 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) const

Defined 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) const

Defined 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) const

Defined 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) const

Defined in Media/AnyFile.h:123

Returns true if path points to a compatible file.

Reimplemented by ​


writeToStream ​

const

cpp
isize writeToStream(std::ostream & stream) const

Defined in Media/AnyFile.h:133

Writes the file to a stream.


writeToStream ​

const

cpp
isize writeToStream(std::ostream & stream, isize offset, isize len) const

Defined in Media/AnyFile.h:138

Writes a portion of the file to a stream.


writeToFile ​

const

cpp
isize writeToFile(const fs::path & path) const

Defined 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) const

Defined in Media/AnyFile.h:140

Writes a portion of the file to a file on disk.