libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
FileInfo Class Reference

Provides information about a file system entry. More...

#include <fileinfo.h>

Public Types

using Status = std::filesystem::file_status
 File status type from the standard filesystem library.
 

Public Member Functions

 FileInfo (const String &filePath)
 Constructs a FileInfo for the given file path.
 
 FileInfo (const char *filePath)
 Constructs a FileInfo from a C string.
 
 FileInfo (const FilePath &fp)
 Constructs a FileInfo from a FilePath.
 
FilePath filePath () const
 Returns the path as a FilePath.
 
bool exists () const
 Returns true if the file or directory exists.
 
String fileName () const
 Returns the filename component of the path (including extension).
 
String baseName () const
 Returns the filename without its extension.
 
String suffix () const
 Returns the file extension without the leading dot.
 
String absolutePath () const
 Returns the absolute path of the parent directory.
 
String absoluteFilePath () const
 Returns the absolute path to the file, including the filename.
 
bool isFile () const
 Returns true if the path refers to a regular file.
 
bool isDirectory () const
 Returns true if the path refers to a directory.
 
void updateStatus (bool force=false) const
 Updates the cached file status.
 
Status status (bool forceUpdate=false) const
 Returns the file status, updating the cache if needed.
 
std::uintmax_t size () const
 Returns the file size in bytes.
 
bool isReadable () const
 Returns true if the file is readable by the owner.
 
bool isWritable () const
 Returns true if the file is writable by the owner.
 
bool isExecutable () const
 Returns true if the file is executable by the owner.
 

Detailed Description

Provides information about a file system entry.

Wraps std::filesystem to query file metadata such as existence, type, size, permissions, and path components. The file status is lazily

Example
FileInfo info("/path/to/video.mxf");
bool exists = info.exists();
size_t bytes = info.size();
String name = info.fileName(); // "video.mxf"
String ext = info.extension(); // "mxf"
Provides information about a file system entry.
Definition fileinfo.h:35
bool exists() const
Returns true if the file or directory exists.
Definition fileinfo.h:76
Dynamic array container wrapping std::vector.
Definition list.h:40
size_t size() const noexcept
Returns the number of elements in the list.
Definition list.h:301
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
cached and can be force-refreshed.

Constructor & Destructor Documentation

◆ FileInfo() [1/3]

FileInfo::FileInfo ( const String filePath)
inline

Constructs a FileInfo for the given file path.

Parameters
filePathThe path to the file or directory.

◆ FileInfo() [2/3]

FileInfo::FileInfo ( const char filePath)
inline

Constructs a FileInfo from a C string.

Parameters
filePathThe path string.

◆ FileInfo() [3/3]

FileInfo::FileInfo ( const FilePath fp)
inline

Constructs a FileInfo from a FilePath.

Parameters
fpThe file path.

Member Function Documentation

◆ absoluteFilePath()

String FileInfo::absoluteFilePath ( ) const
inline

Returns the absolute path to the file, including the filename.

Returns
The fully resolved absolute file path as a String.

◆ absolutePath()

String FileInfo::absolutePath ( ) const
inline

Returns the absolute path of the parent directory.

Returns
The parent directory path as a String.

◆ baseName()

String FileInfo::baseName ( ) const
inline

Returns the filename without its extension.

Returns
The base name (stem) as a String.

◆ exists()

bool FileInfo::exists ( ) const
inline

Returns true if the file or directory exists.

Returns
true if the path refers to an existing file system entry.

◆ fileName()

String FileInfo::fileName ( ) const
inline

Returns the filename component of the path (including extension).

Returns
The filename as a String.

◆ filePath()

FilePath FileInfo::filePath ( ) const
inline

Returns the path as a FilePath.

Returns
The file path.

◆ isDirectory()

bool FileInfo::isDirectory ( ) const
inline

Returns true if the path refers to a directory.

Returns
true if the entry is a directory.

◆ isExecutable()

bool FileInfo::isExecutable ( ) const
inline

Returns true if the file is executable by the owner.

Returns
true if the owner-exec permission is set.

◆ isFile()

bool FileInfo::isFile ( ) const
inline

Returns true if the path refers to a regular file.

Returns
true if the entry is a regular file.

◆ isReadable()

bool FileInfo::isReadable ( ) const
inline

Returns true if the file is readable by the owner.

Returns
true if the owner-read permission is set.

◆ isWritable()

bool FileInfo::isWritable ( ) const
inline

Returns true if the file is writable by the owner.

Returns
true if the owner-write permission is set.

◆ size()

std::uintmax_t FileInfo::size ( ) const
inline

Returns the file size in bytes.

Returns
The size of the file, or 0 if the path is not a regular file.

◆ status()

Status FileInfo::status ( bool  forceUpdate = false) const
inline

Returns the file status, updating the cache if needed.

Parameters
forceUpdateIf true, forces a refresh of the cached status.
Returns
The file status.

◆ suffix()

String FileInfo::suffix ( ) const
inline

Returns the file extension without the leading dot.

Returns
The file suffix as a String (e.g. "png", "wav").

◆ updateStatus()

void FileInfo::updateStatus ( bool  force = false) const
inline

Updates the cached file status.

Parameters
forceIf true, refreshes the status even if already cached.

The documentation for this class was generated from the following file: