1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
26
/* Get a pointer to the file with id */
27
AsyncFile* find(Uint16 id) const;
28
/* Insert file with id */
29
bool insert(AsyncFile* file, Uint16 id);
30
/* Erase file with id */
31
bool erase(Uint16 id);
32
/* Get number of open files */
35
Uint16 getId(unsigned i);
36
AsyncFile* getFile(unsigned i);
43
OpenFileItem(): m_file(NULL), m_id(0){};
49
Vector<OpenFileItem> m_files;
53
//*****************************************************************************
54
inline AsyncFile* OpenFiles::find(Uint16 id) const {
55
for (unsigned i = 0; i < m_files.size(); i++){
56
if (m_files[i].m_id == id){
57
return m_files[i].m_file;
63
//*****************************************************************************
64
inline bool OpenFiles::erase(Uint16 id){
65
for (unsigned i = 0; i < m_files.size(); i++){
66
if (m_files[i].m_id == id){
71
// Item was not found in list
76
//*****************************************************************************
77
inline bool OpenFiles::insert(AsyncFile* file, Uint16 id){
78
// Check if file has already been opened
79
for (unsigned i = 0; i < m_files.size(); i++){
80
if(m_files[i].m_file == NULL)
83
if(strcmp(m_files[i].m_file->theFileName.c_str(),
84
file->theFileName.c_str()) == 0)
87
names.assfmt("open: >%s< existing: >%s<",
88
file->theFileName.c_str(),
89
m_files[i].m_file->theFileName.c_str());
90
ERROR_SET(fatal, NDBD_EXIT_AFS_ALREADY_OPEN, names.c_str(),
91
"OpenFiles::insert()");
95
// Insert the file into vector
96
OpenFileItem openFile;
98
openFile.m_file = file;
99
m_files.push_back(openFile);
104
//*****************************************************************************
105
inline Uint16 OpenFiles::getId(unsigned i){
106
return m_files[i].m_id;
109
//*****************************************************************************
110
inline AsyncFile* OpenFiles::getFile(unsigned i){
111
return m_files[i].m_file;
114
//*****************************************************************************
115
inline unsigned OpenFiles::size(){
116
return m_files.size();