Main Page Class Hierarchy Alphabetical List Compound List Examples

mmfile.h
1/***************************************************************************
2 copyright : (C) 2002-2008 by Stefano Barbato
3 email : stefano@codesink.org
4
5 $Id: mmfile.h,v 1.12 2008-10-07 11:06:26 tat Exp $
6 ***************************************************************************/
7#ifndef _MIMETIC_OS_MMFILE_H
8#define _MIMETIC_OS_MMFILE_H
9#include <sys/types.h>
10#include <sys/stat.h>
11#include <fcntl.h>
12#include <sys/mman.h>
13#include <string>
14#include <cstring>
15#include <mimetic/os/fileop.h>
16
17 namespace mimetic
18{
19
20/// Memory mapped file
21 struct MMFile: public FileOp
22{
23 typedef char* iterator;
24 typedef const char* const_iterator;
25 MMFile();
26 MMFile(const std::string&, int mode = O_RDONLY);
27 ~MMFile();
28 operator bool() const;
29 bool open(const std::string&, int mode = O_RDONLY);
30 void close();
31 uint read(char*, int);
32
33 iterator begin();
34 const_iterator begin() const;
35 iterator end();
36 const_iterator end() const;
37
38 protected:
39 bool map();
40 bool open(int flags);
41 bool stat();
42
43 std::string m_fqn;
44 bool m_stated;
45 struct stat m_st;
46 int m_fd;
47
48 char *m_beg, *m_end;
49};
50
51}
52
53
54#endif
55
mimetic
Definition body.h:18
mimetic::FileOp
Defines some file utility functions.
Definition fileop.h:19