Public Member Functions | Static Public Member Functions

base::Dir Class Reference

Directory functions (create, delete, read). More...

#include <libppbase/base/Dir.h>

List of all members.

Public Member Functions

 Dir ()
 Constructor.
 ~Dir ()
 Destructor.
void close ()
 Closes a directory.
Stat lstat (const String &name)
 Lstats a file.
void open (const String &path)
 Opens a directory.
bool read (String &rstr, bool special=true)
 Reads the next entry from a directory.
Stat stat (const String &name)
 Stats a file.

Static Public Member Functions

static void copy (const String &srcpath, const String &dstpath, bool move=false)
 Copies a directory recursively.
static bool exists (const String &path)
 Checks if a file or directory exists.
static String getCWD ()
 Gets the current working directory.
static bool isDirectory (const String &path)
 Checks if an existing file or directory is a directory.
static void mkdir (const String &path, bool parent=false, unsigned mode=0777, unsigned uid=(unsigned)-1, unsigned gid=(unsigned)-1)
 Creates a new directory.
static void rmdir (const String &path, bool force=false, bool recursive=false)
 Removes a directory.

Detailed Description

Directory functions (create, delete, read).

Author:
Christoph Schwarz
Version:
$Id: Dir.h 21 2010-09-05 04:18:17Z cschwarz1 $

Member Function Documentation

static void base::Dir::copy ( const String srcpath,
const String dstpath,
bool  move = false 
) [static]

Copies a directory recursively.

Parameters:
srcpath the directory to copy
dstpath the target directory
move flag: delete source directory
Exceptions:
IOException on error
static bool base::Dir::exists ( const String path  )  [static]

Checks if a file or directory exists.

Parameters:
path the file or directory name
Returns:
true if the file or directory exists
Exceptions:
IOException on error
static String base::Dir::getCWD (  )  [static]

Gets the current working directory.

Returns:
the current working directory
Exceptions:
IOException on error
static bool base::Dir::isDirectory ( const String path  )  [static]

Checks if an existing file or directory is a directory.

Parameters:
path the file or directory name (entity)
Returns:
true if the entity is a directory
false if the entity is not a directory
Exceptions:
IOException if the entity does not exist or other errors occured
Stat base::Dir::lstat ( const String name  ) 

Lstats a file.

Parameters:
name file name to lstat in the currenly opened directory
Returns:
the stat information
Exceptions:
IOException on error
static void base::Dir::mkdir ( const String path,
bool  parent = false,
unsigned  mode = 0777,
unsigned  uid = (unsigned)-1,
unsigned  gid = (unsigned)-1 
) [static]

Creates a new directory.

Parameters:
path the full path
parent flag: create parent directories if required
mode access mode of the new directories
uid owner (user id) of the new directories, (uid_t)-1 = current user
gid owner (group id) of the new directories, (gid_t)-1 = current group
Exceptions:
IOException on error
void base::Dir::open ( const String path  ) 

Opens a directory.

Parameters:
path directory name
Exceptions:
IOException on error
bool base::Dir::read ( String rstr,
bool  special = true 
)

Reads the next entry from a directory.

Parameters:
rstr returns the next directory entry
special pass true to return the entries "." and ".."
Returns:
true if an entry was read, false if there are no more entries
Exceptions:
IOException on error
static void base::Dir::rmdir ( const String path,
bool  force = false,
bool  recursive = false 
) [static]

Removes a directory.

Parameters:
path the full path name of the directory to remove
force flag: ignore "file not found" errors
recursive flag: remove all subfiles and subdirectories recursively
Exceptions:
IOException on error
Stat base::Dir::stat ( const String name  ) 

Stats a file.

Parameters:
name file name to stat in the currenly opened directory
Returns:
the stat information
Exceptions:
IOException on error

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