| 111 | } |
| 112 | |
| 113 | inline void getSystemFileList( |
| 114 | VectorFileInfo& _result, |
| 115 | const std::wstring& _folder, |
| 116 | const std::wstring& _mask, |
| 117 | bool _sorted = true) |
| 118 | { |
| 119 | #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 |
| 120 | //FIXME add optional parameter? |
| 121 | bool ms_IgnoreHidden = true; |
| 122 | |
| 123 | intptr_t lHandle; |
| 124 | int res; |
| 125 | struct _wfinddata_t tagData; |
| 126 | |
| 127 | // pattern can contain a directory name, separate it from mask |
| 128 | size_t pos = _mask.find_last_of(L"/\\"); |
| 129 | std::wstring directory; |
| 130 | if (pos != _mask.npos) |
| 131 | directory = _mask.substr(0, pos); |
| 132 | |
| 133 | std::wstring full_mask = concatenatePath(_folder, _mask); |
| 134 | |
| 135 | lHandle = _wfindfirst(full_mask.c_str(), &tagData); |
| 136 | res = 0; |
| 137 | while (lHandle != -1 && res != -1) |
| 138 | { |
| 139 | if ((!ms_IgnoreHidden || (tagData.attrib & _A_HIDDEN) == 0) && !isReservedDir(tagData.name)) |
| 140 | { |
| 141 | _result.push_back( |
| 142 | FileInfo(concatenatePath(directory, tagData.name), (tagData.attrib & _A_SUBDIR) != 0)); |
| 143 | } |
| 144 | res = _wfindnext(lHandle, &tagData); |
| 145 | } |
| 146 | // Close if we found any files |
| 147 | if (lHandle != -1) |
| 148 | _findclose(lHandle); |
| 149 | #else |
| 150 | std::string folder = MyGUI::UString(_folder).asUTF8(); |
| 151 | DIR* dir = opendir(folder.c_str()); |
| 152 | struct dirent* dp; |
| 153 | |
| 154 | if (dir == nullptr) |
| 155 | { |
| 156 | /* opendir() failed */ |
| 157 | MYGUI_LOG(Error, "Can't open " + folder); |
| 158 | return; |
| 159 | } |
| 160 | |
| 161 | rewinddir(dir); |
| 162 | |
| 163 | while ((dp = readdir(dir)) != nullptr) |
| 164 | { |
| 165 | if ((fnmatch(MyGUI::UString(_mask).asUTF8_c_str(), dp->d_name, 0) == 0) && |
| 166 | !isReservedDir(MyGUI::UString(dp->d_name).asWStr_c_str())) |
| 167 | { |
| 168 | struct stat fInfo; |
| 169 | std::string path = folder + "/" + dp->d_name; |
| 170 | if (stat(path.c_str(), &fInfo) == -1) |
no test coverage detected