From 9edf1b7bea5ff893f88911fc1a6a2dca3faeece9 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Mon, 9 May 2022 22:38:16 +0000 Subject: Issue #1896 - Port GetNativePath changes from GRE. --- chrome/nsChromeProtocolHandler.cpp | 2 +- dom/media/gmp/GMPServiceParent.cpp | 5 ++- dom/plugins/base/nsPluginHost.cpp | 10 +++++- dom/plugins/base/nsPluginStreamListenerPeer.cpp | 4 +++ dom/plugins/base/nsPluginsDirWin.cpp | 2 +- dom/xul/nsXULPrototypeCache.cpp | 4 +++ .../spellcheck/hunspell/glue/mozHunspell.cpp | 17 +++++++--- gfx/layers/composite/FPSCounter.cpp | 4 +++ gfx/thebes/gfxPlatform.cpp | 7 +++- ipc/glue/GeckoChildProcessHost.cpp | 18 +++++++++- layout/printing/ipc/RemotePrintJobParent.cpp | 4 +++ mailnews/addrbook/src/nsAddrDatabase.cpp | 4 +++ mailnews/base/src/nsMessenger.cpp | 12 +++++++ mailnews/base/src/nsMsgFolderCache.cpp | 4 +++ mailnews/compose/src/nsMsgCompUtils.cpp | 4 +++ mailnews/compose/src/nsMsgCompose.cpp | 4 +++ mailnews/db/msgdb/src/nsMsgDatabase.cpp | 8 +++++ mailnews/imap/src/nsImapMailFolder.cpp | 8 +++++ mailnews/import/outlook/src/MapiMessage.cpp | 4 +++ mailnews/local/src/nsLocalUtils.cpp | 4 +++ mailnews/local/src/nsMailboxService.cpp | 4 +++ modules/libjar/nsJAR.cpp | 39 ++++++++++++++++++---- modules/libjar/nsZipArchive.cpp | 15 ++++++--- modules/libjar/nsZipArchive.h | 4 +-- netwerk/base/nsDirectoryIndexStream.cpp | 14 +++++--- netwerk/base/nsStandardURL.cpp | 5 ++- netwerk/cache/nsCache.cpp | 8 +++++ netwerk/cache/nsCacheService.cpp | 12 +++++++ netwerk/cache/nsDiskCacheDeviceSQL.cpp | 4 +++ netwerk/cache2/CacheFileContextEvictor.cpp | 8 +++++ netwerk/cache2/CacheFileIOManager.cpp | 12 +++++++ netwerk/test/TestFileInput2.cpp | 4 +-- rdf/datasource/nsFileSystemDataSource.cpp | 2 +- security/manager/ssl/CertBlocklist.cpp | 4 +++ toolkit/profile/nsProfileLock.cpp | 8 +++++ toolkit/xre/nsAppRunner.cpp | 31 ++++++++++++++--- toolkit/xre/nsUpdateDriver.cpp | 6 ++++ uriloader/exthandler/nsMIMEInfoImpl.cpp | 8 +++++ widget/nsDeviceContextSpecProxy.cpp | 4 +++ widget/windows/WinTaskbar.cpp | 3 +- widget/windows/nsDataObj.cpp | 2 +- xpcom/base/nsDumpUtils.cpp | 4 +++ xpcom/build/LateWriteChecks.cpp | 15 ++++++--- xpcom/build/XPCOMInit.cpp | 6 +++- xpcom/components/nsNativeModuleLoader.cpp | 6 ++++ xpcom/io/nsLocalFileWin.cpp | 6 ++-- 46 files changed, 312 insertions(+), 51 deletions(-) diff --git a/chrome/nsChromeProtocolHandler.cpp b/chrome/nsChromeProtocolHandler.cpp index f66c6d362f..aa72403c2c 100644 --- a/chrome/nsChromeProtocolHandler.cpp +++ b/chrome/nsChromeProtocolHandler.cpp @@ -160,7 +160,7 @@ nsChromeProtocolHandler::NewChannel2(nsIURI* aURI, file->Exists(&exists); if (!exists) { nsAutoCString path; - file->GetNativePath(path); + file->GetPersistentDescriptor(path); printf("Chrome file doesn't exist: %s\n", path.get()); } } diff --git a/dom/media/gmp/GMPServiceParent.cpp b/dom/media/gmp/GMPServiceParent.cpp index a4afbdad44..d1ad26a4a0 100644 --- a/dom/media/gmp/GMPServiceParent.cpp +++ b/dom/media/gmp/GMPServiceParent.cpp @@ -1018,12 +1018,11 @@ GeckoMediaPluginServiceParent::PluginTerminated(const RefPtr& aPlugin MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread); if (aPlugin->IsMarkedForDeletion()) { - nsCString path8; + nsString path; RefPtr dir = aPlugin->GetDirectory(); - nsresult rv = dir->GetNativePath(path8); + nsresult rv = dir->GetPath(path); NS_ENSURE_SUCCESS_VOID(rv); - nsString path = NS_ConvertUTF8toUTF16(path8); if (mPluginsWaitingForDeletion.Contains(path)) { RemoveOnGMPThread(path, true /* delete */, true /* can defer */); } diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index c9c1b71fe0..cb9990bdd5 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -2037,10 +2037,14 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir, #ifdef PLUGIN_LOGGING nsAutoCString dirPath; +#ifdef XP_WIN + pluginsDir->GetPersistentDescriptor(dirPath); +#else pluginsDir->GetNativePath(dirPath); +#endif PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsPluginHost::ScanPluginsDirectory dir=%s\n", dirPath.get())); -#endif +#endif // PLUGIN_LOGGING nsCOMPtr iter; rv = pluginsDir->GetDirectoryEntries(getter_AddRefs(iter)); @@ -3615,7 +3619,11 @@ nsPluginHost::CreateTempFileToPost(const char *aPostDataURL, nsIFile **aTmpFile) } rv = inFile->GetFileSize(&fileSize); if (NS_FAILED(rv)) return rv; +#ifdef XP_WIN + rv = inFile->GetPersistentDescriptor(filename); +#else rv = inFile->GetNativePath(filename); +#endif if (NS_FAILED(rv)) return rv; if (fileSize != 0) { diff --git a/dom/plugins/base/nsPluginStreamListenerPeer.cpp b/dom/plugins/base/nsPluginStreamListenerPeer.cpp index 603f2408c8..7ee5cd7fbb 100644 --- a/dom/plugins/base/nsPluginStreamListenerPeer.cpp +++ b/dom/plugins/base/nsPluginStreamListenerPeer.cpp @@ -1265,7 +1265,11 @@ nsPluginStreamListenerPeer::OnFileAvailable(nsIFile* aFile) return NS_ERROR_FAILURE; nsAutoCString path; +#ifdef XP_WIN + rv = aFile->GetPersistentDescriptor(path); +#else rv = aFile->GetNativePath(path); +#endif if (NS_FAILED(rv)) return rv; if (path.IsEmpty()) { diff --git a/dom/plugins/base/nsPluginsDirWin.cpp b/dom/plugins/base/nsPluginsDirWin.cpp index 8c2d26ca2c..5a2d85f293 100644 --- a/dom/plugins/base/nsPluginsDirWin.cpp +++ b/dom/plugins/base/nsPluginsDirWin.cpp @@ -239,7 +239,7 @@ static bool CanLoadPlugin(char16ptr_t aBinaryPath) bool nsPluginsDir::IsPluginFile(nsIFile* file) { nsAutoCString path; - if (NS_FAILED(file->GetNativePath(path))) + if (NS_FAILED(file->GetPersistentDescriptor(path))) return false; const char *cPath = path.get(); diff --git a/dom/xul/nsXULPrototypeCache.cpp b/dom/xul/nsXULPrototypeCache.cpp index 5644405f5c..8f08ae5444 100644 --- a/dom/xul/nsXULPrototypeCache.cpp +++ b/dom/xul/nsXULPrototypeCache.cpp @@ -466,7 +466,11 @@ nsXULPrototypeCache::BeginCaching(nsIURI* aURI) if (NS_FAILED(rv)) return rv; nsAutoCString chromePath; +#ifdef XP_WIN + rv = chromeDir->GetPersistentDescriptor(chromePath); +#else rv = chromeDir->GetNativePath(chromePath); +#endif if (NS_FAILED(rv)) return rv; diff --git a/extensions/spellcheck/hunspell/glue/mozHunspell.cpp b/extensions/spellcheck/hunspell/glue/mozHunspell.cpp index 87ffbc661f..1535529c8d 100644 --- a/extensions/spellcheck/hunspell/glue/mozHunspell.cpp +++ b/extensions/spellcheck/hunspell/glue/mozHunspell.cpp @@ -169,13 +169,20 @@ NS_IMETHODIMP mozHunspell::SetDictionary(const char16_t *aDictionary) nsAutoCString dictFileName, affFileName; - // XXX This isn't really good. nsIFile->NativePath isn't safe for all - // character sets on Windows. - // A better way would be to QI to nsIFile, and get a filehandle - // from there. Only problem is that hunspell wants a path - +#ifdef XP_WIN + // nsIFile->NativePath isn't safe for all character sets on Windows. + // Use GetPath and pass it as a UTF-8 to the hunspell lib instead. + // Hunspell 1.5+ supports UTF-8 file paths on Windows + // by prefixing "\\\\?\\". + nsAutoString affFileNameU; + nsresult rv = affFile->GetPath(affFileNameU); + NS_ENSURE_SUCCESS(rv, rv); + affFileName.AssignLiteral("\\\\?\\"); + AppendUTF16toUTF8(affFileNameU, affFileName); +#else nsresult rv = affFile->GetNativePath(affFileName); NS_ENSURE_SUCCESS(rv, rv); +#endif if (mAffixFileName.Equals(affFileName.get())) return NS_OK; diff --git a/gfx/layers/composite/FPSCounter.cpp b/gfx/layers/composite/FPSCounter.cpp index b8e93eb97b..0cbc76066d 100644 --- a/gfx/layers/composite/FPSCounter.cpp +++ b/gfx/layers/composite/FPSCounter.cpp @@ -364,7 +364,11 @@ FPSCounter::WriteFrameTimeStamps() PR_Close(fd); nsAutoCString path; +#ifdef XP_WIN + rv = resultFile->GetPersistentDescriptor(path); +#else rv = resultFile->GetNativePath(path); +#endif NS_ENSURE_SUCCESS(rv, rv); printf_stderr("Wrote FPS data to file: %s\n", path.get()); diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 7ec9139c0a..43980498d3 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -490,7 +490,7 @@ void RecordingPrefChanged(const char *aPrefName, void *aClosure) nsAdoptingString prefFileName = Preferences::GetString("gfx.2d.recordingfile"); if (prefFileName) { - fileName.Append(NS_ConvertUTF16toUTF8(prefFileName)); + CopyUTF16toUTF8(prefFileName, fileName); } else { nsCOMPtr tmpFile; if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile)))) { @@ -502,7 +502,12 @@ void RecordingPrefChanged(const char *aPrefName, void *aClosure) if (NS_FAILED(rv)) return; +#ifdef XP_WIN + rv = tmpFile->GetPath(prefFileName); + CopyUTF16toUTF8(prefFileName, fileName); +#else rv = tmpFile->GetNativePath(fileName); +#endif if (NS_FAILED(rv)) return; } diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index e7c676c944..8a7b4ca5b8 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -666,8 +666,23 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt // Make sure that child processes can find the omnijar // See XRE_InitCommandLine in nsAppRunner.cpp newEnvVars["UXP_CUSTOM_OMNI"] = 1; - nsAutoCString path; nsCOMPtr file = Omnijar::GetPath(Omnijar::GRE); +#ifdef XP_WIN + nsString path; + nsAutoCString childPath; + if (file && NS_SUCCEEDED(file->GetPath(path))) { + CopyUTF16toUTF8(path, childPath); + childArgv.push_back("-greomni"); + childArgv.push_back(childPath.get()); + } + file = Omnijar::GetPath(Omnijar::APP); + if (file && NS_SUCCEEDED(file->GetPath(path))) { + CopyUTF16toUTF8(path, childPath); + childArgv.push_back("-appomni"); + childArgv.push_back(childPath.get()); + } +#else + nsAutoCString path; if (file && NS_SUCCEEDED(file->GetNativePath(path))) { childArgv.push_back("-greomni"); childArgv.push_back(path.get()); @@ -677,6 +692,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt childArgv.push_back("-appomni"); childArgv.push_back(path.get()); } +#endif } // Add the application directory path (-appdir path) diff --git a/layout/printing/ipc/RemotePrintJobParent.cpp b/layout/printing/ipc/RemotePrintJobParent.cpp index 7005bab5a3..98d5dd2ee0 100644 --- a/layout/printing/ipc/RemotePrintJobParent.cpp +++ b/layout/printing/ipc/RemotePrintJobParent.cpp @@ -117,7 +117,11 @@ RemotePrintJobParent::PrintPage(const nsCString& aPageFileName) } nsAutoCString recordingPath; +#ifdef XP_WIN + rv = recordingFile->GetPersistentDescriptor(recordingPath); +#else rv = recordingFile->GetNativePath(recordingPath); +#endif if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } diff --git a/mailnews/addrbook/src/nsAddrDatabase.cpp b/mailnews/addrbook/src/nsAddrDatabase.cpp index 463437958f..51dbe8237f 100644 --- a/mailnews/addrbook/src/nsAddrDatabase.cpp +++ b/mailnews/addrbook/src/nsAddrDatabase.cpp @@ -482,7 +482,11 @@ NS_IMETHODIMP nsAddrDatabase::OpenMDB(nsIFile *dbName, bool create) nsIMdbThumb *thumb = nullptr; nsAutoCString filePath; +#ifdef XP_WIN + ret = dbName->GetPersistentDescriptor(filePath); +#else ret = dbName->GetNativePath(filePath); +#endif NS_ENSURE_SUCCESS(ret, ret); nsIMdbHeap* dbHeap = nullptr; diff --git a/mailnews/base/src/nsMessenger.cpp b/mailnews/base/src/nsMessenger.cpp index 953b462b6a..07efe0cd73 100644 --- a/mailnews/base/src/nsMessenger.cpp +++ b/mailnews/base/src/nsMessenger.cpp @@ -598,7 +598,11 @@ nsMessenger::DetachAttachmentsWOPrompts(nsIFile* aDestFolder, NS_ENSURE_SUCCESS(rv, rv); nsAutoCString path; +#ifdef XP_WIN + rv = attachmentDestination->GetPersistentDescriptor(path); +#else rv = attachmentDestination->GetNativePath(path); +#endif NS_ENSURE_SUCCESS(rv, rv); nsAutoString unescapedFileName; @@ -860,7 +864,11 @@ nsMessenger::SaveOneAttachment(const char * aContentType, const char * aURL, SetLastSaveDirectory(localFile); nsCString dirName; +#ifdef XP_WIN + rv = localFile->GetPersistentDescriptor(dirName); +#else rv = localFile->GetNativePath(dirName); +#endif NS_ENSURE_SUCCESS(rv, rv); nsSaveAllAttachmentsState *saveState = @@ -927,7 +935,11 @@ nsMessenger::SaveAllAttachments(uint32_t count, nsCString dirName; nsSaveAllAttachmentsState *saveState = nullptr; +#ifdef XP_WIN + rv = localFile->GetPersistentDescriptor(dirName); +#else rv = localFile->GetNativePath(dirName); +#endif NS_ENSURE_SUCCESS(rv, rv); saveState = new nsSaveAllAttachmentsState(count, diff --git a/mailnews/base/src/nsMsgFolderCache.cpp b/mailnews/base/src/nsMsgFolderCache.cpp index 9510a6e3d2..caab422aa9 100644 --- a/mailnews/base/src/nsMsgFolderCache.cpp +++ b/mailnews/base/src/nsMsgFolderCache.cpp @@ -236,7 +236,11 @@ NS_IMETHODIMP nsMsgFolderCache::Init(nsIFile *aFile) aFile->Exists(&exists); nsAutoCString dbPath; +#ifdef XP_WIN + aFile->GetPersistentDescriptor(dbPath); +#else aFile->GetNativePath(dbPath); +#endif // ### evil cast until MDB supports file streams. nsresult rv = OpenMDB(dbPath, exists); // if this fails and panacea.dat exists, try blowing away the db and recreating it diff --git a/mailnews/compose/src/nsMsgCompUtils.cpp b/mailnews/compose/src/nsMsgCompUtils.cpp index 6632e3257c..f31c5dc1f3 100644 --- a/mailnews/compose/src/nsMsgCompUtils.cpp +++ b/mailnews/compose/src/nsMsgCompUtils.cpp @@ -118,7 +118,11 @@ nsMsgCreateTempFileName(const char *tFileName) return nullptr; nsCString tempString; +#ifdef XP_WIN + rv = tmpFile->GetPersistentDescriptor(tempString); +#else rv = tmpFile->GetNativePath(tempString); +#endif if (NS_FAILED(rv)) return nullptr; diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index a7c2140ad7..3dbf741878 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -4518,7 +4518,11 @@ nsMsgCompose::ProcessSignature(nsIMsgIdentity *identity, bool aQuoted, nsString { rv = identity->GetSignature(getter_AddRefs(sigFile)); if (NS_SUCCEEDED(rv) && sigFile) { +#ifdef XP_WIN + rv = sigFile->GetPersistentDescriptor(sigNativePath); +#else rv = sigFile->GetNativePath(sigNativePath); +#endif if (NS_SUCCEEDED(rv) && !sigNativePath.IsEmpty()) { bool exists = false; sigFile->Exists(&exists); diff --git a/mailnews/db/msgdb/src/nsMsgDatabase.cpp b/mailnews/db/msgdb/src/nsMsgDatabase.cpp index 31da7bc5e1..96e74359cb 100644 --- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp +++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp @@ -939,7 +939,11 @@ NS_IMETHODIMP nsMsgDatabase::NotifyAnnouncerGoingAway(void) bool nsMsgDatabase::MatchDbName(nsIFile *dbName) // returns true if they match { nsCString dbPath; +#ifdef XP_WIN + dbName->GetPersistentDescriptor(dbPath); +#else dbName->GetNativePath(dbPath); +#endif return dbPath.Equals(m_dbName); } @@ -1197,7 +1201,11 @@ nsresult nsMsgDatabase::OpenInternal(nsMsgDBService *aDBService, bool aLeaveInvalidDB, bool sync) { nsAutoCString summaryFilePath; +#ifdef XP_WIN + summaryFile->GetPersistentDescriptor(summaryFilePath); +#else summaryFile->GetNativePath(summaryFilePath); +#endif MOZ_LOG(DBLog, LogLevel::Info, ("nsMsgDatabase::Open(%s, %s, %p, %s)\n", (const char*)summaryFilePath.get(), aCreate ? "TRUE":"FALSE", diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index da1411cd08..8823b818e7 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -3203,7 +3203,11 @@ NS_IMETHODIMP nsImapMailFolder::BeginCopy(nsIMsgDBHdr *message) if (NS_FAILED(rv)) { nsCString nativePath; +#ifdef XP_WIN + m_copyState->m_tmpFile->GetPersistentDescriptor(nativePath); +#else m_copyState->m_tmpFile->GetNativePath(nativePath); +#endif MOZ_LOG(IMAP, mozilla::LogLevel::Info, ("couldn't remove prev temp file %s: %lx\n", nativePath.get(), rv)); } m_copyState->m_tmpFile = nullptr; @@ -8883,7 +8887,11 @@ NS_IMETHODIMP nsImapMailFolder::RenameSubFolders(nsIMsgWindow *msgWindow, nsIMsg newParentPathFile->AppendNative(oldLeafName); nsCString newPathStr; +#ifdef XP_WIN + newParentPathFile->GetPersistentDescriptor(newPathStr); +#else newParentPathFile->GetNativePath(newPathStr); +#endif nsCOMPtr newPathFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); diff --git a/mailnews/import/outlook/src/MapiMessage.cpp b/mailnews/import/outlook/src/MapiMessage.cpp index 6b02db3145..2536c16809 100644 --- a/mailnews/import/outlook/src/MapiMessage.cpp +++ b/mailnews/import/outlook/src/MapiMessage.cpp @@ -887,7 +887,11 @@ bool CMapiMessage::CopyBinAttachToFile(LPATTACH lpAttach, NS_ENSURE_SUCCESS(rv, false); nsCString tmpPath; +#ifdef XP_WIN + _tmp_file->GetPersistentDescriptor(tmpPath); +#else _tmp_file->GetNativePath(tmpPath); +#endif LPSTREAM lpStreamFile; HRESULT hr = CMapiApi::OpenStreamOnFile(gpMapiAllocateBuffer, gpMapiFreeBuffer, STGM_READWRITE | STGM_CREATE, const_cast(tmpPath.get()), NULL, &lpStreamFile); diff --git a/mailnews/local/src/nsLocalUtils.cpp b/mailnews/local/src/nsLocalUtils.cpp index 14a6a2f218..352ba9f5ad 100644 --- a/mailnews/local/src/nsLocalUtils.cpp +++ b/mailnews/local/src/nsLocalUtils.cpp @@ -150,7 +150,11 @@ nsLocalURI2Path(const char* rootURI, const char* uriStr, nsCString localNativePath; +#ifdef XP_WIN + localPath->GetPersistentDescriptor(localNativePath); +#else localPath->GetNativePath(localNativePath); +#endif nsEscapeNativePath(localNativePath); pathResult = localNativePath.get(); const char *curPos = uriStr + PL_strlen(rootURI); diff --git a/mailnews/local/src/nsMailboxService.cpp b/mailnews/local/src/nsMailboxService.cpp index 00a0d87c8f..3621df262c 100644 --- a/mailnews/local/src/nsMailboxService.cpp +++ b/mailnews/local/src/nsMailboxService.cpp @@ -52,7 +52,11 @@ nsresult nsMailboxService::ParseMailbox(nsIMsgWindow *aMsgWindow, nsIFile *aMail // okay now generate the url string nsCString mailboxPath; +#ifdef XP_WIN + aMailboxPath->GetPersistentDescriptor(mailboxPath); +#else aMailboxPath->GetNativePath(mailboxPath); +#endif nsAutoCString buf; MsgEscapeURL(mailboxPath, nsINetUtil::ESCAPE_URL_MINIMAL | nsINetUtil::ESCAPE_URL_FORCED, buf); diff --git a/modules/libjar/nsJAR.cpp b/modules/libjar/nsJAR.cpp index 96e18e1d31..a9a696cf75 100644 --- a/modules/libjar/nsJAR.cpp +++ b/modules/libjar/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,11 @@ nsJAR::GetJarPath(nsACString& aResult) { NS_ENSURE_ARG_POINTER(mZipFile); +#ifdef XP_WIN + return mZipFile->GetPersistentDescriptor(aResult); +#else return mZipFile->GetNativePath(aResult); +#endif } nsresult @@ -1124,7 +1124,11 @@ nsZipReaderCache::IsCached(nsIFile* zipFile, bool* aResult) MutexAutoLock lock(mLock); nsAutoCString uri; +#ifdef XP_WIN + rv = zipFile->GetPersistentDescriptor(uri); +#else rv = zipFile->GetNativePath(uri); +#endif if (NS_FAILED(rv)) return rv; @@ -1146,8 +1150,14 @@ nsZipReaderCache::GetZip(nsIFile* zipFile, nsIZipReader* *result) #endif nsAutoCString uri; +#ifdef XP_WIN + rv = zipFile->GetPersistentDescriptor(uri); +#else rv = zipFile->GetNativePath(uri); - if (NS_FAILED(rv)) return rv; +#endif + if (NS_FAILED(rv)) { + return rv; + } uri.Insert(NS_LITERAL_CSTRING("file:"), 0); @@ -1190,8 +1200,14 @@ nsZipReaderCache::GetInnerZip(nsIFile* zipFile, const nsACString &entry, #endif nsAutoCString uri; +#ifdef XP_WIN + rv = zipFile->GetPersistentDescriptor(uri); +#else rv = zipFile->GetNativePath(uri); - if (NS_FAILED(rv)) return rv; +#endif + if (NS_FAILED(rv)) { + return rv; + } uri.Insert(NS_LITERAL_CSTRING("jar:"), 0); uri.AppendLiteral("!/"); @@ -1233,7 +1249,11 @@ nsZipReaderCache::GetFd(nsIFile* zipFile, PRFileDesc** aRetVal) nsresult rv; nsAutoCString uri; +#ifdef XP_WIN + rv = zipFile->GetPersistentDescriptor(uri); +#else rv = zipFile->GetNativePath(uri); +#endif if (NS_FAILED(rv)) { return rv; } @@ -1374,8 +1394,13 @@ nsZipReaderCache::Observe(nsISupports *aSubject, return NS_OK; nsAutoCString uri; +#ifdef XP_WIN + if (NS_FAILED(file->GetPersistentDescriptor(uri))) + return NS_OK; +#else if (NS_FAILED(file->GetNativePath(uri))) return NS_OK; +#endif uri.Insert(NS_LITERAL_CSTRING("file:"), 0); diff --git a/modules/libjar/nsZipArchive.cpp b/modules/libjar/nsZipArchive.cpp index b28fddc181..8006ee56c0 100644 --- a/modules/libjar/nsZipArchive.cpp +++ b/modules/libjar/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/modules/libjar/nsZipArchive.h b/modules/libjar/nsZipArchive.h index 6b758c9fd8..133a2aa120 100644 --- a/modules/libjar/nsZipArchive.h +++ b/modules/libjar/nsZipArchive.h @@ -159,10 +159,10 @@ public: * * @param zipEntry Name of file in archive to extract * @param outFD Filedescriptor to write contents to - * @param outname Name of file to write to + * @param outFile Handle 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 diff --git a/netwerk/base/nsDirectoryIndexStream.cpp b/netwerk/base/nsDirectoryIndexStream.cpp index 87a57fd579..bfcc73475b 100644 --- a/netwerk/base/nsDirectoryIndexStream.cpp +++ b/netwerk/base/nsDirectoryIndexStream.cpp @@ -1,17 +1,13 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:set sw=4 sts=4 et cin: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - /* - - The converts a filesystem directory into an "HTTP index" stream per + This converts a filesystem directory into an "HTTP index" stream per Lou Montulli's original spec: http://www.mozilla.org/projects/netlib/dirindexformat.html - */ #include "nsEscape.h" @@ -92,7 +88,11 @@ nsDirectoryIndexStream::Init(nsIFile* aDir) if (MOZ_LOG_TEST(gLog, LogLevel::Debug)) { nsAutoCString path; +#ifdef XP_WIN + aDir->GetPersistentDescriptor(path); +#else aDir->GetNativePath(path); +#endif MOZ_LOG(gLog, LogLevel::Debug, ("nsDirectoryIndexStream[%p]: initialized on %s", this, path.get())); @@ -239,7 +239,11 @@ nsDirectoryIndexStream::Read(char* aBuf, uint32_t aCount, uint32_t* aReadCount) if (MOZ_LOG_TEST(gLog, LogLevel::Debug)) { nsAutoCString path; +#ifdef XP_WIN + current->GetPersistentDescriptor(path); +#else current->GetNativePath(path); +#endif MOZ_LOG(gLog, LogLevel::Debug, ("nsDirectoryIndexStream[%p]: iterated %s", this, path.get())); diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index 57337e480d..42d71620f7 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -1,5 +1,4 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:set ts=4 sw=4 sts=4 et cindent: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -3159,7 +3158,11 @@ nsStandardURL::GetFile(nsIFile **result) if (LOG_ENABLED()) { nsAutoCString path; +#ifdef XP_WIN + mFile->GetPersistentDescriptor(path); +#else mFile->GetNativePath(path); +#endif LOG(("nsStandardURL::GetFile [this=%p spec=%s resulting_path=%s]\n", this, mSpec.get(), path.get())); } diff --git a/netwerk/cache/nsCache.cpp b/netwerk/cache/nsCache.cpp index 7f5d6a0716..b3ecfeae26 100644 --- a/netwerk/cache/nsCache.cpp +++ b/netwerk/cache/nsCache.cpp @@ -20,11 +20,19 @@ void CacheLogPrintPath(mozilla::LogLevel level, const char * format, nsIFile * item) { nsAutoCString path; +#ifdef XP_WIN + nsresult rv = item->GetPersistentDescriptor(path); +#else nsresult rv = item->GetNativePath(path); +#endif if (NS_SUCCEEDED(rv)) { MOZ_LOG(gCacheLog, level, (format, path.get())); } else { +#ifdef XP_WIN + MOZ_LOG(gCacheLog, level, ("GetPersistentDescriptor failed: %x", rv)); +#else MOZ_LOG(gCacheLog, level, ("GetNativePath failed: %x", rv)); +#endif } } diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index 6c8e5f5b84..1e63615044 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -1739,7 +1739,11 @@ nsCacheService::CreateCustomOfflineDevice(nsIFile *aProfileDir, if (MOZ_LOG_TEST(gCacheLog, LogLevel::Info)) { nsAutoCString profilePath; +#ifdef XP_WIN + aProfileDir->GetPersistentDescriptor(profilePath); +#else aProfileDir->GetNativePath(profilePath); +#endif CACHE_LOG_INFO(("Creating custom offline device, %s, %d", profilePath.BeginReading(), aQuota)); } @@ -3093,7 +3097,11 @@ nsCacheService::MoveOrRemoveDiskCache(nsIFile *aOldCacheDir, return; nsAutoCString newPath; +#ifdef XP_WIN + rv = aNewCacheSubdir->GetPersistentDescriptor(newPath); +#else rv = aNewCacheSubdir->GetNativePath(newPath); +#endif if (NS_FAILED(rv)) return; @@ -3105,7 +3113,11 @@ nsCacheService::MoveOrRemoveDiskCache(nsIFile *aOldCacheDir, rv = aNewCacheDir->Create(nsIFile::DIRECTORY_TYPE, 0777); if (NS_SUCCEEDED(rv) || NS_ERROR_FILE_ALREADY_EXISTS == rv) { nsAutoCString oldPath; +#ifdef XP_WIN + rv = aOldCacheSubdir->GetPersistentDescriptor(oldPath); +#else rv = aOldCacheSubdir->GetNativePath(oldPath); +#endif if (NS_FAILED(rv)) return; if (rename(oldPath.get(), newPath.get()) == 0) diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.cpp b/netwerk/cache/nsDiskCacheDeviceSQL.cpp index 297c0f362a..85344a615e 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp +++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp @@ -287,7 +287,11 @@ nsOfflineCacheEvictionFunction::Apply() for (int32_t i = 0; i < items.Count(); i++) { if (MOZ_LOG_TEST(gCacheLog, LogLevel::Debug)) { nsAutoCString path; +#ifdef XP_WIN + items[i]->GetPersistentDescriptor(path); +#else items[i]->GetNativePath(path); +#endif LOG((" removing %s\n", path.get())); } diff --git a/netwerk/cache2/CacheFileContextEvictor.cpp b/netwerk/cache2/CacheFileContextEvictor.cpp index 65feb44620..fd4e97550d 100644 --- a/netwerk/cache2/CacheFileContextEvictor.cpp +++ b/netwerk/cache2/CacheFileContextEvictor.cpp @@ -269,7 +269,11 @@ CacheFileContextEvictor::PersistEvictionInfoToDisk( } nsAutoCString path; +#ifdef XP_WIN + file->GetPersistentDescriptor(path); +#else file->GetNativePath(path); +#endif PRFileDesc *fd; rv = file->OpenNSPRFileDesc(PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE, 0600, @@ -306,7 +310,11 @@ CacheFileContextEvictor::RemoveEvictInfoFromDisk( } nsAutoCString path; +#ifdef XP_WIN + file->GetPersistentDescriptor(path); +#else file->GetNativePath(path); +#endif rv = file->Remove(false); if (NS_WARN_IF(NS_FAILED(rv))) { diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp index 845ad73147..71dcb47155 100644 --- a/netwerk/cache2/CacheFileIOManager.cpp +++ b/netwerk/cache2/CacheFileIOManager.cpp @@ -3096,7 +3096,11 @@ nsresult CacheFileIOManager::TrashDirectory(nsIFile *aFile) { nsAutoCString path; +#ifdef XP_WIN + aFile->GetPersistentDescriptor(path); +#else aFile->GetNativePath(path); +#endif LOG(("CacheFileIOManager::TrashDirectory() [file=%s]", path.get())); nsresult rv; @@ -3340,7 +3344,11 @@ CacheFileIOManager::RemoveTrashInternal() "recursively, but this can block IO thread for a while!"); if (LOG_ENABLED()) { nsAutoCString path; +#ifdef XP_WIN + file->GetPersistentDescriptor(path); +#else file->GetNativePath(path); +#endif LOG(("CacheFileIOManager::RemoveTrashInternal() - Found a directory in a trash " "directory! It will be removed recursively, but this can block IO " "thread for a while! [file=%s]", path.get())); @@ -3873,7 +3881,11 @@ CacheFileIOManager::SyncRemoveDir(nsIFile *aFile, const char *aDir) if (LOG_ENABLED()) { nsAutoCString path; +#ifdef XP_WIN + file->GetPersistentDescriptor(path); +#else file->GetNativePath(path); +#endif LOG(("CacheFileIOManager::SyncRemoveDir() - Removing directory %s", path.get())); } diff --git a/netwerk/test/TestFileInput2.cpp b/netwerk/test/TestFileInput2.cpp index f51988010e..c75d7677c1 100644 --- a/netwerk/test/TestFileInput2.cpp +++ b/netwerk/test/TestFileInput2.cpp @@ -323,8 +323,8 @@ Test(CreateFun create, uint32_t count, nsAutoCString inDir; nsAutoCString outDir; - (void)inDirSpec->GetNativePath(inDir); - (void)outDirSpec->GetNativePath(outDir); + (void)inDirSpec->GetPersistentDescriptor(inDir); + (void)outDirSpec->GetPersistentDescriptor(outDir); printf("###########\nTest: from %s to %s, bufSize = %d\n", inDir.get(), outDir.get(), bufSize); gTimeSampler.Reset(); diff --git a/rdf/datasource/nsFileSystemDataSource.cpp b/rdf/datasource/nsFileSystemDataSource.cpp index 35632d1a3b..c67656cd92 100644 --- a/rdf/datasource/nsFileSystemDataSource.cpp +++ b/rdf/datasource/nsFileSystemDataSource.cpp @@ -186,7 +186,7 @@ FileSystemDataSource::Init() NS_NewFileURI(getter_AddRefs(furi), file); NS_ENSURE_TRUE(furi, NS_ERROR_FAILURE); - file->GetNativePath(ieFavoritesDir); + file->GetPersistentDescriptor(ieFavoritesDir); } #endif diff --git a/security/manager/ssl/CertBlocklist.cpp b/security/manager/ssl/CertBlocklist.cpp index 8701032ed5..43b99b359a 100644 --- a/security/manager/ssl/CertBlocklist.cpp +++ b/security/manager/ssl/CertBlocklist.cpp @@ -193,7 +193,11 @@ CertBlocklist::Init() return rv; } nsAutoCString path; +#ifdef XP_WIN + rv = mBackingFile->GetPersistentDescriptor(path); +#else rv = mBackingFile->GetNativePath(path); +#endif if (NS_FAILED(rv)) { return rv; } diff --git a/toolkit/profile/nsProfileLock.cpp b/toolkit/profile/nsProfileLock.cpp index d75b6082d3..a0ebadedae 100644 --- a/toolkit/profile/nsProfileLock.cpp +++ b/toolkit/profile/nsProfileLock.cpp @@ -197,7 +197,11 @@ nsresult nsProfileLock::LockWithFcntl(nsIFile *aLockFile) nsresult rv = NS_OK; nsAutoCString lockFilePath; +#ifdef XP_WIN + rv = aLockFile->GetPersistentDescriptor(lockFilePath); +#else rv = aLockFile->GetNativePath(lockFilePath); +#endif if (NS_FAILED(rv)) { NS_ERROR("Could not get native path"); return rv; @@ -303,7 +307,11 @@ nsresult nsProfileLock::LockWithSymlink(nsIFile *aLockFile, bool aHaveFcntlLock) { nsresult rv; nsAutoCString lockFilePath; +#ifdef XP_WIN + rv = aLockFile->GetPersistentDescriptor(lockFilePath); +#else rv = aLockFile->GetNativePath(lockFilePath); +#endif if (NS_FAILED(rv)) { NS_ERROR("Could not get native path"); return rv; diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 274631aac8..f9f007c6c8 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -2031,8 +2031,13 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n profile->GetRootDir(getter_AddRefs(prefsJSFile)); prefsJSFile->AppendNative(NS_LITERAL_CSTRING("prefs.js")); nsAutoCString pathStr; +#ifdef XP_WIN + prefsJSFile->GetPersistentDescriptor(pathStr); +#else prefsJSFile->GetNativePath(pathStr); +#endif PR_fprintf(PR_STDERR, "Success: created profile '%s' at '%s'\n", arg, pathStr.get()); + bool exists; prefsJSFile->Exists(&exists); if (!exists) { @@ -2271,11 +2276,15 @@ CheckCompatibility(nsIFile* aProfileDir, const nsCString& aVersion, return false; nsCOMPtr lf; - rv = NS_NewNativeLocalFile(buf, false, + rv = NS_NewNativeLocalFile(EmptyCString(), false, getter_AddRefs(lf)); if (NS_FAILED(rv)) return false; + rv = lf->SetPersistentDescriptor(buf); + if (NS_FAILED(rv)) + return false; + bool eq; rv = lf->Equals(aXULRunnerDir, &eq); if (NS_FAILED(rv) || !eq) @@ -2286,11 +2295,15 @@ CheckCompatibility(nsIFile* aProfileDir, const nsCString& aVersion, if (NS_FAILED(rv)) return false; - rv = NS_NewNativeLocalFile(buf, false, + rv = NS_NewNativeLocalFile(EmptyCString(), false, getter_AddRefs(lf)); if (NS_FAILED(rv)) return false; + rv = lf->SetPersistentDescriptor(buf); + if (NS_FAILED(rv)) + return false; + rv = lf->Equals(aAppDir, &eq); if (NS_FAILED(rv) || !eq) return false; @@ -2330,11 +2343,11 @@ WriteVersion(nsIFile* aProfileDir, const nsCString& aVersion, file->AppendNative(FILE_COMPATIBILITY_INFO); nsAutoCString platformDir; - aXULRunnerDir->GetNativePath(platformDir); + Unused << aXULRunnerDir->GetPersistentDescriptor(platformDir); nsAutoCString appDir; if (aAppDir) - aAppDir->GetNativePath(appDir); + Unused << aAppDir->GetPersistentDescriptor(appDir); PRFileDesc *fd; nsresult rv = @@ -3673,6 +3686,16 @@ XREMain::XRE_mainRun() } } +#ifndef XP_WIN + nsCOMPtr profileDir; + nsAutoCString path; + rv = mDirProvider.GetProfileStartupDir(getter_AddRefs(profileDir)); + if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(profileDir->GetNativePath(path)) && !IsUTF8(path)) { + PR_fprintf(PR_STDERR, "Error: The profile path is not valid UTF-8. Unable to continue.\n"); + return NS_ERROR_FAILURE; + } +#endif + mDirProvider.DoStartup(); // As FilePreferences need the profile directory, we must initialize right here. diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp index 4994458852..c4c0a0f105 100644 --- a/toolkit/xre/nsUpdateDriver.cpp +++ b/toolkit/xre/nsUpdateDriver.cpp @@ -1075,7 +1075,13 @@ nsUpdateProcessor::ProcessUpdate(nsIUpdate* aUpdate) rv = ds->Get(XRE_EXECUTABLE_FILE, NS_GET_IID(nsIFile), getter_AddRefs(binary)); NS_ASSERTION(NS_SUCCEEDED(rv), "Can't get the binary path"); +#ifdef XP_WIN + nsAutoString binPathW; + binary->GetPath(binPathW); + NS_ConvertUTF16toUTF8 binPath(binPathW); +#else binary->GetNativePath(binPath); +#endif } // Copy the parameters to the StagedUpdateInfo structure shared with the diff --git a/uriloader/exthandler/nsMIMEInfoImpl.cpp b/uriloader/exthandler/nsMIMEInfoImpl.cpp index 59886e4651..ca23722740 100644 --- a/uriloader/exthandler/nsMIMEInfoImpl.cpp +++ b/uriloader/exthandler/nsMIMEInfoImpl.cpp @@ -305,7 +305,11 @@ nsMIMEInfoBase::LaunchWithFile(nsIFile* aFile) NS_ENSURE_SUCCESS(rv, rv); nsAutoCString path; +#ifdef XP_WIN + aFile->GetPersistentDescriptor(path); +#else aFile->GetNativePath(path); +#endif return LaunchWithIProcess(executable, path); } @@ -423,7 +427,11 @@ nsMIMEInfoImpl::LaunchDefaultWithFile(nsIFile* aFile) return NS_ERROR_FILE_NOT_FOUND; nsAutoCString nativePath; +#ifdef XP_WIN + aFile->GetPersistentDescriptor(nativePath); +#else aFile->GetNativePath(nativePath); +#endif return LaunchWithIProcess(mDefaultApplication, nativePath); } diff --git a/widget/nsDeviceContextSpecProxy.cpp b/widget/nsDeviceContextSpecProxy.cpp index df09272375..7ff3c6e974 100644 --- a/widget/nsDeviceContextSpecProxy.cpp +++ b/widget/nsDeviceContextSpecProxy.cpp @@ -169,7 +169,11 @@ nsDeviceContextSpecProxy::CreateUniqueTempPath(nsACString& aFilePath) return rv; } +#ifdef XP_WIN + return recordingFile->GetPersistentDescriptor(aFilePath); +#else return recordingFile->GetNativePath(aFilePath); +#endif } NS_IMETHODIMP diff --git a/widget/windows/WinTaskbar.cpp b/widget/windows/WinTaskbar.cpp index 530cfd5b94..3c00fae7a6 100644 --- a/widget/windows/WinTaskbar.cpp +++ b/widget/windows/WinTaskbar.cpp @@ -1,4 +1,3 @@ -/* vim: se cin sw=2 ts=2 et : */ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * This Source Code Form is subject to the terms of the Mozilla Public @@ -246,7 +245,7 @@ WinTaskbar::GetAppUserModelID(nsAString & aDefaultGroupId) { bool exists = false; if (profileDir && NS_SUCCEEDED(profileDir->Exists(&exists)) && exists) { nsAutoCString path; - if (NS_SUCCEEDED(profileDir->GetNativePath(path))) { + if (NS_SUCCEEDED(profileDir->GetPersistentDescriptor(path))) { nsAutoString id; id.AppendInt(HashString(path)); if (!id.IsEmpty()) { diff --git a/widget/windows/nsDataObj.cpp b/widget/windows/nsDataObj.cpp index 39b269d0db..81dcb8f162 100644 --- a/widget/windows/nsDataObj.cpp +++ b/widget/windows/nsDataObj.cpp @@ -1294,7 +1294,7 @@ nsDataObj :: GetFileContentsInternetShortcut ( FORMATETC& aFE, STGMEDIUM& aSTG ) rv = mozilla::widget::FaviconHelper::GetOutputIconPath(aUri, icoFile, true); NS_ENSURE_SUCCESS(rv, E_FAIL); - rv = icoFile->GetNativePath(path); + rv = icoFile->GetPersistentDescriptor(path); NS_ENSURE_SUCCESS(rv, E_FAIL); shortcutFormatStr = "[InternetShortcut]\r\nURL=%s\r\n" diff --git a/xpcom/base/nsDumpUtils.cpp b/xpcom/base/nsDumpUtils.cpp index 1333fdb63f..df71bde10b 100644 --- a/xpcom/base/nsDumpUtils.cpp +++ b/xpcom/base/nsDumpUtils.cpp @@ -324,7 +324,11 @@ FifoWatcher::OpenFd() } nsAutoCString path; +#ifdef XP_WIN + rv = file->GetPersistentDescriptor(path); +#else rv = file->GetNativePath(path); +#endif if (NS_WARN_IF(NS_FAILED(rv))) { return -1; } diff --git a/xpcom/build/LateWriteChecks.cpp b/xpcom/build/LateWriteChecks.cpp index 7ace9a0fbd..218454c4d3 100644 --- a/xpcom/build/LateWriteChecks.cpp +++ b/xpcom/build/LateWriteChecks.cpp @@ -122,10 +122,17 @@ InitLateWriteChecks() nsCOMPtr mozFile; NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mozFile)); if (mozFile) { - nsAutoCString nativePath; - nsresult rv = mozFile->GetNativePath(nativePath); - if (NS_SUCCEEDED(rv) && nativePath.get()) { - sLateWriteObserver = new LateWriteObserver(nativePath.get()); + nsAutoCString writeObserverPath; +#ifdef XP_WIN + nsAutoString U16Path; + nsresult rv = mozFile->GetPath(U16Path); + CopyUTF16toUTF8(U16Path, writeObserverPath); +#else + // On non-Windows just get the native path. + nsresult rv = mozFile->GetNativePath(writeObserverPath); +#endif + if (NS_SUCCEEDED(rv) && writeObserverPath.get()) { + sLateWriteObserver = new LateWriteObserver(writeObserverPath.get()); } } } diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp index 185a823155..835f250da1 100644 --- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -688,9 +688,13 @@ NS_InitXPCOM2(nsIServiceManager** aResult, getter_AddRefs(greDir)); MOZ_ASSERT(greDir); nsAutoCString nativeGREPath; +#ifdef XP_WIN + greDir->GetPersistentDescriptor(nativeGREPath); +#else greDir->GetNativePath(nativeGREPath); - u_setDataDirectory(nativeGREPath.get()); #endif + u_setDataDirectory(nativeGREPath.get()); +#endif // MOZ_ICU_DATA_ARCHIVE // Initialize the JS engine. const char* jsInitFailureReason = JS_InitWithFailureDiagnostic(); diff --git a/xpcom/components/nsNativeModuleLoader.cpp b/xpcom/components/nsNativeModuleLoader.cpp index bec3a11757..42e322be1b 100644 --- a/xpcom/components/nsNativeModuleLoader.cpp +++ b/xpcom/components/nsNativeModuleLoader.cpp @@ -104,7 +104,13 @@ nsNativeModuleLoader::LoadModule(FileLocation& aFile) } nsAutoCString filePath; +#ifdef XP_WIN + nsAutoString filePathW; + file->GetPath(filePathW); + CopyUTF16toUTF8(filePathW, filePath); +#else file->GetNativePath(filePath); +#endif NativeLoadData data; diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp index 2ff05666b1..db1d646bf2 100644 --- a/xpcom/io/nsLocalFileWin.cpp +++ b/xpcom/io/nsLocalFileWin.cpp @@ -3564,7 +3564,7 @@ nsLocalFile::SetNativeLeafName(const nsACString& aLeafName) NS_IMETHODIMP nsLocalFile::GetNativePath(nsACString& aResult) { - //NS_WARNING("This API is lossy. Use GetPath !"); + NS_WARNING("The GetNativePath API is lossy. Use GetPath!"); nsAutoString tmp; nsresult rv = GetPath(tmp); if (NS_SUCCEEDED(rv)) { @@ -3578,7 +3578,7 @@ nsLocalFile::GetNativePath(nsACString& aResult) NS_IMETHODIMP nsLocalFile::GetNativeCanonicalPath(nsACString& aResult) { - NS_WARNING("This method is lossy. Use GetCanonicalPath !"); + NS_WARNING("This method is lossy. Use GetCanonicalPath!"); EnsureShortPath(); NS_CopyUnicodeToNative(mShortWorkingPath, aResult); return NS_OK; @@ -3646,7 +3646,7 @@ nsLocalFile::GetNativeTarget(nsACString& aResult) // Check we are correctly initialized. CHECK_mWorkingPath(); - NS_WARNING("This API is lossy. Use GetTarget !"); + NS_WARNING("This API is lossy. Use GetTarget!"); nsAutoString tmp; nsresult rv = GetTarget(tmp); if (NS_SUCCEEDED(rv)) { -- cgit v1.2.3