зеркало из https://github.com/mozilla/pjs.git
Bug 482942. Implement nsILocalFile::DELETE_ON_CLOSE. r=bsmedberg
This commit is contained in:
Родитель
11ab6c6a18
Коммит
432e24cfea
|
@ -101,9 +101,17 @@ interface nsILocalFile : nsIFile
|
|||
*/
|
||||
attribute PRBool followLinks;
|
||||
|
||||
const unsigned long DELETE_ON_CLOSE = 0x80000000;
|
||||
|
||||
/**
|
||||
* Return the result of PR_Open on the file. The caller is
|
||||
* responsible for calling PR_Close on the result.
|
||||
*
|
||||
* @param flags the PR_Open flags from prio.h, plus optionally
|
||||
* DELETE_ON_CLOSE. DELETE_ON_CLOSE may be implemented by removing
|
||||
* the file (by path name) immediately after opening it, so beware
|
||||
* of possible races; the file should be exclusively owned by this
|
||||
* process.
|
||||
*/
|
||||
[noscript] PRFileDescStar openNSPRFileDesc(in long flags, in long mode);
|
||||
|
||||
|
|
|
@ -731,6 +731,10 @@ nsLocalFile::OpenNSPRFileDesc(PRInt32 flags, PRInt32 mode, PRFileDesc **_retval)
|
|||
if (*_retval)
|
||||
return NS_OK;
|
||||
|
||||
if (flags & DELETE_ON_CLOSE) {
|
||||
PR_Delete(mWorkingPath.get());
|
||||
}
|
||||
|
||||
return NS_ErrorAccordingToNSPR();
|
||||
}
|
||||
|
||||
|
@ -749,8 +753,6 @@ nsLocalFile::OpenANSIFileDesc(const char *mode, FILE * *_retval)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::Create(PRUint32 type, PRUint32 attributes)
|
||||
{
|
||||
|
|
|
@ -1467,6 +1467,10 @@ NS_IMETHODIMP nsLocalFile::OpenNSPRFileDesc(PRInt32 flags, PRInt32 mode, PRFileD
|
|||
if (! *_retval)
|
||||
return NS_ErrorAccordingToNSPR();
|
||||
|
||||
if (flags & DELETE_ON_CLOSE) {
|
||||
PR_Delete(path.get());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -408,6 +408,10 @@ nsLocalFile::OpenNSPRFileDesc(PRInt32 flags, PRInt32 mode, PRFileDesc **_retval)
|
|||
if (! *_retval)
|
||||
return NS_ErrorAccordingToNSPR();
|
||||
|
||||
if (flags & DELETE_ON_CLOSE) {
|
||||
PR_Delete(mPath.get());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -401,6 +401,10 @@ OpenFile(const nsAFlatString &name, PRIntn osflags, PRIntn mode,
|
|||
flags = OPEN_EXISTING;
|
||||
}
|
||||
|
||||
if (osflags & nsILocalFile::DELETE_ON_CLOSE) {
|
||||
flag6 |= FILE_FLAG_DELETE_ON_CLOSE;
|
||||
}
|
||||
|
||||
HANDLE file = ::CreateFileW(name.get(), access,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||
NULL, flags, flag6, NULL);
|
||||
|
|
Загрузка…
Ссылка в новой задаче