-
Notifications
You must be signed in to change notification settings - Fork 67
/
GenericFile_Blob.h
65 lines (45 loc) · 1.4 KB
/
GenericFile_Blob.h
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
/*++
Module Name:
GenericFile_Blob.h
Abstract:
Generic IO class for SNAP that can read from an in-memory blob.
Authors:
Bill Bolosky, March, 2014
Environment:
User mode service.
Revision History:
--*/
#pragma once
#include "GenericFile.h"
class GenericFile_Blob: public GenericFile
{
public:
//
// This object does not take ownership of the blob, so it's the caller's
// responsibility to assure that it continues to exist as long as the
// GenericFile_Blob object does, and to free the memory as necessary.
// In addition, if anyone calls mapAndAdvance, the caller must
// assure that the blob continues to exist until all uses of that
// pointer are finished as well.
//
static GenericFile_Blob *open(void *i_blob, size_t i_blobSize);
virtual size_t read(void *ptr, size_t count);
virtual int getchar();
virtual char *gets(char *buf, size_t count);
virtual int advance(long long offset);
virtual void close();
virtual ~GenericFile_Blob();
virtual size_t getAmountUsed();
//
// This gives a pointer into the blob rather than copying it.
// It's the caller's responsibility to assure that the blob doesn't
// go away while this pointer's still in use.
//
void *mapAndAdvance(size_t count, size_t *bytesReturned);
private:
GenericFile_Blob();
char *blob;
char *blobEnd;
char *readPointer;
size_t blobSize;
};