00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __JUCE_DIRECTORYCONTENTSLIST_JUCEHEADER__
00033 #define __JUCE_DIRECTORYCONTENTSLIST_JUCEHEADER__
00034
00035 #include "juce_FileFilter.h"
00036 #include "../../../events/juce_ChangeBroadcaster.h"
00037 #include "../../../../juce_core/threads/juce_TimeSliceThread.h"
00038 #include "../../graphics/imaging/juce_Image.h"
00039
00040
00041
00051 class JUCE_API DirectoryContentsList : public ChangeBroadcaster,
00052 public TimeSliceClient
00053 {
00054 public:
00055
00075 DirectoryContentsList (const FileFilter* const fileFilter,
00076 TimeSliceThread& threadToUse);
00077
00079 ~DirectoryContentsList();
00080
00081
00082
00088 void setDirectory (const File& directory,
00089 const bool includeDirectories,
00090 const bool includeFiles);
00091
00093 const File& getDirectory() const throw();
00094
00096 void clear();
00097
00099 void refresh();
00100
00102 bool isStillLoading() const;
00103
00108 void setIgnoresHiddenFiles (const bool shouldIgnoreHiddenFiles);
00109
00110
00113 struct FileInfo
00114 {
00115
00123 String filename;
00124
00126 int64 fileSize;
00127
00132 Time modificationTime;
00133
00138 Time creationTime;
00139
00141 bool isDirectory;
00142
00144 bool isReadOnly;
00145 };
00146
00147
00158 int getNumFiles() const;
00159
00170 bool getFileInfo (const int index,
00171 FileInfo& resultInfo) const;
00172
00179 const File getFile (const int index) const;
00180
00185 const FileFilter* getFilter() const throw() { return fileFilter; }
00186
00187
00189 bool useTimeSlice();
00191 TimeSliceThread& getTimeSliceThread() throw() { return thread; }
00193 static int compareElements (const DirectoryContentsList::FileInfo* const first,
00194 const DirectoryContentsList::FileInfo* const second) throw();
00195
00196 juce_UseDebuggingNewOperator
00197
00198 private:
00199 File root;
00200 const FileFilter* fileFilter;
00201 TimeSliceThread& thread;
00202 bool includeDirectories, includeFiles, ignoreHiddenFiles;
00203
00204 CriticalSection fileListLock;
00205 OwnedArray <FileInfo> files;
00206
00207 void* volatile fileFindHandle;
00208 bool volatile shouldStop;
00209
00210 void changed();
00211 bool checkNextFile (bool& hasChanged);
00212 bool addFile (const String& filename, const bool isDir, const bool isHidden,
00213 const int64 fileSize, const Time& modTime,
00214 const Time& creationTime, const bool isReadOnly);
00215
00216 DirectoryContentsList (const DirectoryContentsList&);
00217 const DirectoryContentsList& operator= (const DirectoryContentsList&);
00218 };
00219
00220
00221 #endif // __JUCE_DIRECTORYCONTENTSLIST_JUCEHEADER__