MCPcopy Create free account
hub / github.com/MyGUI/mygui / getSystemFileList

Function getSystemFileList

Common/FileSystemInfo/FileSystemInfo.h:113–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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)

Callers 6

scanFolderFunction · 0.85
updateMethod · 0.85
SampleLayoutMethod · 0.85
notifyTreeNodePrepareMethod · 0.85
isExistFileMethod · 0.85
updateMethod · 0.85

Calls 14

concatenatePathFunction · 0.85
isReservedDirFunction · 0.85
FileInfoClass · 0.85
UStringFunction · 0.85
statClass · 0.85
find_last_ofMethod · 0.80
substrMethod · 0.80
asUTF8_c_strMethod · 0.80
asWStr_c_strMethod · 0.80
sortFunction · 0.50
c_strMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected