OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
10 #ifndef RANDOM_ACCESS_FILE_TYPE_H
11 #define RANDOM_ACCESS_FILE_TYPE_H
49 size_t GetStartPos()
const {
return this->
start_pos; }
50 size_t GetEndPos()
const {
return this->
end_pos; }
51 void SeekTo(
size_t pos,
int mode);
uint8_t ReadByte()
Read a byte from the file.
static constexpr int BUFFER_SIZE
The number of bytes to allocate for the buffer.
size_t pos
Position in the file of the end of the read buffer.
const std::string & GetFilename() const
Get the filename of the opened file with the path from the SubDirectory and the extension.
size_t end_pos
End position of file.
void ReadBlock(void *ptr, size_t size)
Read a block.
uint8_t * buffer
Current position within the local buffer.
std::optional< FileHandle > file_handle
File handle of the open file.
std::string simplified_filename
Simplified lowecase name of the file; only the name, no path or extension.
std::string filename
Full name of the file; relative path to subdir plus the extension of the file.
size_t GetPos() const
Get position in the file.
uint8_t * buffer_end
Last valid byte of buffer.
uint16_t ReadWord()
Read a word (16 bits) from the file (in low endian format).
void SkipBytes(size_t n)
Skip n bytes ahead in the file.
RandomAccessFile(const std::string &filename, Subdirectory subdir)
Create the RandomAccesFile.
size_t start_pos
Start position of file. May be non-zero if file is within a tar file.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
bool AtEndOfFile() const
Test if we have reached the end of the file.
const std::string & GetSimplifiedFilename() const
Get the simplified filename of the opened file.
void SeekTo(size_t pos, int mode)
Seek in the current file.
uint32_t ReadDword()
Read a double word (32 bits) from the file (in low endian format).
uint8_t buffer_start[BUFFER_SIZE]
Local buffer when read from file.
A file from which bytes, words and double words are read in (potentially) a random order.