| 152 | } |
| 153 | |
| 154 | size_t DescriptionsCollector::FindPageAndFill(std::string const & path, descriptions::LangMeta & meta) |
| 155 | { |
| 156 | size_t size = 0; |
| 157 | if (path.empty() || !IsValidDir(path)) |
| 158 | return size; |
| 159 | |
| 160 | Platform::FilesList filelist; |
| 161 | Platform::GetFilesByExt(path, ".html", filelist); |
| 162 | for (auto const & filename : filelist) |
| 163 | { |
| 164 | auto const lang = base::FilenameWithoutExt(filename); |
| 165 | localisation::LanguageIndex const languageIndex = localisation::ConvertLanguageCodeToLanguageIndex(lang); |
| 166 | if (languageIndex == localisation::kUnsupportedLanguageIndex) |
| 167 | { |
| 168 | LOG(LWARNING, (languageIndex, "is an unsupported language.")); |
| 169 | continue; |
| 170 | } |
| 171 | |
| 172 | auto res = m_path2Index.try_emplace(base::JoinPath(path, filename), 0); |
| 173 | if (res.second) |
| 174 | { |
| 175 | auto const & filePath = res.first->first; |
| 176 | auto content = FillStringFromFile(filePath); |
| 177 | size_t const sz = content.size(); |
| 178 | if (sz == 0) |
| 179 | { |
| 180 | LOG(LWARNING, ("Empty descriptions file:", filePath)); |
| 181 | m_path2Index.erase(res.first); |
| 182 | continue; |
| 183 | } |
| 184 | |
| 185 | auto & strings = m_collection.m_strings; |
| 186 | res.first->second = strings.size(); |
| 187 | strings.push_back(std::move(content)); |
| 188 | |
| 189 | size += sz; |
| 190 | } |
| 191 | |
| 192 | m_stat.IncCode(languageIndex); |
| 193 | meta.emplace_back(languageIndex, res.first->second); |
| 194 | } |
| 195 | |
| 196 | return size; |
| 197 | } |
| 198 | |
| 199 | // static |
| 200 | void DescriptionsSectionBuilder::CollectAndBuild(std::string const & wikipediaDir, std::string const & mwmFile, |
nothing calls this directly
no test coverage detected