CernVM-FS  2.9.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/single_copy.h"
12 
13 #ifdef CVMFS_NAMESPACE_GUARD
14 namespace CVMFS_NAMESPACE_GUARD {
15 #endif
16 
17 
24  public:
25  explicit MemoryMappedFile(const std::string &file_path);
27 
28  bool Map();
29  void Unmap();
30 
31  inline unsigned char* buffer() const { return mapped_file_; }
32  inline size_t size() const { return mapped_size_; }
33  inline const std::string& file_path() const { return file_path_; }
34 
35  inline bool IsMapped() const { return mapped_; }
36 
37  private:
38  const std::string file_path_;
40  unsigned char *mapped_file_;
41  size_t mapped_size_;
42  bool mapped_;
43 };
44 
45 
46 #ifdef CVMFS_NAMESPACE_GUARD
47 } // namespace CVMFS_NAMESPACE_GUARD
48 #endif
49 
50 #endif // CVMFS_UTIL_MMAP_FILE_H_
unsigned char * mapped_file_
Definition: mmap_file.h:40
const std::string file_path_
Definition: mmap_file.h:38
size_t mapped_size_
Definition: mmap_file.h:41
size_t size() const
Definition: mmap_file.h:32
bool IsMapped() const
Definition: mmap_file.h:35
int file_descriptor_
Definition: mmap_file.h:39
const std::string & file_path() const
Definition: mmap_file.h:33
unsigned char * buffer() const
Definition: mmap_file.h:31