56 File(std::unique_ptr<FileBase> file_);
63 [[nodiscard]]
bool is_open()
const {
return file !=
nullptr; }
75 void read(
void* buffer,
size_t num);
82 void write(
const void* buffer,
size_t num);
104 void seek(
size_t pos);
110 [[nodiscard]]
size_t getPos();
126 [[nodiscard]]
const std::string&
getURL()
const;
153 [[nodiscard]] std::string getLocalReference()
const;
155 std::unique_ptr<FileBase> file;
void close()
Close the current file.
span< const uint8_t > mmap()
Map file in memory.
void seek(size_t pos)
Move read/write pointer to the specified position.
bool isReadOnly() const
Check if this file is readonly.
File()
Create a closed file handle.
File & operator=(File &&other) noexcept
std::string_view getOriginalName()
Get Original filename for this object.
void read(void *buffer, size_t num)
Read from file.
time_t getModificationDate()
Get the date/time of last modification.
void truncate(size_t size)
Truncate file size.
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.
void write(const void *buffer, size_t num)
Write to file.
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:
constexpr const char *const filename
size_t size(std::string_view utf8)