Fix memory_mapped_file to correctly build in mingw (windows).

This commit is contained in:
vng 2011-01-24 22:41:40 +02:00 committed by Alex Zolotarev
parent 66522077ac
commit 4606f80b94
2 changed files with 13 additions and 12 deletions

View file

@ -1,15 +1,21 @@
#include "../base/SRC_FIRST.hpp"
// it's a shit; remove this into coding folder
#include "../coding/internal/file64_api.hpp"
#include "memory_mapped_file.hpp"
#ifdef OMIM_OS_WINDOWS
#include "../coding/internal/file64_api.hpp"
#else
#include <sys/mman.h>
#include <sys/errno.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#endif
MemoryMappedFile::MemoryMappedFile(char const * fileName, bool isReadOnly)
: m_isReadOnly(isReadOnly)
{
#ifdef OMIM_OS_WINDOWS_NATIVE
#ifdef OMIM_OS_WINDOWS
m_fp = fopen(fileName, isReadOnly ? "r" : "w");
fseek(m_fp, 0, SEEK_END);
m_size = ftell(m_fp);
@ -28,7 +34,7 @@ MemoryMappedFile::MemoryMappedFile(char const * fileName, bool isReadOnly)
MemoryMappedFile::~MemoryMappedFile()
{
#ifdef OMIM_OS_WINDOWS_NATIVE
#ifdef OMIM_OS_WINDOWS
if (!m_isReadOnly)
{
fwrite(m_data, 1, m_size, m_fp);

View file

@ -2,20 +2,15 @@
#include "../std/target_os.hpp"
#ifdef OMIM_OS_WINDOWS_NATIVE
#ifdef OMIM_OS_WINDOWS
#include "../std/windows.hpp"
#else
#include <sys/mman.h>
#include <sys/errno.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#endif
class MemoryMappedFile
{
bool m_isReadOnly;
#ifdef OMIM_OS_WINDOWS_NATIVE
#ifdef OMIM_OS_WINDOWS
FILE * m_fp;
#else
int m_fd;