Provides a platform-independent way to get a filtered directory listing.
#include <Workspace/Application/System/directoryfilter.h>
◆ DirectoryFilter() [1/2]
DirectoryFilter |
( |
const QString & |
dir = "" , |
|
|
const QString & |
filter = "" , |
|
|
bool |
isRegex = false |
|
) |
| |
- Parameters
-
dir | The directory to filter. The default value results in the current directory being used. |
filter | The filter to use when reading the directory entries. If left unspecified, all entries will be returned (this is the default). |
isRegex | If true, then filter should be treated as a regular expression. Otherwise, filter can only contain valid file name characters and the * and ? wildcards. |
◆ DirectoryFilter() [2/2]
◆ ~DirectoryFilter()
◆ getDirectory()
const QString & getDirectory |
( |
| ) |
const |
- Returns
- The currently set directory. If this is an empty string, it is equivalent to using the current directory.
◆ getEntry()
const QString & getEntry |
( |
unsigned |
index | ) |
const |
- Parameters
-
index | The array index to retrieve. No check is performed on whether this refers to a valid entry. It is the caller's responsibility to ensure that this is less than the value returned from getNumEntries(). |
- Returns
- The directory entry at the specified index.
◆ getEntrySubExpression()
QString getEntrySubExpression |
( |
unsigned |
entryIndex, |
|
|
unsigned |
subexpressionIndex |
|
) |
| const |
- Parameters
-
entryIndex | Index of the entry to analyze. |
subexpressionIndex | Index of the subexpression to return. |
- Returns
- The string corresponding to the subexpressionIndex captured subexpression in the string for entry entryIndex. If no such entry exists or there is no subexpression at the specified subexpressionIndex, an empty string is returned. In debug mode, both of these conditions are protected by assertions, since it is considered a programming error to ask for an index which does not exists (either an entry or a subexpression index).
◆ getFilter()
const QString & getFilter |
( |
| ) |
const |
- Returns
- The currently set filter. If this is an empty string, all directory entries will be returned.
- See also
- setFilter()
◆ getFullPath()
QString getFullPath |
( |
unsigned |
index | ) |
const |
- Parameters
-
index | The array index to retrieve. No check is performed on whether this refers to a valid entry. It is the caller's responsibility to ensure that this is less than the value returned from getNumEntries(). |
- Returns
- The path of the directory entry at the specified index. This is essentially the same as concatenating the currently set directory with the file name at the specified entry index. An appropriate directory separator is inserted between the two. The path returned is guaranteed to use the correct path separators for the current platform.
◆ getIncludeHidden()
bool getIncludeHidden |
( |
| ) |
const |
◆ getNumEntries()
unsigned getNumEntries |
( |
| ) |
const |
- Returns
- The number of directory entries read in by the last call to refresh(). This will be zero if refresh() has not yet been called or if the last call to refresh() failed for some reason.
◆ getPathSeparator()
char getPathSeparator |
( |
| ) |
|
|
static |
- Returns
- The platform-specific path separator.
◆ isDirectory()
bool isDirectory |
( |
const QString & |
fileName | ) |
const |
- Parameters
-
fileName | Name of an entry in the currently set directory. |
- Returns
- True if fileName is a subdirectory in the currently set directory.
- Note
- It is not necessary to have called refresh() before calling this function, although it will usually be used after such a call to test the entries found by refresh().
◆ isFile()
bool isFile |
( |
const QString & |
fileName | ) |
const |
- Parameters
-
fileName | Name of an entry in the currently set directory. |
- Returns
- True if fileName is a file or symbolic link in the currently set directory.
- Note
- It is not necessary to have called refresh() before calling this function, although it will usually be used after such a call to test the entries found by refresh().
◆ isReadable()
bool isReadable |
( |
const QString & |
fileName | ) |
const |
- Parameters
-
fileName | Name of an entry in the currently set directory. |
- Returns
- True if fileName is readable.
- Note
- It is not necessary to have called refresh() before calling this function, although it will usually be used after such a call to test the entries found by refresh().
◆ isRegex()
- Returns
- True if the currently set filter should be treated as a regular expression.
- See also
- setFilter()
◆ isSymbolicLink()
bool isSymbolicLink |
( |
const QString & |
fileName | ) |
const |
- Parameters
-
fileName | Name of an entry in the currently set directory. |
- Returns
- True if fileName is a symbolic link in the currently set directory (under Windows, this is a
*.lnk
file).
- Note
- It is not necessary to have called refresh() before calling this function, although it will usually be used after such a call to test the entries found by refresh().
◆ isWritable()
bool isWritable |
( |
const QString & |
fileName | ) |
const |
- Parameters
-
fileName | Name of an entry in the currently set directory. |
- Returns
- True if fileName is writable.
- Note
- It is not necessary to have called refresh() before calling this function, although it will usually be used after such a call to test the entries found by refresh().
◆ operator=()
◆ platformDependentPath()
QString platformDependentPath |
( |
const QString & |
path | ) |
|
|
static |
- Parameters
-
path | The path string to return as a platform dependent string. |
- Returns
- The path with path separators converted to their platform-specific representation.
◆ refresh()
Reads the currently set directory and fills the internal data cache with all directory entries which match the current filter.
- Returns
- True if the directory could be read, or false if there was an error (such as the directory didn't exist). If false is returned, the current contents cached internally will always be set to an empty list.
- See also
- getNumEntries(), getEntry()
◆ setDirectory()
void setDirectory |
( |
const QString & |
dir | ) |
|
- Parameters
-
dir | The new directory to use. |
No check is performed on whether or not dir exists.
- Postcondition
- Entries from a previous call to refresh() will still be available.
◆ setFilter()
void setFilter |
( |
const QString & |
filter, |
|
|
bool |
isRegex |
|
) |
| |
- Parameters
-
filter | The new directory filter to use. |
isRegex | If true, then filter will be treated as a regular expression. Otherwise, it is assumed that it can only contain valid file name characters plus the * and ? wildcards. |
- Postcondition
- Entries from a previous call to refresh() will still be available.
◆ setIncludeHidden()
void setIncludeHidden |
( |
bool |
b | ) |
|
◆ sort()
Sorts the last set of entries in ascending alphabetical order, with all uppercase appearing before lowercase entries as per the usual ASCII character ordering.