Skip to content

File

Base class used to manage files in a FileSystem .

Inherited by the following classes: SparkyStudios::Audio::Amplitude::AssetManagerFile, SparkyStudios::Audio::Amplitude::DiskFile, SparkyStudios::Audio::Amplitude::MappedFile, SparkyStudios::Audio::Amplitude::MemoryFile, SparkyStudios::Audio::Amplitude::NSFile, SparkyStudios::Audio::Amplitude::PackageItemFile

Public Functions

Type Name
virtual void Close () = 0
Closes the file an releases allocated resources.
virtual bool Eof () const = 0
Checks if the read cursor is at the end of the file.
virtual AmOsString GetPath () const = 0
Gets the path to the file in the loaded FileSystem .
virtual AmVoidPtr GetPtr () const = 0
Gets the pointer to the internal file handle.
virtual bool IsValid () const = 0
Checks if the file is valid.
virtual AmSize Length () const = 0
Gets the size of the file in bytes.
virtual AmSize Position () const = 0
Gets the current position of the read/write cursor.
virtual AmSize Read (AmUInt8Buffer dst, AmSize bytes) const = 0
Reads data from the file.
AmUInt16 Read16 () const
Reads two bytes from the file in an AmUInt16 .
AmUInt32 Read32 () const
Reads four bytes from the file in an AmUInt32 .
AmUInt64 Read64 () const
Reads eight bytes from the file in an AmUInt64 .
AmUInt8 Read8 () const
Reads a single byte from the file in an AmUInt8 .
AmString ReadString () const
Reads a string from the file.
void Seek (AmSize offset)
Seeks the read/write to the specified offset.
virtual void Seek (AmInt64 offset, eFileSeekOrigin origin) = 0
Seeks the read/write to the specified offset, starting at the given origin.
virtual AmSize Write (AmConstUInt8Buffer src, AmSize bytes) = 0
Writes data to the file.
AmSize Write16 (AmUInt16 value)
Writes two bytes to the file from an AmUInt16 .
AmSize Write32 (AmUInt32 value)
Writes four bytes to the file from an AmUInt32 .
AmSize Write64 (AmUInt64 value)
Writes eight bytes to the file from an AmUInt64 .
AmSize Write8 (AmUInt8 value)
Writes a single byte to the file from an AmUInt8 .
AmSize WriteString (const AmString & value)
Writes a string to the file.
virtual ~File () = default
Default destructor.

Public Functions Documentation

Close

Closes the file an releases allocated resources.

virtual void Amplitude::File::Close () = 0
Eof

Checks if the read cursor is at the end of the file.

virtual bool Amplitude::File::Eof () const = 0

Returns:

true if the read cursor is at the end of the file, false otherwise.

GetPath

Gets the path to the file in the loaded FileSystem .

virtual AmOsString Amplitude::File::GetPath () const = 0

Returns:

The path to the file.

GetPtr

Gets the pointer to the internal file handle.

virtual AmVoidPtr Amplitude::File::GetPtr () const = 0

Returns:

The internal file handle. This depends on the implementation.

IsValid

Checks if the file is valid.

virtual bool Amplitude::File::IsValid () const = 0

The validity of a file is determined by the underlying implementation. But this should primarily mean that the file exists AND has been opened.

Returns:

true if the file is valid, false otherwise.

Length

Gets the size of the file in bytes.

virtual AmSize Amplitude::File::Length () const = 0

Returns:

The size of the file in bytes.

Position

Gets the current position of the read/write cursor.

virtual AmSize Amplitude::File::Position () const = 0

Returns:

The actual position of the read/write cursor.

Read

Reads data from the file.

virtual AmSize Amplitude::File::Read (
    AmUInt8Buffer dst,
    AmSize bytes
) const = 0

Parameters:

  • dst The destination buffer of the read data.
  • bytes The number of bytes to read from the file. The destination buffer must be at least as large as the number of bytes to read.

Returns:

The number of bytes read from the file.

Read16

Reads two bytes from the file in an AmUInt16 .

AmUInt16 Amplitude::File::Read16 () const

Returns:

The read value.

Read32

Reads four bytes from the file in an AmUInt32 .

AmUInt32 Amplitude::File::Read32 () const

Returns:

The read value.

Read64

Reads eight bytes from the file in an AmUInt64 .

AmUInt64 Amplitude::File::Read64 () const

Returns:

The read value.

Read8

Reads a single byte from the file in an AmUInt8 .

AmUInt8 Amplitude::File::Read8 () const

Returns:

The read value.

ReadString

Reads a string from the file.

AmString Amplitude::File::ReadString () const

Returns:

The read value.

Seek[1/2]

Seeks the read/write to the specified offset.

void Amplitude::File::Seek (
    AmSize offset
) 

Parameters:

  • offset The offset in bytes from the beginning of the file.
Seek[2/2]

Seeks the read/write to the specified offset, starting at the given origin.

virtual void Amplitude::File::Seek (
    AmInt64 offset,
    eFileSeekOrigin origin
) = 0

Parameters:

  • offset The offset in bytes from the beginning of the file.
  • origin The origin from which to begin seeking.
Write

Writes data to the file.

virtual AmSize Amplitude::File::Write (
    AmConstUInt8Buffer src,
    AmSize bytes
) = 0

Parameters:

  • src The source buffer of the data to write.
  • bytes The number of bytes to write to the file. The source buffer must be at least as large as the number of bytes to write.

Returns:

The number of bytes written to the file.

Write16

Writes two bytes to the file from an AmUInt16 .

AmSize Amplitude::File::Write16 (
    AmUInt16 value
) 

Parameters:

  • value The value to write.
Write32

Writes four bytes to the file from an AmUInt32 .

AmSize Amplitude::File::Write32 (
    AmUInt32 value
) 

Parameters:

  • value The value to write.
Write64

Writes eight bytes to the file from an AmUInt64 .

AmSize Amplitude::File::Write64 (
    AmUInt64 value
) 

Parameters:

  • value The value to write.
Write8

Writes a single byte to the file from an AmUInt8 .

AmSize Amplitude::File::Write8 (
    AmUInt8 value
) 

Parameters:

  • value The value to write.
WriteString

Writes a string to the file.

AmSize Amplitude::File::WriteString (
    const AmString & value
) 

Parameters:

  • value The value to write.
~File

Default destructor.

virtual Amplitude::File::~File () = default

The documentation for this class was generated from the following file: include/SparkyStudios/Audio/Amplitude/IO/File.h