コード例 #1
0
// ZZZ new function finds any or all default files at once.
// default file is now the first matching file of correct type (no more "Map", "Shapes", "Sounds", etc.)
void get_default_file_specs(FileSpecifier* outMapSpec, FileSpecifier* outShapesSpec, FileSpecifier* outSoundsSpec, FileSpecifier* outPhysicsSpec)
{
    for(int i = 0; i < NUMBER_OF_FILE_TYPECODES_TO_FIND; i++)
    {
        file_types_to_find[i].type = file_typecodes_to_find[i];

        // Set up to find what the caller is looking for (anything not NULL)
        switch(file_types_to_find[i].type)
        {
        case _typecode_scenario:
            file_types_to_find[i].output_file = outMapSpec;
            break;
        case _typecode_shapes:
            file_types_to_find[i].output_file = outShapesSpec;
            break;
        case _typecode_sounds:
            file_types_to_find[i].output_file = outSoundsSpec;
            break;
        case _typecode_physics:
            file_types_to_find[i].output_file = outPhysicsSpec;
            break;
        default:
            assert(false);
            break;
        }

        file_types_to_find[i].found = (file_types_to_find[i].output_file == NULL);
    }

    // Do the search
    DirectorySpecifier BaseDir;
    Files_GetRootDirectory(BaseDir);
    search_from_directory(BaseDir);

    // Write out the results and determine whether we found the required files.
    bool FoundAllRequired = true;
    for(int i = 0; i < NUMBER_OF_FILE_TYPECODES_TO_FIND; i++)
    {
        if(file_types_to_find[i].found)
        {
            if(file_types_to_find[i].output_file != NULL)
                *(file_types_to_find[i].output_file) = file_types_to_find[i].file;
        }
        else
        {
            // We don't care if we don't find physics file
            if(file_types_to_find[i].type != _typecode_physics)
                FoundAllRequired = false;
        }
    }

    if(!FoundAllRequired)
    {
        // This will also exit the application.
        alert_user(fatalError, strERRORS, badExtraFileLocations, fnfErr);
    }
}
コード例 #2
0
bool find_file_with_modification_date(
  FileSpecifier& MatchingFile,
  Typecode file_type,
  short path_resource_id,
  TimeType modification_date)
{
  bool file_matched= false;

  /* Look for the files in the same directory that we are in.. */
  // LP: for now, will only care about looking in the Marathon app's directory
  DirectorySpecifier BaseDir;
  Files_GetRootDirectory(BaseDir);
  file_matched=
    find_file_with_modification_date_in_directory(MatchingFile, BaseDir,
                                                  file_type,
                                                  modification_date);

  return file_matched;
}
コード例 #3
0
/* Search all the directories in the path.. */
bool find_wad_file_that_has_checksum(
  FileSpecifier& MatchingFile,
  Typecode file_type,
  short path_resource_id,
  uint32 checksum)
{
  bool file_matched= false;

  /* Look for the files in the same directory that we are in.. */

  // LP: for now, will only care about looking in the Marathon app's directory
  DirectorySpecifier BaseDir;
  Files_GetRootDirectory(BaseDir);
  file_matched=
    find_wad_file_with_checksum_in_directory(MatchingFile, BaseDir,file_type,
                                             checksum);

  return file_matched;
}