1 //----------------------------------------------------------------------------
2 //  Block of memory with File interface
3 //----------------------------------------------------------------------------
4 //
5 //  Copyright (c) 2007-2008  The EDGE Team.
6 //
7 //  This program is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU General Public License
9 //  as published by the Free Software Foundation; either version 2
10 //  of the License, or (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU General Public License for more details.
16 //
17 //----------------------------------------------------------------------------
18 
19 #ifndef __EPI_FILE_MEMORY_H__
20 #define __EPI_FILE_MEMORY_H__
21 
22 #include "file.h"
23 
24 namespace epi
25 {
26 
27 class mem_file_c : public file_c
28 {
29 private:
30 	byte *data;
31 
32 	int length;
33 	int pos;
34 	bool copied;
35 
36 public:
37      mem_file_c(const byte *_block, int _len, bool copy_it = true);
38     ~mem_file_c();
39 
GetLength()40     int GetLength()   { return length; }
GetPosition()41     int GetPosition() { return pos; }
42 
43     unsigned int Read(void *dest, unsigned int size);
44     unsigned int Write(const void *src, unsigned int size);
45 
46     bool Seek(int offset, int seekpoint);
47 };
48 
49 } // namespace epi
50 
51 #endif /*__EPI_FILE_MEMORY_H__*/
52 
53 //--- editor settings ---
54 // vi:ts=4:sw=4:noexpandtab
55