File: mapfile.h

package info (click to toggle)
sdcv 0.3.4-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,644 kB
  • ctags: 1,207
  • sloc: sh: 9,235; ansic: 7,803; cpp: 2,613; makefile: 485; yacc: 316; sed: 16
file content (44 lines) | stat: -rw-r--r-- 746 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef MAPFILE_H
#define MAPFILE_H

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif


#ifdef HAVE_MMAP
#  include <cstdlib>
#  include <sys/types.h>
#  include <fcntl.h>
#  include <sys/mman.h>
#  else
#  ifdef _WIN32
#  else
#  endif
#endif


class TMapFile{
public:
  TMapFile(void) : data_buffer(NULL){}
  ~TMapFile(){close();}
  bool open(const char *filename, size_t _file_size);
  bool open(const char *filename);
  void close(void);
  inline const char *begin(void){return data_buffer;}
  inline const char *end(void){return data_buffer+file_size;}
private:
  char *data_buffer;
  size_t file_size;
#ifdef HAVE_MMAP
  int mmap_fd;
#else
#  ifdef _WIN32
  HANDLE hFile;
  HANDLE hFileMap;
#  else
#  endif
#endif
};

#endif/*mapfile.h*/