diff options
author | Moonchild <moonchild@palemoon.org> | 2022-01-31 23:05:42 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-01-31 23:05:42 +0000 |
commit | e076c6facb81f8e6f8e5f20e1000cc9c36ed118c (patch) | |
tree | 5ebe840332bbceaac499c7e34723d6d993efd3b4 /components | |
parent | 8a7bfad6d1c04aaeb4f28aed05bc4b317ddb438b (diff) | |
download | aura-central-e076c6facb81f8e6f8e5f20e1000cc9c36ed118c.tar.gz |
Issue %3057 - Part 2: Stop using GetNativePath in JAR reader.
Diffstat (limited to 'components')
-rw-r--r-- | components/jar/src/nsJAR.cpp | 18 | ||||
-rw-r--r-- | components/jar/src/nsZipArchive.cpp | 15 | ||||
-rw-r--r-- | components/jar/src/nsZipArchive.h | 2 |
3 files changed, 18 insertions, 17 deletions
diff --git a/components/jar/src/nsJAR.cpp b/components/jar/src/nsJAR.cpp index 96e18e1d3..205649e8d 100644 --- a/components/jar/src/nsJAR.cpp +++ b/components/jar/src/nsJAR.cpp @@ -271,11 +271,7 @@ nsJAR::Extract(const nsACString &aEntryName, nsIFile* outFile) if (NS_FAILED(rv)) return rv; // ExtractFile also closes the fd handle and resolves the symlink if needed - nsAutoCString path; - rv = outFile->GetNativePath(path); - if (NS_FAILED(rv)) return rv; - - rv = mZip->ExtractFile(item, path.get(), fd); + rv = mZip->ExtractFile(item, outFile, fd); } if (NS_FAILED(rv)) return rv; @@ -422,7 +418,7 @@ nsJAR::GetJarPath(nsACString& aResult) { NS_ENSURE_ARG_POINTER(mZipFile); - return mZipFile->GetNativePath(aResult); + return mZipFile->GetPersistentDescriptor(aResult); } nsresult @@ -1124,7 +1120,7 @@ nsZipReaderCache::IsCached(nsIFile* zipFile, bool* aResult) MutexAutoLock lock(mLock); nsAutoCString uri; - rv = zipFile->GetNativePath(uri); + rv = zipFile->GetPersistentDescriptor(uri); if (NS_FAILED(rv)) return rv; @@ -1146,7 +1142,7 @@ nsZipReaderCache::GetZip(nsIFile* zipFile, nsIZipReader* *result) #endif nsAutoCString uri; - rv = zipFile->GetNativePath(uri); + rv = zipFile->GetPersistentDescriptor(uri); if (NS_FAILED(rv)) return rv; uri.Insert(NS_LITERAL_CSTRING("file:"), 0); @@ -1190,7 +1186,7 @@ nsZipReaderCache::GetInnerZip(nsIFile* zipFile, const nsACString &entry, #endif nsAutoCString uri; - rv = zipFile->GetNativePath(uri); + rv = zipFile->GetPersistentDescriptor(uri); if (NS_FAILED(rv)) return rv; uri.Insert(NS_LITERAL_CSTRING("jar:"), 0); @@ -1233,7 +1229,7 @@ nsZipReaderCache::GetFd(nsIFile* zipFile, PRFileDesc** aRetVal) nsresult rv; nsAutoCString uri; - rv = zipFile->GetNativePath(uri); + rv = zipFile->GetPersistentDescriptor(uri); if (NS_FAILED(rv)) { return rv; } @@ -1374,7 +1370,7 @@ nsZipReaderCache::Observe(nsISupports *aSubject, return NS_OK; nsAutoCString uri; - if (NS_FAILED(file->GetNativePath(uri))) + if (NS_FAILED(file->GetPersistentDescriptor(uri))) return NS_OK; uri.Insert(NS_LITERAL_CSTRING("file:"), 0); diff --git a/components/jar/src/nsZipArchive.cpp b/components/jar/src/nsZipArchive.cpp index b28fddc18..8006ee56c 100644 --- a/components/jar/src/nsZipArchive.cpp +++ b/components/jar/src/nsZipArchive.cpp @@ -486,7 +486,7 @@ MOZ_WIN_MEM_TRY_CATCH(return nullptr) // On extraction error(s) it removes the file. // When needed, it also resolves the symlink. //--------------------------------------------- -nsresult nsZipArchive::ExtractFile(nsZipItem *item, const char *outname, +nsresult nsZipArchive::ExtractFile(nsZipItem *item, nsIFile* outFile, PRFileDesc* aFd) { if (!item) @@ -524,11 +524,16 @@ nsresult nsZipArchive::ExtractFile(nsZipItem *item, const char *outname, //-- delete the file on errors, or resolve symlink if needed if (aFd) { PR_Close(aFd); - if (rv != NS_OK) - PR_Delete(outname); + if (NS_FAILED(rv) && outFile) { + outFile->Remove(false); + } #ifdef XP_UNIX - else if (item->IsSymlink()) - rv = ResolveSymlink(outname); + else if (item->IsSymlink()) { + nsAutoCString path; + rv = outFile->GetNativePath(path); + if (NS_FAILED(rv)) return rv; + rv = ResolveSymlink(path.get()); + } #endif } diff --git a/components/jar/src/nsZipArchive.h b/components/jar/src/nsZipArchive.h index 6b758c9fd..278f41c5f 100644 --- a/components/jar/src/nsZipArchive.h +++ b/components/jar/src/nsZipArchive.h @@ -162,7 +162,7 @@ public: * @param outname Name of file to write to * @return status code */ - nsresult ExtractFile(nsZipItem * zipEntry, const char *outname, PRFileDesc * outFD); + nsresult ExtractFile(nsZipItem * zipEntry, nsIFile* outFile, PRFileDesc * outFD); /** * FindInit |