![]() |
Qore Programming Language 2.2.0
|
provides controlled access to the filesystem through directories More...
#include <QoreDir.h>
Inherited by Dir.
Public Member Methods | |
| DLLEXPORT | QoreDir (ExceptionSink *xsink, const QoreDir &old) |
| copies the object | |
| DLLEXPORT | QoreDir (ExceptionSink *xsink, const QoreEncoding *cs=QCS_DEFAULT, const char *dir=nullptr) |
| creates the object and sets the default encoding | |
| DLLEXPORT | ~QoreDir () |
| closes the directory and frees all memory allocated to the object | |
| DLLEXPORT int | chdir (const char *dir) |
| changes the directory in relation to the current | |
| DLLEXPORT int | chdir (const char *dir, ExceptionSink *xsink) |
| changes the directory in relation to the current | |
| DLLEXPORT int | checkPath () const |
| returns 0 = OK (path exists), non-zero = errno returned by opendir() | |
| DLLEXPORT int | chmod (int mode, ExceptionSink *xsink) const |
| changes the mode of the current directory | |
| DLLEXPORT int | create (int mode) const |
| creates the current directory, including all parent directories, if they do not exist | |
| DLLEXPORT int | create (int mode, ExceptionSink *xsink) const |
| creates the current directory, including all parent directories, if they do not exist | |
| DLLEXPORT QoreStringNode * | dirname () const |
| returns the current directory name or 0 if none is set | |
| DLLEXPORT const QoreEncoding * | getEncoding () const |
| returns the encoding used for the filesystem | |
| DLLEXPORT std::string | getPath (const char *sub) const |
| returns a complete path with the argument appended to the current directory name | |
| DLLEXPORT QoreHashNode * | hstat (ExceptionSink *xsink) const |
| returns a QoreHashNode with directory status information | |
| DLLEXPORT QoreListNode * | list (ExceptionSink *xsink, int stat_filter, const QoreString *regex=nullptr, int regex_options=0, bool full=false) const |
| returns a list of files in the current directory, taking an option regular expression filter | |
| DLLEXPORT int | mkdir (ExceptionSink *xsink, const char *subdir, int mode=0777) const |
| creates a subdirectory of the current directory | |
| 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 int | rmdir (const char *subdir, ExceptionSink *xsink) const |
| removes a subdirectory of the current directory | |
| DLLEXPORT QoreListNode * | stat (ExceptionSink *xsink) const |
| returns a QoreListNode with directory status information | |
| DLLEXPORT QoreHashNode * | statvfs (ExceptionSink *xsink) const |
| returns a QoreHashNode with filesystem status information | |
Static Public Member Methods | |
| static DLLEXPORT bool | file_exists (const QoreString &filePath) |
| checks whether file exists | |
| static DLLEXPORT bool | folder_exists (const QoreString &folderPath, ExceptionSink &xsink, const QoreEncoding *cs=QCS_DEFAULT) |
| checks whether folder exists | |
| static DLLEXPORT std::string | get_file_content (const QoreString &fullPath) |
| reads file content | |
| static DLLEXPORT QoreListNode * | get_files (const QoreString &path, ExceptionSink &xsink, QoreString *regex=nullptr, const QoreEncoding *cs=QCS_DEFAULT) |
| look up files | |
provides controlled access to the filesystem through directories
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 = nullptr |
||
| ) |
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 |
| old | the old object to copy |
| DLLEXPORT int QoreDir::chdir | ( | const char * | dir | ) |
changes the directory in relation to the current
| dir | the directory to change to. can include .. and . |
| 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::checkPath | ( | ) | const |
returns 0 = OK (path exists), non-zero = errno returned by opendir()
| 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::create | ( | int | mode | ) | const |
creates the current directory, including all parent directories, if they do not exist
| mode | the mode for any directoreis created |
| 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 QoreStringNode * QoreDir::dirname | ( | ) | const |
returns the current directory name or 0 if none is set
|
static |
checks whether file exists
| filePath | file path |
|
static |
checks whether folder exists
| folderPath | folder path |
| xsink | a Qore-language exception can be raised only on out of memory |
| cs | the encoding to use for this directory return 0 = OK (folder exists) non-zero = errno returned by opendir() |
|
static |
reads file content
| fullPath | file name |
|
static |
look up files
| path | path where files should be looked up |
| xsink | a Qore-language exception can be raised only on out of memory |
| regex | filter |
| cs | the encoding to use for this directory |
| DLLEXPORT const QoreEncoding * QoreDir::getEncoding | ( | ) | const |
returns the encoding used for the filesystem
| 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 QoreHashNode * QoreDir::hstat | ( | ExceptionSink * | xsink | ) | const |
returns a QoreHashNode with directory status information
| xsink | if an error occurs, the Qore-language exception info will be added here |
| DLLEXPORT QoreListNode * QoreDir::list | ( | ExceptionSink * | xsink, |
| int | stat_filter, | ||
| const QoreString * | regex = nullptr, |
||
| int | regex_options = 0, |
||
| bool | full = false |
||
| ) | 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 |
| full | if false a list of file name is returned, if true then a list of hashes corresponding to the stat() information is returned |
| 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 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 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 QoreListNode * QoreDir::stat | ( | ExceptionSink * | xsink | ) | const |
returns a QoreListNode with directory status information
| xsink | if an error occurs, the Qore-language exception info will be added here |
| DLLEXPORT QoreHashNode * QoreDir::statvfs | ( | ExceptionSink * | xsink | ) | const |
returns a QoreHashNode with filesystem status information
| xsink | if an error occurs, the Qore-language exception info will be added here |