#include <QDir.h>
This class permits you to enumerate the contents of a directory in a very flexible fashion. It works in tandem with FX::QFileInfo to provide the ultimate in both directory enumeration and comparing before & after snapshots of directory contents.
You should (like QDir) try to avoid fancy filtering as it's slow - often getting the full list and copying the items you want into a new list based upon a speculative retrieval of QFileInfo's can be faster than running a regular expression match on a subset filter though care has been taken to avoid quadratic behaviour (unlike Qt, which goes real slow on large directories). In particular, setting FilterSpec or SortSpec options which require fetching a QFileInfo for each item can be particularly slow. Note that all expression matches are case insensitive - this can cause too much data to be returned on POSIX, but also means consistent behaviour between Windows and POSIX.
QDir like QDir performs a certain amount of caching - the list of names are cached. If a list of FX::QFileInfo's is requested, the cached list of names are used to generate the list of FX::QFileInfo's - which may mean an incomplete listing. If the directory enumerated has vanished altogether, then a null pointer is returned. The static method extractChanges() is additional functionality over Qt.
Note that as with all TnFOX functionality, if something fails it throws an exception. Thus many of the boolean returns are always true.
Definition at line 76 of file QDir.h.
Public Types | |
Dirs | |
Files | |
NoSymLinks | |
All | |
TypeMask | |
Readable | |
Writeable | |
Writable | |
Executable | |
RWEMask | |
Hidden | |
AccessMask | |
DefaultFilter | |
Name | |
Time | |
Size | |
Unsorted | |
SortByMask | |
DirsFirst | |
Reversed | |
IgnoreCase | |
DefaultSort | |
enum | FilterSpec { Dirs, Files, NoSymLinks, All, TypeMask, Readable, Writeable, Writable, Executable, RWEMask, Hidden, AccessMask, DefaultFilter } |
enum | SortSpec { Name, Time, Size, Unsorted, SortByMask, DirsFirst, Reversed, IgnoreCase, DefaultSort } |
Public Member Functions | |
QDir () | |
QDir (const FXString &path, const FXString ®ex=FXString::nullStr(), int sortBy=Name|IgnoreCase, int filter=All) | |
QDir (const QDir &o) | |
QDir & | operator= (const QDir &o) |
QDir & | operator= (const FXString &path) |
~QDir () | |
bool | operator== (const QDir &o) const |
bool | operator!= (const QDir &o) const |
void | setPath (const FXString &path) |
const FXString & | path () const |
FXString | absPath () const |
FXString | canonicalPath () const |
FXString | dirName () const |
FXString | filePath (const FXString &file, bool acceptAbs=true) const |
FXString | absFilePath (const FXString &file, bool acceptAbs=true) const |
bool | cd (const FXString &name, bool acceptAbs=true) |
bool | cdUp () |
const FXString & | nameFilter () const |
void | setNameFilter (const FXString ®ex) |
FilterSpec | filter () const |
void | setFilter (int filter) |
SortSpec | sorting () const |
void | setSorting (int sorting) |
bool | matchAllDirs () const |
void | setMatchAllDirs (bool matchAll) |
FXuint | count () const |
const FXString & | operator[] (int idx) const |
QStringList | entryList (const FXString ®ex, int filter=DefaultFilter, int sorting=DefaultSort) |
QStringList | entryList (int filter=DefaultFilter, int sorting=DefaultSort) |
const QFileInfoList * | entryInfoList (const FXString ®ex, int filter=DefaultFilter, int sorting=DefaultSort) |
const QFileInfoList * | entryInfoList (int filter=DefaultFilter, int sorting=DefaultSort) |
void | refresh () |
bool | mkdir (const FXString &leaf, bool acceptAbs=true) |
bool | rmdir (const FXString &leaf, bool acceptAbs=true) |
bool | remove (const FXString &leaf, bool acceptAbs=true) |
bool | rename (const FXString &src, const FXString &dest, bool acceptAbs=true) |
bool | exists (const FXString &leaf, bool acceptAbs=true) |
bool | isReadable () const |
bool | exists () const |
bool | isRoot () const |
bool | isRelative () const |
void | convertToAbs () |
Static Public Member Functions | |
static FXString | convertSeparators (const FXString &path) |
static QStringList | drives () |
static FXString | separator () |
static QDir | current () |
static QDir | home () |
static QDir | root () |
static FXString | currentDirPath () |
static FXString | homeDirPath () |
static FXString | rootDirPath () |
static bool | match (const FXString &filter, const FXString &filename) |
static FXString | cleanDirPath (const FXString &path) |
static bool | isRelativePath (const FXString &path) |
static QStringList | extractChanges (const QDir &A, const QDir &B) |