30 : fileFilter (f), thread (t)
42 : (fileTypeFlags &
~File::ignoreHiddenFiles));
57 if (directory != root)
78void DirectoryContentsList::setTypeFlags (
const int newFlags)
87void DirectoryContentsList::stopSearching()
98 if (! files.isEmpty())
108 wasEmpty = files.isEmpty();
113 fileFindHandle = std::make_unique<RangedDirectoryIterator> (root,
false,
"*", fileTypeFlags);
137 if (
auto* info = files [index])
150 if (
auto* info = files [index])
160 for (
int i = files.size(); --i >= 0;)
161 if (root.
getChildFile (files.getUnchecked (i)->filename) == targetFile)
172void DirectoryContentsList::changed()
178int DirectoryContentsList::useTimeSlice()
183 for (
int i = 100; --i >= 0;)
203bool DirectoryContentsList::checkNextFile (
bool&
hasChanged)
205 if (fileFindHandle ==
nullptr)
208 if (*fileFindHandle == RangedDirectoryIterator())
210 fileFindHandle =
nullptr;
216 const auto entry = *(*fileFindHandle)++;
221 entry.getModificationTime(),
222 entry.getCreationTime(),
228bool DirectoryContentsList::addFile (
const File& file,
const bool isDir,
229 const int64 fileSize,
230 Time modTime, Time creationTime,
231 const bool isReadOnly)
235 if (fileFilter ==
nullptr
239 auto info = std::make_unique<FileInfo>();
241 info->filename = file.getFileName();
242 info->fileSize = fileSize;
243 info->modificationTime = modTime;
244 info->creationTime = creationTime;
245 info->isDirectory = isDir;
246 info->isReadOnly = isReadOnly;
248 for (
int i = files.size(); --i >= 0;)
249 if (files.getUnchecked (i)->filename == info->filename)
252 files.add (std::move (info));
254 std::sort (files.begin(), files.end(), [] (
const FileInfo* a,
const FileInfo* b)
257 if (a->isDirectory != b->isDirectory)
258 return a->isDirectory;
261 return a->filename.compareNatural (b->filename) < 0;
void sendChangeMessage()
Causes an asynchronous change message to be sent to all the registered listeners.
void setFileFilter(const FileFilter *newFileFilter)
Replaces the current FileFilter.
bool getFileInfo(int index, FileInfo &resultInfo) const
Returns the cached information about one of the files in the list.
bool ignoresHiddenFiles() const
Returns true if hidden files are ignored.
void setDirectory(const File &directory, bool includeDirectories, bool includeFiles)
Sets the directory to look in for files.
bool isStillLoading() const
True if the background thread hasn't yet finished scanning for files.
int getNumFiles() const noexcept
Returns the number of files currently available in the list.
void refresh()
Clears the list and restarts scanning the directory for files.
File getFile(int index) const
Returns one of the files in the list.
void clear()
Clears the list, and stops the thread scanning for files.
void setIgnoresHiddenFiles(bool shouldIgnoreHiddenFiles)
Tells the list whether or not to ignore hidden files.
DirectoryContentsList(const FileFilter *fileFilter, TimeSliceThread &threadToUse)
Creates a directory list.
bool contains(const File &) const
Returns true if the list contains the specified file.
~DirectoryContentsList() override
Destructor.
Contains cached information about one of the files in a DirectoryContentsList.
Interface for deciding which files are suitable for something.
virtual bool isFileSuitable(const File &file) const =0
Should return true if this file is suitable for inclusion in whatever context the object is being use...
virtual bool isDirectorySuitable(const File &file) const =0
Should return true if this directory is suitable for inclusion in whatever context the object is bein...
Represents a local file or directory.
bool isDirectory() const
Checks whether the file is a directory that exists.
File getChildFile(StringRef relativeOrAbsolutePath) const
Returns a file that represents a relative (or absolute) sub-path of the current one.
@ ignoreHiddenFiles
Add this flag to avoid returning any hidden files in the results.
@ findDirectories
Use this flag to indicate that you want to find directories.
@ findFiles
Use this flag to indicate that you want to find files.
Automatically locks and unlocks a mutex object.
A thread that keeps a list of clients, and calls each one in turn, giving them all a chance to run so...
void removeTimeSliceClient(TimeSliceClient *clientToRemove)
Removes a client from the list.
void addTimeSliceClient(TimeSliceClient *clientToAdd, int millisecondsBeforeStarting=0)
Adds a client to the list.
static uint32 getApproximateMillisecondCounter() noexcept
Less-accurate but faster version of getMillisecondCounter().
CriticalSection::ScopedLockType ScopedLock
Automatically locks and unlocks a CriticalSection object.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
long long int64
A platform-independent 64-bit integer type.