MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
File.hpp
1 /*
2  Copyright (C) 2003-2006 MySQL AB, 2008 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef FILE_H
20 #define FILE_H
21 
22 #include <ndb_global.h>
23 
31 {
32 public:
39  static time_t mtime(const char* aFileName);
40 
47  static bool exists(const char* aFileName);
48 
55  static off_t size(FILE* f);
56 
64  static bool rename(const char* currFileName, const char* newFileName);
65 
72  static bool remove(const char* aFileName);
73 
77  File_class();
78 
88  File_class(const char* aFileName, const char* mode = "r");
89 
93  ~File_class();
94 
101  bool open();
102 
112  bool open(const char* aFileName, const char* mode);
113 
119  bool is_open();
120 
126  bool remove();
127 
131  bool close();
132 
141  int read(void* buf, size_t itemSize, size_t nitems) const;
142 
151  int readChar(char* buf, long start, long length) const;
152 
159  int readChar(char* buf);
160 
169  int write(const void* buf, size_t itemSize, size_t nitems);
170 
179  int writeChar(const char* buf, long start, long length);
180 
187  int writeChar(const char* buf);
188 
194  off_t size() const;
195 
201  const char* getName() const;
202 
208  int flush() const;
209 
210 private:
211  FILE* m_file;
212  char m_fileName[PATH_MAX];
213  const char* m_fileMode;
214  /* Prohibit */
215  File_class (const File_class& aCopy);
216  File_class operator = (const File_class&);
217  bool operator == (const File_class&);
218 };
219 #endif
220