wavelength 1.0.0
Loading...
Searching...
No Matches
AsyncFile.h
Go to the documentation of this file.
1#pragma once
2
3#include "os/File.h"
4#include "utl/Str.h"
5
11extern int gAsyncBufSize;
12
19
26class AsyncFile : public File {
27public:
35 AsyncFile(const char *name, int mode);
36
42 virtual ~AsyncFile();
43
52 virtual int Read(void *data, int bytes);
53
62 virtual bool ReadAsync(void *data, int bytes);
63
72 virtual int Write(const void *data, int bytes);
73
82 virtual int Seek(int offset, int origin);
83
90 virtual int Tell();
91
97 virtual void Flush();
98
105 virtual bool Eof();
106
113 virtual bool Fail();
114
121 virtual int Size();
122
129 virtual int UncompressedSize();
130
138 virtual bool ReadDone(int *bytes);
139
147 void Open(const char *name, int mode);
148
154 void Close();
155
156private:
163 int _Open();
164
173 int _Write(const void *data, int bytes);
174
180 void _SeekToTell();
181
189 void _ReadAsync(void *data, int bytes);
190
197 bool _ReadDone();
198
204 void _Close();
205
206 int mMode;
207 int mHandle;
208 int mSize;
209 int mUCSize;
210 int mTell;
211 int mOffset;
212 bool mReadStarted;
213 bool mFail;
214 char *mBuffer;
215 char *mData;
216 int mBytesLeft;
217 int mBytesRead;
218 String mFilename;
219};
int gAsyncBufSize
Bytes of the buffer of each AsyncFile, from buf_size of the file configuration array.
void AsyncFileInit()
Read the file configuration array.
File of the host or the disc file system, read and written through a buffer with non-blocking I/O.
Definition asyncfile.h:13
virtual bool Eof()
Report whether the position is at the end.
virtual int Seek(int offset, int origin)
Move the position, clamped to the file.
AsyncFile(const char *name, int mode)
Allocate the buffer and open a file.
virtual ~AsyncFile()
Close the file and free the buffer.
virtual bool ReadDone(int *bytes)
Copy buffered bytes of the read ReadAsync() started, refilling the buffer when it runs out.
virtual int Size()
Report the size.
virtual void Flush()
Write the buffer when writing, or refill it when reading.
void Open(const char *name, int mode)
Open a file.
virtual bool ReadAsync(void *data, int bytes)
Start reading bytes, at most up to the end of the file.
virtual bool Fail()
Report whether an operation failed.
virtual int Read(void *data, int bytes)
Read bytes and wait for them.
void Close()
Write out a written file and close it.
virtual int Tell()
Report the position.
virtual int Write(const void *data, int bytes)
Write bytes through the buffer.
virtual int UncompressedSize()
Report the size a .gz file records in its last four bytes, or zero for other files.
Open file of the host or the disc.
Definition file.h:29
Growable text buffer that is also a PrnStream.
Definition string.h:19