The world's most popular open source database
00001 /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 00018 /* interface for memory mapped files */ 00019 00020 #ifdef USE_PRAGMA_INTERFACE 00021 #pragma interface /* gcc class implementation */ 00022 #endif 00023 00024 class mapped_files; 00025 mapped_files *map_file(const my_string name,byte *magic,uint magic_length); 00026 void unmap_file(mapped_files *map); 00027 00028 class mapped_files :public ilink { 00029 byte *map; 00030 ha_rows size; 00031 char *name; // name of mapped file 00032 File file; // >= 0 if open 00033 int error; // If not mapped 00034 uint use_count; 00035 00036 public: 00037 mapped_files(const my_string name,byte *magic,uint magic_length); 00038 ~mapped_files(); 00039 00040 friend class mapped_file; 00041 friend mapped_files *map_file(const my_string name,byte *magic, 00042 uint magic_length); 00043 friend void unmap_file(mapped_files *map); 00044 }; 00045 00046 00047 class mapped_file 00048 { 00049 mapped_files *file; 00050 public: 00051 mapped_file(const my_string name,byte *magic,uint magic_length) 00052 { 00053 file=map_file(name,magic,magic_length); /* old or new map */ 00054 } 00055 ~mapped_file() 00056 { 00057 unmap_file(file); /* free map */ 00058 } 00059 byte *map() 00060 { 00061 return file->map; 00062 } 00063 };
1.4.7

