wavelength 1.0.0
Loading...
Searching...
No Matches
file.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "os/string.h"
6
13constexpr int kImageFirstWord = 0;
14
21constexpr int kImageSecondWord = 0;
22
29class File {
30public:
32 enum Mode {
35 };
36
38 static constexpr int kFlagNoArchive = 1;
39
54 static File *New(const char *pszPath, int nMode, int nFlags);
55
62 virtual ~File() {
63 }
64
72 virtual int Read(void *pBuffer, int nBytes) = 0;
73
81 virtual bool ReadAsync(void *pBuffer, int nBytes) = 0;
82
90 virtual int Write(const void *pBuffer, int nBytes) = 0;
91
100 virtual int Seek(int nOffset, int nOrigin) = 0;
101
107 virtual int Tell() = 0;
108
110 virtual void Flush() = 0;
111
117 virtual bool Eof() = 0;
118
124 virtual bool Fail() = 0;
125
131 virtual int Size() = 0;
132
138 virtual int UncompressedSize() = 0;
139
146 virtual bool ReadDone(int *pnBytes) = 0;
147};
148
150struct FileStat {
151 int mMode;
152 int mSize;
153 unsigned char mCreated[8];
154 unsigned char mAccessed[8];
155 unsigned char mModified[8];
156};
157
163extern std::vector<File *> gFileTable;
164
177void FormatDevicePath(char *pszDest, int nSize, const char *pszFile);
178
189void MakeDevicePath(String &path, const char *pszFile);
190
200void FileSetBootPath(const char *pszPath);
201
209const char *FileBootExecutable();
210
218void FileOpenTraceLog(const char *pszPath);
219
227void FileSetTraceEnabled(int nEnabled);
228
237
244void FileInit();
245
253
263void FileNoteRead(const char *pszPath);
264
276int FileGetStat(const char *pszPath, FileStat *pStat);
277
286int FileMkDir(const char *pszPath);
287
Open file of the host or the disc.
Definition file.h:29
virtual int UncompressedSize()=0
Report the size before compression.
static File * New(const char *pszPath, int nMode, int nFlags)
Open a file.
virtual int Read(void *pBuffer, int nBytes)=0
Read bytes and wait for them.
virtual ~File()
Close the file.
Definition file.h:62
virtual bool ReadAsync(void *pBuffer, int nBytes)=0
Start reading bytes.
virtual int Seek(int nOffset, int nOrigin)=0
Move the position.
static constexpr int kFlagNoArchive
The open flags New() takes to read even a disc file through AsyncFile.
Definition file.h:38
virtual int Size()=0
Report the size.
virtual bool Fail()=0
Report whether an operation failed.
virtual int Tell()=0
Report the position.
Mode
Open modes of New().
Definition file.h:32
@ kModeRead
Definition file.h:33
@ kModeWrite
Definition file.h:34
virtual bool ReadDone(int *pnBytes)=0
Report whether the read ReadAsync() started is complete.
virtual void Flush()=0
Write out buffered bytes.
virtual bool Eof()=0
Report whether the position is at the end.
virtual int Write(const void *pBuffer, int nBytes)=0
Write bytes.
Growable text buffer that is also a PrnStream.
Definition string.h:19
void FileSetTraceEnabled(int nEnabled)
Turn the trace of File::New() on or off.
void FileSetBootPath(const char *pszPath)
Record the path the executable was started from, without its device and version.
void FileNoteRead(const char *pszPath)
Note the first read of a file.
void FileInit()
Read the file settings of the system configuration.
void FileOpenTraceLog(const char *pszPath)
Open the trace log that File::New() writes the path of each file read to, and turn the trace on.
void FormatDevicePath(char *pszDest, int nSize, const char *pszFile)
Format the device path of a game file.
void MakeDevicePath(String &path, const char *pszFile)
Build the device path of a game file.
int FileIsTraceEnabled()
Report whether the trace of File::New() is on.
char FileSourceLetter()
Report the letter the module loader puts in front of a module's source.
constexpr int kImageFirstWord
The word at 0x00100000, the load address of the executable.
Definition file.h:13
std::vector< File * > gFileTable
Files the gzip reader reads by descriptor, 128 entries.
constexpr int kImageSecondWord
The word at 0x00100004.
Definition file.h:21
int FileMkDir(const char *pszPath)
Create a host directory.
int FileGetStat(const char *pszPath, FileStat *pStat)
Report the status of a host file.
void FileTerminate()
Close the trace log.
const char * FileBootExecutable()
Report the path FileSetBootPath() recorded.
Status of a host file FileGetStat() reports.
Definition file.h:150
int mSize
Definition file.h:152
unsigned char mModified[8]
Definition file.h:155
unsigned char mAccessed[8]
Definition file.h:154
int mMode
Definition file.h:151
unsigned char mCreated[8]
Definition file.h:153