MySQL 8.0.40
Source Code Documentation
mysql_harness::Directory Class Reference

Class representing a directory in a file system. More...

#include <filesystem.h>

Inheritance diagram for mysql_harness::Directory:
[legend]

Classes

class  DirectoryIterator
 Directory iterator for iterating over directory entries. More...
 

Public Member Functions

 Directory (const std::string &path)
 Construct a directory instance. More...
 
 Directory (const Path &path)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 Directory (const Directory &)=default
 
Directoryoperator= (const Directory &)=default
 
 ~Directory ()
 
DirectoryIterator begin ()
 Iterator to first entry. More...
 
DirectoryIterator begin () const
 
DirectoryIterator cbegin () const
 Constant iterator to first entry. More...
 
DirectoryIterator end ()
 Iterator past-the-end of entries. More...
 
DirectoryIterator end () const
 
DirectoryIterator cend () const
 Constant iterator past-the-end of entries. More...
 
bool is_empty () const
 Check if the directory is empty. More...
 
std::vector< Pathlist_recursive () const
 Recursively list all paths in a directory. More...
 
DirectoryIterator glob (const std::string &glob)
 Iterate over entries matching a glob. More...
 
- Public Member Functions inherited from mysql_harness::Path
 Path () noexcept
 
 Path (std::string path)
 Construct a path. More...
 
 Path (std::string_view path)
 
 Path (const char *path)
 
bool operator== (const Path &rhs) const
 
bool operator!= (const Path &rhs) const
 
bool operator< (const Path &rhs) const
 Path ordering operator. More...
 
FileType type (bool refresh=false) const
 Get the file type. More...
 
bool is_directory () const
 Check if the file is a directory. More...
 
bool is_regular () const
 Check if the file is a regular file. More...
 
bool is_absolute () const
 Check if the path is absolute or not. More...
 
bool exists () const
 Check if path exists. More...
 
bool is_readable () const
 
Path dirname () const
 Get the directory name of the path. More...
 
Path basename () const
 Get the basename of the path. More...
 
void append (const Path &other)
 Append a path component to the current path. More...
 
Path join (const Path &other) const
 Join two path components to form a new path. More...
 
Path real_path () const
 Returns the canonical form of the path, resolving relative paths. More...
 
const char * c_str () const
 Get a C-string representation to the path. More...
 
const std::string & str () const noexcept
 Get a string representation of the path. More...
 
bool is_set () const noexcept
 Test if path is set. More...
 
 operator bool () const noexcept
 

Additional Inherited Members

- Public Types inherited from mysql_harness::Path
enum class  FileType {
  STATUS_ERROR , EMPTY_PATH , FILE_NOT_FOUND , REGULAR_FILE ,
  DIRECTORY_FILE , SYMLINK_FILE , BLOCK_FILE , CHARACTER_FILE ,
  FIFO_FILE , SOCKET_FILE , TYPE_UNKNOWN
}
 Enum used to identify file types. More...
 
- Static Public Member Functions inherited from mysql_harness::Path
static Path make_path (const Path &directory, const std::string &basename, const std::string &extension)
 Create a path from directory, basename, and extension. More...
 
- Static Public Attributes inherited from mysql_harness::Path
static const char *const directory_separator = "/"
 Directory separator string. More...
 
static const char *const root_directory = "/"
 Root directory string. More...
 

Detailed Description

Class representing a directory in a file system.

In addition to being a refinement of Path, it also have functions that make it act like a container of paths and support iterating over the entries in a directory.

An example of how it could be used is:

for (auto&& entry: Directory(path))
std::cout << entry << std::endl;
Directory(const std::string &path)
Construct a directory instance.
Definition: filesystem.h:404
static char * path
Definition: mysqldump.cc:137
Definition: completion_hash.h:35

Constructor & Destructor Documentation

◆ Directory() [1/3]

mysql_harness::Directory::Directory ( const std::string &  path)
inline

Construct a directory instance.

Construct a directory instance in different ways depending on the version of the constructor used.

◆ Directory() [2/3]

mysql_harness::Directory::Directory ( const Path path)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Directory() [3/3]

mysql_harness::Directory::Directory ( const Directory )
default

◆ ~Directory()

mysql_harness::Directory::~Directory ( )
default

Member Function Documentation

◆ begin() [1/2]

Directory::DirectoryIterator mysql_harness::Directory::begin ( )

Iterator to first entry.

Returns
Returns an iterator pointing to the first entry.

◆ begin() [2/2]

DirectoryIterator mysql_harness::Directory::begin ( ) const
inline

◆ cbegin()

Directory::DirectoryIterator mysql_harness::Directory::cbegin ( ) const

Constant iterator to first entry.

Returns
Returns a constant iterator pointing to the first entry.

◆ cend()

Directory::DirectoryIterator mysql_harness::Directory::cend ( ) const

Constant iterator past-the-end of entries.

Returns
Returns a constant iterator pointing past-the-end of the entries.

◆ end() [1/2]

Directory::DirectoryIterator mysql_harness::Directory::end ( )

Iterator past-the-end of entries.

Returns
Returns an iterator pointing past-the-end of the entries.

◆ end() [2/2]

DirectoryIterator mysql_harness::Directory::end ( ) const
inline

◆ glob()

Directory::DirectoryIterator mysql_harness::Directory::glob ( const std::string &  glob)

Iterate over entries matching a glob.

◆ is_empty()

bool mysql_harness::Directory::is_empty ( ) const

Check if the directory is empty.

Return values
trueDirectory is empty.
falseDirectory is no empty.

◆ list_recursive()

std::vector< Path > mysql_harness::Directory::list_recursive ( ) const

Recursively list all paths in a directory.

Recursively create a list of relative paths from a directory. Path will be relative to the given directory. Empty directories are also listed.

Returns
Recursive list of paths from a directory.

◆ operator=()

Directory & mysql_harness::Directory::operator= ( const Directory )
default

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