Last change
on this file since 608 was
80,
checked in by Sam Hocevar, 15 years ago
|
- Adding the Golgotha source code. Not sure what's going to be interesting
in there, but since it's all public domain, there's certainly stuff to
pick up.
|
File size:
1.5 KB
|
Line | |
---|
1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef I4_RAM_FILE_HH
|
---|
10 | #define I4_RAM_FILE_HH
|
---|
11 |
|
---|
12 | #include "file/file.hh"
|
---|
13 | #include <memory.h>
|
---|
14 |
|
---|
15 | class i4_ram_file_class : public i4_file_class
|
---|
16 | {
|
---|
17 | w8 *buf;
|
---|
18 | w32 bs, offset;
|
---|
19 |
|
---|
20 | public:
|
---|
21 | virtual i4_file_class *dup()
|
---|
22 | {
|
---|
23 | i4_file_class *f=new i4_ram_file_class(buf, bs);
|
---|
24 | f->seek(tell());
|
---|
25 | return f;
|
---|
26 | }
|
---|
27 |
|
---|
28 | i4_ram_file_class(void *buffer, int buffer_size)
|
---|
29 | : buf((w8 *)buffer), bs(buffer_size), offset(0) { ; }
|
---|
30 |
|
---|
31 | virtual w32 read (void *buffer, w32 size)
|
---|
32 | {
|
---|
33 | if (size>bs-offset)
|
---|
34 | size=bs-offset;
|
---|
35 | memcpy(buffer, buf+offset, size);
|
---|
36 | offset+=size;
|
---|
37 | return size;
|
---|
38 | }
|
---|
39 |
|
---|
40 | virtual w32 write(const void *buffer, w32 size)
|
---|
41 | {
|
---|
42 | if (size>bs-offset)
|
---|
43 | size=bs-offset;
|
---|
44 | memcpy(buf+offset, buffer, size);
|
---|
45 | offset+=size;
|
---|
46 | return size;
|
---|
47 | }
|
---|
48 |
|
---|
49 | virtual w32 seek (w32 _offset) { offset=_offset; return offset; }
|
---|
50 | virtual w32 size () { return bs; }
|
---|
51 | virtual w32 tell () { return offset; }
|
---|
52 | };
|
---|
53 |
|
---|
54 |
|
---|
55 | #endif
|
---|
Note: See
TracBrowser
for help on using the repository browser.