Changeset - r16511:ee224126d104
[Not reviewed]
master
0 1 0
rubidium - 14 years ago 2010-11-18 22:26:29
rubidium@openttd.org
(svn r21247) -Fix: make the tar scanner forget about old (possibly removed) tars
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/fileio.cpp
Show inline comments
 
@@ -522,49 +522,53 @@ static void TarAddLink(const std::string
 
	}
 
}
 

	
 
void FioTarAddLink(const char *src, const char *dest)
 
{
 
	TarAddLink(src, dest);
 
}
 

	
 
/**
 
 * Simplify filenames from tars.
 
 * Replace '/' by PATHSEPCHAR, and force 'name' to lowercase.
 
 * @param name Filename to process.
 
 */
 
static void SimplifyFileName(char *name)
 
{
 
	/* Force lowercase */
 
	strtolower(name);
 

	
 
	/* Tar-files always have '/' path-seperator, but we want our PATHSEPCHAR */
 
#if (PATHSEPCHAR != '/')
 
	for (char *n = name; *n != '\0'; n++) if (*n == '/') *n = PATHSEPCHAR;
 
#endif
 
}
 

	
 
/* static */ uint TarScanner::DoScan() {
 
/* static */ uint TarScanner::DoScan()
 
{
 
	_tar_filelist.clear();
 
	_tar_list.clear();
 

	
 
	DEBUG(misc, 1, "Scanning for tars");
 
	TarScanner fs;
 
	uint num = fs.Scan(".tar", DATA_DIR, false);
 
	num += fs.Scan(".tar", AI_DIR, false);
 
	num += fs.Scan(".tar", AI_LIBRARY_DIR, false);
 
	num += fs.Scan(".tar", SCENARIO_DIR, false);
 
	DEBUG(misc, 1, "Scan complete, found %d files", num);
 
	return num;
 
}
 

	
 
bool TarScanner::AddFile(const char *filename, size_t basepath_length)
 
{
 
	/* The TAR-header, repeated for every file */
 
	typedef struct TarHeader {
 
		char name[100];      ///< Name of the file
 
		char mode[8];
 
		char uid[8];
 
		char gid[8];
 
		char size[12];       ///< Size of the file, in ASCII
 
		char mtime[12];
 
		char chksum[8];
 
		char typeflag;
 
		char linkname[100];
 
		char magic[6];
0 comments (0 inline, 0 general)