2 * Copyright (C) 2017 Cisco Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // @author Changxue Deng <chadeng@cisco.com>
26 #include <sys/types.h>
32 #define MMAP_ANONYMOUS_MODE 0x80000000 // This bit should not be used in fcntl.h.
34 // This is the basic file io class
38 FileIO(const std::string &fpath, int oflags, int fmode, bool sync);
42 int TruncateFile(off_t filesize);
46 size_t Write(const void *data, size_t bytes);
47 size_t Read(void *buff, size_t bytes);
48 off_t SetOffset(off_t offset);
50 virtual size_t RandomWrite(const void *data, size_t size, off_t offset);
51 virtual size_t RandomRead(void *buff, size_t size, off_t offset);
54 const std::string& GetFilePath() const;
61 void* MapFile(size_t size, int prot, int flags, off_t offset);