wavelength 1.0.0
Loading...
Searching...
No Matches
LazyFileStream.h
Go to the documentation of this file.
1#pragma once
2
3#include "os/File.h"
4#include "utl/Str.h"
5
12class LazyFileStream {
13public:
21 LazyFileStream(const String &filename, int bufferSize);
22
29
36 bool Eof() const;
37
44 bool ReadDone();
45
54 char *GetData(int *position, int *bytesAvailable);
55
56private:
58 enum { kNumBuffers = 2 };
59
65 void StartRead();
66
67 bool mMoreData;
68 int mPosition;
69 File *mFile;
70 char *mBuffers[kNumBuffers];
71 unsigned int mCurBuffer;
72 int mBufferSize;
73 int mBytesAvailable;
74};
Open file of the host or the disc.
Definition file.h:29
Double-buffered reader with one asynchronous read of a file always in flight.
Definition lazyfilestream.h:14
char * GetData(int *position, int *bytesAvailable)
Take the buffer of the completed read, and start the next read unless the file ended.
bool ReadDone()
Report whether the read in flight is complete, recording how many bytes arrived.
~LazyFileStream()
Close the file and free the buffers.
LazyFileStream(const String &filename, int bufferSize)
Open a file, allocate the buffers, and start the first read.
bool Eof() const
Report whether the last read reached the end of the file.
Growable text buffer that is also a PrnStream.
Definition string.h:19