-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileTreeParser.c
More file actions
43 lines (39 loc) · 1.13 KB
/
FileTreeParser.c
File metadata and controls
43 lines (39 loc) · 1.13 KB
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
#include "FileTreeParser.h"
void FileTreeParser_recGetAllFiles(MyString* path, List* list)
{
MyString* tmp = MyString_copy(path);
MyString_pathAppend(tmp, "*");
WIN32_FIND_DATA FindFileData;
HANDLE hFindFile;
hFindFile = FindFirstFile(tmp->data, &FindFileData);
MyString_deleteLastChar(tmp);
if(hFindFile != INVALID_HANDLE_VALUE)
{
do
{
char* fileName = FindFileData.cFileName;
if(fileName[0] == '.')
{
continue;
}
MyString_pathAppend(tmp, fileName);
if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
FileTreeParser_recGetAllFiles(tmp, list);
}
else
{
List_add(list, MyString_copy(tmp));
}
MyString_deleteRange(tmp, tmp->size-strlen(fileName));
}while(FindNextFile(hFindFile, &FindFileData));
}
FindClose(hFindFile);
MyString_delete(tmp);
}
List* FileTreeParser_getAllFiles(MyString* path)
{
List* l = List_create();
FileTreeParser_recGetAllFiles(path, l);
return l;
}