Expose mapped_file only if mmap is available

This commit is contained in:
Danny Robson 2011-07-04 16:26:08 +10:00 committed by U-steve\danny
parent 7cba9b8496
commit f6d96fbe1b
2 changed files with 6 additions and 2 deletions

6
io.cpp
View File

@ -6,7 +6,6 @@
#include <cstdio>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
@ -68,6 +67,9 @@ fd_ref::operator int (void) const
{ return fd; }
#if defined(HAVE_MMAP)
#include <sys/mman.h>
//----------------------------------------------------------------------------
mapped_file::mapped_file (const char *_path):
m_fd (open (_path, O_RDONLY))
@ -119,6 +121,6 @@ mapped_file::data (void) const {
return m_data;
}
#endif

2
io.hpp
View File

@ -52,6 +52,7 @@ struct fd_ref {
};
#if defined(HAVE_MMAP)
/// Wraps a mechanism to map a file into memory. Read only.
class mapped_file {
protected:
@ -74,6 +75,7 @@ class mapped_file {
const uint8_t* data (void) const;
size_t size (void) const;
};
#endif
#endif