OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
34 auto t =
filename.rfind(PATHSEPCHAR);
35 std::string name_without_path =
filename.substr(t != std::string::npos ? t + 1 : 0);
39 this->
SeekTo((
size_t)pos, SEEK_SET);
85 if (mode == SEEK_CUR)
pos += this->
GetPos();
88 if (fseek(this->
file_handle, this->pos, SEEK_SET) < 0) {
108 if (size == 0)
return 0;
130 return (this->
ReadWord() << 16) | b;
151 if (n <= remaining) {
154 this->
SeekTo(n, SEEK_CUR);
void CDECL usererror(const char *s,...)
Error handling for fatal user errors.
static constexpr int BUFFER_SIZE
The number of bytes to allocate for the buffer.
bool strtolower(char *str)
Convert a given ASCII string to lowercase.
byte * buffer
Current position within the local 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.
byte * buffer_end
Last valid byte of buffer.
void ReadBlock(void *ptr, size_t size)
Read a block.
byte ReadByte()
Read a byte from the file.
void SkipBytes(int n)
Skip n bytes ahead in the file.
std::string simplified_filename
Simplified lowecase name of the file; only the name, no path or extension.
FILE * FioFOpenFile(const std::string &filename, const char *mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
FILE * file_handle
File handle of the open file.
virtual ~RandomAccessFile()
Close the file's file handle.
std::string filename
Full name of the file; relative path to subdir plus the extension of the file.
uint16 ReadWord()
Read a word (16 bits) from the file (in low endian format).
uint32 ReadDword()
Read a double word (32 bits) from the file (in low endian format).
size_t GetPos() const
Get position in the file.
RandomAccessFile(const std::string &filename, Subdirectory subdir)
Create the RandomAccesFile.
byte buffer_start[BUFFER_SIZE]
Local buffer when read from file.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
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.
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.