#include <QoreDir.h>
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 QoreStringNode * | dirname () 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 QoreEncoding * | getEncoding () 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 QoreListNode * | 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 |
Each QoreDir object has a default character encoding associated with it. The class is thread-safe.
DLLEXPORT QoreDir::QoreDir | ( | ExceptionSink * | xsink, | |
const QoreEncoding * | cs = QCS_DEFAULT , |
|||
const char * | dir = 0 | |||
) |
creates the object and sets the default encoding
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
xsink | a Qore-language exception can be raised only on out of memory |
DLLEXPORT int QoreDir::chdir | ( | const char * | dir, | |
ExceptionSink * | xsink | |||
) |
changes the directory in relation to the current
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 |
DLLEXPORT int QoreDir::mkdir | ( | ExceptionSink * | xsink, | |
const char * | subdir, | |||
int | mode = 0777 | |||
) | const |
creates a subdirectory of the current directory
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) |
DLLEXPORT int QoreDir::rmdir | ( | const char * | subdir, | |
ExceptionSink * | xsink | |||
) | const |
removes a subdirectory of the current directory
subdir | the subdirectory name to remove | |
xsink | if errors occur, qore-language exception information is added here |
DLLEXPORT int QoreDir::chmod | ( | int | mode, | |
ExceptionSink * | xsink | |||
) | const |
changes the mode of the current directory
mode | the moddoe to change the directory to | |
xsink | if errors occur, qore-language exception information is added here |
DLLEXPORT int QoreDir::chown | ( | uid_t | uid, | |
gid_t | gid, | |||
ExceptionSink * | xsink | |||
) | const |
changes the user and/or group owner for the current directory
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 |
DLLEXPORT int QoreDir::create | ( | int | mode, | |
ExceptionSink * | xsink | |||
) | const |
creates the current directory, including all parent directories, if they do not exist
mode | the mode for any directoreis created | |
xsink | if errors occur, qore-language exception information is added here |
DLLEXPORT int QoreDir::checkPath | ( | ) | const |
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
DLLEXPORT std::string QoreDir::getPath | ( | const char * | sub | ) | const |
returns a complete path with the argument appended to the current directory name
sub | the subdirectory name to append to the current directory name |
DLLEXPORT const QoreEncoding* QoreDir::getEncoding | ( | ) | const |
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
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 |
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
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 |