forked from iamOgunyinka/tinydircpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
32 lines (27 loc) · 846 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include "filehandler.h"
int main()
{
Folder a("/path/to/folder");
std::vector<std::string> vec;
if(a.is_open()){ //explicitly requesting if is "openable"
a.recurseDownDirectory(); //get all Filenames down the "tree"
vec = a.getExtension("cc"); //automatically prefix with a '.', return vector of strings
for(const auto &i: vec){
std::cout << i << std::endl;
}
} else {
std::cout << "Unable to open directory/file" << std::endl;
}
std::cout << "Changing directory to \"C:\\New\\FilePath\"" << std::endl;
a.setFilename("C:\\WindowsPathName\\");
if(a){
a.getSingle(); //get filenames ONLY within the given directory
for(const auto &i: a){ //Folder objects are iterable
std::cout << i << std::endl;
}
} else {
std::cout << "Unable to open directory/file" << std::endl;
}
return 0;
}