mirror of https://github.com/OpenTTD/OpenTTD
(svn r15607) -Codechange: support searching files without filtering on extension.
parent
d1d0778a54
commit
4f3da358ee
|
@ -1049,11 +1049,13 @@ static uint ScanPath(FileScanner *fs, const char *extension, const char *path, s
|
||||||
num += ScanPath(fs, extension, filename, basepath_length, recursive);
|
num += ScanPath(fs, extension, filename, basepath_length, recursive);
|
||||||
} else if (S_ISREG(sb.st_mode)) {
|
} else if (S_ISREG(sb.st_mode)) {
|
||||||
/* File */
|
/* File */
|
||||||
|
if (extension != NULL) {
|
||||||
char *ext = strrchr(filename, '.');
|
char *ext = strrchr(filename, '.');
|
||||||
|
|
||||||
/* If no extension or extension isn't .grf, skip the file */
|
/* If no extension or extension isn't .grf, skip the file */
|
||||||
if (ext == NULL) continue;
|
if (ext == NULL) continue;
|
||||||
if (strcasecmp(ext, extension) != 0) continue;
|
if (strcasecmp(ext, extension) != 0) continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (fs->AddFile(filename, basepath_length)) num++;
|
if (fs->AddFile(filename, basepath_length)) num++;
|
||||||
}
|
}
|
||||||
|
@ -1073,11 +1075,14 @@ static uint ScanTar(FileScanner *fs, const char *extension, TarFileList::iterato
|
||||||
{
|
{
|
||||||
uint num = 0;
|
uint num = 0;
|
||||||
const char *filename = (*tar).first.c_str();
|
const char *filename = (*tar).first.c_str();
|
||||||
|
|
||||||
|
if (extension != NULL) {
|
||||||
const char *ext = strrchr(filename, '.');
|
const char *ext = strrchr(filename, '.');
|
||||||
|
|
||||||
/* If no extension or extension isn't .grf, skip the file */
|
/* If no extension or extension isn't .grf, skip the file */
|
||||||
if (ext == NULL) return false;
|
if (ext == NULL) return false;
|
||||||
if (strcasecmp(ext, extension) != 0) return false;
|
if (strcasecmp(ext, extension) != 0) return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (fs->AddFile(filename, 0)) num++;
|
if (fs->AddFile(filename, 0)) num++;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue