ram_file_man.cc 1.5 KB

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