Classes | Namespaces | Typedefs | Functions | Variables
FileOperations.hh File Reference
#include "Date.hh"
#include "unistdp.hh"
#include "statp.hh"
#include "zstring_view.hh"
#include <fstream>
#include <memory>
#include <optional>
#include <string_view>
#include <sys/types.h>
Include dependency graph for FileOperations.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


struct  openmsx::FileOperations::FClose


namespace  openmsx
 This file implemented 3 utility functions:
namespace  openmsx::FileOperations


using openmsx::FileOperations::FILE_t = std::unique_ptr< FILE, FClose >
using openmsx::FileOperations::Stat = stat


string openmsx::FileOperations::expandTilde (std::string path)
 Expand the '~' character to the users home directory.
bool openmsx::FileOperations::needsTildeExpansion (std::string_view path)
 Returns true iff expandTilde(s) would have an effect.
void openmsx::FileOperations::mkdir (zstring_view path, mode_t mode)
 Create the specified directory.
void openmsx::FileOperations::mkdirp (std::string path)
 Acts like the unix command "mkdir -p".
int openmsx::FileOperations::unlink (zstring_view path)
 Call unlink() in a platform-independent manner.
int openmsx::FileOperations::rmdir (zstring_view path)
 Call rmdir() in a platform-independent manner.
int openmsx::FileOperations::deleteRecursive (zstring_view path)
 Recursively delete a file or directory and (in case of a directory) all its sub-components.
FILE_t openmsx::FileOperations::openFile (zstring_view filename, zstring_view mode)
 Call fopen() in a platform-independent manner.
void openmsx::FileOperations::openOfStream (std::ofstream &stream, zstring_view filename)
 Open an ofstream in a platform-independent manner.
void openmsx::FileOperations::openOfStream (std::ofstream &stream, zstring_view filename, std::ios_base::openmode mode)
 Open an ofstream in a platform-independent manner.
string_view openmsx::FileOperations::getFilename (std::string_view path)
 Returns the file portion of a path name.
string_view openmsx::FileOperations::getDirName (std::string_view path)
 Returns the directory portion of a path.
string_view openmsx::FileOperations::getExtension (std::string_view path)
 Returns the extension portion of a path.
string_view openmsx::FileOperations::stripExtension (std::string_view path)
 Returns the path without extension.
string openmsx::FileOperations::join (std::string_view part1, std::string_view part2)
 Join two paths.
string openmsx::FileOperations::join (string_view part1, string_view part2, string_view part3)
string openmsx::FileOperations::join (string_view part1, string_view part2, string_view part3, string_view part4)
const std::string & openmsx::FileOperations::getConventionalPath (const std::string &path)
 Returns the path in conventional path-delimiter.
std::string openmsx::FileOperations::getConventionalPath (std::string &&path)
const std::string & openmsx::FileOperations::getNativePath (const std::string &path)
 Returns the path in native path-delimiter.
std::string openmsx::FileOperations::getNativePath (std::string &&path)
const std::string & openmsx::FileOperations::expandCurrentDirFromDrive (const std::string &path)
 Get the current directory of the specified drive Linux: return the given string unchanged.
std::string openmsx::FileOperations::expandCurrentDirFromDrive (std::string &&path)
string openmsx::FileOperations::getCurrentWorkingDirectory ()
 Returns the current working directory.
string openmsx::FileOperations::getAbsolutePath (std::string_view path)
 Transform given path into an absolute path.
bool openmsx::FileOperations::isAbsolutePath (std::string_view path)
 Checks whether it's a absolute path or not.
string openmsx::FileOperations::getUserHomeDir (std::string_view username)
 Get user's home directory.
const string & openmsx::FileOperations::getUserOpenMSXDir ()
 Get the openMSX dir in the user's home directory.
const string & openmsx::FileOperations::getUserDataDir ()
 Get the openMSX data dir in the user's home directory.
const string & openmsx::FileOperations::getSystemDataDir ()
 Get system directory.
const string & openmsx::FileOperations::getSystemDocDir ()
 Get system doc directory.
std::optional< Statopenmsx::FileOperations::getStat (zstring_view filename)
 Call stat() and return the stat structure.
bool openmsx::FileOperations::isRegularFile (zstring_view filename)
 Is this a regular file (no directory, device, ..)?
bool openmsx::FileOperations::isRegularFile (const Stat &st)
bool openmsx::FileOperations::isDirectory (zstring_view directory)
 Is this a directory?
bool openmsx::FileOperations::isDirectory (const Stat &st)
bool openmsx::FileOperations::exists (zstring_view filename)
 Does this file (directory) exists?
time_t openmsx::FileOperations::getModificationDate (const Stat &st)
 Get the date/time of last modification.
string openmsx::FileOperations::getNextNumberedFileName (std::string_view directory, std::string_view prefix, std::string_view extension, bool addSeparator=false)
 Gets the next numbered file name with the specified prefix in the specified directory, with the specified extension.
string openmsx::FileOperations::parseCommandFileArgument (std::string_view argument, std::string_view directory, std::string_view prefix, std::string_view extension)
 Helper function for parsing filename arguments in Tcl commands.
string openmsx::FileOperations::getTempDir ()
 Get the name of the temp directory on the system.
FILE_t openmsx::FileOperations::openUniqueFile (const std::string &directory, std::string &filename)
 Open a new file with a unique name in the provided directory.


const char openmsx::FileOperations::nativePathSeparator