Skip to content

AnyFile ​

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

Defined in Media/AnyFile.h:65

Base class of all media files

Provides basic functionality for reading and writing files, streams, and buffers.

Public Attributes ​

ReturnNameDescription
std::filesystem::pathpathPhysical location of this file.
Buffer< u8 >dataThe raw data of this file.

path ​

cpp
std::filesystem::path path = ""

Defined in Media/AnyFile.h:70

Physical location of this file.


data ​

cpp
Buffer< u8 > data

Defined in Media/AnyFile.h:73

The raw data of this file.

Public Methods ​

ReturnNameDescription
FileTypetype virtual const inlineReturns the media type of this file.
~AnyFile virtual inlineDestructor.
voidinitInitializes the file with an empty buffer of the given capacity.
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.
voidinitInitializes the file with the contents of a memory region.
isizegetSize virtual const inlineReturns the size of this file.
u8 *getData virtual const inlineReturns a pointer to the file data.
u8getData inlineReturns a data byte.
u64fnv64 virtual const inlineReturns a FNV-64 fingerprint of this file.
u32crc32 virtual const inlineReturns a CRC-32 fingerprint of this file.
stringname virtual constReturns the logical name of this file.
PETName< 16 >getName virtual constReturns the logical name of this file in PETSCII encoding.
voidstripRemoves a certain number of bytes from the beginning of the file.
voidflash virtual constCopies a portion of the file contents into a buffer.
voidflash virtual constCopies the file contents (starting at an offset) into a buffer.
isizewriteToStreamWrites a portion of the file to a stream.
isizewriteToStreamWrites the file to a stream.
isizewriteToFileWrites a portion of the file to a file on disk.
isizewriteToFileWrites the file to a file on disk.
isizewriteToBufferWrites a portion of the file to a memory buffer.
isizewriteToBufferWrites a portion of the file to a buffer.
isizewriteToBufferWrites the file to a memory buffer.
isizewriteToBufferWrites the file to a buffer.

type ​

virtual const inline

cpp
virtual inline FileType type() const

Defined in Media/AnyFile.h:123

Returns the media type of this file.

Reimplemented by ​


~AnyFile ​

virtual inline

cpp
virtual inline ~AnyFile()

Defined in Media/AnyFile.h:101

Destructor.


init ​

cpp
void init(isize capacity)

Defined in Media/AnyFile.h:104

Initializes the file with an empty buffer of the given capacity.


init ​

cpp
void init(const Buffer< u8 > & buffer)

Defined in Media/AnyFile.h:106

Initializes the file with the contents of a buffer.


init ​

cpp
void init(const string & str)

Defined in Media/AnyFile.h:108

Initializes the file with the contents of a string.


init ​

cpp
void init(const std::filesystem::path & path)

Defined in Media/AnyFile.h:110

Initializes the file with the contents of a file.


init ​

cpp
void init(const u8 * buf, isize len)

Defined in Media/AnyFile.h:112

Initializes the file with the contents of a memory region.


getSize ​

virtual const inline

cpp
virtual inline isize getSize() const

Defined in Media/AnyFile.h:127

Returns the size of this file.


getData ​

virtual const inline

cpp
virtual inline u8 * getData() const

Defined in Media/AnyFile.h:134

Returns a pointer to the file data.


getData ​

inline

cpp
inline u8 getData(isize nr)

Defined in Media/AnyFile.h:160

Returns a data byte.


fnv64 ​

virtual const inline

cpp
virtual inline u64 fnv64() const

Defined in Media/AnyFile.h:141

Returns a FNV-64 fingerprint of this file.


crc32 ​

virtual const inline

cpp
virtual inline u32 crc32() const

Defined in Media/AnyFile.h:143

Returns a CRC-32 fingerprint of this file.


name ​

virtual const

cpp
virtual string name() const

Defined in Media/AnyFile.h:154

Returns the logical name of this file.


getName ​

virtual const

cpp
virtual PETName< 16 > getName() const

Defined in Media/AnyFile.h:156

Returns the logical name of this file in PETSCII encoding.


strip ​

cpp
void strip(isize count)

Defined in Media/AnyFile.h:163

Removes a certain number of bytes from the beginning of the file.


flash ​

virtual const

cpp
virtual void flash(u8 * buf, isize offset, isize len) const

Defined in Media/AnyFile.h:172

Copies a portion of the file contents into a buffer.


flash ​

virtual const

cpp
virtual void flash(u8 * buf, isize offset = 0) const

Defined in Media/AnyFile.h:174

Copies the file contents (starting at an offset) into a buffer.


writeToStream ​

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

Defined in Media/AnyFile.h:193

Writes a portion of the file to a stream.


writeToStream ​

cpp
isize writeToStream(std::ostream & stream)

Defined in Media/AnyFile.h:202

Writes the file to a stream.


writeToFile ​

cpp
isize writeToFile(const std::filesystem::path & path, isize offset, isize len)

Defined in Media/AnyFile.h:195

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


writeToFile ​

cpp
isize writeToFile(const std::filesystem::path & path)

Defined in Media/AnyFile.h:204

Writes the file to a file on disk.


writeToBuffer ​

cpp
isize writeToBuffer(u8 * buf, isize offset, isize len)

Defined in Media/AnyFile.h:197

Writes a portion of the file to a memory buffer.


writeToBuffer ​

cpp
isize writeToBuffer(Buffer< u8 > & buffer, isize offset, isize len)

Defined in Media/AnyFile.h:199

Writes a portion of the file to a buffer.


writeToBuffer ​

cpp
isize writeToBuffer(u8 * buf)

Defined in Media/AnyFile.h:206

Writes the file to a memory buffer.


writeToBuffer ​

cpp
isize writeToBuffer(Buffer< u8 > & buffer)

Defined in Media/AnyFile.h:208

Writes the file to a buffer.

Public Static Methods ​

ReturnNameDescription
FileTypetype staticDetermines the type of an arbitrary file on disk.
AnyFile *make staticCreates a media file from a file on disk. The file type is determined automatically.
AnyFile *make staticCreates a media file of a given type from a file on disk.
AnyFile *make staticCreates a media file of a given type from a memory buffer.
AnyFile *make staticCreates a media file of a given type from the contents of a drive.

type ​

static

cpp
static FileType type(const fs::path & path)

Defined in Media/AnyFile.h:81

Determines the type of an arbitrary file on disk.


make ​

static

cpp
static AnyFile * make(const fs::path & path)

Defined in Media/AnyFile.h:85

Creates a media file from a file on disk. The file type is determined automatically.


make ​

static

cpp
static AnyFile * make(const fs::path & path, FileType type)

Defined in Media/AnyFile.h:87

Creates a media file of a given type from a file on disk.


make ​

static

cpp
static AnyFile * make(const u8 * buf, isize len, FileType type)

Defined in Media/AnyFile.h:89

Creates a media file of a given type from a memory buffer.


make ​

static

cpp
static AnyFile * make(class DriveAPI & drive, FileType type)

Defined in Media/AnyFile.h:91

Creates a media file of a given type from the contents of a drive.