MP4v2
Static Public Member Functions | Static Public Attributes | List of all members
mp4v2::platform::io::FileSystem Class Reference

General file-system abstraction. More...

Static Public Member Functions

static bool exists (const std::string &name)
 Query file presence. More...
 
static bool isDirectory (const std::string &name)
 Query directory type. More...
 
static bool isFile (const std::string &name)
 Query file type. More...
 
static bool getFileSize (const std::string &name, File::Size &size)
 Query file size. More...
 
static bool rename (const std::string &oldname, const std::string &newname)
 Rename file or directory. More...
 
static void pathnameTemp (string &name, const std::string &dir=".", const std::string &prefix="tmp", const std::string &suffix="")
 Generate temporary pathname. More...
 
static void pathnameCleanup (string &name)
 Cleanup pathname. More...
 
static void pathnameOnlyExtension (string &name)
 Remove everything except file extension. More...
 
static void pathnameStripExtension (string &name)
 Remove file extension from pathname. More...
 

Static Public Attributes

static string DIR_SEPARATOR
 separator string used in file pathnames
 
static string PATH_SEPARATOR
 separator string used in search-paths
 

Detailed Description

General file-system abstraction.

FileSystem abstracts operations on files and directories.

Member Function Documentation

◆ exists()

static bool mp4v2::platform::io::FileSystem::exists ( const std::string &  name)
static

Query file presence.

Check if name exists.

Parameters
namefilename to query. On Windows, this should be a UTF-8 encoded string. On other platforms, it should be an 8-bit encoding that is appropriate for the platform, locale, file system, etc. (prefer to use UTF-8 when possible).
Returns
true if present, false otherwise.

◆ getFileSize()

static bool mp4v2::platform::io::FileSystem::getFileSize ( const std::string &  name,
File::Size size 
)
static

Query file size.

Check if name exists and is a file.

Parameters
namefilename to query. On Windows, this should be a UTF-8 encoded string. On other platforms, it should be an 8-bit encoding that is appropriate for the platform, locale, file system, etc. (prefer to use UTF-8 when possible).
sizeoutput indicating file size in bytes.
Returns
true on failure, false on success.

◆ isDirectory()

static bool mp4v2::platform::io::FileSystem::isDirectory ( const std::string &  name)
static

Query directory type.

Check if name exists and is a directory.

Parameters
namepathname to query. On Windows, this should be a UTF-8 encoded string. On other platforms, it should be an 8-bit encoding that is appropriate for the platform, locale, file system, etc. (prefer to use UTF-8 when possible).
Returns
true if directory, false otherwise.

◆ isFile()

static bool mp4v2::platform::io::FileSystem::isFile ( const std::string &  name)
static

Query file type.

Check if name exists and is a file. On Windows, this should be a UTF-8 encoded string. On other platforms, it should be an 8-bit encoding that is appropriate for the platform, locale, file system, etc. (prefer to use UTF-8 when possible).

Parameters
namefilename to query.
Returns
true if file, false otherwise.

◆ pathnameCleanup()

static void mp4v2::platform::io::FileSystem::pathnameCleanup ( string &  name)
static

Cleanup pathname.

Redundant (repeating) directory-separators are folded into a single directory-separator.

Redundant /./ are folded into a single directory-separator.

Parameters
namepathname to modify.

◆ pathnameOnlyExtension()

static void mp4v2::platform::io::FileSystem::pathnameOnlyExtension ( string &  name)
static

Remove everything except file extension.

A pathname cleanup is always performed. See pathnameCleanup(). A file extension is considered to everything after the last '.' in the file component of a pathname. If no file extension exists then an empty-string is output.

Parameters
namepathname to modify.

◆ pathnameStripExtension()

static void mp4v2::platform::io::FileSystem::pathnameStripExtension ( string &  name)
static

Remove file extension from pathname.

A pathname cleanup is always performed. See pathnameCleanup(). A file extension is considered to everything after the last '.' in the file component of a pathname. The last '.' is also removed.

Parameters
namepathname to modify.

◆ pathnameTemp()

static void mp4v2::platform::io::FileSystem::pathnameTemp ( string &  name,
const std::string &  dir = ".",
const std::string &  prefix = "tmp",
const std::string &  suffix = "" 
)
static

Generate temporary pathname.

Parameters
nameoutput containing generated pathname.
dirrelative or absolute directory of pathname.
prefixtext prepended to base pathname.
suffixtext appended to base pathname.

◆ rename()

static bool mp4v2::platform::io::FileSystem::rename ( const std::string &  oldname,
const std::string &  newname 
)
static

Rename file or directory.

Rename oldname to newname. If newname exists, it is first removed. Both oldname and newname must be of the same type; that is, both must be either files or directories and must reside on the same filesystem.

Parameters
oldnameexisting pathname to rename. On Windows, this should be a UTF-8 encoded string. On other platforms, it should be an 8-bit encoding that is appropriate for the platform, locale, file system, etc. (prefer to use UTF-8 when possible).
newnamenew pathname. On Windows, this should be a UTF-8 encoded string. On other platforms, it should be an 8-bit encoding that is appropriate for the platform, locale, file system, etc. (prefer to use UTF-8 when possible).
Returns
true on failure, false on success.