CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mmap_file.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_UTIL_MMAP_FILE_H_
6 #define CVMFS_UTIL_MMAP_FILE_H_
7 
8 #include <cstddef>
9 #include <string>
10 
11 #include "util/export.h"
12 #include "util/single_copy.h"
13 
14 #ifdef CVMFS_NAMESPACE_GUARD
15 namespace CVMFS_NAMESPACE_GUARD {
16 #endif
17 
18 
25  public:
26  explicit MemoryMappedFile(const std::string &file_path);
28 
29  bool Map();
30  void Unmap();
31 
32  inline unsigned char* buffer() const { return mapped_file_; }
33  inline size_t size() const { return mapped_size_; }
34  inline const std::string& file_path() const { return file_path_; }
35 
36  inline bool IsMapped() const { return mapped_; }
37 
38  private:
39  const std::string file_path_;
41  unsigned char *mapped_file_;
42  size_t mapped_size_;
43  bool mapped_;
44 };
45 
46 
47 #ifdef CVMFS_NAMESPACE_GUARD
48 } // namespace CVMFS_NAMESPACE_GUARD
49 #endif
50 
51 #endif // CVMFS_UTIL_MMAP_FILE_H_
unsigned char * mapped_file_
Definition: mmap_file.h:41
#define CVMFS_EXPORT
Definition: export.h:11
const std::string file_path_
Definition: mmap_file.h:39
size_t mapped_size_
Definition: mmap_file.h:42
size_t size() const
Definition: mmap_file.h:33
bool IsMapped() const
Definition: mmap_file.h:36
int file_descriptor_
Definition: mmap_file.h:40
const std::string & file_path() const
Definition: mmap_file.h:34
unsigned char * buffer() const
Definition: mmap_file.h:32