MCPcopy Create free account
hub / github.com/JACoders/OpenJK / SE_R_ListFiles

Function SE_R_ListFiles

code/qcommon/stringed_interface.cpp:149–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147//
148int giFilesFound;
149static void SE_R_ListFiles( const char *psExtension, const char *psDir, std::string &strResults )
150{
151// Com_Printf(va("Scanning Dir: %s\n",psDir));
152
153 char **sysFiles, **dirFiles;
154 int numSysFiles, i, numdirs;
155
156 dirFiles = FS_ListFiles( psDir, "/", &numdirs);
157 for (i=0;i<numdirs;i++)
158 {
159 if (dirFiles[i][0] && dirFiles[i][0] != '.') // skip blanks, plus ".", ".." etc
160 {
161 char sDirName[MAX_QPATH];
162 Com_sprintf(sDirName, sizeof(sDirName), "%s/%s", psDir, dirFiles[i]);
163 //
164 // for some reason the quake filesystem in this game now returns an extra slash on the end,
165 // didn't used to. Sigh...
166 //
167 if (sDirName[strlen(sDirName)-1] == '/')
168 {
169 sDirName[strlen(sDirName)-1] = '\0';
170 }
171 SE_R_ListFiles( psExtension, sDirName, strResults );
172 }
173 }
174
175 sysFiles = FS_ListFiles( psDir, psExtension, &numSysFiles );
176 for(i=0; i<numSysFiles; i++)
177 {
178 char sFilename[MAX_QPATH];
179 Com_sprintf(sFilename, sizeof(sFilename), "%s/%s", psDir, sysFiles[i]);
180
181// Com_Printf("%sFound file: %s",!i?"\n":"",sFilename);
182
183 strResults += sFilename;
184 strResults += ';';
185 giFilesFound++;
186
187 // read it in...
188 //
189/* byte *pbData = NULL;
190 int iSize = FS_ReadFile( sFilename, (void **)&pbData);
191
192 if (pbData)
193 {
194
195 FS_FreeFile( pbData );
196 }
197*/
198 }
199 FS_FreeFileList( sysFiles );
200 FS_FreeFileList( dirFiles );
201}
202#endif
203
204

Callers 1

SE_BuildFileListFunction · 0.70

Calls 3

FS_ListFilesFunction · 0.70
Com_sprintfFunction · 0.70
FS_FreeFileListFunction · 0.70

Tested by

no test coverage detected