Bug 1656515 - Decompress multilocale.txt if necessary r=dthayer

Differential Revision: https://phabricator.services.mozilla.com/D86604
This commit is contained in:
James Willcox 2020-08-14 18:51:13 +00:00
Родитель ca92527f50
Коммит c5e63477e0
1 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -297,12 +297,24 @@ static bool GetGREFileContents(const char* aFilePath, nsCString* aOutString) {
// Look for the requested file in omnijar.
RefPtr<CacheAwareZipReader> zip = Omnijar::GetReader(Omnijar::GRE);
if (zip) {
uint32_t length;
const uint8_t* data = zip->GetData(aFilePath, &length);
if (!data) {
const auto item = zip->GetItem(aFilePath);
if (!item) {
return false;
}
aOutString->Assign(reinterpret_cast<const char*>(data), length);
MOZ_ASSERT(item->RealSize());
auto buf = MakeUnique<uint8_t[]>(item->RealSize());
CacheAwareZipCursor cursor(item, zip, buf.get(), item->RealSize());
uint32_t count;
uint8_t* data = cursor.Read(&count);
if (count != item->RealSize()) {
return false;
}
aOutString->Assign(reinterpret_cast<const char*>(data), count);
return true;
}