summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-03-04 00:19:42 +0000
committerrubidium <rubidium@openttd.org>2009-03-04 00:19:42 +0000
commit4f3da358eec324ac4bc34927d4d8997e6181da2e (patch)
treeab74eaef2c6f63fade06fe1184f73611982e7682 /src
parentd1d0778a5494edf9e8bc9144bbafa2f8604456f7 (diff)
downloadopenttd-4f3da358eec324ac4bc34927d4d8997e6181da2e.tar.xz
(svn r15607) -Codechange: support searching files without filtering on extension.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 85c4e2d04..a976135d0 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -1049,11 +1049,13 @@ static uint ScanPath(FileScanner *fs, const char *extension, const char *path, s
num += ScanPath(fs, extension, filename, basepath_length, recursive);
} else if (S_ISREG(sb.st_mode)) {
/* File */
- char *ext = strrchr(filename, '.');
+ if (extension != NULL) {
+ char *ext = strrchr(filename, '.');
- /* If no extension or extension isn't .grf, skip the file */
- if (ext == NULL) continue;
- if (strcasecmp(ext, extension) != 0) continue;
+ /* If no extension or extension isn't .grf, skip the file */
+ if (ext == NULL) continue;
+ if (strcasecmp(ext, extension) != 0) continue;
+ }
if (fs->AddFile(filename, basepath_length)) num++;
}
@@ -1073,11 +1075,14 @@ static uint ScanTar(FileScanner *fs, const char *extension, TarFileList::iterato
{
uint num = 0;
const char *filename = (*tar).first.c_str();
- const char *ext = strrchr(filename, '.');
- /* If no extension or extension isn't .grf, skip the file */
- if (ext == NULL) return false;
- if (strcasecmp(ext, extension) != 0) return false;
+ if (extension != NULL) {
+ const char *ext = strrchr(filename, '.');
+
+ /* If no extension or extension isn't .grf, skip the file */
+ if (ext == NULL) return false;
+ if (strcasecmp(ext, extension) != 0) return false;
+ }
if (fs->AddFile(filename, 0)) num++;