forked from mirrors/gecko-dev
Bug 1940027 - Use nsACString in jar code a=dmeehan
Differential Revision: https://phabricator.services.mozilla.com/D237704
This commit is contained in:
parent
9e1c0c56f8
commit
7ab72cf96a
14 changed files with 64 additions and 60 deletions
|
|
@ -4165,7 +4165,7 @@ nsresult ArrayBufferBuilder::MapToFileInPackage(const nsCString& aFile,
|
||||||
if (!zip) {
|
if (!zip) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
nsZipItem* zipItem = zip->GetItem(aFile.get());
|
nsZipItem* zipItem = zip->GetItem(aFile);
|
||||||
if (!zipItem) {
|
if (!zipItem) {
|
||||||
return NS_ERROR_FILE_NOT_FOUND;
|
return NS_ERROR_FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ already_AddRefed<SharedFTFace> FT2FontEntry::GetFTFace(bool aCommit) {
|
||||||
RefPtr<SharedFTFace> face;
|
RefPtr<SharedFTFace> face;
|
||||||
if (mFilename[0] != '/') {
|
if (mFilename[0] != '/') {
|
||||||
RefPtr<nsZipArchive> reader = Omnijar::GetReader(Omnijar::Type::GRE);
|
RefPtr<nsZipArchive> reader = Omnijar::GetReader(Omnijar::Type::GRE);
|
||||||
nsZipItem* item = reader->GetItem(mFilename.get());
|
nsZipItem* item = reader->GetItem(mFilename);
|
||||||
NS_ASSERTION(item, "failed to find zip entry");
|
NS_ASSERTION(item, "failed to find zip entry");
|
||||||
|
|
||||||
uint32_t bufSize = item->RealSize();
|
uint32_t bufSize = item->RealSize();
|
||||||
|
|
@ -468,7 +468,7 @@ hb_face_t* FT2FontEntry::CreateHBFace() const {
|
||||||
// A relative path means an omnijar resource, which we may need to
|
// A relative path means an omnijar resource, which we may need to
|
||||||
// decompress to a temporary buffer.
|
// decompress to a temporary buffer.
|
||||||
RefPtr<nsZipArchive> reader = Omnijar::GetReader(Omnijar::Type::GRE);
|
RefPtr<nsZipArchive> reader = Omnijar::GetReader(Omnijar::Type::GRE);
|
||||||
nsZipItem* item = reader->GetItem(mFilename.get());
|
nsZipItem* item = reader->GetItem(mFilename);
|
||||||
MOZ_ASSERT(item, "failed to find zip entry");
|
MOZ_ASSERT(item, "failed to find zip entry");
|
||||||
if (item) {
|
if (item) {
|
||||||
// TODO(jfkthame):
|
// TODO(jfkthame):
|
||||||
|
|
@ -1507,7 +1507,7 @@ void gfxFT2FontList::AppendFacesFromOmnijarEntry(nsZipArchive* aArchive,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsZipItem* item = aArchive->GetItem(aEntryName.get());
|
nsZipItem* item = aArchive->GetItem(aEntryName);
|
||||||
NS_ASSERTION(item, "failed to find zip entry");
|
NS_ASSERTION(item, "failed to find zip entry");
|
||||||
|
|
||||||
uint32_t bufSize = item->RealSize();
|
uint32_t bufSize = item->RealSize();
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ static const void* GetItemPtrFromJarURI(nsIJARURI* aJAR, uint32_t* aLength) {
|
||||||
if (archive) {
|
if (archive) {
|
||||||
nsCString path;
|
nsCString path;
|
||||||
aJAR->GetJAREntry(path);
|
aJAR->GetJAREntry(path);
|
||||||
nsZipItem* item = archive->GetItem(path.get());
|
nsZipItem* item = archive->GetItem(path);
|
||||||
if (item && item->Compression() == 0 && item->Size() > 0) {
|
if (item && item->Compression() == 0 && item->Size() > 0) {
|
||||||
// We do NOT own this data, but it won't go away until the omnijar
|
// We do NOT own this data, but it won't go away until the omnijar
|
||||||
// file is closed during shutdown.
|
// file is closed during shutdown.
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ static bool GetGREFileContents(const char* aFilePath, nsCString* aOutString) {
|
||||||
// Look for the requested file in omnijar.
|
// Look for the requested file in omnijar.
|
||||||
RefPtr<nsZipArchive> zip = Omnijar::GetReader(Omnijar::GRE);
|
RefPtr<nsZipArchive> zip = Omnijar::GetReader(Omnijar::GRE);
|
||||||
if (zip) {
|
if (zip) {
|
||||||
nsZipItemPtr<char> item(zip, aFilePath);
|
nsZipItemPtr<char> item(zip, nsDependentCString(aFilePath));
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -402,7 +402,7 @@ void URLPreloader::BackgroundReadFiles() {
|
||||||
entry->TypeString(), entry->mPath.get());
|
entry->TypeString(), entry->mPath.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto item = zip->GetItem(entry->mPath.get());
|
auto item = zip->GetItem(entry->mPath);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
entry->mResultCode = NS_ERROR_FILE_NOT_FOUND;
|
entry->mResultCode = NS_ERROR_FILE_NOT_FOUND;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -567,7 +567,7 @@ Result<nsCString, nsresult> URLPreloader::ReadURIInternal(nsIURI* uri,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not an Omnijar archive, so just read it directly.
|
// Not an Omnijar archive, so just read it directly.
|
||||||
FileLocation location(zip, PromiseFlatCString(path).BeginReading());
|
FileLocation location(zip, path);
|
||||||
return URLEntry::ReadLocation(location);
|
return URLEntry::ReadLocation(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -636,7 +636,7 @@ Result<FileLocation, nsresult> URLPreloader::CacheKey::ToFileLocation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<nsZipArchive> zip = Archive();
|
RefPtr<nsZipArchive> zip = Archive();
|
||||||
return FileLocation(zip, mPath.get());
|
return FileLocation(zip, mPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<nsCString, nsresult> URLPreloader::URLEntry::Read() {
|
Result<nsCString, nsresult> URLPreloader::URLEntry::Read() {
|
||||||
|
|
|
||||||
|
|
@ -135,8 +135,7 @@ nsJAR::OpenInner(nsIZipReader* aZipReader, const nsACString& aZipEntry) {
|
||||||
{
|
{
|
||||||
nsJAR* outerJAR = static_cast<nsJAR*>(aZipReader);
|
nsJAR* outerJAR = static_cast<nsJAR*>(aZipReader);
|
||||||
RecursiveMutexAutoLock outerLock(outerJAR->mLock);
|
RecursiveMutexAutoLock outerLock(outerJAR->mLock);
|
||||||
rv = nsZipHandle::Init(outerJAR->mZip.get(),
|
rv = nsZipHandle::Init(outerJAR->mZip.get(), aZipEntry,
|
||||||
PromiseFlatCString(aZipEntry).get(),
|
|
||||||
getter_AddRefs(handle));
|
getter_AddRefs(handle));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
@ -191,8 +190,7 @@ nsJAR::Test(const nsACString& aEntryName) {
|
||||||
if (!mZip) {
|
if (!mZip) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
return mZip->Test(
|
return mZip->Test(aEntryName);
|
||||||
aEntryName.IsEmpty() ? nullptr : PromiseFlatCString(aEntryName).get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
@ -205,7 +203,7 @@ nsJAR::Extract(const nsACString& aEntryName, nsIFile* outFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(("Extract[%p] %s", this, PromiseFlatCString(aEntryName).get()));
|
LOG(("Extract[%p] %s", this, PromiseFlatCString(aEntryName).get()));
|
||||||
nsZipItem* item = mZip->GetItem(PromiseFlatCString(aEntryName).get());
|
nsZipItem* item = mZip->GetItem(aEntryName);
|
||||||
NS_ENSURE_TRUE(item, NS_ERROR_FILE_NOT_FOUND);
|
NS_ENSURE_TRUE(item, NS_ERROR_FILE_NOT_FOUND);
|
||||||
|
|
||||||
// Remove existing file or directory so we set permissions correctly.
|
// Remove existing file or directory so we set permissions correctly.
|
||||||
|
|
@ -245,7 +243,7 @@ nsJAR::GetEntry(const nsACString& aEntryName, nsIZipEntry** result) {
|
||||||
if (!mZip) {
|
if (!mZip) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
nsZipItem* zipItem = mZip->GetItem(PromiseFlatCString(aEntryName).get());
|
nsZipItem* zipItem = mZip->GetItem(aEntryName);
|
||||||
NS_ENSURE_TRUE(zipItem, NS_ERROR_FILE_NOT_FOUND);
|
NS_ENSURE_TRUE(zipItem, NS_ERROR_FILE_NOT_FOUND);
|
||||||
|
|
||||||
nsJARItem* jarItem = new nsJARItem(zipItem);
|
nsJARItem* jarItem = new nsJARItem(zipItem);
|
||||||
|
|
@ -261,7 +259,7 @@ nsJAR::HasEntry(const nsACString& aEntryName, bool* result) {
|
||||||
if (!mZip) {
|
if (!mZip) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
*result = mZip->GetItem(PromiseFlatCString(aEntryName).get()) != nullptr;
|
*result = mZip->GetItem(aEntryName) != nullptr;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -300,7 +298,7 @@ nsJAR::GetInputStream(const nsACString& aEntryName, nsIInputStream** result) {
|
||||||
const nsCString& entry = PromiseFlatCString(aEntryName);
|
const nsCString& entry = PromiseFlatCString(aEntryName);
|
||||||
if (*entry.get()) {
|
if (*entry.get()) {
|
||||||
// First check if item exists in jar
|
// First check if item exists in jar
|
||||||
item = mZip->GetItem(entry.get());
|
item = mZip->GetItem(entry);
|
||||||
if (!item) return NS_ERROR_FILE_NOT_FOUND;
|
if (!item) return NS_ERROR_FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
nsJARInputStream* jis = new nsJARInputStream();
|
nsJARInputStream* jis = new nsJARInputStream();
|
||||||
|
|
|
||||||
|
|
@ -342,7 +342,8 @@ nsresult nsJARInputStream::ReadDirectory(char* aBuffer, uint32_t aCount,
|
||||||
|
|
||||||
const char* entryName = mArray[mArrPos].get();
|
const char* entryName = mArray[mArrPos].get();
|
||||||
uint32_t entryNameLen = mArray[mArrPos].Length();
|
uint32_t entryNameLen = mArray[mArrPos].Length();
|
||||||
nsZipItem* ze = mJar->mZip->GetItem(entryName);
|
nsZipItem* ze = mJar->mZip->GetItem(
|
||||||
|
nsDependentCString(mArray[mArrPos].get(), mArray[mArrPos].Length()));
|
||||||
NS_ENSURE_TRUE(ze, NS_ERROR_FILE_NOT_FOUND);
|
NS_ENSURE_TRUE(ze, NS_ERROR_FILE_NOT_FOUND);
|
||||||
|
|
||||||
// Last Modified Time
|
// Last Modified Time
|
||||||
|
|
|
||||||
|
|
@ -237,12 +237,12 @@ nsresult nsZipHandle::Init(nsIFile* file, nsZipHandle** ret, PRFileDesc** aFd) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsZipHandle::Init(nsZipArchive* zip, const char* entry,
|
nsresult nsZipHandle::Init(nsZipArchive* zip, const nsACString& entry,
|
||||||
nsZipHandle** ret) {
|
nsZipHandle** ret) {
|
||||||
RefPtr<nsZipHandle> handle = new nsZipHandle();
|
RefPtr<nsZipHandle> handle = new nsZipHandle();
|
||||||
if (!handle) return NS_ERROR_OUT_OF_MEMORY;
|
if (!handle) return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
LOG(("ZipHandle::Init entry %s", entry));
|
LOG(("ZipHandle::Init entry %s", PromiseFlatCString(entry).get()));
|
||||||
|
|
||||||
nsZipItem* item = zip->GetItem(entry);
|
nsZipItem* item = zip->GetItem(entry);
|
||||||
if (item && item->Compression() == DEFLATED &&
|
if (item && item->Compression() == DEFLATED &&
|
||||||
|
|
@ -414,10 +414,10 @@ already_AddRefed<nsZipArchive> nsZipArchive::OpenArchive(nsIFile* aFile) {
|
||||||
//---------------------------------------------
|
//---------------------------------------------
|
||||||
// nsZipArchive::Test
|
// nsZipArchive::Test
|
||||||
//---------------------------------------------
|
//---------------------------------------------
|
||||||
nsresult nsZipArchive::Test(const char* aEntryName) {
|
nsresult nsZipArchive::Test(const nsACString& aEntryName) {
|
||||||
nsZipItem* currItem;
|
nsZipItem* currItem;
|
||||||
|
|
||||||
if (aEntryName) // only test specified item
|
if (aEntryName.Length()) // only test specified item
|
||||||
{
|
{
|
||||||
currItem = GetItem(aEntryName);
|
currItem = GetItem(aEntryName);
|
||||||
if (!currItem) return NS_ERROR_FILE_NOT_FOUND;
|
if (!currItem) return NS_ERROR_FILE_NOT_FOUND;
|
||||||
|
|
@ -442,12 +442,13 @@ nsresult nsZipArchive::Test(const char* aEntryName) {
|
||||||
//---------------------------------------------
|
//---------------------------------------------
|
||||||
// nsZipArchive::GetItem
|
// nsZipArchive::GetItem
|
||||||
//---------------------------------------------
|
//---------------------------------------------
|
||||||
nsZipItem* nsZipArchive::GetItem(const char* aEntryName) {
|
nsZipItem* nsZipArchive::GetItem(const nsACString& aEntryName) {
|
||||||
MutexAutoLock lock(mLock);
|
MutexAutoLock lock(mLock);
|
||||||
|
|
||||||
LOG(("ZipHandle::GetItem[%p] %s", this, aEntryName));
|
LOG(("ZipHandle::GetItem[%p] %s", this,
|
||||||
if (aEntryName) {
|
PromiseFlatCString(aEntryName).get()));
|
||||||
uint32_t len = strlen(aEntryName);
|
if (aEntryName.Length()) {
|
||||||
|
uint32_t len = aEntryName.Length();
|
||||||
//-- If the request is for a directory, make sure that synthetic entries
|
//-- If the request is for a directory, make sure that synthetic entries
|
||||||
//-- are created for the directories without their own entry.
|
//-- are created for the directories without their own entry.
|
||||||
if (!mBuiltSynthetics) {
|
if (!mBuiltSynthetics) {
|
||||||
|
|
@ -456,14 +457,14 @@ nsZipItem* nsZipArchive::GetItem(const char* aEntryName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MMAP_FAULT_HANDLER_BEGIN_HANDLE(mFd)
|
MMAP_FAULT_HANDLER_BEGIN_HANDLE(mFd)
|
||||||
nsZipItem* item = mFiles[HashName(aEntryName, len)];
|
nsZipItem* item = mFiles[HashName(aEntryName.BeginReading(), len)];
|
||||||
while (item) {
|
while (item) {
|
||||||
if ((len == item->nameLength) &&
|
if ((len == item->nameLength) &&
|
||||||
(!memcmp(aEntryName, item->Name(), len))) {
|
(!memcmp(aEntryName.BeginReading(), item->Name(), len))) {
|
||||||
// Successful GetItem() is a good indicator that the file is about to be
|
// Successful GetItem() is a good indicator that the file is about to be
|
||||||
// read
|
// read
|
||||||
if (mUseZipLog && mURI.Length()) {
|
if (mUseZipLog && mURI.Length()) {
|
||||||
zipLog.Write(mURI, aEntryName);
|
zipLog.Write(mURI, aEntryName.BeginReading());
|
||||||
}
|
}
|
||||||
return item; //-- found it
|
return item; //-- found it
|
||||||
}
|
}
|
||||||
|
|
@ -1202,8 +1203,8 @@ uint8_t* nsZipCursor::ReadOrCopy(uint32_t* aBytesRead, bool aCopy) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsZipItemPtr_base::nsZipItemPtr_base(nsZipArchive* aZip, const char* aEntryName,
|
nsZipItemPtr_base::nsZipItemPtr_base(nsZipArchive* aZip,
|
||||||
bool doCRC)
|
const nsACString& aEntryName, bool doCRC)
|
||||||
: mReturnBuf(nullptr), mReadlen(0) {
|
: mReturnBuf(nullptr), mReadlen(0) {
|
||||||
// make sure the ziparchive hangs around
|
// make sure the ziparchive hangs around
|
||||||
mZipHandle = aZip->GetFD();
|
mZipHandle = aZip->GetFD();
|
||||||
|
|
|
||||||
|
|
@ -116,14 +116,14 @@ class nsZipArchive final {
|
||||||
*
|
*
|
||||||
* @return status code
|
* @return status code
|
||||||
*/
|
*/
|
||||||
nsresult Test(const char* aEntryName);
|
nsresult Test(const nsACString& aEntryName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetItem
|
* GetItem
|
||||||
* @param aEntryName Name of file in the archive
|
* @param aEntryName Name of file in the archive
|
||||||
* @return pointer to nsZipItem
|
* @return pointer to nsZipItem
|
||||||
*/
|
*/
|
||||||
nsZipItem* GetItem(const char* aEntryName);
|
nsZipItem* GetItem(const nsACString& aEntryName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ExtractFile
|
* ExtractFile
|
||||||
|
|
@ -303,7 +303,8 @@ class nsZipItemPtr_base {
|
||||||
* @param aEntryName Archive membername
|
* @param aEntryName Archive membername
|
||||||
* @param doCRC When set to true Read() will check crc
|
* @param doCRC When set to true Read() will check crc
|
||||||
*/
|
*/
|
||||||
nsZipItemPtr_base(nsZipArchive* aZip, const char* aEntryName, bool doCRC);
|
nsZipItemPtr_base(nsZipArchive* aZip, const nsACString& aEntryName,
|
||||||
|
bool doCRC);
|
||||||
|
|
||||||
uint32_t Length() const { return mReadlen; }
|
uint32_t Length() const { return mReadlen; }
|
||||||
|
|
||||||
|
|
@ -321,7 +322,8 @@ class nsZipItemPtr final : public nsZipItemPtr_base {
|
||||||
" a number of assumptions.");
|
" a number of assumptions.");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
nsZipItemPtr(nsZipArchive* aZip, const char* aEntryName, bool doCRC = false)
|
nsZipItemPtr(nsZipArchive* aZip, const nsACString& aEntryName,
|
||||||
|
bool doCRC = false)
|
||||||
: nsZipItemPtr_base(aZip, aEntryName, doCRC) {}
|
: nsZipItemPtr_base(aZip, aEntryName, doCRC) {}
|
||||||
/**
|
/**
|
||||||
* @return buffer containing the whole zip member or nullptr on error.
|
* @return buffer containing the whole zip member or nullptr on error.
|
||||||
|
|
@ -363,7 +365,8 @@ class nsZipHandle final {
|
||||||
public:
|
public:
|
||||||
static nsresult Init(nsIFile* file, nsZipHandle** ret,
|
static nsresult Init(nsIFile* file, nsZipHandle** ret,
|
||||||
PRFileDesc** aFd = nullptr);
|
PRFileDesc** aFd = nullptr);
|
||||||
static nsresult Init(nsZipArchive* zip, const char* entry, nsZipHandle** ret);
|
static nsresult Init(nsZipArchive* zip, const nsACString& entry,
|
||||||
|
nsZipHandle** ret);
|
||||||
static nsresult Init(const uint8_t* aData, uint32_t aLen, nsZipHandle** aRet);
|
static nsresult Init(const uint8_t* aData, uint32_t aLen, nsZipHandle** aRet);
|
||||||
|
|
||||||
NS_METHOD_(MozExternalRefCountType) AddRef(void);
|
NS_METHOD_(MozExternalRefCountType) AddRef(void);
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ static Result<FileLocation, nsresult> GetFileLocation(nsIURI* uri) {
|
||||||
|
|
||||||
MOZ_TRY_VAR(file, GetFile(fileURI));
|
MOZ_TRY_VAR(file, GetFile(fileURI));
|
||||||
|
|
||||||
location.Init(file, entry.get());
|
location.Init(file, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::move(location);
|
return std::move(location);
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@ FileLocation::~FileLocation() = default;
|
||||||
|
|
||||||
FileLocation::FileLocation(nsIFile* aFile) { Init(aFile); }
|
FileLocation::FileLocation(nsIFile* aFile) { Init(aFile); }
|
||||||
|
|
||||||
FileLocation::FileLocation(nsIFile* aFile, const char* aPath) {
|
FileLocation::FileLocation(nsIFile* aFile, const nsACString& aPath) {
|
||||||
Init(aFile, aPath);
|
Init(aFile, aPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileLocation::FileLocation(nsZipArchive* aZip, const char* aPath) {
|
FileLocation::FileLocation(nsZipArchive* aZip, const nsACString& aPath) {
|
||||||
Init(aZip, aPath);
|
Init(aZip, aPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,14 +37,14 @@ FileLocation::FileLocation(FileLocation&& aOther)
|
||||||
aOther.mPath.Truncate();
|
aOther.mPath.Truncate();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileLocation::FileLocation(const FileLocation& aFile, const char* aPath) {
|
FileLocation::FileLocation(const FileLocation& aFile, const nsACString& aPath) {
|
||||||
if (aFile.IsZip()) {
|
if (aFile.IsZip()) {
|
||||||
if (aFile.mBaseFile) {
|
if (aFile.mBaseFile) {
|
||||||
Init(aFile.mBaseFile, aFile.mPath.get());
|
Init(aFile.mBaseFile, aFile.mPath);
|
||||||
} else {
|
} else {
|
||||||
Init(aFile.mBaseZip, aFile.mPath.get());
|
Init(aFile.mBaseZip, aFile.mPath);
|
||||||
}
|
}
|
||||||
if (aPath) {
|
if (aPath.Length()) {
|
||||||
int32_t i = mPath.RFindChar('/');
|
int32_t i = mPath.RFindChar('/');
|
||||||
if (kNotFound == i) {
|
if (kNotFound == i) {
|
||||||
mPath.Truncate(0);
|
mPath.Truncate(0);
|
||||||
|
|
@ -54,7 +54,7 @@ FileLocation::FileLocation(const FileLocation& aFile, const char* aPath) {
|
||||||
mPath += aPath;
|
mPath += aPath;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (aPath) {
|
if (aPath.Length()) {
|
||||||
nsCOMPtr<nsIFile> cfile;
|
nsCOMPtr<nsIFile> cfile;
|
||||||
aFile.mBaseFile->GetParent(getter_AddRefs(cfile));
|
aFile.mBaseFile->GetParent(getter_AddRefs(cfile));
|
||||||
|
|
||||||
|
|
@ -69,7 +69,7 @@ FileLocation::FileLocation(const FileLocation& aFile, const char* aPath) {
|
||||||
}
|
}
|
||||||
cfile->AppendRelativeNativePath(pathStr);
|
cfile->AppendRelativeNativePath(pathStr);
|
||||||
#else
|
#else
|
||||||
cfile->AppendRelativeNativePath(nsDependentCString(aPath));
|
cfile->AppendRelativeNativePath(aPath);
|
||||||
#endif
|
#endif
|
||||||
Init(cfile);
|
Init(cfile);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -84,13 +84,13 @@ void FileLocation::Init(nsIFile* aFile) {
|
||||||
mPath.Truncate();
|
mPath.Truncate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileLocation::Init(nsIFile* aFile, const char* aPath) {
|
void FileLocation::Init(nsIFile* aFile, const nsACString& aPath) {
|
||||||
mBaseZip = nullptr;
|
mBaseZip = nullptr;
|
||||||
mBaseFile = aFile;
|
mBaseFile = aFile;
|
||||||
mPath = aPath;
|
mPath = aPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileLocation::Init(nsZipArchive* aZip, const char* aPath) {
|
void FileLocation::Init(nsZipArchive* aZip, const nsACString& aPath) {
|
||||||
mBaseZip = aZip;
|
mBaseZip = aZip;
|
||||||
mBaseFile = nullptr;
|
mBaseFile = nullptr;
|
||||||
mPath = aPath;
|
mPath = aPath;
|
||||||
|
|
@ -158,7 +158,7 @@ nsresult FileLocation::GetData(Data& aData) {
|
||||||
aData.mZip = nsZipArchive::OpenArchive(mBaseFile);
|
aData.mZip = nsZipArchive::OpenArchive(mBaseFile);
|
||||||
}
|
}
|
||||||
if (aData.mZip) {
|
if (aData.mZip) {
|
||||||
aData.mItem = aData.mZip->GetItem(mPath.get());
|
aData.mItem = aData.mZip->GetItem(mPath);
|
||||||
if (aData.mItem) {
|
if (aData.mItem) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,23 +47,23 @@ class FileLocation {
|
||||||
* Constructors for path within an archive. The archive can be given either
|
* Constructors for path within an archive. The archive can be given either
|
||||||
* as nsIFile or nsZipArchive.
|
* as nsIFile or nsZipArchive.
|
||||||
*/
|
*/
|
||||||
FileLocation(nsIFile* aZip, const char* aPath);
|
FileLocation(nsIFile* aZip, const nsACString& aPath);
|
||||||
|
|
||||||
FileLocation(nsZipArchive* aZip, const char* aPath);
|
FileLocation(nsZipArchive* aZip, const nsACString& aPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new file location relative to another one.
|
* Creates a new file location relative to another one.
|
||||||
*/
|
*/
|
||||||
FileLocation(const FileLocation& aFile, const char* aPath);
|
FileLocation(const FileLocation& aFile, const nsACString& aPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization functions corresponding to constructors
|
* Initialization functions corresponding to constructors
|
||||||
*/
|
*/
|
||||||
void Init(nsIFile* aFile);
|
void Init(nsIFile* aFile);
|
||||||
|
|
||||||
void Init(nsIFile* aZip, const char* aPath);
|
void Init(nsIFile* aZip, const nsACString& aPath);
|
||||||
|
|
||||||
void Init(nsZipArchive* aZip, const char* aPath);
|
void Init(nsZipArchive* aZip, const nsACString& aPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an URI string corresponding to the file location
|
* Returns an URI string corresponding to the file location
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ void Omnijar::CleanUpOne(Type aType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Omnijar::InitOne(nsIFile* aPath, Type aType) {
|
void Omnijar::InitOne(nsIFile* aPath, Type aType) {
|
||||||
|
constexpr auto kOmnijarName = nsLiteralCString{MOZ_STRINGIFY(OMNIJAR_NAME)};
|
||||||
nsCOMPtr<nsIFile> file;
|
nsCOMPtr<nsIFile> file;
|
||||||
if (aPath) {
|
if (aPath) {
|
||||||
file = aPath;
|
file = aPath;
|
||||||
|
|
@ -83,8 +84,8 @@ void Omnijar::InitOne(nsIFile* aPath, Type aType) {
|
||||||
|
|
||||||
RefPtr<nsZipArchive> outerReader;
|
RefPtr<nsZipArchive> outerReader;
|
||||||
RefPtr<nsZipHandle> handle;
|
RefPtr<nsZipHandle> handle;
|
||||||
if (NS_SUCCEEDED(nsZipHandle::Init(zipReader, MOZ_STRINGIFY(OMNIJAR_NAME),
|
if (NS_SUCCEEDED(
|
||||||
getter_AddRefs(handle)))) {
|
nsZipHandle::Init(zipReader, kOmnijarName, getter_AddRefs(handle)))) {
|
||||||
outerReader = zipReader;
|
outerReader = zipReader;
|
||||||
zipReader = nsZipArchive::OpenArchive(handle);
|
zipReader = nsZipArchive::OpenArchive(handle);
|
||||||
if (!zipReader) {
|
if (!zipReader) {
|
||||||
|
|
|
||||||
|
|
@ -399,7 +399,7 @@ nsresult nsComponentManagerImpl::Init() {
|
||||||
RefPtr<nsZipArchive> greOmnijar =
|
RefPtr<nsZipArchive> greOmnijar =
|
||||||
mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE);
|
mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE);
|
||||||
if (greOmnijar) {
|
if (greOmnijar) {
|
||||||
cl->location.Init(greOmnijar, "chrome.manifest");
|
cl->location.Init(greOmnijar, "chrome.manifest"_ns);
|
||||||
} else {
|
} else {
|
||||||
nsCOMPtr<nsIFile> lf = CloneAndAppend(greDir, "chrome.manifest"_ns);
|
nsCOMPtr<nsIFile> lf = CloneAndAppend(greDir, "chrome.manifest"_ns);
|
||||||
cl->location.Init(lf);
|
cl->location.Init(lf);
|
||||||
|
|
@ -410,7 +410,7 @@ nsresult nsComponentManagerImpl::Init() {
|
||||||
if (appOmnijar) {
|
if (appOmnijar) {
|
||||||
cl = sModuleLocations->AppendElement();
|
cl = sModuleLocations->AppendElement();
|
||||||
cl->type = NS_APP_LOCATION;
|
cl->type = NS_APP_LOCATION;
|
||||||
cl->location.Init(appOmnijar, "chrome.manifest");
|
cl->location.Init(appOmnijar, "chrome.manifest"_ns);
|
||||||
} else {
|
} else {
|
||||||
bool equals = false;
|
bool equals = false;
|
||||||
appDir->Equals(greDir, &equals);
|
appDir->Equals(greDir, &equals);
|
||||||
|
|
@ -524,7 +524,7 @@ void nsComponentManagerImpl::RegisterManifest(NSLocationType aType,
|
||||||
void nsComponentManagerImpl::ManifestManifest(ManifestProcessingContext& aCx,
|
void nsComponentManagerImpl::ManifestManifest(ManifestProcessingContext& aCx,
|
||||||
int aLineNo, char* const* aArgv) {
|
int aLineNo, char* const* aArgv) {
|
||||||
char* file = aArgv[0];
|
char* file = aArgv[0];
|
||||||
FileLocation f(aCx.mFile, file);
|
FileLocation f(aCx.mFile, nsDependentCString(file));
|
||||||
RegisterManifest(aCx.mType, f, aCx.mChromeOnly);
|
RegisterManifest(aCx.mType, f, aCx.mChromeOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1458,7 +1458,7 @@ nsComponentManagerImpl::RemoveBootstrappedManifestLocation(nsIFile* aLocation) {
|
||||||
elem.type = NS_BOOTSTRAPPED_LOCATION;
|
elem.type = NS_BOOTSTRAPPED_LOCATION;
|
||||||
|
|
||||||
if (Substring(path, path.Length() - 4).EqualsLiteral(".xpi")) {
|
if (Substring(path, path.Length() - 4).EqualsLiteral(".xpi")) {
|
||||||
elem.location.Init(aLocation, "chrome.manifest");
|
elem.location.Init(aLocation, "chrome.manifest"_ns);
|
||||||
} else {
|
} else {
|
||||||
nsCOMPtr<nsIFile> lf = CloneAndAppend(aLocation, "chrome.manifest"_ns);
|
nsCOMPtr<nsIFile> lf = CloneAndAppend(aLocation, "chrome.manifest"_ns);
|
||||||
elem.location.Init(lf);
|
elem.location.Init(lf);
|
||||||
|
|
@ -1541,7 +1541,7 @@ XRE_AddJarManifestLocation(NSLocationType aType, nsIFile* aLocation) {
|
||||||
nsComponentManagerImpl::sModuleLocations->AppendElement();
|
nsComponentManagerImpl::sModuleLocations->AppendElement();
|
||||||
|
|
||||||
c->type = aType;
|
c->type = aType;
|
||||||
c->location.Init(aLocation, "chrome.manifest");
|
c->location.Init(aLocation, "chrome.manifest"_ns);
|
||||||
|
|
||||||
if (nsComponentManagerImpl::gComponentManager &&
|
if (nsComponentManagerImpl::gComponentManager &&
|
||||||
nsComponentManagerImpl::NORMAL ==
|
nsComponentManagerImpl::NORMAL ==
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue