FindAllFiles Retrieves the files in the current directory that match the pattern given. Call FindAllFilesSize() to determine how much memory will be needed for the buffer. pattern = wildcard pattern to use to match list = buffer of memory that will be filled in with the filenames (each seperated by a \0) size = size of memory allocated for list parm filecount = filled in with the number of file
| 2254 | // size = size of memory allocated for list parm |
| 2255 | // filecount = filled in with the number of files it found |
| 2256 | int FindAllFiles(const char *pattern, char *list, int size, int *filecount) { |
| 2257 | int count = 0; |
| 2258 | char filename[_MAX_PATH]; |
| 2259 | *filecount = 0; |
| 2260 | int memory = 0; |
| 2261 | |
| 2262 | if (size <= 0) |
| 2263 | return 0; |
| 2264 | if (!list) |
| 2265 | return 0; |
| 2266 | if (!pattern) |
| 2267 | return 0; |
| 2268 | |
| 2269 | if (ddio_FindFileStart(pattern, filename)) { |
| 2270 | count++; |
| 2271 | strcpy(&list[memory], filename); |
| 2272 | memory += strlen(&list[memory]) + 1; |
| 2273 | while ((count < size) && (ddio_FindNextFile(filename))) { |
| 2274 | strcpy(&list[memory], filename); |
| 2275 | memory += strlen(&list[memory]) + 1; |
| 2276 | count++; |
| 2277 | } |
| 2278 | } |
| 2279 | ddio_FindFileClose(); |
| 2280 | *filecount = count; |
| 2281 | return memory; |
| 2282 | } |
| 2283 | |
| 2284 | // FindAllFilesSize |
| 2285 | // |
no test coverage detected