diff --git a/xpcom/base/moz.build b/xpcom/base/moz.build index 581454393d0..f2027b2e1a5 100644 --- a/xpcom/base/moz.build +++ b/xpcom/base/moz.build @@ -53,6 +53,7 @@ EXPORTS += [ 'nscore.h', 'nsCycleCollector.h', 'nsDebugImpl.h', + 'nsDumpUtils.h', 'nsError.h', 'nsGZFileWriter.h', 'nsIID.h', diff --git a/xpcom/base/nsDumpUtils.cpp b/xpcom/base/nsDumpUtils.cpp index 0007e8c3a8e..35b0a3862b2 100644 --- a/xpcom/base/nsDumpUtils.cpp +++ b/xpcom/base/nsDumpUtils.cpp @@ -435,7 +435,7 @@ FifoWatcher::OnFileCanReadWithoutBlocking(int aFd) // Otherwise, it will open a file named aFilename under "NS_OS_TEMP_DIR". /* static */ nsresult nsDumpUtils::OpenTempFile(const nsACString& aFilename, nsIFile** aFile, - const nsACString& aFoldername) + const nsACString& aFoldername, Mode aMode) { #ifdef ANDROID // For Android, first try the downloads directory which is world-readable @@ -488,9 +488,13 @@ nsDumpUtils::OpenTempFile(const nsACString& aFilename, nsIFile** aFile, return rv; } - rv = file->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0666); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; + if (aMode == CREATE_UNIQUE) { + rv = file->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0666); + if (NS_WARN_IF(NS_FAILED(rv))) { + return rv; + } + } else { + file->Create(nsIFile::NORMAL_FILE_TYPE, 0666); } #ifdef ANDROID diff --git a/xpcom/base/nsDumpUtils.h b/xpcom/base/nsDumpUtils.h index 5b341a10922..56c58f7eec6 100644 --- a/xpcom/base/nsDumpUtils.h +++ b/xpcom/base/nsDumpUtils.h @@ -180,10 +180,15 @@ private: #endif // XP_UNIX } - class nsDumpUtils { public: + + enum Mode { + CREATE, + CREATE_UNIQUE + }; + /** * This function creates a new unique file based on |aFilename| in a * world-readable temp directory. This is the system temp directory @@ -193,7 +198,8 @@ public: */ static nsresult OpenTempFile(const nsACString& aFilename, nsIFile** aFile, - const nsACString& aFoldername = EmptyCString()); + const nsACString& aFoldername = EmptyCString(), + Mode aMode = CREATE_UNIQUE); }; #endif