openMSX
FileBase.hh
Go to the documentation of this file.
1#ifndef FILEBASE_HH
2#define FILEBASE_HH
3
4#include "MemBuffer.hh"
5#include <cstdint>
6#include <ctime>
7#include <span>
8#include <string>
9
10namespace openmsx {
11
13{
14public:
15 virtual ~FileBase() = default;
16
17 virtual void read(std::span<uint8_t> buffer) = 0;
18 virtual void write(std::span<const uint8_t> buffer) = 0;
19
20 // If you override mmap(), make sure to call munmap() in
21 // your destructor.
22 [[nodiscard]] virtual std::span<const uint8_t> mmap();
23 virtual void munmap();
24
25 [[nodiscard]] virtual size_t getSize() = 0;
26 virtual void seek(size_t pos) = 0;
27 [[nodiscard]] virtual size_t getPos() = 0;
28 virtual void truncate(size_t size);
29 virtual void flush() = 0;
30
31 [[nodiscard]] virtual const std::string& getURL() const = 0;
32 [[nodiscard]] virtual std::string getLocalReference();
33 [[nodiscard]] virtual std::string_view getOriginalName();
34 [[nodiscard]] virtual bool isReadOnly() const = 0;
35 [[nodiscard]] virtual time_t getModificationDate() = 0;
36
37private:
38 MemBuffer<uint8_t> mmapBuf;
39};
40
41} // namespace openmsx
42
43#endif
virtual void write(std::span< const uint8_t > buffer)=0
virtual size_t getSize()=0
virtual const std::string & getURL() const =0
virtual void read(std::span< uint8_t > buffer)=0
virtual std::string_view getOriginalName()
Definition FileBase.cc:55
virtual std::string getLocalReference()
Definition FileBase.cc:48
virtual void flush()=0
virtual void seek(size_t pos)=0
virtual ~FileBase()=default
virtual bool isReadOnly() const =0
virtual std::span< const uint8_t > mmap()
Definition FileBase.cc:9
virtual size_t getPos()=0
virtual time_t getModificationDate()=0
virtual void truncate(size_t size)
Definition FileBase.cc:30
virtual void munmap()
Definition FileBase.cc:25
This class manages the lifetime of a block of memory.
Definition MemBuffer.hh:29
This file implemented 3 utility functions:
Definition Autofire.cc:9