0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/util/mmap.h

43 lines
1.1 KiB
C
Raw Normal View History

2008-06-06 15:43:15 +02:00
// mmap.h
/**
* Copyright (C) 2008 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2008-06-06 15:43:15 +02:00
#pragma once
class MemoryMappedFile {
public:
static void closeAllFiles();
2008-06-06 15:43:15 +02:00
MemoryMappedFile();
~MemoryMappedFile(); /* closes the file if open */
void close();
2008-06-06 15:43:15 +02:00
/* only smart enough right now to deal with files of a fixed length.
creates if DNE
*/
void* map(const char *filename, int length);
void flush(bool sync);
2008-06-30 04:33:59 +02:00
void* viewOfs() { return view; }
2008-06-06 15:43:15 +02:00
private:
HANDLE fd;
HANDLE maphandle;
void *view;
int len;
};