| 2594 | } |
| 2595 | |
| 2596 | BOOL LASreadOpener::add_file_name(const CHAR* file_name, BOOL unique) { |
| 2597 | BOOL r = FALSE; |
| 2598 | HANDLE h; |
| 2599 | WIN32_FIND_DATA info; |
| 2600 | |
| 2601 | // extract the extension from the pattern |
| 2602 | std::string ext = getFileExtension(file_name); |
| 2603 | |
| 2604 | h = FindFirstFile(file_name, &info); |
| 2605 | if (h != INVALID_HANDLE_VALUE) { |
| 2606 | // find the path |
| 2607 | I32 len = (I32)strlen(file_name); |
| 2608 | while (len && (file_name[len] != '\\') && (file_name[len] != '/') && (file_name[len] != ':')) len--; |
| 2609 | if (len) { |
| 2610 | len++; |
| 2611 | CHAR full_file_name[512]; |
| 2612 | strncpy_las(full_file_name, sizeof(full_file_name), file_name, len); |
| 2613 | size_t remaining_size = (sizeof(full_file_name) > len) ? (sizeof(full_file_name) - len) : 0; |
| 2614 | do { |
| 2615 | // windows wildcards also return partial matches. Here a strict check is performed for the exact file ext |
| 2616 | if (!ext.empty() && !HasFileExt(info.cFileName, ext)) continue; |
| 2617 | |
| 2618 | snprintf(&full_file_name[len], remaining_size, "%s", info.cFileName); |
| 2619 | if (add_file_name_single(full_file_name, unique)) r = TRUE; |
| 2620 | } while (FindNextFile(h, &info)); |
| 2621 | } else { |
| 2622 | do { |
| 2623 | // windows wildcards also return partial matche. Here a strict check is performed for the exact file ext |
| 2624 | if (!ext.empty() && !HasFileExt(info.cFileName, ext)) continue; |
| 2625 | |
| 2626 | if (add_file_name_single(info.cFileName, unique)) r = TRUE; |
| 2627 | } while (FindNextFile(h, &info)); |
| 2628 | } |
| 2629 | FindClose(h); |
| 2630 | } |
| 2631 | return r; |
| 2632 | } |
| 2633 | #else |
| 2634 | #include <dirent.h> |
| 2635 | #include <glob.h> |
no test coverage detected