52 File(std::string filename,
const char* mode);
58 explicit File(std::unique_ptr<FileBase> file_);
65 [[nodiscard]]
bool is_open()
const {
return file !=
nullptr; }
76 void read(std::span<uint8_t> buffer);
79 void read(std::span<T> buffer) {
80 read(std::span<uint8_t>{std::bit_cast<uint8_t*>(buffer.data()), buffer.size_bytes()});
87 void write(std::span<const uint8_t> buffer);
90 void write(std::span<T> buffer) {
91 write(std::span<const uint8_t>{std::bit_cast<const uint8_t*>(buffer.data()), buffer.size_bytes()});
98 [[nodiscard]] std::span<const uint8_t>
mmap();
108 [[nodiscard]]
size_t getSize();
114 void seek(
size_t pos);
120 [[nodiscard]]
size_t getPos();
136 [[nodiscard]]
const std::string&
getURL()
const;
163 [[nodiscard]] std::string getLocalReference()
const;
165 std::unique_ptr<FileBase> file;
void close()
Close the current file.
void seek(size_t pos)
Move read/write pointer to the specified position.
bool isReadOnly() const
Check if this file is readonly.
std::span< const uint8_t > mmap()
Map file in memory.
File()
Create a closed file handle.
File & operator=(File &&other) noexcept
std::string_view getOriginalName()
Get Original filename for this object.
void read(std::span< uint8_t > buffer)
Read from file.
void write(std::span< const uint8_t > buffer)
Write to file.
time_t getModificationDate()
Get the date/time of last modification.
void read(std::span< T > buffer)
void truncate(size_t size)
Truncate file size.
void write(std::span< T > buffer)
bool is_open() const
Return true iff this file handle refers to an open file.
size_t getSize()
Returns the size of this file.
size_t getPos()
Get the current position of the read/write pointer.
void munmap()
Unmap file from memory.
const std::string & getURL() const
Returns the URL of this file object.
void flush()
Force a write of all buffered data to disk.
This class represents a filename.
Helper class to use files in APIs other than openmsx::File.
This file implemented 3 utility functions: