Esempio n. 1
0
static void * FetchAndVerifyConfigFile(TCascStorage * hs, PQUERY_KEY pFileKey)
{
    TCHAR * szFileName;
    void * pvListFile = NULL;

    // Construct the local file name
    szFileName = CascNewStr(hs->szDataPath, 8 + 3 + 3 + 32);
    if(szFileName != NULL)
    {
        // Add the part where the config file path is
        AppendConfigFilePath(szFileName, pFileKey);

        // Load and verify the external listfile
        pvListFile = ListFile_OpenExternal(szFileName);
        if(pvListFile != NULL)
        {
            if(!ListFile_VerifyMD5(pvListFile, pFileKey->pbData))
            {
                ListFile_Free(pvListFile);
                pvListFile = NULL;
            }
        }

        // Free the file name
        CASC_FREE(szFileName);
    }

    return pvListFile;
}
Esempio n. 2
0
static int LoadTextFile(TCascStorage * hs, PARSEINFOFILE PfnParseProc)
{
    void * pvListFile;
    int nError = ERROR_FILE_NOT_FOUND;

    // Load the text file for line-to-line parsing
    pvListFile = ListFile_OpenExternal(hs->szBuildFile);
    if (pvListFile != NULL)
    {
        // Parse the text file
        nError = PfnParseProc(hs, pvListFile);
        ListFile_Free(pvListFile);
    }

    return nError;
}
Esempio n. 3
0
static int FetchAndLoadConfigFile(TCascStorage * hs, PQUERY_KEY pFileKey, PARSEINFOFILE PfnParseProc)
{
    TCHAR * szFileName;
    void * pvListFile = NULL;
    int nError = ERROR_CAN_NOT_COMPLETE;

    // Construct the local file name
    szFileName = CascNewStr(hs->szDataPath, 8 + 3 + 3 + 32);
    if (szFileName != NULL)
    {
        // Add the part where the config file path is
        AppendConfigFilePath(szFileName, pFileKey);

        // Load and verify the external listfile
        pvListFile = ListFile_OpenExternal(szFileName);
        if (pvListFile != NULL)
        {
            if (ListFile_VerifyMD5(pvListFile, pFileKey->pbData))
            {
                nError = PfnParseProc(hs, pvListFile);
            }
            else
            {
                nError = ERROR_FILE_CORRUPT;
            }
            ListFile_Free(pvListFile);
        }
        else
        {
            nError = ERROR_FILE_NOT_FOUND;
        }
        CASC_FREE(szFileName);
    }
    else
    {
        nError = ERROR_NOT_ENOUGH_MEMORY;
    }

    return nError;
}
Esempio n. 4
0
PLISTFILE_MAP ListFile_CreateMap(const TCHAR * szListFile)
{
    PLISTFILE_MAP pListMap = NULL;
    void * pvListFile;
    char szFileName[MAX_PATH+1];
    size_t nLength;

    // Only if the listfile name has been given
    if(szListFile != NULL)
    {
        // Create map for the listfile
        pListMap = ListMap_Create();
        if(pListMap != NULL)
        {
            // Open the external listfile
            pvListFile = ListFile_OpenExternal(szListFile);
            if(pvListFile != NULL)
            {
                // Go through the entire listfile and insert each name to the map
                while((nLength = ListFile_GetNext(pvListFile, "*", szFileName, MAX_PATH)) != 0)
                {
                    // Insert the file name to the map
                    pListMap = ListMap_InsertName(pListMap, szFileName, nLength);
                    if(pListMap == NULL)
                        break;
                }

                // Finish the listfile map
                pListMap = ListMap_Finish(pListMap);

                // Free the listfile
                ListFile_Free(pvListFile);
            }
        }
    }

    // Return the created map
    return pListMap;
}
Esempio n. 5
0
int LoadBuildInfo(TCascStorage * hs)
{
    TCHAR * szAgentFile;
    TCHAR * szInfoFile;
    void * pvListFile;
    bool bBuildConfigComplete = false;
    int nError = ERROR_SUCCESS;

    // Since HOTS build 30027, the game uses .build.info file for storage info
    if(bBuildConfigComplete == false)
    {
        szInfoFile = CombinePath(hs->szRootPath, _T(".build.info"));
        if(szInfoFile != NULL)
        {
            pvListFile = ListFile_OpenExternal(szInfoFile);
            if(pvListFile != NULL)
            {
                // Parse the info file
                nError = ParseInfoFile(hs, pvListFile);
                if(nError == ERROR_SUCCESS)
                    bBuildConfigComplete = true;
                
                ListFile_Free(pvListFile);
            }

            CASC_FREE(szInfoFile);
        }
    }

    // If the info file has not been loaded, try the legacy .build.db
    if(bBuildConfigComplete == false)
    {
        szAgentFile = CombinePath(hs->szRootPath, _T(".build.db"));
        if(szAgentFile != NULL)
        {
            pvListFile = ListFile_OpenExternal(szAgentFile);
            if(pvListFile != NULL)
            {
                nError = ParseAgentFile(hs, pvListFile);
                if(nError == ERROR_SUCCESS)
                    bBuildConfigComplete = true;

                ListFile_Free(pvListFile);
            }
            CASC_FREE(szAgentFile);
        }
    }

    // If the .build.info OR .build.db file has been loaded,
    // proceed with loading the CDN config file and CDN build file
    if(nError == ERROR_SUCCESS && bBuildConfigComplete)
    {
        // Load the configuration file
        pvListFile = FetchAndVerifyConfigFile(hs, &hs->CdnConfigKey);
        if(pvListFile != NULL)
        {
            nError = LoadCdnConfigFile(hs, pvListFile);
            ListFile_Free(pvListFile);
        }
        else
            nError = ERROR_FILE_NOT_FOUND;
    }

    // Load the build file
    if(nError == ERROR_SUCCESS && bBuildConfigComplete)
    {
        pvListFile = FetchAndVerifyConfigFile(hs, &hs->CdnBuildKey);
        if(pvListFile != NULL)
        {
            nError = LoadCdnBuildFile(hs, pvListFile);
            ListFile_Free(pvListFile);
        }
        else
            nError = ERROR_FILE_NOT_FOUND;
    }

    // Fill the index directory
    if(nError == ERROR_SUCCESS)
    {
        // First, check for more common "data" subdirectory
        if((hs->szIndexPath = CheckForIndexDirectory(hs, _T("data"))) != NULL)
            return ERROR_SUCCESS;

        // Second, try the "darch" subdirectory (older builds of HOTS - Alpha)
        if((hs->szIndexPath = CheckForIndexDirectory(hs, _T("darch"))) != NULL)
            return ERROR_SUCCESS;

        nError = ERROR_FILE_NOT_FOUND;
    }

    return nError;
}
Esempio n. 6
0
int LoadBuildInfo(TCascStorage * hs)
{
    PARSEINFOFILE PfnParseProc = NULL;
    void * pvListFile;
    int nError = ERROR_SUCCESS;

    switch(hs->BuildFileType)
    {
        case CascBuildInfo:
            PfnParseProc = ParseFile_BuildInfo;
            break;

        case CascBuildDb:
            PfnParseProc = ParseFile_BuildDb;
            break;

        default:
            nError = ERROR_NOT_SUPPORTED;
            break;
    }

    // Parse the appropriate build file
    if(nError == ERROR_SUCCESS)
    {
        pvListFile = ListFile_OpenExternal(hs->szBuildFile);
        if(pvListFile != NULL)
        {
            // Parse the info file
            nError = PfnParseProc(hs, pvListFile);
            ListFile_Free(pvListFile);
        }
        else
            nError = ERROR_FILE_NOT_FOUND;
    }

    // If the .build.info OR .build.db file has been loaded,
    // proceed with loading the CDN config file and CDN build file
    if(nError == ERROR_SUCCESS)
    {
        // Load the configuration file
        pvListFile = FetchAndVerifyConfigFile(hs, &hs->CdnConfigKey);
        if(pvListFile != NULL)
        {
            nError = LoadCdnConfigFile(hs, pvListFile);
            ListFile_Free(pvListFile);
        }
        else
            nError = ERROR_FILE_NOT_FOUND;
    }

    // Load the build file
    if(nError == ERROR_SUCCESS)
    {
        pvListFile = FetchAndVerifyConfigFile(hs, &hs->CdnBuildKey);
        if(pvListFile != NULL)
        {
            nError = LoadCdnBuildFile(hs, pvListFile);
            ListFile_Free(pvListFile);
        }
        else
            nError = ERROR_FILE_NOT_FOUND;
    }

    // Fill the index directory
    if(nError == ERROR_SUCCESS)
    {
        // First, check for more common "data" subdirectory
        if((hs->szIndexPath = CheckForIndexDirectory(hs, _T("data"))) != NULL)
            return ERROR_SUCCESS;

        // Second, try the "darch" subdirectory (older builds of HOTS - Alpha)
        if((hs->szIndexPath = CheckForIndexDirectory(hs, _T("darch"))) != NULL)
            return ERROR_SUCCESS;

        nError = ERROR_FILE_NOT_FOUND;
    }

    return nError;
}