22 File file(std::move(filename));
37 : tmpFile(std::move(other.tmpFile))
38 , tmpDir (std::move(other.tmpDir ))
46 tmpFile = std::move(other.tmpFile);
47 tmpDir = std::move(other.tmpDir);
57void LocalFileReference::init(
File& file)
59 tmpFile = file.getLocalReference();
60 if (!tmpFile.empty()) {
63 assert(tmpDir.empty());
68#if defined(_WIN32) || PLATFORM_ANDROID
72 tmpDir =
strCat(
"/tmp/openmsx.",
int(getpid()));
81 throw FileException(
"Couldn't create temp file");
85 auto mmap = file.
mmap();
86 if (fwrite(mmap.data(), 1, mmap.size(), fp.get()) != mmap.size()) {
87 throw FileException(
"Couldn't write temp file");
91void LocalFileReference::cleanup()
const
93 if (!tmpDir.empty()) {
103 assert(!tmpFile.empty());
std::span< const uint8_t > mmap()
Map file in memory.
This class represents a filename.
Helper class to use files in APIs other than openmsx::File.
LocalFileReference()=default
LocalFileReference & operator=(const LocalFileReference &)=delete
const std::string & getFilename() const
Returns path to a local uncompressed version of this file.
FILE_t openUniqueFile(const std::string &directory, std::string &filename)
Open a new file with a unique name in the provided directory.
int rmdir(zstring_view path)
Call rmdir() in a platform-independent manner.
string getTempDir()
Get the name of the temp directory on the system.
const char nativePathSeparator
void mkdirp(string path)
Acts like the unix command "mkdir -p".
int unlink(zstring_view path)
Call unlink() in a platform-independent manner.
This file implemented 3 utility functions: