Loading...
Searching...
No Matches
juce_RangedDirectoryIterator.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4996)
class DirectoryEntry final
{
public:
File getFile() const { return file; }
Time getModificationTime() const { return modTime; }
Time getCreationTime() const { return creationTime; }
int64 getFileSize() const { return fileSize; }
bool isDirectory() const { return directory; }
bool isHidden() const { return hidden; }
bool isReadOnly() const { return readOnly; }
float getEstimatedProgress() const;
private:
std::weak_ptr<DirectoryIterator> iterator;
File file;
Time modTime;
Time creationTime;
int64 fileSize = 0;
bool directory = false;
bool hidden = false;
bool readOnly = false;
friend class RangedDirectoryIterator;
};
inline const DirectoryEntry& operator* (const DirectoryEntry& e) noexcept { return e; }
//==============================================================================
class RangedDirectoryIterator final
{
public:
using difference_type = std::ptrdiff_t;
using value_type = DirectoryEntry;
using reference = DirectoryEntry;
using pointer = void;
using iterator_category = std::input_iterator_tag;
RangedDirectoryIterator() = default;
RangedDirectoryIterator (const File& directory,
bool isRecursive,
const String& wildCard = "*",
int whatToLookFor = File::findFiles,
File::FollowSymlinks followSymlinks = File::FollowSymlinks::yes);
bool operator== (const RangedDirectoryIterator& other) const noexcept
{
return iterator == nullptr && other.iterator == nullptr;
}
bool operator!= (const RangedDirectoryIterator& other) const noexcept
{
return ! operator== (other);
}
const DirectoryEntry& operator* () const noexcept { return entry; }
const DirectoryEntry* operator->() const noexcept { return &entry; }
RangedDirectoryIterator& operator++()
{
increment();
return *this;
}
DirectoryEntry operator++ (int)
{
auto result = *(*this);
++(*this);
return result;
}
private:
bool next();
void increment();
std::shared_ptr<DirectoryIterator> iterator;
DirectoryEntry entry;
};
inline RangedDirectoryIterator begin (const RangedDirectoryIterator& it) { return it; }
inline RangedDirectoryIterator end (const RangedDirectoryIterator&) { return {}; }
JUCE_END_IGNORE_WARNINGS_MSVC
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
} // namespace juce
juce::DirectoryEntry
Definition juce_RangedDirectoryIterator.h:36
juce::DirectoryEntry::getFileSize
int64 getFileSize() const
Definition juce_RangedDirectoryIterator.h:48
juce::DirectoryEntry::getModificationTime
Time getModificationTime() const
Definition juce_RangedDirectoryIterator.h:42
juce::DirectoryEntry::isHidden
bool isHidden() const
Definition juce_RangedDirectoryIterator.h:54
juce::DirectoryEntry::getCreationTime
Time getCreationTime() const
Definition juce_RangedDirectoryIterator.h:45
juce::DirectoryEntry::isReadOnly
bool isReadOnly() const
Definition juce_RangedDirectoryIterator.h:57
juce::DirectoryEntry::isDirectory
bool isDirectory() const
Definition juce_RangedDirectoryIterator.h:51
juce::DirectoryEntry::getFile
File getFile() const
Definition juce_RangedDirectoryIterator.h:39
juce::File
Definition juce_File.h:45
juce::File::findFiles
@ findFiles
Definition juce_File.h:566
juce::File::FollowSymlinks
FollowSymlinks
Definition juce_File.h:572
juce::File::FollowSymlinks::yes
@ yes
Definition juce_File.h:585
juce::RangedDirectoryIterator
Definition juce_RangedDirectoryIterator.h:100
juce::RangedDirectoryIterator::RangedDirectoryIterator
RangedDirectoryIterator()=default
juce::RangedDirectoryIterator::operator++
RangedDirectoryIterator & operator++()
Definition juce_RangedDirectoryIterator.h:150
juce::RangedDirectoryIterator::operator==
bool operator==(const RangedDirectoryIterator &other) const noexcept
Definition juce_RangedDirectoryIterator.h:132
juce::RangedDirectoryIterator::operator!=
bool operator!=(const RangedDirectoryIterator &other) const noexcept
Definition juce_RangedDirectoryIterator.h:138
juce::RangedDirectoryIterator::operator*
const DirectoryEntry & operator*() const noexcept
Definition juce_RangedDirectoryIterator.h:146
juce::String
Definition juce_String.h:53
juce::Time
Definition juce_Time.h:37