QoreDir Class Reference

provides controlled access to the filesystem through directories More...

#include <QoreDir.h>

List of all members.

Public Member Functions

DLLEXPORT QoreDir (ExceptionSink *xsink, const QoreEncoding *cs=QCS_DEFAULT, const char *dir=0)
 creates the object and sets the default encoding
DLLEXPORT QoreDir (ExceptionSink *xsink, const QoreDir &old)
 copies the object
DLLEXPORT ~QoreDir ()
 closes the directory and frees all memory allocated to the object
DLLEXPORT int chdir (const char *dir, ExceptionSink *xsink)
 changes the directory in relation to the current
DLLEXPORT int mkdir (ExceptionSink *xsink, const char *subdir, int mode=0777) const
 creates a subdirectory of the current directory
DLLEXPORT int rmdir (const char *subdir, ExceptionSink *xsink) const
 removes a subdirectory of the current directory
DLLEXPORT int chmod (int mode, ExceptionSink *xsink) const
 changes the mode of the current directory
DLLEXPORT int chown (uid_t uid, gid_t gid, ExceptionSink *xsink) const
 changes the user and/or group owner for the current directory
DLLEXPORT int create (int mode, ExceptionSink *xsink) const
 creates the current directory, including all parent directories, if they do not exist
DLLEXPORT int checkPath () const
 returns 0 = OK (path exists), non-zero = errno returned by opendir()
DLLEXPORT QoreStringNodedirname () const
 returns the current directory name or 0 if none is set
DLLEXPORT std::string getPath (const char *sub) const
 returns a complete path with the argument appended to the current directory name
DLLEXPORT const QoreEncodinggetEncoding () const
 returns the encoding used for the filesystem
DLLEXPORT QoreFile openFile (ExceptionSink *xsink, const char *fn, int flags=O_RDONLY, int mode=0777, const QoreEncoding *cs=QCS_DEFAULT)
 returns a new file in this directory
DLLEXPORT QoreListNodelist (ExceptionSink *xsink, int stat_filter, const QoreString *regex=0, int regex_options=0) const
 returns a list of files in the current directory, taking an option regular expression filter


Detailed Description

provides controlled access to the filesystem through directories

Each QoreDir object has a default character encoding associated with it. The class is thread-safe.

See also:
QoreEncoding

Constructor & Destructor Documentation

DLLEXPORT QoreDir::QoreDir ( ExceptionSink xsink,
const QoreEncoding cs = QCS_DEFAULT,
const char *  dir = 0 
)

creates the object and sets the default encoding

Parameters:
xsink if an out of memory error occurs in the constructor
cs the encoding to use for this directory
dir the initial directory; 0 = the current directory

DLLEXPORT QoreDir::QoreDir ( ExceptionSink xsink,
const QoreDir old 
)

copies the object

Parameters:
xsink a Qore-language exception can be raised only on out of memory
Returns:
a copy of the current object


Member Function Documentation

DLLEXPORT int QoreDir::chdir ( const char *  dir,
ExceptionSink xsink 
)

changes the directory in relation to the current

Parameters:
dir the directory to change to. can include .. and .
xsink if the path is relative and no current directory is set, a qore-language exception is thrown
Returns:
0 for success

DLLEXPORT int QoreDir::mkdir ( ExceptionSink xsink,
const char *  subdir,
int  mode = 0777 
) const

creates a subdirectory of the current directory

Parameters:
xsink if an error occurs, qore-language exception information is added here
subdir the subdirectory name to create
mode the mode of the directory to create (default = 0777)
Returns:
0 = OK, -1 = an exception was raised

DLLEXPORT int QoreDir::rmdir ( const char *  subdir,
ExceptionSink xsink 
) const

removes a subdirectory of the current directory

Parameters:
subdir the subdirectory name to remove
xsink if errors occur, qore-language exception information is added here
Returns:
0 = OK, -1 = an exception was raised

DLLEXPORT int QoreDir::chmod ( int  mode,
ExceptionSink xsink 
) const

changes the mode of the current directory

Parameters:
mode the moddoe to change the directory to
xsink if errors occur, qore-language exception information is added here
Returns:
0 = OK, -1 = an exception was raised

DLLEXPORT int QoreDir::chown ( uid_t  uid,
gid_t  gid,
ExceptionSink xsink 
) const

changes the user and/or group owner for the current directory

Parameters:
uid the UID to change to (-1 = leave the same)
gid the GID to change to (-1 = leave the same)
xsink if errors occur, qore-language exception information is added here
Returns:
0 = OK, -1 = an exception was raised

DLLEXPORT int QoreDir::create ( int  mode,
ExceptionSink xsink 
) const

creates the current directory, including all parent directories, if they do not exist

Parameters:
mode the mode for any directoreis created
xsink if errors occur, qore-language exception information is added here
Returns:
the number of directories created, -1 = error

DLLEXPORT int QoreDir::checkPath (  )  const

returns 0 = OK (path exists), non-zero = errno returned by opendir()

Returns:
0 = OK (path exists), non-zero = errno returned by opendir()

DLLEXPORT QoreStringNode* QoreDir::dirname (  )  const

returns the current directory name or 0 if none is set

Returns:
the current directory name or 0 if none is set

DLLEXPORT std::string QoreDir::getPath ( const char *  sub  )  const

returns a complete path with the argument appended to the current directory name

Parameters:
sub the subdirectory name to append to the current directory name
Returns:
a complete path with the argument appended to the current directory name

DLLEXPORT const QoreEncoding* QoreDir::getEncoding (  )  const

returns the encoding used for the filesystem

Returns:
the encoding used for the filesystem

DLLEXPORT QoreFile QoreDir::openFile ( ExceptionSink xsink,
const char *  fn,
int  flags = O_RDONLY,
int  mode = 0777,
const QoreEncoding cs = QCS_DEFAULT 
)

returns a new file in this directory

Parameters:
xsink if errors occur, qore-language exception information is added here
fn the name of the file to be opened
flags the flags to use when opening the file
mode the mode mask to use when opening the file
cs the encoding to use for the file
Returns:
the File class, throws an exception on error

DLLEXPORT QoreListNode* QoreDir::list ( ExceptionSink xsink,
int  stat_filter,
const QoreString regex = 0,
int  regex_options = 0 
) const

returns a list of files in the current directory, taking an option regular expression filter

Parameters:
xsink if errors occur, qore-language exception information is added here
stat_filter set to -1 to get everything, otherwise use S_* constants from stat() to filter for particular file types
regex an optional regular expression to filter the resulting list
regex_options optional regular expression options
Returns:
a list of the results


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

Generated on Wed Sep 17 21:24:41 2008 for Qore Programming Language by  doxygen 1.5.5