CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
Dir Class Referencefinal

File system directories More...

#include <cc/Dir>

Inheritance diagram for Dir:

Public Types

using Item = String
 Item type.
 

Public Member Functions

 Dir ()=default
 Create a null directory.
 
 Dir (const String &path)
 Open directory at path.
 
bool tryOpen (const String &path, Out< Dir > dir)
 Try to open directory at path.
 
String path () const
 Directory path used to open this directory.
 
bool read (Out< String > name)
 Read the next directory entry.
 
SourceIterator< Dirbegin ()
 Iteration start.
 
SourceIterator< Dirend ()
 Iteration end.
 
- Public Member Functions inherited from Object
 Object ()=default
 Create a null object.
 
 operator bool () const
 Check if this is a non-null object.
 
bool isNull () const
 Check if this is a null object.
 
template<class T >
bool is () const
 Check if this object is of type T.
 
template<class T >
as () const
 Cast this object to type T.
 
bool isWeak () const
 Check if the underlying object reference is weak.
 
bool operator== (const Object &other) const
 Equality operator.
 
std::strong_ordering operator<=> (const Object &other) const
 Ordering operator.
 
long useCount () const
 Reference count.
 

Static Public Member Functions

static bool access (const String &path, FileAccess mode)
 Check if directory under path is accessible with mode.
 
static bool exists (const String &path)
 Check if directory exists under path.
 
static void create (const String &path, FileMode mode=FileMode::DirDefault)
 Create a new directory under path with initial permissions mode.
 
static void establish (const String &path, FileMode mode=FileMode::DirDefault)
 Establish a new directory path.
 
static String createUnique (const String &path, FileMode mode=FileMode::DirDefault, char placeHolder='#')
 Create a uniquely named directory.
 
static String createTemp (FileMode mode=FileMode::DirDefault)
 Create a temporary directory.
 
static void remove (const String &path)
 Remove directory under path.
 
static void deplete (const String &path)
 Recursively remove all files and directories within path.
 

Additional Inherited Members

- Protected Member Functions inherited from Object
template<class T >
weak () const
 
template<class T >
void initOnce ()
 Create the object state when called the first time.
 
template<class T >
void initOncePerThread ()
 Create a distinct object state for each thread when called the first time in that thread.
 
 Object (State *newState)
 Initialize object with newState.
 
 Object (State *state, Alias)
 
 Object (State *state, Weak)
 
Objectoperator= (std::nullptr_t)
 
- Static Protected Member Functions inherited from Object
template<class T >
static T alias (const State *state)
 Create an alias object for the given state.
 
template<class T >
static T weak (const State *state)
 
- Protected Attributes inherited from Object
Handle< Stateme
 Internal object state
 

Detailed Description

File system directories

See also
DirWalk

Member Typedef Documentation

◆ Item

using Item = String

Item type.

Constructor & Destructor Documentation

◆ Dir() [1/2]

Dir ( )
default

Create a null directory.

◆ Dir() [2/2]

Dir ( const String & path)
explicit

Open directory at path.

Exceptions
SystemResourceError
See also
tryOpen()

Member Function Documentation

◆ access()

bool access ( const String & path,
FileAccess mode )
static

Check if directory under path is accessible with mode.

◆ exists()

bool exists ( const String & path)
static

Check if directory exists under path.

◆ create()

void create ( const String & path,
FileMode mode = FileMode::DirDefault )
static

Create a new directory under path with initial permissions mode.

◆ establish()

void establish ( const String & path,
FileMode mode = FileMode::DirDefault )
static

Establish a new directory path.

Parameters
pathDirectory path to establish
modeInitial permissions

◆ createUnique()

String createUnique ( const String & path,
FileMode mode = FileMode::DirDefault,
char placeHolder = '#' )
static

Create a uniquely named directory.

Parameters
pathDirectory path pattern
modeInitial permissions
placeHolderPlace holder character in path to be replaced with random characters
Returns
Path to the newly created directory

◆ createTemp()

String createTemp ( FileMode mode = FileMode::DirDefault)
static

Create a temporary directory.

Parameters
modeInitial permissions
Returns
Path to the newly created directory

◆ remove()

void remove ( const String & path)
static

Remove directory under path.

◆ deplete()

void deplete ( const String & path)
static

Recursively remove all files and directories within path.

◆ tryOpen()

bool tryOpen ( const String & path,
Out< Dir > dir )

Try to open directory at path.

Parameters
pathFilesystem path
dirReturns the directory object if operation was successful
Returns
True if successful

◆ path()

String path ( ) const

Directory path used to open this directory.

◆ read()

bool read ( Out< String > name)

Read the next directory entry.

Parameters
nameReturns the name of next entry
Returns
False if no more entries, else true

◆ begin()

SourceIterator< Dir > begin ( )

Iteration start.

◆ end()

SourceIterator< Dir > end ( )

Iteration end.