OpenShot Library | libopenshot-audio
0.2.0
juce_FileSearchPath.h
1
2
/** @weakgroup juce_core-files
3
* @{
4
*/
5
/*
6
==============================================================================
7
8
This file is part of the JUCE library.
9
Copyright (c) 2017 - ROLI Ltd.
10
11
JUCE is an open source library subject to commercial or open-source
12
licensing.
13
14
The code included in this file is provided under the terms of the ISC license
15
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
16
To use, copy, modify, and/or distribute this software for any purpose with or
17
without fee is hereby granted provided that the above copyright notice and
18
this permission notice appear in all copies.
19
20
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22
DISCLAIMED.
23
24
==============================================================================
25
*/
26
27
namespace
juce
28
{
29
30
//==============================================================================
31
/**
32
Represents a set of folders that make up a search path.
33
34
@see File
35
36
@tags{Core}
37
*/
38
class
JUCE_API
FileSearchPath
39
{
40
public
:
41
//==============================================================================
42
/** Creates an empty search path. */
43
FileSearchPath
();
44
45
/** Creates a search path from a string of pathnames.
46
47
The path can be semicolon- or comma-separated, e.g.
48
"/foo/bar;/foo/moose;/fish/moose"
49
50
The separate folders are tokenised and added to the search path.
51
*/
52
FileSearchPath
(
const
String
& path);
53
54
/** Creates a copy of another search path. */
55
FileSearchPath
(
const
FileSearchPath
&);
56
57
/** Copies another search path. */
58
FileSearchPath
& operator= (
const
FileSearchPath
&);
59
60
/** Destructor. */
61
~
FileSearchPath
();
62
63
/** Uses a string containing a list of pathnames to re-initialise this list.
64
65
This search path is cleared and the semicolon- or comma-separated folders
66
in this string are added instead. e.g. "/foo/bar;/foo/moose;/fish/moose"
67
*/
68
FileSearchPath
& operator= (
const
String
& path);
69
70
//==============================================================================
71
/** Returns the number of folders in this search path.
72
@see operator[]
73
*/
74
int
getNumPaths()
const
;
75
76
/** Returns one of the folders in this search path.
77
The file returned isn't guaranteed to actually be a valid directory.
78
@see getNumPaths
79
*/
80
File
operator[] (
int
index)
const
;
81
82
/** Returns the search path as a semicolon-separated list of directories. */
83
String
toString()
const
;
84
85
//==============================================================================
86
/** Adds a new directory to the search path.
87
88
The new directory is added to the end of the list if the insertIndex parameter is
89
less than zero, otherwise it is inserted at the given index.
90
*/
91
void
add (
const
File
& directoryToAdd,
92
int
insertIndex = -1);
93
94
/** Adds a new directory to the search path if it's not already in there.
95
96
@return true if the directory has been added, false otherwise.
97
*/
98
bool
addIfNotAlreadyThere (
const
File
& directoryToAdd);
99
100
/** Removes a directory from the search path. */
101
void
remove (
int
indexToRemove);
102
103
/** Merges another search path into this one.
104
This will remove any duplicate directories.
105
*/
106
void
addPath (
const
FileSearchPath
&);
107
108
/** Removes any directories that are actually subdirectories of one of the other directories in the search path.
109
110
If the search is intended to be recursive, there's no point having nested folders in the search
111
path, because they'll just get searched twice and you'll get duplicate results.
112
113
e.g. if the path is "c:\abc\de;c:\abc", this method will simplify it to "c:\abc"
114
*/
115
void
removeRedundantPaths();
116
117
/** Removes any directories that don't actually exist. */
118
void
removeNonExistentPaths();
119
120
//==============================================================================
121
/** Searches the path for a wildcard.
122
123
This will search all the directories in the search path in order and return
124
an array of the files that were found.
125
126
@param whatToLookFor a value from the File::TypesOfFileToFind enum, specifying whether to
127
return files, directories, or both.
128
@param searchRecursively whether to recursively search the subdirectories too
129
@param wildCardPattern a pattern to match against the filenames
130
@returns the number of files added to the array
131
@see File::findChildFiles
132
*/
133
Array<File>
findChildFiles (
int
whatToLookFor,
134
bool
searchRecursively,
135
const
String
& wildCardPattern =
"*"
)
const
;
136
137
/** Searches the path for a wildcard.
138
Note that there's a newer, better version of this method which returns the results
139
array, and in almost all cases, you should use that one instead! This one is kept around
140
mainly for legacy code to use.
141
*/
142
int
findChildFiles (
Array<File>
& results,
143
int
whatToLookFor,
144
bool
searchRecursively,
145
const
String
& wildCardPattern =
"*"
)
const
;
146
147
//==============================================================================
148
/** Finds out whether a file is inside one of the path's directories.
149
150
This will return true if the specified file is a child of one of the
151
directories specified by this path. Note that this doesn't actually do any
152
searching or check that the files exist - it just looks at the pathnames
153
to work out whether the file would be inside a directory.
154
155
@param fileToCheck the file to look for
156
@param checkRecursively if true, then this will return true if the file is inside a
157
subfolder of one of the path's directories (at any depth). If false
158
it will only return true if the file is actually a direct child
159
of one of the directories.
160
@see File::isAChildOf
161
162
*/
163
bool
isFileInPath (
const
File
& fileToCheck,
164
bool
checkRecursively)
const
;
165
166
private
:
167
//==============================================================================
168
StringArray
directories;
169
170
void
init (
const
String
&);
171
172
JUCE_LEAK_DETECTOR (
FileSearchPath
)
173
};
174
175
}
// namespace juce
176
177
/** @}*/
juce::StringArray
A special array for holding a list of strings.
Definition:
juce_StringArray.h:38
juce::Array
Holds a resizable array of primitive or copy-by-value objects.
Definition:
juce_Array.h:59
JUCE_API
#define JUCE_API
This macro is added to all JUCE public class declarations.
Definition:
juce_StandardHeader.h:143
juce::File
Represents a local file or directory.
Definition:
juce_File.h:44
juce::String
The JUCE String class!
Definition:
juce_String.h:42
juce::FileSearchPath
Represents a set of folders that make up a search path.
Definition:
juce_FileSearchPath.h:38
juce_core
files
juce_FileSearchPath.h
Generated on Mon Jun 29 2020 19:03:32 for OpenShot Library | libopenshot-audio by
1.8.17