| 534 | } |
| 535 | |
| 536 | bool OSDir::windowsAddFileStack(std::string pathName, std::string fileMask, bool bRecursive) { |
| 537 | #ifdef _WIN32 |
| 538 | struct _finddata_t fileInfo; |
| 539 | |
| 540 | long hFile; |
| 541 | std::string searchstr; |
| 542 | |
| 543 | std::string FilePath; |
| 544 | |
| 545 | bool bDone = false; |
| 546 | |
| 547 | searchstr = pathName; |
| 548 | searchstr += "\\"; |
| 549 | if (fileMask.size() > 0) { |
| 550 | searchstr += fileMask; |
| 551 | } |
| 552 | else { |
| 553 | searchstr += "*.*"; |
| 554 | } |
| 555 | |
| 556 | hFile = (long)_findfirst(searchstr.c_str(), &fileInfo); |
| 557 | |
| 558 | if (hFile != -1) { |
| 559 | while (!bDone) { |
| 560 | if ((strlen(fileInfo.name) > 0) && (strcmp(fileInfo.name, ".") != 0) && |
| 561 | (strcmp(fileInfo.name, "..") != 0)) { |
| 562 | FilePath = pathName; |
| 563 | FilePath += "\\"; |
| 564 | FilePath += fileInfo.name; |
| 565 | |
| 566 | if ((fileInfo.attrib & _A_SUBDIR) && bRecursive) { |
| 567 | windowsAddFileStack(FilePath, fileMask, bRecursive); |
| 568 | } |
| 569 | else if (!(fileInfo.attrib & _A_SUBDIR)) { |
| 570 | info->nameList.push_back(FilePath); |
| 571 | } |
| 572 | } |
| 573 | if (_findnext(hFile, &fileInfo) == -1) { |
| 574 | bDone = true; |
| 575 | } |
| 576 | } |
| 577 | } |
| 578 | return true; |
| 579 | #else |
| 580 | // quell warnings |
| 581 | if (!bRecursive) { |
| 582 | fileMask.size(); |
| 583 | pathName.size(); |
| 584 | } |
| 585 | return false; |
| 586 | #endif |
| 587 | } |
| 588 | |
| 589 | // linux mask filter functions |
| 590 | // we don't need these for windows as it can do it right in findNextFile |