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-13 15:01:42 +00:00
parent df36200714
commit 3b1e388971

View File

@ -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 data = MakeUnique<uint8_t[]>(item->RealSize());
CacheAwareZipCursor cursor(item, zip, data.get(), item->RealSize());
uint32_t count;
cursor.Read(&count);
if (count != item->RealSize()) {
return false;
}
aOutString->Assign(reinterpret_cast<const char*>(data.get()), count);
return true;
}