src/newgrf_config.cpp
changeset 7592 792daecf7c77
parent 7586 efc1a25de95e
child 7644 a7ff5c8ae47e
equal deleted inserted replaced
7591:06202df3799e 7592:792daecf7c77
    49 		size -= len;
    49 		size -= len;
    50 		md5_append(&md5state, buffer, len);
    50 		md5_append(&md5state, buffer, len);
    51 	}
    51 	}
    52 	md5_finish(&md5state, config->md5sum);
    52 	md5_finish(&md5state, config->md5sum);
    53 
    53 
    54 	fclose(f);
    54 	FioFCloseFile(f);
    55 
    55 
    56 	return true;
    56 	return true;
    57 }
    57 }
    58 
    58 
    59 
    59 
   354 	closedir(dir);
   354 	closedir(dir);
   355 
   355 
   356 	return num;
   356 	return num;
   357 }
   357 }
   358 
   358 
   359 bool FioTarFileListScanNewGRFCallback(const char *filename, int size, void *userdata)
   359 static uint ScanTar(TarFileList::iterator tar)
   360 {
   360 {
   361 	uint *num = (uint *)userdata;
   361 	uint num = 0;
       
   362 	const char *filename = (*tar).first.c_str();
   362 	const char *ext = strrchr(filename, '.');
   363 	const char *ext = strrchr(filename, '.');
   363 
   364 
   364 	/* If no extension or extension isn't .grf, skip the file */
   365 	/* If no extension or extension isn't .grf, skip the file */
   365 	if (ext == NULL) return false;
   366 	if (ext == NULL) return false;
   366 	if (strcasecmp(ext, ".grf") != 0) return false;
   367 	if (strcasecmp(ext, ".grf") != 0) return false;
   367 
   368 
   368 	if (ScanPathAddGrf(filename)) (*num)++;
   369 	if (ScanPathAddGrf(filename)) num++;
   369 
   370 
   370 	/* Always return false, as we don't want to stop with listing all the files */
       
   371 	return false;
       
   372 }
       
   373 
       
   374 static uint ScanTar(const char *filename)
       
   375 {
       
   376 	uint num = 0;
       
   377 
       
   378 	FioTarFileList(filename, "rb", NULL, FioTarFileListScanNewGRFCallback, &num);
       
   379 	return num;
   371 	return num;
   380 }
   372 }
   381 
   373 
   382 /* Scan for all NewGRFs */
   374 /* Scan for all NewGRFs */
   383 void ScanNewGRFFiles()
   375 void ScanNewGRFFiles()
   384 {
   376 {
   385 	Searchpath sp;
   377 	Searchpath sp;
   386 	char path[MAX_PATH];
   378 	char path[MAX_PATH];
   387 	const char *tar;
   379 	TarFileList::iterator tar;
   388 	uint num = 0;
   380 	uint num = 0;
   389 
   381 
   390 	ClearGRFConfigList(&_all_grfs);
   382 	ClearGRFConfigList(&_all_grfs);
   391 
   383 
   392 	DEBUG(grf, 1, "Scanning for NewGRFs");
   384 	DEBUG(grf, 1, "Scanning for NewGRFs");