OpenShot Audio Library | OpenShotAudio: juce_RangedDirectoryIterator.h Source File

OpenShot Audio Library | OpenShotAudio 1.0.0

Loading...
Searching...
No Matches
juce_RangedDirectoryIterator.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
27JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
28JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4996)
29
35class DirectoryEntry final
36{
37public:
39 File getFile() const { return file; }
40
42 Time getModificationTime() const { return modTime; }
43
45 Time getCreationTime() const { return creationTime; }
46
48 int64 getFileSize() const { return fileSize; }
49
51 bool isDirectory() const { return directory; }
52
54 bool isHidden() const { return hidden; }
55
57 bool isReadOnly() const { return readOnly; }
58
62 float getEstimatedProgress() const;
63
64private:
65 std::weak_ptr<DirectoryIterator> iterator;
66 File file;
67 Time modTime;
68 Time creationTime;
69 int64 fileSize = 0;
70 bool directory = false;
71 bool hidden = false;
72 bool readOnly = false;
73
74 friend class RangedDirectoryIterator;
75};
76
80inline const DirectoryEntry& operator* (const DirectoryEntry& e) noexcept { return e; }
81
82//==============================================================================
99 class RangedDirectoryIterator final
100{
101public:
102 using difference_type = std::ptrdiff_t;
103 using value_type = DirectoryEntry;
104 using reference = DirectoryEntry;
105 using pointer = void;
106 using iterator_category = std::input_iterator_tag;
107
109 RangedDirectoryIterator() = default;
110
123 RangedDirectoryIterator (const File& directory,
124 bool isRecursive,
125 const String& wildCard = "*",
126 int whatToLookFor = File::findFiles,
127 File::FollowSymlinks followSymlinks = File::FollowSymlinks::yes);
128
132 bool operator== (const RangedDirectoryIterator& other) const noexcept
133 {
134 return iterator == nullptr && other.iterator == nullptr;
135 }
136
138 bool operator!= (const RangedDirectoryIterator& other) const noexcept
139 {
140 return ! operator== (other);
141 }
142
146 const DirectoryEntry& operator* () const noexcept { return entry; }
147 const DirectoryEntry* operator->() const noexcept { return &entry; }
148
150 RangedDirectoryIterator& operator++()
151 {
152 increment();
153 return *this;
154 }
155
161 DirectoryEntry operator++ (int)
162 {
163 auto result = *(*this);
164 ++(*this);
165 return result;
166 }
167
168private:
169 bool next();
170 void increment();
171
172 std::shared_ptr<DirectoryIterator> iterator;
173 DirectoryEntry entry;
174};
175
179inline RangedDirectoryIterator begin (const RangedDirectoryIterator& it) { return it; }
180
184inline RangedDirectoryIterator end (const RangedDirectoryIterator&) { return {}; }
185
186
187JUCE_END_IGNORE_WARNINGS_MSVC
188JUCE_END_IGNORE_WARNINGS_GCC_LIKE
189
190} // 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