Пример #1
0
std::vector<std::pair<std::string, std::string>> getConversions()
{
    std::vector<std::pair<std::string, std::string>> result;
    char upperCase[20];
    char separator[20];
    char lowerCase[20];
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    ssize_t bufferSize = 0;
    //Load file from apk
    const char* charbuffer = reinterpret_cast<const char*>(FileUtils::getInstance()->getFileData("letters_conversion.txt", "r", &bufferSize));
    if (charbuffer) {
        int index = 0;
        while (sscanf(&charbuffer[index], "%20s %20s %20s", upperCase, separator, lowerCase) !=EOF)
        {
            result.push_back(std::pair<std::string, std::string>(upperCase, lowerCase));
            //3 => 2 spaces + backspace
            index += strlen(upperCase) + strlen(lowerCase) + strlen(separator) + 3;
        }
    }
#else
    FILE* file = fopen(getResourcesPath("letters_conversion.txt").c_str(), "r");
    if (file) {
        while (fscanf(file, "%s %s %s", upperCase, separator, lowerCase)!=EOF)
        {
            result.push_back(std::pair<std::string, std::string>(upperCase, lowerCase));
        }
        fclose(file);
    }
#endif
    return result;
}
Пример #2
0
//---------------------------------------------------------------------------//
  void PathService::convertToAbsPath( String& szRelPath, bool bInResources /* = true */ )
  {
    if( bInResources )
      szRelPath = getResourcesPath() + szRelPath;

    else
      szRelPath = getExePath() + szRelPath;
  }
Пример #3
0
//---------------------------------------------------------------------------//
  String PathService::convertToAbsPath( const String& szRelPath, bool bInResources /* = true */ )
  {
    if( bInResources )
      return getResourcesPath() + szRelPath;

    else
      return getExePath() + szRelPath;
  }
Пример #4
0
//---------------------------------------------------------------------------//
  String PathService::toRelPath(const String& _anAbsPath, bool _isInResources)
  {
    const String theAbsPart = _isInResources ? getResourcesPath() : getExePath();

    std::size_t thePosOfAbsPart = _anAbsPath.find(theAbsPart);

    if (thePosOfAbsPart != String::npos)
    {
      return _anAbsPath.substr(thePosOfAbsPart + theAbsPart.length());
    }

    return _anAbsPath;
  }
Пример #5
0
NS_FENNEX_BEGIN

std::vector<std::pair<std::string, std::string>>* getConversions()
{
    //Conversions is heavy, avoid copying it. There are 15695 pairs
    static std::vector<std::pair<std::string, std::string>>* result = NULL;
    if(result != NULL)
    {
        return result;
    }
    result = new std::vector<std::pair<std::string, std::string>>();
    char* upperCase = new char[20];
    char* separator = new char[20];
    char* lowerCase = new char[20];
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    ssize_t bufferSize = 0;
    //Load file from apk
    const char* charbuffer = reinterpret_cast<const char*>(FileUtils::getInstance()->getFileData("letters_conversion.txt", "r", &bufferSize));
    if (charbuffer) {
        int index = 0;
        while (sscanf(&charbuffer[index], "%20s %20s %20s", upperCase, separator, lowerCase) !=EOF)
        {
            result->push_back(std::pair<std::string, std::string>(upperCase, lowerCase));
            //3 => 2 spaces + backspace
            index += strlen(upperCase) + strlen(lowerCase) + strlen(separator) + 3;
        }
    }
#else
    FILE* file = fopen(getResourcesPath("letters_conversion.txt").c_str(), "r");
    if (file) {
        while (fscanf(file, "%s %s %s", upperCase, separator, lowerCase)!=EOF)
        {
            result->push_back(std::pair<std::string, std::string>(upperCase, lowerCase));
        }
        fclose(file);
    }
#endif
    delete[] upperCase;
    delete[] separator;
    delete[] lowerCase;
    return result;
}
Пример #6
0
boost::filesystem::path LootPaths::getL10nPath() {
  return getResourcesPath() / "l10n";
}