Example #1
0
bool   ParseCache::write()
{
    LOGI("writeCache [" << _cacheFile);

    std::string text = "<?xml version=\"1.0\" encoding=\"UTF - 8\"?>\n\n";
    for (int i = SL_NORMAL + 1; i < SL_END; i++)
    {
        std::string md5;
        if (i != SL_XML)
        {
            md5 = genFileMD5(_configPath + "/" + SupportLanguageFilePath[i] + "/" + _configFileName + SupportLanguageFileSuffix[i]);
        }
        else
        {
            md5 = genFileMD5(_configPath + "/" + _configFileName + SupportLanguageFileSuffix[i]);
        }
        text += std::string() + "<" + SupportLanguageString[i] + ">";
        text += md5;
        text += std::string() + "</" + SupportLanguageString[i] + ">" + LFCR;
    }
    
    text += "<cacheNumber>\n";

    for (auto &pr : _cacheNumber)
    {
        text += "    <cache key = \"" + pr.first +"\" Number = \"" + toString(pr.second) + "\" /> \n";
    }
    text += "</cacheNumber>\n";
    if (writeFileContent(_cacheFile, text.c_str(), text.length(), false) != text.length())
    {
        LOGE("write cache file error. filename=" << _cacheFile);
    }
    return true;
}
Example #2
0
bool ParseCache::isNeedUpdate()
{
    for (int i = SL_NORMAL+1; i < SL_END; i++)
    {
        if (_md5Cache[i].empty())
        {
            return true;
        }
        std::string md5;
        if (i != SL_XML)
        {
            md5 = genFileMD5(_configPath + "/" + SupportLanguageFilePath[i] + "/" + _configFileName + SupportLanguageFileSuffix[i]);
        }
        else
        {
            md5 = genFileMD5(_configPath + "/" + _configFileName + SupportLanguageFileSuffix[i]);
        }
        
        if (md5 != _md5Cache[i])
        {
            return true;
        }
    }
    return false;
}
Example #3
0
bool   ParseCache::write()
{
    std::string filename = _fileName + ".xml.cache";
    LOGI("writeCache [" << filename );
    std::ofstream os;
    os.open(filename, std::ios::binary);
    if (!os.is_open())
    {
        E(filename << " can not open!.");
    }
    std::string text = "<?xml version=\"1.0\" encoding=\"UTF - 8\"?>\n\n";
    for (int i = SL_NORMAL + 1; i < SL_END; i++)
    {
        std::string md5 = genFileMD5(std::string("./") + SupportLanguageFilePath[i] + "/" + _fileName + SupportLanguageFileSuffix[i]);
        text += std::string() + "<" + SupportLanguageString[i] + ">";
        text += md5;
        text += std::string() + "</" + SupportLanguageString[i] + ">" + LFCR;
    }
    
    text += "<cacheNumber>\n";

    for (auto &pr : _cacheNumber)
    {
        text += "    <cache key = \"" + pr.first +"\" Number = \"" + boost::lexical_cast<std::string>(pr.second) + "\" /> \n";
    }
    text += "</cacheNumber>\n";
    os.write(text.c_str(), text.length());
    os.close();
    return true;
}
Example #4
0
bool ParseCache::isNeedUpdate()
{
    for (int i = SL_NORMAL+1; i < SL_END; i++)
    {
        if (_md5Cache[i].empty())
        {
            return true;
        }
        std::string md5 = genFileMD5(std::string("./") + SupportLanguageFilePath[i] + _fileName + SupportLanguageFileSuffix[i]);
        if (md5 != _md5Cache[i])
        {
            return true;
        }
    }
    return false;
}