OpenShot Audio Library | OpenShotAudio  0.3.2
juce_DirectoryIterator.h
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2017 - ROLI Ltd.
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 
23 namespace juce
24 {
25 
26 //==============================================================================
46 class JUCE_API DirectoryIterator final
47 {
48 public:
49  //==============================================================================
72  DirectoryIterator (const File& directory,
73  bool isRecursive,
74  const String& wildCard = "*",
75  int whatToLookFor = File::findFiles);
76 
79 
85  bool next();
86 
99  bool next (bool* isDirectory,
100  bool* isHidden,
101  int64* fileSize,
102  Time* modTime,
103  Time* creationTime,
104  bool* isReadOnly);
105 
110  const File& getFile() const;
111 
117  float getEstimatedProgress() const;
118 
119 private:
120  //==============================================================================
121  struct NativeIterator
122  {
123  NativeIterator (const File& directory, const String& wildCard);
124  ~NativeIterator();
125 
126  bool next (String& filenameFound,
127  bool* isDirectory, bool* isHidden, int64* fileSize,
128  Time* modTime, Time* creationTime, bool* isReadOnly);
129 
130  class Pimpl;
131  std::unique_ptr<Pimpl> pimpl;
132 
133  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeIterator)
134  };
135 
136  StringArray wildCards;
137  NativeIterator fileFinder;
138  String wildCard, path;
139  int index = -1;
140  mutable int totalNumFiles = -1;
141  const int whatToLookFor;
142  const bool isRecursive;
143  bool hasBeenAdvanced = false;
144  std::unique_ptr<DirectoryIterator> subIterator;
145  File currentFile;
146 
147  static StringArray parseWildcards (const String& pattern);
148  static bool fileMatches (const StringArray& wildCards, const String& filename);
149 
150  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryIterator)
151 };
152 
153 } // namespace juce