19 File file(std::move(filename));
34 : tmpFile(std::move(other.tmpFile))
35 , tmpDir (std::move(other.tmpDir ))
43 tmpFile = std::move(other.tmpFile);
44 tmpDir = std::move(other.tmpDir);
54void LocalFileReference::init(
File& file)
56 tmpFile = file.getLocalReference();
57 if (!tmpFile.empty()) {
60 assert(tmpDir.empty());
65#if defined(_WIN32) || PLATFORM_ANDROID
69 tmpDir =
strCat(
"/tmp/openmsx.",
int(getpid()));
78 throw FileException(
"Couldn't create temp file");
82 auto mmap = file.
mmap();
83 if (fwrite(mmap.data(), 1, mmap.size(), fp.get()) != mmap.size()) {
84 throw FileException(
"Couldn't write temp file");
88void LocalFileReference::cleanup()
90 if (!tmpDir.empty()) {
100 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:
std::string strCat(Ts &&...ts)