bool VirtualKeyboard::openPack(const String &packName, const FSNode &node) { if (node.getChild(packName + ".xml").exists()) { _fileArchive = new FSDirectory(node, 1); // uncompressed keyboard pack if (!_parser->loadFile(node.getChild(packName + ".xml"))) { delete _fileArchive; _fileArchive = 0; return false; } return true; } if (node.getChild(packName + ".zip").exists()) { // compressed keyboard pack _fileArchive = makeZipArchive(node.getChild(packName + ".zip")); if (_fileArchive && _fileArchive->hasFile(packName + ".xml")) { if (!_parser->loadStream(_fileArchive->createReadStreamForMember(packName + ".xml"))) { delete _fileArchive; _fileArchive = 0; return false; } } else { warning("Could not find %s.xml file in %s.zip keyboard pack", packName.c_str(), packName.c_str()); delete _fileArchive; _fileArchive = 0; return false; } return true; } return false; }
bool TranslationManager::openTranslationsFile(const FSNode &node, File &inFile, int depth) { if (!node.exists() || !node.isReadable() || !node.isDirectory()) return false; // Check if we can find the file in this directory // Since File::open(FSNode) makes all the needed tests, it is not really // necessary to make them here. But it avoid printing warnings. FSNode fileNode = node.getChild("translations.dat"); if (fileNode.exists() && fileNode.isReadable() && !fileNode.isDirectory()) { if (inFile.open(fileNode)) { if (checkHeader(inFile)) return true; inFile.close(); } } // Check if we exceeded the given recursion depth if (depth - 1 == -1) return false; // Otherwise look for it in sub-directories FSList fileList; if (!node.getChildren(fileList, FSNode::kListDirectoriesOnly)) return false; for (FSList::iterator i = fileList.begin(); i != fileList.end(); ++i) { if (openTranslationsFile(*i, inFile, depth == -1 ? - 1 : depth - 1)) return true; } // Not found in this directory or its sub-directories return false; }