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; }
//---------------------------------------------------------------------------// void PathService::convertToAbsPath( String& szRelPath, bool bInResources /* = true */ ) { if( bInResources ) szRelPath = getResourcesPath() + szRelPath; else szRelPath = getExePath() + szRelPath; }
//---------------------------------------------------------------------------// String PathService::convertToAbsPath( const String& szRelPath, bool bInResources /* = true */ ) { if( bInResources ) return getResourcesPath() + szRelPath; else return getExePath() + szRelPath; }
//---------------------------------------------------------------------------// 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; }
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; }
boost::filesystem::path LootPaths::getL10nPath() { return getResourcesPath() / "l10n"; }