pick up CXXFLAGS passed on commandline
[rofl0r-df-libgraphics.git] / g_src / find_files.cpp
blob059dcc7b16ab25211e2ed879a44f434b2f2c399a
1 #include "../game_g.h"
2 #include "../game_extv.h"
4 void find_files_by_pattern(const char* pattern, svector<char *>& filenames)
6 HANDLE h;
7 WIN32_FIND_DATA finddata;
8 char *c;
10 h=FindFirstFile(pattern,&finddata);
12 if(h!=INVALID_HANDLE_VALUE)
14 if(strcmp(finddata.cFileName,".")&&strcmp(finddata.cFileName,".."))
16 if(!(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
18 c=new char[strlen(finddata.cFileName)+1];
19 strcpy(c,finddata.cFileName);
20 filenames.push_back(c);
24 while(FindNextFile(h,&finddata))
26 if(strcmp(finddata.cFileName,".")&&strcmp(finddata.cFileName,".."))
28 if(!(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
30 c=new char[strlen(finddata.cFileName)+1];
31 strcpy(c,finddata.cFileName);
32 filenames.push_back(c);
37 FindClose(h);
41 void find_files_by_pattern_with_exception(const char* pattern, svector<char *>& filenames,const char *exception)
43 HANDLE h;
44 WIN32_FIND_DATA finddata;
45 char *c;
47 h=FindFirstFile(pattern,&finddata);
49 if(h!=INVALID_HANDLE_VALUE)
51 if(strcmp(finddata.cFileName,".")&&strcmp(finddata.cFileName,"..")&&strcmp(finddata.cFileName,exception))
53 if(!(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
55 c=new char[strlen(finddata.cFileName)+1];
56 strcpy(c,finddata.cFileName);
57 filenames.push_back(c);
61 while(FindNextFile(h,&finddata))
63 if(strcmp(finddata.cFileName,".")&&strcmp(finddata.cFileName,"..")&&strcmp(finddata.cFileName,exception))
65 if(!(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
67 c=new char[strlen(finddata.cFileName)+1];
68 strcpy(c,finddata.cFileName);
69 filenames.push_back(c);
74 FindClose(h);
78 void find_files_by_pattern(const char* pattern, stringvectst &filenames)
80 HANDLE h;
81 WIN32_FIND_DATA finddata;
83 h=FindFirstFile(pattern,&finddata);
85 if(h!=INVALID_HANDLE_VALUE)
87 if(strcmp(finddata.cFileName,".")&&strcmp(finddata.cFileName,".."))
89 if(!(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))filenames.add_string(finddata.cFileName);
92 while(FindNextFile(h,&finddata))
94 if(strcmp(finddata.cFileName,".")&&strcmp(finddata.cFileName,".."))
96 if(!(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))filenames.add_string(finddata.cFileName);
100 FindClose(h);
104 void find_files_by_pattern_with_exception(const char* pattern, stringvectst &filenames,const char *exception)
106 HANDLE h;
107 WIN32_FIND_DATA finddata;
109 h=FindFirstFile(pattern,&finddata);
111 if(h!=INVALID_HANDLE_VALUE)
113 if(strcmp(finddata.cFileName,".")&&strcmp(finddata.cFileName,"..")&&strcmp(finddata.cFileName,exception))
115 if(!(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))filenames.add_string(finddata.cFileName);
118 while(FindNextFile(h,&finddata))
120 if(strcmp(finddata.cFileName,".")&&strcmp(finddata.cFileName,"..")&&strcmp(finddata.cFileName,exception))
122 if(!(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))filenames.add_string(finddata.cFileName);
126 FindClose(h);
130 void find_directories_by_pattern(const char* pattern, stringvectst &filenames)
132 HANDLE h;
133 WIN32_FIND_DATA finddata;
135 h=FindFirstFile(pattern,&finddata);
137 if(h!=INVALID_HANDLE_VALUE)
139 if(strcmp(finddata.cFileName,".")&&strcmp(finddata.cFileName,".."))
141 if(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)filenames.add_string(finddata.cFileName);
144 while(FindNextFile(h,&finddata))
146 if(strcmp(finddata.cFileName,".")&&strcmp(finddata.cFileName,".."))
148 if(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)filenames.add_string(finddata.cFileName);
152 FindClose(h);
156 void find_directories_by_pattern_with_exception(const char* pattern, stringvectst &filenames,const char *exception)
158 HANDLE h;
159 WIN32_FIND_DATA finddata;
161 h=FindFirstFile(pattern,&finddata);
163 if(h!=INVALID_HANDLE_VALUE)
165 if(strcmp(finddata.cFileName,".")&&strcmp(finddata.cFileName,"..")&&strcmp(finddata.cFileName,exception))
167 if(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)filenames.add_string(finddata.cFileName);
170 while(FindNextFile(h,&finddata))
172 if(strcmp(finddata.cFileName,".")&&strcmp(finddata.cFileName,"..")&&strcmp(finddata.cFileName,exception))
174 if(finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)filenames.add_string(finddata.cFileName);
178 FindClose(h);