/usr/include/kmer/readBuffer.H is in libmeryl-dev 0~20150903+r2013-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #ifndef READ_BUFFER_H
#define READ_BUFFER_H
class readBuffer {
public:
readBuffer(const char *filename, uint64 bufferMax = 32 * 1024);
readBuffer(FILE *F, uint64 bufferMax = 32 * 1024);
~readBuffer();
bool eof(void) { return(_eof); };
char peek(void);
char read(void);
uint64 read(void *buf, uint64 len);
uint64 read(void *buf, uint64 maxlen, char stop);
void seek(uint64 pos);
uint64 tell(void) { return(_filePos); };
const char *filename(void) { return(_filename); };
private:
void fillBuffer(void);
void init(int fileptr, const char *filename, uint64 bufferMax);
char *_filename;
int _file;
uint64 _filePos;
bool _mmap;
bool _stdin;
bool _eof;
// If bufferMax is zero, then we are using the mmapped interface, otherwise,
// we are using a open()/read() and a small buffer.
uint64 _bufferPos;
uint64 _bufferLen;
uint64 _bufferMax;
char *_buffer;
};
// Returns the next letter in the buffer, but DOES NOT advance past
// it. Might have some wierd interaction with EOF -- if you peek()
// and the next thing is eof , the _eof flag might get set.
//
inline
char
readBuffer::peek(void) {
if ((_eof == false) && (_bufferPos >= _bufferLen))
fillBuffer();
if (_eof)
return(0);
return(_buffer[_bufferPos]);
}
// Returns the next letter in the buffer. Returns EOF (0) if there
// is no next letter.
//
inline
char
readBuffer::read(void) {
if ((_eof == false) && (_bufferPos >= _bufferLen))
fillBuffer();
if (_eof)
return(0);
_bufferPos++;
_filePos++;
return(_buffer[_bufferPos-1]);
}
#endif // READ_BUFFER_H
|