mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1311466 - Part 4: Add a C++ only getFileDescriptor() method to nsIFileMetadata interface. All file stream implementations (nsFileInputStream, nsPartialFileInputStream, nsFileOutputStream, nsAtomicFileOutputStream, nsSafeFileOutputStream and nsFileStream) support nsIFileMetadata interface so the new method is available on all these streams. The returned file descriptor can be used for memory mapping of the underlying file. The new method exposes stream's internal member variable, so it should be used carefully; r=froydnj
This commit is contained in:
parent
00707ba46a
commit
12b2353123
@ -167,6 +167,22 @@ nsFileStreamBase::GetLastModified(int64_t* _retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileStreamBase::GetFileDescriptor(PRFileDesc** _retval)
|
||||
{
|
||||
nsresult rv = DoPendingOpen();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!mFD) {
|
||||
return NS_BASE_STREAM_CLOSED;
|
||||
}
|
||||
|
||||
*_retval = mFD;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFileStreamBase::Close()
|
||||
{
|
||||
|
@ -8,6 +8,12 @@
|
||||
|
||||
interface nsIFile;
|
||||
|
||||
%{C++
|
||||
struct PRFileDesc;
|
||||
%}
|
||||
|
||||
[ptr] native PRFileDescPtr(PRFileDesc);
|
||||
|
||||
/**
|
||||
* An input stream that allows you to read from a file.
|
||||
*/
|
||||
@ -222,4 +228,10 @@ interface nsIFileMetadata : nsISupports
|
||||
* January 1, 1970 Greenwich Mean Time (GMT).
|
||||
*/
|
||||
readonly attribute long long lastModified;
|
||||
|
||||
/**
|
||||
* The internal file descriptor. It can be used for memory mapping of the
|
||||
* underlying file. Please use carefully!
|
||||
*/
|
||||
[noscript] PRFileDescPtr getFileDescriptor();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user