src/XPMPMultiplayer.cpp
/// Validate all required files are available in the resource directory
Validate all required files are available in the resource directory
Validate all required files are available in the resource directory
const char* XPMPValidateResourceFiles (const char* resourceDir)
{
    if (!resourceDir || strlen(resourceDir) < 5) {
        LOG_MSG(logERR, ERR_RSRC_DIR_INVALID, resourceDir ? resourceDir : "<nullptr>");
        return "resourceDir too short / nullptr";
    }
    glob.resourceDir = TOPOSIX(resourceDir);
    if (glob.resourceDir.back() == PATH_DELIM_STD)
        glob.resourceDir.pop_back();    
    if (!IsDir(glob.resourceDir)) {
        LOG_MSG(logERR, ERR_RSRC_DIR_UNAVAIL, glob.resourceDir.c_str());
        return "Resource directory unavailable";
    }
    glob.resourceDir += PATH_DELIM_STD;
    if (!FindResFile(RSRC_RELATED, glob.pathRelated))
        return "related.txt not found in resource directory";
    if (!FindResFile(RSRC_DOC8643, glob.pathDoc8643))
        return "Doc8643.txt not found in resource directory";
    if (!FindResFile(RSRC_MAP_ICONS, glob.pathMapIcons))
        return "MapIcons.png not found in resource directory";
    if (!FindResFile(RSRC_OBJ8DATAREFS, glob.pathObj8DataRefs, false) &&
        glob.bObjReplDataRefs) {
        LOG_MSG(logWARN, ERR_RSRC_FILE_UNAVAIL,
                RSRC_OBJ8DATAREFS, glob.resourceDir.c_str());
    }
    return "";
}
const char * XPMPValidateResourceFiles ( const char * resourceDir ) { if ( ! resourceDir || strlen ( resourceDir ) < 5 ) { LOG_MSG ( logERR , ERR_RSRC_DIR_INVALID , resourceDir ? resourceDir : " " ) ; return " " ; } glob . resourceDir = TOPOSIX ( resourceDir ) ; if ( glob . resourceDir . back ( ) == PATH_DELIM_STD ) glob . resourceDir . pop_back ( ) ; if ( ! IsDir ( glob . resourceDir ) ) { LOG_MSG ( logERR , ERR_RSRC_DIR_UNAVAIL , glob . resourceDir . c_str ( ) ) ; return " " ; } glob . resourceDir += PATH_DELIM_STD ; if ( ! FindResFile ( RSRC_RELATED , glob . pathRelated ) ) return " " ; if ( ! FindResFile ( RSRC_DOC8643 , glob . pathDoc8643 ) ) return " " ; if ( ! FindResFile ( RSRC_MAP_ICONS , glob . pathMapIcons ) ) return " " ; if ( ! FindResFile ( RSRC_OBJ8DATAREFS , glob . pathObj8DataRefs , false ) && glob . bObjReplDataRefs ) { LOG_MSG ( logWARN , ERR_RSRC_FILE_UNAVAIL , RSRC_OBJ8DATAREFS , glob . resourceDir . c_str ( ) ) ; } return " " ; }
Validate all required files are available in the resource directory
Validate all required files are available in the resource directory
// Store the resource dir // for path validation it must not end in the path separator // Check for its existence // now add a separator to the path for ease of future use // Validate and save a few files // this last one is not essentially required: // Success