-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakeFileList.cpp
47 lines (37 loc) · 1.25 KB
/
MakeFileList.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
typedef struct{
string filepath;
}FILE_LIST;
typedef std::vector<char*> Temp_Path;
bool has_suffix(const string& s, const string& suffix){ //Fileリストを取得するのに必要
return (s.size() >= suffix.size()) && equal(suffix.rbegin(), suffix.rend(), s.rbegin());
}
vector<char*> getFileList(const char* path, int *found_file_num) {
// Get File list: http://xr0038.hatenadiary.jp/entry/2015/02/26/154608sR
DIR *dp; // pointer to the directory
dirent* entry; // readdir() で返されるエントリーポイント
dp = opendir(path);
Temp_Path temp_path;
if (dp==NULL) exit(1);
do {
entry = readdir(dp);
if (entry != NULL){
if(has_suffix(entry->d_name, ".tsv"))
temp_path.push_back(entry->d_name);
++(*found_file_num);
}
} while (entry != NULL);
return temp_path;
}
int filteredFileList(vector<char*> temp_path, int *found_file_num, FILE_LIST *File_List, int *put_file_num){
if (0 < *found_file_num){
Temp_Path::iterator iter;
regex re("(.*)(CCALL)(.*)"); // re HERE, TYPE OF FILE USED IS DEFINED
for (iter = temp_path.begin(); iter != temp_path.end(); ++iter) {
if(regex_match(*iter, re)){
File_List[*put_file_num].filepath = *iter;
++*put_file_num;
}
}
}
return 0;
}