rcolyer.net
RC Lib  Version 202403231100
Static Public Member Functions | Static Public Attributes | List of all members
RC::File Class Reference

A class with static methods for file and directory info and manipulation. More...

#include <File.h>

Static Public Member Functions

static size_t Size (const RStr &pathname)
 Returns the file size of pathname, or 0 if the file does not exist.
 
static bool Exists (const RStr &pathname)
 Returns true if the file pathname exists.
 
static bool Delete (const RStr &pathname, bool quiet_fail=true)
 Deletes the file pathname, returning true if it succeeded. More...
 
static void Copy (const RStr &srcfile, const RStr &destfile, bool overwrite=true)
 Copies the contents of srcfile to destfile. It will overwrite an existing file only if overwrite is true. More...
 
static void Move (const RStr &srcfile, const RStr &destfile, bool overwrite=true)
 Moves srcfile to destfile by copying the contents and then deleting srcfile. More...
 
static bool MakeDir (const RStr &dirname, bool return_true_if_exists=true)
 Makes a new directory dirname. More...
 
static RStr CurrentDir ()
 Returns the current working directory.
 
static Data1D< RStrDirList (const RStr &path, bool qualified=false)
 Returns a list of entries in the directory path. More...
 
static RStr Dirname (const RStr &filename)
 Extracts the directory portion of filename, or the current directory if filename has no directory.
 
static RStr Basename (const RStr &filename)
 Extracts the basename portion of filename, which excludes the directory.
 
static RStr FullPath (const RStr &path, const RStr &filename)
 Merges path and filename into a path with a divider inserted if needed.
 
static RStr Extension (const RStr &filename)
 Extracts the filename's extension.
 
static RStr NoExtension (const RStr &filename)
 Extracts the filename without the extension.
 

Static Public Attributes

static const char divider = '\\'
 The OS-specific divider between directories in a pathname.
 

Detailed Description

A class with static methods for file and directory info and manipulation.

Member Function Documentation

◆ Copy()

static void RC::File::Copy ( const RStr srcfile,
const RStr destfile,
bool  overwrite = true 
)
inlinestatic

Copies the contents of srcfile to destfile. It will overwrite an existing file only if overwrite is true.

Throws ErrorMsgFile if an error occurs.

◆ Delete()

static bool RC::File::Delete ( const RStr pathname,
bool  quiet_fail = true 
)
inlinestatic

Deletes the file pathname, returning true if it succeeded.

If quiet_fail is false, an exception is thrown upon failure.

◆ DirList()

static Data1D<RStr> RC::File::DirList ( const RStr path,
bool  qualified = false 
)
inlinestatic

Returns a list of entries in the directory path.

If qualified is true, the returned entries are fully qualified pathnames. Throws ErrorMsgFile if the directory cannot be read.

◆ MakeDir()

static bool RC::File::MakeDir ( const RStr dirname,
bool  return_true_if_exists = true 
)
inlinestatic

Makes a new directory dirname.

Returns
True if it succeeded. If return_true_if_exists is true, success is if the directory exists upon return. If it's false, success is if the directory was newly created.

◆ Move()

static void RC::File::Move ( const RStr srcfile,
const RStr destfile,
bool  overwrite = true 
)
inlinestatic

Moves srcfile to destfile by copying the contents and then deleting srcfile.

Note: This first attempts an efficient rename, but if that fails it falls back to a copy/delete operation. ErrorMsgFile is thrown if the move fails.


The documentation for this class was generated from the following file:
email address
— (c) 2015