/* * LoadRscFiles: Load all the resource files with the given filespec. * Returns True iff any was loaded. */ Bool LoadRscFiles(char *filespec) { HANDLE hFindFile; WIN32_FIND_DATA file_info; char file_load_path[MAX_PATH + FILENAME_MAX], game_path[MAX_PATH]; GetGamePath( game_path ); sprintf(file_load_path,"%s%s\\%s", game_path, resource_dir, filespec); hFindFile = FindFirstFile(file_load_path, &file_info); if (hFindFile == INVALID_HANDLE_VALUE) return False; for(;;) { // Skip directories if (!(file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { /* Add subdirectory name, using file_load_path as temporary */ sprintf(file_load_path, "%s%s\\%s", game_path, resource_dir, file_info.cFileName); _RPT1(_CRT_WARN,"Loading File : %s\n",file_load_path); if (!RscFileLoad(file_load_path, RscAddCallback)) debug(("Can't load resource file %s\n", file_info.cFileName)); } if (FindNextFile(hFindFile, &file_info) == FALSE) break; } FindClose(hFindFile); return True; }
/* * LoadRsc: Loads the RESOURCE_RSC_SPEC files (.rsc or .rsb). */ void LoadRsc(void) { char file_load_path[MAX_PATH+FILENAME_MAX]; char *filespec = ConfigStr(RESOURCE_RSC_SPEC); char *filepath = ConfigStr(PATH_RSC); int files_loaded = 0; sprintf(file_load_path, "%s%s", filepath, filespec); StringVector files; if (FindMatchingFiles(file_load_path, &files)) { for (StringVector::iterator it = files.begin(); it != files.end(); ++it) { sprintf(file_load_path, "%s%s", filepath, it->c_str()); if (RscFileLoad(file_load_path, EachLoadRsc)) { if (stricmp(filespec, "*.rsb") == 0) LoadRSBHash(file_load_path); files_loaded++; } else eprintf("LoadRsc error loading %s\n", it->c_str()); } } dprintf("LoadRsc loaded %i of %i found %s files\n", files_loaded, files.size(), filespec); }
/* * LoadRscFiles: Read resources from given rsc files into global resources variable. * Return true on success. */ bool LoadRscFiles(int num_files, char **filenames) { int i; for (i=0; i < num_files; i++) if (!RscFileLoad(filenames[i], EachRscCallback)) { printf("Failure reading rsc file %s!\n", filenames[i]); return false; } return true; }
int main(int argc, char **argv) { int i; if (argc < 2) Usage(); num = 0; for (i=1; i < argc; i++) { printf("*** File %s\n", argv[i]); if (!RscFileLoad(argv[i], test_callback)) printf("Failure reading rsc file!\n"); } printf("Total: %d resources\n", num); }
/* * LoadRscFilesSorted: Load all the resource files with the given filespec, in * sorted filename order. * Returns True iff any was loaded. */ Bool LoadRscFilesSorted(char *filespec) { HANDLE hFindFile; WIN32_FIND_DATA file_info; char file_load_path[MAX_PATH + FILENAME_MAX], game_path[MAX_PATH]; list_type filenames, l; GetGamePath( game_path ); sprintf(file_load_path,"%s%s\\%s", game_path, resource_dir, filespec); hFindFile = FindFirstFile(file_load_path, &file_info); if (hFindFile == INVALID_HANDLE_VALUE) return False; filenames = NULL; for(;;) { // Skip directories if (!(file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) filenames = list_add_sorted_item(filenames, strdup(file_info.cFileName), CompareFilenames); if (FindNextFile(hFindFile, &file_info) == FALSE) break; } for (l = filenames; l != NULL; l = l->next) { /* Add subdirectory name, using file_load_path as temporary */ sprintf(file_load_path, "%s%s\\%s", game_path, resource_dir, (char *) (l->data)); _RPT1(_CRT_WARN,"Loading File : %s\n",file_load_path); if (!RscFileLoad((char *) file_load_path, RscAddCallback)) debug(("Can't load resource file %s\n", file_info.cFileName)); } FindClose(hFindFile); list_destroy(filenames); return True; }
void LoadRsc(void) { char file_load_path[MAX_PATH+FILENAME_MAX]; int files_loaded = 0; StringVector files; if (FindMatchingFiles(ConfigStr(PATH_RSC), RSC_EXTENSION, &files)) { for (StringVector::iterator it = files.begin(); it != files.end(); ++it) { sprintf(file_load_path,"%s%s",ConfigStr(PATH_RSC), it->c_str()); if (RscFileLoad(file_load_path,EachLoadRsc)) files_loaded++; else eprintf("LoadRsc error loading %s\n", it->c_str()); } } /* dprintf("LoadRsc loaded %i of %i found .rsc files\n",files_loaded,files.size()); */ }