Changeset - r11253:859882bdf5aa
[Not reviewed]
master
0 1 0
rubidium - 15 years ago 2009-03-04 00:19:42
rubidium@openttd.org
(svn r15607) -Codechange: support searching files without filtering on extension.
1 file changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/fileio.cpp
Show inline comments
 
@@ -1046,17 +1046,19 @@ static uint ScanPath(FileScanner *fs, co
 
			if (!recursive) continue;
 
			if (strcmp(d_name, ".") == 0 || strcmp(d_name, "..") == 0) continue;
 
			AppendPathSeparator(filename, lengthof(filename));
 
			num += ScanPath(fs, extension, filename, basepath_length, recursive);
 
		} else if (S_ISREG(sb.st_mode)) {
 
			/* File */
 
			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 (fs->AddFile(filename, basepath_length)) num++;
 
		}
 
	}
 

	
 
	closedir(dir);
 
@@ -1070,17 +1072,20 @@ static uint ScanPath(FileScanner *fs, co
 
 * @param tar       the tar to search in.
 
 */
 
static uint ScanTar(FileScanner *fs, const char *extension, TarFileList::iterator tar)
 
{
 
	uint num = 0;
 
	const char *filename = (*tar).first.c_str();
 

	
 
	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++;
 

	
 
	return num;
 
}
 

	
0 comments (0 inline, 0 general)