/* Complete filename via path cache */ bool completeFilenamePC(const char *filename, FileSystem::FileType type, char *outBuffer, size_t outN, const char **foundExt) { size_t i; char lowCase[512]; for (i = 0; i < sizeof(lowCase)-1 && filename[i]; ++i) lowCase[i] = tolower(filename[i]); lowCase[i] = '\0'; std::string key; const std::vector<std::string> &extList = extensions[type]; for (size_t i = 0; i < extList.size(); ++i) { const char *ext = extList[i].c_str(); snprintf(outBuffer, outN, "%s.%s", lowCase, ext); key = outBuffer; if (pathCache.contains(key)) { strncpy(outBuffer, pathCache[key].c_str(), outN); if (foundExt) *foundExt = ext; return true; } } key = lowCase; if (pathCache.contains(key)) { strncpy(outBuffer, pathCache[key].c_str(), outN); if (foundExt) *foundExt = findExt(filename); return true; } return false; }
bool completeFilenamePC(const char *filepath, char *outBuffer, size_t outN) { std::string lowCase(filepath); for (size_t i = 0; i < lowCase.size(); ++i) lowCase[i] = tolower(lowCase[i]); if (!pathCache.contains(lowCase)) return false; const std::string &fullPath = pathCache[lowCase]; strcpySafe(outBuffer, fullPath.c_str(), outN, fullPath.size()); return true; }
bool contains(T value) { return hash.contains(value); }