You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.8 KiB

26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
  1. /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  13. /* interface for memory mapped files */
  14. #ifdef USE_PRAGMA_INTERFACE
  15. #pragma interface /* gcc class implementation */
  16. #endif
  17. class mapped_files;
  18. mapped_files *map_file(const my_string name,byte *magic,uint magic_length);
  19. void unmap_file(mapped_files *map);
  20. class mapped_files :public ilink {
  21. byte *map;
  22. ha_rows size;
  23. char *name; // name of mapped file
  24. File file; // >= 0 if open
  25. int error; // If not mapped
  26. uint use_count;
  27. public:
  28. mapped_files(const my_string name,byte *magic,uint magic_length);
  29. ~mapped_files();
  30. friend class mapped_file;
  31. friend mapped_files *map_file(const my_string name,byte *magic,
  32. uint magic_length);
  33. friend void unmap_file(mapped_files *map);
  34. };
  35. class mapped_file
  36. {
  37. mapped_files *file;
  38. public:
  39. mapped_file(const my_string name,byte *magic,uint magic_length)
  40. {
  41. file=map_file(name,magic,magic_length); /* old or new map */
  42. }
  43. ~mapped_file()
  44. {
  45. unmap_file(file); /* free map */
  46. }
  47. byte *map()
  48. {
  49. return file->map;
  50. }
  51. };