Debian Codegraph @

lib/dat/file.hpp

raw symbols SCIP
1 /*
2 Copyright(C) 2011-2016 Brazil
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library 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 GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #pragma once
20
21 #include "dat.hpp"
22
23 namespace grn {
24 namespace dat {
25
26 // This implementation class hides environment dependent codes required for
27 // memory-mapped I/O.
28 class FileImpl;
29
30 class GRN_DAT_API File {
31 public:
32 File();
33 ~File();
34
35 // This function creates a file and maps the entire file to a certain range
36 // of the address space. Note that a file is truncated if exists.
37 void create(const char *path, UInt64 size);
38
39 // This function opens a file and maps the entire file to a certain range of
40 // the address space.
41 void open(const char *path);
42 void close();
43
44 void *ptr() const;
45 UInt64 size() const;
46
47 void swap(File *rhs);
48
49 void flush();
50
51 private:
52 FileImpl *impl_;
53
54 // Disallows copy and assignment.
55 File(const File &);
56 File &operator=(const File &);
57 };
58
59 } // namespace dat
60 } // namespace grn