JUCE
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
Classes | Public Member Functions | Static Public Member Functions
DirectoryContentsList Class Reference

A class to asynchronously scan for details about the files in a directory. More...

Inherits ChangeBroadcaster, and TimeSliceClient.

List of all members.

Classes

struct  FileInfo
 Contains cached information about one of the files in a DirectoryContentsList. More...

Public Member Functions

 DirectoryContentsList (const FileFilter *fileFilter, TimeSliceThread &threadToUse)
 Creates a directory list.
 ~DirectoryContentsList ()
 Destructor.
void setDirectory (const File &directory, bool includeDirectories, bool includeFiles)
 Sets the directory to look in for files.
const FilegetDirectory () const
 Returns the directory that's currently being used.
void clear ()
 Clears the list, and stops the thread scanning for files.
void refresh ()
 Clears the list and restarts scanning the directory for files.
bool isStillLoading () const
 True if the background thread hasn't yet finished scanning for files.
void setIgnoresHiddenFiles (bool shouldIgnoreHiddenFiles)
 Tells the list whether or not to ignore hidden files.
bool ignoresHiddenFiles () const
 Returns true if hidden files are ignored.
int getNumFiles () const
 Returns the number of files currently available in the list.
bool getFileInfo (int index, FileInfo &resultInfo) const
 Returns the cached information about one of the files in the list.
File getFile (int index) const
 Returns one of the files in the list.
const FileFiltergetFilter () const
 Returns the file filter being used.
bool contains (const File &) const
 Returns true if the list contains the specified file.
int useTimeSlice ()
TimeSliceThreadgetTimeSliceThread ()

Static Public Member Functions

static int compareElements (const DirectoryContentsList::FileInfo *first, const DirectoryContentsList::FileInfo *second)

Detailed Description

A class to asynchronously scan for details about the files in a directory.

This keeps a list of files and some information about them, using a background thread to scan for more files. As files are found, it broadcasts change messages to tell any listeners.

See also:
FileListComponent, FileBrowserComponent

Constructor & Destructor Documentation

DirectoryContentsList::DirectoryContentsList ( const FileFilter fileFilter,
TimeSliceThread threadToUse 
)

Creates a directory list.

To set the directory it should point to, use setDirectory(), which will also start it scanning for files on the background thread.

When the background thread finds and adds new files to this list, the ChangeBroadcaster class will send a change message, so you can register listeners and update them when the list changes.

Parameters:
fileFilteran optional filter to select which files are included in the list. If this is 0, then all files and directories are included. Make sure that the filter doesn't get deleted during the lifetime of this object
threadToUsea thread object that this list can use to scan for files as a background task. Make sure that the thread you give it has been started, or you won't get any files!

Destructor.


Member Function Documentation

void DirectoryContentsList::setDirectory ( const File directory,
bool  includeDirectories,
bool  includeFiles 
)

Sets the directory to look in for files.

If the directory that's passed in is different to the current one, this will also start the background thread scanning it for files.

Returns the directory that's currently being used.

Clears the list, and stops the thread scanning for files.

Clears the list and restarts scanning the directory for files.

True if the background thread hasn't yet finished scanning for files.

void DirectoryContentsList::setIgnoresHiddenFiles ( bool  shouldIgnoreHiddenFiles)

Tells the list whether or not to ignore hidden files.

By default these are ignored.

Returns true if hidden files are ignored.

See also:
setIgnoresHiddenFiles

Returns the number of files currently available in the list.

The info about one of these files can be retrieved with getFileInfo() or getFile().

Obviously as the background thread runs and scans the directory for files, this number will change.

See also:
getFileInfo, getFile
bool DirectoryContentsList::getFileInfo ( int  index,
FileInfo resultInfo 
) const

Returns the cached information about one of the files in the list.

If the index is in-range, this will return true and will copy the file's details to the structure that is passed-in.

If it returns false, then the index wasn't in range, and the structure won't be affected.

See also:
getNumFiles, getFile
File DirectoryContentsList::getFile ( int  index) const

Returns one of the files in the list.

Parameters:
indexshould be less than getNumFiles(). If this is out-of-range, the return value will be File::nonexistent
See also:
getNumFiles, getFileInfo

Returns the file filter being used.

The filter is specified in the constructor.

bool DirectoryContentsList::contains ( const File ) const

Returns true if the list contains the specified file.

Implements TimeSliceClient.


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