source: golgotha/src/i4/file/ram_file_man.cc

Last change on this file 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#include "file/ram_file_man.hh"
10#include "file/ram_file.hh"
11#include "file/file_man.hh"
12#include "string/string.hh"
13
14i4_openable_ram_file_info *i4_flist=0;
15
16class i4_ram_file_manager_class : public i4_file_manager_class
17
18public:
19
20  virtual i4_file_class *open(const i4_const_str &name, w32 flags)
21  {
22    if (flags==I4_READ)
23    {
24      char buf[256];
25      i4_os_string(name, buf, 256);
26
27      for (i4_openable_ram_file_info *f=i4_flist; f; f=f->next)
28        if (strcmp(buf, f->filename)==0)
29          return new i4_ram_file_class(f->data, f->data_size);         
30    }
31
32    return 0;
33  }
34
35  i4_ram_file_manager_class()
36  {
37    i4_add_file_manager(this, i4_F);
38  }
39
40  ~i4_ram_file_manager_class()
41  {
42    i4_remove_file_manger(this);
43  }
44} i4_ram_file_manager_instance;
45
46i4_openable_ram_file_info::i4_openable_ram_file_info(char *filename, void *data, w32 data_size)
47  : filename(filename), data(data), data_size(data_size)
48{
49  next=i4_flist;
50  i4_flist=this;
51}
Note: See TracBrowser for help on using the repository browser.