lfilesystem  0.0.1
C++ filesystem library
limes::files::FilesystemEntry Class Reference

The base class for any kind of object on the filesystem. More...

#include <lfilesystem_FilesystemEntry.h>

+ Inheritance diagram for limes::files::FilesystemEntry:

Public Types

Typedefs
using PermOptions = std::filesystem::perm_options
 Options bitfield for setting permissions. More...
 
using CopyOptions = std::filesystem::copy_options
 Options bitfield for copying. More...
 
using Time = std::filesystem::file_time_type
 A time point used for filesystem time. More...
 

Public Member Functions

 FilesystemEntry (const FilesystemEntry &)=default
 
 FilesystemEntry (FilesystemEntry &&)=default
 
virtual ~FilesystemEntry ()=default
 Destructor. More...
 
bool copyFrom (const FilesystemEntry &source, CopyOptions options=CopyOptions::update_existing) const noexcept
 
bool copyFrom (const Path &source, CopyOptions options=CopyOptions::update_existing) const noexcept
 Overwriting. More...
 
FilesystemEntryoperator= (const FilesystemEntry &)=default
 
FilesystemEntryoperator= (FilesystemEntry &&)=default
 
bool revealToUserInFileBrowser () const
 Uses the system's native file browser to display this file to the user. More...
 
Constructors
 FilesystemEntry ()=default
 Creates a FilesystemEntry with an empty path. More...
 
 FilesystemEntry (const Path &pathToUse)
 Creates a FilesystemEntry referring to the specified path. More...
 
Path assignment
FilesystemEntryoperator= (const Path &newPath)
 Assigns the path this filesystem entry represents. More...
 
FilesystemEntryoperator= (const std::string_view &newPath)
 Assigns the path this filesystem entry represents. More...
 
FilesystemEntryassignPath (const Path &newPath) noexcept
 Assigns the path this filesystem entry represents. More...
 
Equality comparison
bool operator== (const FilesystemEntry &other) const noexcept
 Compares this filesystem entry's absolute path with the other one's for equality. More...
 
bool operator== (const Path &other) const noexcept
 Compares this filesystem entry's absolute path with the other one's for equality. More...
 
bool operator!= (const FilesystemEntry &other) const noexcept
 Compares this filesystem entry's absolute path with the other one's for equality. More...
 
bool operator!= (const Path &other) const noexcept
 Compares this filesystem entry's absolute path with the other one's for equality. More...
 
Lexicographic comparison
bool operator< (const FilesystemEntry &other) const noexcept
 Lexicographically compares this filesystem entry's absolute path with another path. More...
 
bool operator> (const FilesystemEntry &other) const noexcept
 Lexicographically compares this filesystem entry's absolute path with another path. More...
 
bool operator< (const Path &other) const noexcept
 Lexicographically compares this filesystem entry's absolute path with another path. More...
 
bool operator> (const Path &other) const noexcept
 Lexicographically compares this filesystem entry's absolute path with another path. More...
 
Path manipulation
FilesystemEntry operator/ (const std::string_view &subpathName) const
 Returns a new FilesystemEntry referring to a subpath of this one. More...
 
FilesystemEntryoperator/= (const std::string_view &subpathName)
 Assigns this object's path to a subpath of the current path. More...
 
FilesystemEntrychangeName (const std::string_view &newName)
 Changes the last section of the path (the filename). More...
 
bool makeAbsoluteRelativeTo (const Path &basePath) noexcept
 If the path this object holds is already absolute, this function does nothing and returns false. More...
 
bool makeAbsoluteRelativeToCWD () noexcept
 Similar to makeAbsoluteRelativeTo(), but uses the current working directory as the base path. More...
 
Path queries
Path getPath (bool makePreferred=false) const noexcept
 Returns the current path held by this object. More...
 
Path getAbsolutePath (bool makePreferred=false) const noexcept
 Returns the full, absolute path of this filesystem entry. More...
 
 operator Path () const noexcept
 Converts this filesystem entry to the path it holds. More...
 
std::string getName () const noexcept
 Returns the last section of the path (the filename). More...
 
Directory getDirectory () const
 Returns the directory containing this filesystem entry. More...
 
Directory getParentDirectory () const
 Returns the parent directory of this filesystem entry. More...
 
bool isBelow (const Directory &directory, std::size_t depthLimit=50) const
 Returns true if this filesystem entry is in a subdirectory of the given directory – ie, if that directory is a parent or grandparent of this filepath. More...
 
bool isAbsolutePath () const noexcept
 Returns true if the path this object holds is an absolute path. More...
 
bool isRelativePath () const noexcept
 Returns true if the path this object holds is a relative path. More...
 
bool isValid () const noexcept
 Returns true if this object holds a valid filesystem path. More...
 
bool isHidden () const
 Returns true if this path is a hidden file or directory. More...
 
FilesystemEntry getSibling (const std::string_view &siblingName) const
 Returns a filesystem entry with the given name in the same directory as this one. More...
 
Filesystem queries
virtual bool isFile () const noexcept
 Returns true if this filesystem entry refers to a file. More...
 
virtual bool isDirectory () const noexcept
 Returns true if this filesystem entry refers to a directory. More...
 
virtual bool isSymLink () const noexcept
 Returns true if this filesystem entry refers to a symbolic link. More...
 
bool exists () const noexcept
 Returns true if the filesystem object this object refers to exists on disk. More...
 
 operator bool () const noexcept
 Returns true if this filesystem object exists. More...
 
virtual std::uintmax_t sizeInBytes () const
 Returns the size, in bytes, of the filesystem entry referred to by this object. More...
 
Time getLastModificationTime () const noexcept
 Returns the last modification time of the filesystem entry. More...
 
std::optional< VolumegetVolume () const noexcept
 Returns a Volume object representing the logical filesystem volume that this object exists on. More...
 
Type conversion
std::optional< FilegetFileObject () const noexcept
 If this object refers to a file, constructs a File object referring to the same file. More...
 
std::optional< DirectorygetDirectoryObject () const noexcept
 If this object refers to a directory, constructs a Directory object referring to the same directory. More...
 
std::optional< SymLinkgetSymLinkObject () const noexcept
 If this object refers to a symbolic link, constructs a SymLink object referring to the same link. More...
 
Filesystem actions
virtual bool createIfDoesntExist () const noexcept
 Creates the filesystem entry this object refers to, if it doesn't already exist. More...
 
bool deleteIfExists () const noexcept
 Deletes the filesystem entry this object refers to, if it exists. More...
 
bool moveToTrash () noexcept
 Attempts to move this filesystem object to the system's trash folder. More...
 
void touch () const
 If the filesystem entry this object refers do doesn't exist, this function creates it. More...
 
bool touch_noCreate () const
 The same as touch() , except this function does not create the filesystem entry if it didn't already exist. More...
 
bool rename (const Path &newPath) noexcept
 Renames this filesystem object to a new path. More...
 
Permissions
bool setPermissions (FSPerms permissions, PermOptions options=PermOptions::replace) const noexcept
 Sets the permissions for the filesystem entry. More...
 
Permissions getPermissions () const
 Returns the current permissions of the filesystem entry this object refers to. More...
 
Creating copies
bool copyTo (const Path &dest, CopyOptions options=CopyOptions::update_existing) const noexcept
 Creates a copy of this filesystem entry at a new location on disk. More...
 
bool copyTo (const FilesystemEntry &dest, CopyOptions options=CopyOptions::update_existing) const noexcept
 Creates a copy of this filesystem entry at a new location on disk. More...
 
std::optional< FilesystemEntrycopyToDirectory (const Path &destDirectory, CopyOptions options=CopyOptions::update_existing) const noexcept
 Creates a copy of this filesystem object, with the same filename, in a different directory. More...
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, const FilesystemEntry &value)
 Writes a FilesystemEntry's path to the output stream. More...
 

Detailed Description

The base class for any kind of object on the filesystem.

This class is essentially a wrapper around std::filesystem::path , with a more object-oriented design. This class holds only the path, and so is relatively trivial to construct or copy (think of it like a string).

This class normalizes paths passed to it using the normalizePath() function.

The kinds of filesystem objects Limes defines are File, Directory, and SymLink, but custom file-like object types can be created as well. To satisfy this interface, a custom type must have and be able to logically manipulate a std::filesystem::path .

This base class contains various semantic operations on and queries of the path, some basic disk operations, and provides functions for converting any FilesystemEntry object to higher-level Directory , File , or SymLink objects.

For example:

limes::files::FilesystemEntry file { "/path/to/some/file.txt" };
assert (file.isFile());
assert (! file.isDirectory());
assert (file.isAbsolutePath());
if (file.exists())
std::cout << file.getFileObject()->loadAsString();
The base class for any kind of object on the filesystem.
See also
File, Directory, SymLink
Todo:

getNonexistentSibling()

getCreationTime(), getLastAccessTime()

tests for getModificationTime(), getCreationTime(), getLastAccessTime()

Examples
files_dir_listen.cpp.

Definition at line 79 of file lfilesystem_FilesystemEntry.h.

Member Typedef Documentation

◆ CopyOptions

using limes::files::FilesystemEntry::CopyOptions = std::filesystem::copy_options

Options bitfield for copying.

Definition at line 89 of file lfilesystem_FilesystemEntry.h.

◆ PermOptions

using limes::files::FilesystemEntry::PermOptions = std::filesystem::perm_options

Options bitfield for setting permissions.

Definition at line 86 of file lfilesystem_FilesystemEntry.h.

◆ Time

using limes::files::FilesystemEntry::Time = std::filesystem::file_time_type

A time point used for filesystem time.

Definition at line 92 of file lfilesystem_FilesystemEntry.h.

Constructor & Destructor Documentation

◆ FilesystemEntry() [1/2]

limes::files::FilesystemEntry::FilesystemEntry ( )
default

Creates a FilesystemEntry with an empty path.

After creating a FilesystemEntry with this default constructor, calling isValid() on it will return false. You can use the assignPath() function to assign this object to a path after it has been constructed.

◆ FilesystemEntry() [2/2]

limes::files::FilesystemEntry::FilesystemEntry ( const Path pathToUse)
explicit

Creates a FilesystemEntry referring to the specified path.

Parameters
pathToUseThe path to this filesystem entry. This can be an absolute or relative path, and it is not an error if the passed path doesn't actually exist on disk. The path will be normalized using the normalizePath() function.

◆ ~FilesystemEntry()

virtual limes::files::FilesystemEntry::~FilesystemEntry ( )
virtualdefault

Destructor.

Member Function Documentation

◆ assignPath()

FilesystemEntry& limes::files::FilesystemEntry::assignPath ( const Path newPath)
noexcept

Assigns the path this filesystem entry represents.

Note
This has no effect on disk contents, this only updates the semantic path this object holds. To change the path on disk, see the rename() function. The path will be normalized using the normalizePath() function.
Todo:
test coverage (for all 3)

◆ changeName()

FilesystemEntry& limes::files::FilesystemEntry::changeName ( const std::string_view &  newName)

Changes the last section of the path (the filename).

For example:

limes::files::FilesystemEntry file { "/path/to/directory/file.txt" };
file.changeName ("newName");
assert (file.getAbsolutePath() == "/path/to/directory/newName.txt");
FilesystemEntry & changeName(const std::string_view &newName)
Changes the last section of the path (the filename).
Note
This has no effect on disk contents, this only updates the semantic path this object holds. To change the path on disk, see the rename() function.

◆ copyFrom()

bool limes::files::FilesystemEntry::copyFrom ( const Path source,
CopyOptions  options = CopyOptions::update_existing 
) const
noexcept

Overwriting.

Overwrites this filesystem entry by copying from another location.

Returns
True if copying was successful.

◆ copyTo() [1/2]

bool limes::files::FilesystemEntry::copyTo ( const FilesystemEntry dest,
CopyOptions  options = CopyOptions::update_existing 
) const
noexcept

Creates a copy of this filesystem entry at a new location on disk.

Returns
True if copying was successful.

◆ copyTo() [2/2]

bool limes::files::FilesystemEntry::copyTo ( const Path dest,
CopyOptions  options = CopyOptions::update_existing 
) const
noexcept

Creates a copy of this filesystem entry at a new location on disk.

Returns
True if copying was successful.

◆ copyToDirectory()

std::optional<FilesystemEntry> limes::files::FilesystemEntry::copyToDirectory ( const Path destDirectory,
CopyOptions  options = CopyOptions::update_existing 
) const
noexcept

Creates a copy of this filesystem object, with the same filename, in a different directory.

If the destDirectory is the same directory that this object is in, this function will make no changes on disk and return a nullopt .

Returns
A new object holding the path this file was copied to, or a nullopt if copying was not successful.

◆ createIfDoesntExist()

virtual bool limes::files::FilesystemEntry::createIfDoesntExist ( ) const
virtualnoexcept

Creates the filesystem entry this object refers to, if it doesn't already exist.

Returns
True if the filesystem object needed to be created, and was successfully created. False if it already existed or if creation fails.
Todo:
test coverage for directories and symlinks

Reimplemented in limes::files::Directory.

◆ deleteIfExists()

bool limes::files::FilesystemEntry::deleteIfExists ( ) const
noexcept

Deletes the filesystem entry this object refers to, if it exists.

Returns
True if the object existed and was successfully deleted. False if it did not exist or if deletion fails.
See also
moveToTrash()

◆ exists()

bool limes::files::FilesystemEntry::exists ( ) const
noexcept

Returns true if the filesystem object this object refers to exists on disk.

See also
isValid()

◆ getAbsolutePath()

Path limes::files::FilesystemEntry::getAbsolutePath ( bool  makePreferred = false) const
noexcept

Returns the full, absolute path of this filesystem entry.

The returned path will be normalized using the normalizePath() function.

Parameters
makePreferredIf true, this converts any directory separators present in the path to the platform's preferred directory separator. See dirSeparator()
See also
getPath()
Todo:
test coverage for makePreferred=true
Examples
files_dir_listen.cpp.

◆ getDirectory()

Directory limes::files::FilesystemEntry::getDirectory ( ) const

Returns the directory containing this filesystem entry.

If this FilesystemEntry is a directory, its own path is returned; otherwise, the path of the directory containing this file is returned.

For example:

const limes::files::FilesystemEntry path1 { "path/to/a/directory" };
const limes::files::FilesystemEntry path2 { "path/to/a/file.json" };
const auto dir1 = path1.getDirectory();
const auto dir2 = path2.getDirectory();
assert (dir1.getAbsolutePath() == "path/to/a/directory");
assert (dir2.getAbsolutePath() == "path/to/a");
Directory getDirectory() const
Returns the directory containing this filesystem entry.
See also
getParentDirectory()

◆ getDirectoryObject()

std::optional<Directory> limes::files::FilesystemEntry::getDirectoryObject ( ) const
noexcept

If this object refers to a directory, constructs a Directory object referring to the same directory.

Otherwise, returns a nullopt.

See also
getFileObject(), getSymLinkObject()
Todo:
test coverage for nullopt case

◆ getFileObject()

std::optional<File> limes::files::FilesystemEntry::getFileObject ( ) const
noexcept

If this object refers to a file, constructs a File object referring to the same file.

Otherwise, returns a nullopt.

See also
getDirectoryObject(), getSymLinkObject()
Todo:
test coverage for nullopt case
Examples
files_dir_listen.cpp.

◆ getLastModificationTime()

Time limes::files::FilesystemEntry::getLastModificationTime ( ) const
noexcept

Returns the last modification time of the filesystem entry.

Todo:
test coverage

◆ getName()

std::string limes::files::FilesystemEntry::getName ( ) const
noexcept

Returns the last section of the path (the filename).

◆ getParentDirectory()

Directory limes::files::FilesystemEntry::getParentDirectory ( ) const

Returns the parent directory of this filesystem entry.

If this FilesystemEntry is a directory, this returns its parent directory; otherwise, this returns the parent directory of the directory containing this file or symlink.

For example:

const limes::files::FilesystemEntry path1 { "path/to/a/directory" };
const limes::files::FilesystemEntry path2 { "path/to/a/file.json" };
const auto dir1 = path1.getParentDirectory();
const auto dir2 = path2.getParentDirectory();
assert (dir1.getAbsolutePath() == "path/to/a");
assert (dir2.getAbsolutePath() == "path/to");
Directory getParentDirectory() const
Returns the parent directory of this filesystem entry.
See also
getDirectory()

◆ getPath()

Path limes::files::FilesystemEntry::getPath ( bool  makePreferred = false) const
noexcept

Returns the current path held by this object.

If this object was constructed with or assigned to a relative path, this function will return that relative path.

The returned path will be normalized using the normalizePath() function.

Parameters
makePreferredIf true, this converts any directory separators present in the path to the platform's preferred directory separator. See dirSeparator()
See also
getAbsolutePath()
Todo:
test coverage for makePreferred=true

◆ getPermissions()

Permissions limes::files::FilesystemEntry::getPermissions ( ) const

Returns the current permissions of the filesystem entry this object refers to.

See also
setPermissions()

◆ getSibling()

FilesystemEntry limes::files::FilesystemEntry::getSibling ( const std::string_view &  siblingName) const

Returns a filesystem entry with the given name in the same directory as this one.

◆ getSymLinkObject()

std::optional<SymLink> limes::files::FilesystemEntry::getSymLinkObject ( ) const
noexcept

If this object refers to a symbolic link, constructs a SymLink object referring to the same link.

Otherwise, returns a nullopt.

See also
getFileObject(), getDirectoryObject()
Todo:
better test coverage for function's internal branches

◆ getVolume()

std::optional<Volume> limes::files::FilesystemEntry::getVolume ( ) const
noexcept

Returns a Volume object representing the logical filesystem volume that this object exists on.

Returns a nullopt if the volume for this path cannot be computed correctly, or if this FilesystemEntry holds an invalid path.

◆ isAbsolutePath()

bool limes::files::FilesystemEntry::isAbsolutePath ( ) const
noexcept

Returns true if the path this object holds is an absolute path.

Note that this function does not always return true if isRelativePath() returns false – if isValid() returns false, then both isAbsolutePath() and isRelativePath() will always return false.

See also
isRelativePath()

◆ isBelow()

bool limes::files::FilesystemEntry::isBelow ( const Directory directory,
std::size_t  depthLimit = 50 
) const

Returns true if this filesystem entry is in a subdirectory of the given directory – ie, if that directory is a parent or grandparent of this filepath.

Parameters
directoryThe directory that may be a parent of this path.
depthLimitSpecifies the number of parent paths of this entry that will be checked for equivalence to directory . Setting this to 1 will only allow this function to return true if directory is the directory this entry is in (its direct parent); 2 would return true if directory is this path's directory or the directory's parent directory, etc.
Todo:
test coverage for false case

◆ isDirectory()

virtual bool limes::files::FilesystemEntry::isDirectory ( ) const
virtualnoexcept

Returns true if this filesystem entry refers to a directory.

See also
isFile(), isSymLink()

Reimplemented in limes::files::SymLink, limes::files::File, and limes::files::Directory.

◆ isFile()

virtual bool limes::files::FilesystemEntry::isFile ( ) const
virtualnoexcept

Returns true if this filesystem entry refers to a file.

If this path is not an existing directory or symlink, this class will assume that the path refers to a nonexistent file, because a file is assumed to be the "default" type of filesystem object.

See also
isDirectory(), isSymLink()

Reimplemented in limes::files::SymLink, limes::files::File, and limes::files::Directory.

◆ isHidden()

bool limes::files::FilesystemEntry::isHidden ( ) const

Returns true if this path is a hidden file or directory.

On Linux and iOS, this returns true if the filename begins with a dot (.) character. On Windows and MacOS, the actual OS filesystem APIs are queried.

◆ isRelativePath()

bool limes::files::FilesystemEntry::isRelativePath ( ) const
noexcept

Returns true if the path this object holds is a relative path.

Note that this function does not always return true if isAbsolutePath() returns false – if isValid() returns false, then both isAbsolutePath() and isRelativePath() will always return false.

See also
isAbsolutePath()

◆ isSymLink()

virtual bool limes::files::FilesystemEntry::isSymLink ( ) const
virtualnoexcept

Returns true if this filesystem entry refers to a symbolic link.

See also
isFile(), isDirectory()

Reimplemented in limes::files::SymLink, limes::files::File, and limes::files::Directory.

◆ isValid()

bool limes::files::FilesystemEntry::isValid ( ) const
noexcept

Returns true if this object holds a valid filesystem path.

See also
exists(), isValidPath()

◆ makeAbsoluteRelativeTo()

bool limes::files::FilesystemEntry::makeAbsoluteRelativeTo ( const Path basePath)
noexcept

If the path this object holds is already absolute, this function does nothing and returns false.

Otherwise, this function assigns the path to basePath/currentPath (prepending the basePath to the previous path this object was already assigned to).

Note
If basePath is not an absolute path, this function always returns false and does not alter the path held by this object.

For example:

limes::files::FilesystemEntry path1 { "a/relative/path" };
limes::files::FilesystemEntry path2 { "/an/absolute/path" };
const limes::files::Path basePath { "/some/other/directory" };
path1.makeAbsoluteRelativeTo (basePath);
path2.makeAbsoluteRelativeTo (basePath);
assert (path1.getAbsolutePath() == "some/other/directory/a/relative/path");
assert (path2.getAbsolutePath() == "/an/absolute/path");
bool makeAbsoluteRelativeTo(const Path &basePath) noexcept
If the path this object holds is already absolute, this function does nothing and returns false.
std::filesystem::path Path
Convenience typedef for filesystem paths.
Returns
True if this function changed the path this object refers to.
See also
makeAbsoluteRelativeToCWD()
Todo:
test coverage – should return false if basePath is not absolute

◆ makeAbsoluteRelativeToCWD()

bool limes::files::FilesystemEntry::makeAbsoluteRelativeToCWD ( )
noexcept

Similar to makeAbsoluteRelativeTo(), but uses the current working directory as the base path.

Returns
True if this function changed the path this object refers to.
See also
makeAbsoluteRelativeTo(), dirs::cwd()

◆ moveToTrash()

bool limes::files::FilesystemEntry::moveToTrash ( )
noexcept

Attempts to move this filesystem object to the system's trash folder.

Returns
True if the object existed and moving to the trash folder was successful.
See also
deleteIfExists()

◆ operator bool()

limes::files::FilesystemEntry::operator bool ( ) const
noexcept

Returns true if this filesystem object exists.

See also
exists()
Todo:
test coverage

◆ operator Path()

limes::files::FilesystemEntry::operator Path ( ) const
noexcept

Converts this filesystem entry to the path it holds.

See also
getPath()

◆ operator!=() [1/2]

bool limes::files::FilesystemEntry::operator!= ( const FilesystemEntry other) const
noexcept

Compares this filesystem entry's absolute path with the other one's for equality.

Note that this is a path comparison, and does not compare the contents of files. This comparison attempts to respect the case sensitivity of the underlying filesystem.

Todo:
test coverage for overloads accepting a Path argument

◆ operator!=() [2/2]

bool limes::files::FilesystemEntry::operator!= ( const Path other) const
noexcept

Compares this filesystem entry's absolute path with the other one's for equality.

Note that this is a path comparison, and does not compare the contents of files. This comparison attempts to respect the case sensitivity of the underlying filesystem.

Todo:
test coverage for overloads accepting a Path argument

◆ operator/()

FilesystemEntry limes::files::FilesystemEntry::operator/ ( const std::string_view &  subpathName) const

Returns a new FilesystemEntry referring to a subpath of this one.

For example:

const limes::files::FilesystemEntry dir { "/path/to/directory" };
const auto child = dir / "file.txt";
assert (child.getAbsolutePath() == "/path/to/directory/file.txt");
Note
This has no effect on disk contents, this only updates the semantic path this object holds. To change the path on disk, see the rename() function.
Todo:
test coverage

◆ operator/=()

FilesystemEntry& limes::files::FilesystemEntry::operator/= ( const std::string_view &  subpathName)

Assigns this object's path to a subpath of the current path.

For example:

limes::files::FilesystemEntry dir { "/path/to/directory" };
dir /= "file.txt";
assert (dir.getAbsolutePath() == "/path/to/directory/file.txt");
Path getAbsolutePath(bool makePreferred=false) const noexcept
Returns the full, absolute path of this filesystem entry.
Note
This has no effect on disk contents, this only updates the semantic path this object holds. To change the path on disk, see the rename() function.
Todo:
test coverage

◆ operator<() [1/2]

bool limes::files::FilesystemEntry::operator< ( const FilesystemEntry other) const
noexcept

Lexicographically compares this filesystem entry's absolute path with another path.

Directories will always be sorted before other types of filesystem objects; other than this, std::filesystem::path 's built-in lexicographic sort is used.

Todo:
test coverage

◆ operator<() [2/2]

bool limes::files::FilesystemEntry::operator< ( const Path other) const
noexcept

Lexicographically compares this filesystem entry's absolute path with another path.

Directories will always be sorted before other types of filesystem objects; other than this, std::filesystem::path 's built-in lexicographic sort is used.

Todo:
test coverage

◆ operator=() [1/2]

FilesystemEntry& limes::files::FilesystemEntry::operator= ( const Path newPath)

Assigns the path this filesystem entry represents.

Note
This has no effect on disk contents, this only updates the semantic path this object holds. To change the path on disk, see the rename() function. The path will be normalized using the normalizePath() function.
Todo:
test coverage (for all 3)

◆ operator=() [2/2]

FilesystemEntry& limes::files::FilesystemEntry::operator= ( const std::string_view &  newPath)

Assigns the path this filesystem entry represents.

Note
This has no effect on disk contents, this only updates the semantic path this object holds. To change the path on disk, see the rename() function. The path will be normalized using the normalizePath() function.
Todo:
test coverage (for all 3)

◆ operator==() [1/2]

bool limes::files::FilesystemEntry::operator== ( const FilesystemEntry other) const
noexcept

Compares this filesystem entry's absolute path with the other one's for equality.

Note that this is a path comparison, and does not compare the contents of files. This comparison attempts to respect the case sensitivity of the underlying filesystem.

Todo:
test coverage for overloads accepting a Path argument

◆ operator==() [2/2]

bool limes::files::FilesystemEntry::operator== ( const Path other) const
noexcept

Compares this filesystem entry's absolute path with the other one's for equality.

Note that this is a path comparison, and does not compare the contents of files. This comparison attempts to respect the case sensitivity of the underlying filesystem.

Todo:
test coverage for overloads accepting a Path argument

◆ operator>() [1/2]

bool limes::files::FilesystemEntry::operator> ( const FilesystemEntry other) const
noexcept

Lexicographically compares this filesystem entry's absolute path with another path.

Directories will always be sorted before other types of filesystem objects; other than this, std::filesystem::path 's built-in lexicographic sort is used.

Todo:
test coverage

◆ operator>() [2/2]

bool limes::files::FilesystemEntry::operator> ( const Path other) const
noexcept

Lexicographically compares this filesystem entry's absolute path with another path.

Directories will always be sorted before other types of filesystem objects; other than this, std::filesystem::path 's built-in lexicographic sort is used.

Todo:
test coverage

◆ rename()

bool limes::files::FilesystemEntry::rename ( const Path newPath)
noexcept

Renames this filesystem object to a new path.

The filesystem object is moved on disk, and this object stores the new path.

To manipulate the path this object holds without writing the changes to disk, see assignPath() , changeName() , etc.

Returns
True if renaming was successful.

◆ revealToUserInFileBrowser()

bool limes::files::FilesystemEntry::revealToUserInFileBrowser ( ) const

Uses the system's native file browser to display this file to the user.

This will open a Finder window on Mac, a file explorer window on Windows, etc.

This function returns immediately.

◆ setPermissions()

bool limes::files::FilesystemEntry::setPermissions ( FSPerms  permissions,
PermOptions  options = PermOptions::replace 
) const
noexcept

Sets the permissions for the filesystem entry.

Returns
True if setting permissions was successful
See also
getPermissions()

◆ sizeInBytes()

virtual std::uintmax_t limes::files::FilesystemEntry::sizeInBytes ( ) const
virtual

Returns the size, in bytes, of the filesystem entry referred to by this object.

If the filesystem entry doesn't exist, this will return 0. For directories, this returns the cumulative size of all the directory's contents, recursively. For symbolic links, this returns the size of the link itself, not what it points to.

Reimplemented in limes::files::Directory.

◆ touch()

void limes::files::FilesystemEntry::touch ( ) const

If the filesystem entry this object refers do doesn't exist, this function creates it.

If it did already exist, this function updates its modification time to the current system time.

See also
touch_noCreate()
Todo:
test coverage

◆ touch_noCreate()

bool limes::files::FilesystemEntry::touch_noCreate ( ) const

The same as touch() , except this function does not create the filesystem entry if it didn't already exist.

Returns
True if the filesystem entry existed when this function was called.
See also
touch()

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