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