| 867 | } |
| 868 | |
| 869 | int CLocatorAPI::file_list(FS_FileSet& dest, LPCSTR path, u32 flags, LPCSTR mask) |
| 870 | { |
| 871 | R_ASSERT(path); |
| 872 | VERIFY(flags); |
| 873 | |
| 874 | string_path N; |
| 875 | if (path_exist(path)) |
| 876 | update_path(N, path, ""); |
| 877 | else |
| 878 | strcpy_s(N, path); |
| 879 | |
| 880 | files_it I = file_find_it(N); |
| 881 | if (I == files.end()) |
| 882 | return 0; |
| 883 | |
| 884 | SStringVec masks; |
| 885 | _SequenceToList(masks, mask); |
| 886 | BOOL b_mask = !masks.empty(); |
| 887 | |
| 888 | size_t base_len = xr_strlen(N); |
| 889 | for (++I; I != files.end(); ++I) |
| 890 | { |
| 891 | const file& entry = *I; |
| 892 | if (0 != strncmp(entry.name, N, base_len)) |
| 893 | break; // end of list |
| 894 | |
| 895 | LPCSTR end_symbol = entry.name + xr_strlen(entry.name) - 1; |
| 896 | if ((*end_symbol) != '\\') |
| 897 | { |
| 898 | // file |
| 899 | if ((flags & FS_ListFiles) == 0) |
| 900 | continue; |
| 901 | |
| 902 | LPCSTR entry_begin = entry.name + base_len; |
| 903 | if ((flags & FS_RootOnly) && strchr(entry_begin, '\\')) |
| 904 | continue; // folder in folder |
| 905 | |
| 906 | // check extension |
| 907 | if (b_mask) |
| 908 | { |
| 909 | bool bOK = false; |
| 910 | for (auto& mask : masks) |
| 911 | { |
| 912 | if (pattern_match(entry_begin, mask.c_str())) |
| 913 | { |
| 914 | bOK = true; |
| 915 | break; |
| 916 | } |
| 917 | } |
| 918 | if (!bOK) |
| 919 | continue; |
| 920 | } |
| 921 | |
| 922 | xr_string fn = entry_begin; |
| 923 | |
| 924 | // insert file entry |
| 925 | if (flags & FS_ClampExt) |
| 926 | { |
no test coverage detected