9
9
## Table of Contents
10
10
11
11
- [ Quick Start] ( #quick-start )
12
+ * [ Build Library and Standalone Sample] ( #build-library-and-standalone-sample )
12
13
- [ API] ( #api )
13
14
- [ Wildcards] ( #wildcards )
14
- - [ Example ] ( #example )
15
+ - [ Examples ] ( #examples )
15
16
* [ Match file extensions] ( #match-file-extensions )
16
17
* [ Match files in absolute pathnames] ( #match-files-in-absolute-pathnames )
17
18
* [ Wildcards: Match a range of characters listed in brackets ('[ ] ')] ( #wildcards-match-a-range-of-characters-listed-in-brackets- )
18
19
* [ Exclude files from the matching] ( #exclude-files-from-the-matching )
19
20
* [ Wildcards: Match any one character with question mark ('?')] ( #wildcards-match-any-one-character-with-question-mark- )
20
21
* [ Case sensitivity] ( #case-sensitivity )
21
22
- [ Contributing] ( #contributing )
22
- - [ License) (#license)
23
+ - [ License] ( #license )
23
24
24
25
## Quick Start
25
26
29
30
- If you can't use ` C++17 ` , you can integrate [ gulrak/filesystem] ( https://github.com/gulrak/filesystem ) with minimal effort.
30
31
* MIT License
31
32
33
+ ### Build Library and Standalone Sample
34
+
32
35
``` bash
33
- git clone https://github.com/p-ranav/glob
34
- cd glob
35
- mkdir build && cd build
36
- cmake .. && make
36
+ cmake -Hall -Bbuild
37
+ cmake --build build
38
+
39
+ # run standalone `glob` sample
40
+ ./build/standalone/glob --help
37
41
```
38
42
39
43
## API
@@ -77,28 +81,7 @@ vector<filesystem::path> rglob(vector<string> pathnames);
77
81
| ` [-] ` | any character in the range listed in brackets | ` [A-Z]* ` matches files starting with capital letters |
78
82
| ` [!] ` | any character listed in the brackets | ` [!ABC]* ` matches files that do not start with A,B or C |
79
83
80
- ## Example
81
-
82
- Below is a short program that runs ` glob ` and prints matching path names.
83
-
84
- *** NOTE*** Replace ` glob ` with ` rglob ` if you want to glob recursively.
85
-
86
- ``` cpp
87
- #include < glob/glob.h>
88
- #include < iostream>
89
-
90
- int main (int argc, char * argv[ ] ) {
91
- if (argc != 2) {
92
- std::cerr << "Usage: ./exe <pattern >\n";
93
- return EXIT_FAILURE;
94
- }
95
-
96
- // Run glob on the vector of patterns
97
- for (auto &f : glob::glob(argv[ 1] )) {
98
- std::cout << f << "\n";
99
- }
100
- }
101
- ```
84
+ ## Examples
102
85
103
86
### Match file extensions
104
87
@@ -118,19 +101,19 @@ foo@bar:~$ tree
118
101
119
102
3 directories, 7 files
120
103
121
- foo@bar:~$ ./main "**/*.hpp"
104
+ foo@bar:~ $ ./glob -i " **/*.hpp"
122
105
"test/doctest.hpp"
123
106
124
- foo@bar:~$ ./main "**/**/*.hpp"
107
+ foo@bar:~ $ ./glob -i " **/**/*.hpp"
125
108
"include/foo/baz.hpp"
126
109
"include/foo/foo.hpp"
127
110
"include/foo/bar.hpp"
128
111
```
129
112
130
- *** NOTE*** If you use ` rglob ` instead of ` glob ` :
113
+ *** NOTE*** If you run glob recursively, i.e., using ` rglob ` :
131
114
132
115
``` console
133
- foo@bar:~ $ ./main " **/*.hpp"
116
+ foo@bar:~ $ ./glob -r -i " **/*.hpp"
134
117
"test/doctest.hpp"
135
118
"include/foo/baz.hpp"
136
119
"include/foo/foo.hpp"
@@ -140,7 +123,7 @@ foo@bar:~$ ./main "**/*.hpp"
140
123
### Match files in absolute pathnames
141
124
142
125
``` console
143
- foo@bar:~ $ ./main ' /usr/local/include/nc*.h'
126
+ foo@bar:~ $ ./glob -i ' /usr/local/include/nc*.h'
144
127
"/usr/local/include/ncCheck.h"
145
128
"/usr/local/include/ncGroupAtt.h"
146
129
"/usr/local/include/ncUshort.h"
@@ -162,13 +145,13 @@ foo@bar:~$ ./main '/usr/local/include/nc*.h'
162
145
foo@bar:~ $ ls test_files_02
163
146
1.txt 2.txt 3.txt 4.txt
164
147
165
- foo@bar:~ $ ./main ' test_files_02/[0-9].txt'
148
+ foo@bar:~ $ ./glob -i ' test_files_02/[0-9].txt'
166
149
"test_files_02/4.txt"
167
150
"test_files_02/3.txt"
168
151
"test_files_02/2.txt"
169
152
"test_files_02/1.txt"
170
153
171
- foo@bar:~ $ ./main ' test_files_02/[1-2]*'
154
+ foo@bar:~ $ ./glob -i ' test_files_02/[1-2]*'
172
155
"test_files_02/2.txt"
173
156
"test_files_02/1.txt"
174
157
```
@@ -177,7 +160,7 @@ foo@bar:~$ ./main 'test_files_02/[1-2]*'
177
160
foo@bar:~ $ ls test_files_03
178
161
file1.txt file2.txt file3.txt file4.txt
179
162
180
- foo@bar:~ $ ./main ' test_files_03/file[0-9].*'
163
+ foo@bar:~ $ ./glob -i ' test_files_03/file[0-9].*'
181
164
"test_files_03/file2.txt"
182
165
"test_files_03/file3.txt"
183
166
"test_files_03/file1.txt"
@@ -190,14 +173,14 @@ foo@bar:~$ ./main 'test_files_03/file[0-9].*'
190
173
foo@bar:~ $ ls test_files_01
191
174
__init__.py bar.py foo.py
192
175
193
- foo@bar:~ $ ./main ' test_files_01/*[!__init__].py'
176
+ foo@bar:~ $ ./glob -i ' test_files_01/*[!__init__].py'
194
177
"test_files_01/bar.py"
195
178
"test_files_01/foo.py"
196
179
197
- foo@bar:~ $ ./main ' test_files_01/*[!__init__][!bar].py'
180
+ foo@bar:~ $ ./glob -i ' test_files_01/*[!__init__][!bar].py'
198
181
"test_files_01/foo.py"
199
182
200
- foo@bar:~ $ ./main ' test_files_01/[!_]*.py'
183
+ foo@bar:~ $ ./glob -i ' test_files_01/[!_]*.py'
201
184
"test_files_01/bar.py"
202
185
"test_files_01/foo.py"
203
186
```
@@ -208,7 +191,7 @@ foo@bar:~$ ./main 'test_files_01/[!_]*.py'
208
191
foo@bar:~ $ ls test_files_02
209
192
1.txt 2.txt 3.txt 4.txt
210
193
211
- foo@bar:~ $ ./main ' test_files_02/?.txt'
194
+ foo@bar:~ $ ./glob -i ' test_files_02/?.txt'
212
195
"test_files_02/4.txt"
213
196
"test_files_02/3.txt"
214
197
"test_files_02/2.txt"
@@ -219,7 +202,7 @@ foo@bar:~$ ./main 'test_files_02/?.txt'
219
202
foo@bar:~ $ ls test_files_03
220
203
file1.txt file2.txt file3.txt file4.txt
221
204
222
- foo@bar:~ $ ./main ' test_files_03/????[3-4].txt'
205
+ foo@bar:~ $ ./glob -i ' test_files_03/????[3-4].txt'
223
206
"test_files_03/file3.txt"
224
207
"test_files_03/file4.txt"
225
208
```
@@ -232,11 +215,17 @@ foo@bar:~$ ./main 'test_files_03/????[3-4].txt'
232
215
foo@bar:~ $ ls test_files_05
233
216
file1.png file2.png file3.PNG file4.PNG
234
217
235
- foo@bar:~ $ ./main ' test_files_05/*.png'
218
+ foo@bar:~ $ ./glob -i ' test_files_05/*.png'
236
219
"test_files_05/file2.png"
237
220
"test_files_05/file1.png"
238
221
239
- foo@bar:~ $ ./main ' test_files_05/*.PNG'
222
+ foo@bar:~ $ ./glob -i ' test_files_05/*.PNG'
223
+ "test_files_05/file3.PNG"
224
+ "test_files_05/file4.PNG"
225
+
226
+ foo@bar:~ $ ./glob -i " test_files_05/*.png" ," test_files_05/*.PNG"
227
+ "test_files_05/file2.png"
228
+ "test_files_05/file1.png"
240
229
"test_files_05/file3.PNG"
241
230
"test_files_05/file4.PNG"
242
231
```
0 commit comments