| 688 | #endif |
| 689 | |
| 690 | bool OSDir::linuxAddFileStack(std::string pathName, std::string fileMask, bool bRecursive) { |
| 691 | #ifdef _WIN32 |
| 692 | // quell warnings |
| 693 | if (!bRecursive) { |
| 694 | fileMask.size(); |
| 695 | pathName.size(); |
| 696 | } |
| 697 | return false; |
| 698 | #else |
| 699 | DIR* directory; |
| 700 | dirent* fileInfo; |
| 701 | struct stat statbuf; |
| 702 | char searchstr[1025]; |
| 703 | std::string FilePath; |
| 704 | |
| 705 | strncpy(searchstr, pathName.c_str(), 1024); |
| 706 | if (searchstr[strlen(searchstr) - 1] != '/') { |
| 707 | strcat(searchstr, "/"); |
| 708 | } |
| 709 | directory = opendir(searchstr); |
| 710 | if (!directory) { |
| 711 | return false; |
| 712 | } |
| 713 | |
| 714 | // TODO: make it use the filemask |
| 715 | while ((fileInfo = readdir(directory))) { |
| 716 | if (!((strcmp(fileInfo->d_name, ".") == 0) || (strcmp(fileInfo->d_name, "..") == 0))) { |
| 717 | FilePath = searchstr; |
| 718 | FilePath += fileInfo->d_name; |
| 719 | strncpy(fileInfo->d_name, TextUtils::toupper(fileInfo->d_name).c_str(), strlen(fileInfo->d_name)); |
| 720 | |
| 721 | stat(FilePath.c_str(), &statbuf); |
| 722 | |
| 723 | if (S_ISDIR(statbuf.st_mode) && bRecursive) { |
| 724 | linuxAddFileStack(FilePath, fileMask, bRecursive); |
| 725 | } |
| 726 | else if (match_mask(fileMask.c_str(), fileInfo->d_name)) { |
| 727 | info->nameList.push_back(FilePath); |
| 728 | } |
| 729 | } |
| 730 | } |
| 731 | closedir(directory); |
| 732 | return true; |
| 733 | #endif// !Win32 |
| 734 | } |
| 735 | |
| 736 | // Local Variables: *** |
| 737 | // mode: C++ *** |