зеркало из https://github.com/mozilla/gecko-dev.git
Added NewChannelFromNativePath for convenience.
This commit is contained in:
Родитель
158480b852
Коммит
98606d8e53
|
@ -18,10 +18,6 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{C++
|
||||
#include "nscore.h" // for PRUnichar
|
||||
%}
|
||||
|
||||
interface nsIProtocolHandler;
|
||||
interface nsIURI;
|
||||
interface nsIEventSinkGetter;
|
||||
|
@ -31,6 +27,7 @@ interface nsIStreamListener;
|
|||
interface nsIEventQueue;
|
||||
interface nsIBufferInputStream;
|
||||
interface nsIBufferOutputStream;
|
||||
interface nsIFileChannel;
|
||||
|
||||
[scriptable, uuid(01f0a170-1881-11d3-9337-00104ba0fd40)]
|
||||
interface nsIIOService : nsISupports
|
||||
|
@ -128,6 +125,11 @@ interface nsIIOService : nsISupports
|
|||
nsIStreamListener NewSyncStreamListener(out nsIBufferInputStream inStream,
|
||||
out nsIBufferOutputStream outStream);
|
||||
|
||||
/**
|
||||
* This convenience routine first looks up the file protocol handler, and
|
||||
* then uses it to construct a file channel from a native path string.
|
||||
*/
|
||||
nsIFileChannel NewChannelFromNativePath(in string nativePath);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "prprf.h"
|
||||
#include "prmem.h" // for PR_Malloc
|
||||
#include <ctype.h> // for isalpha
|
||||
#include "nsIFileProtocolHandler.h" // for NewChannelFromNativePath
|
||||
|
||||
static NS_DEFINE_CID(kFileTransportService, NS_FILETRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID);
|
||||
|
@ -292,6 +293,29 @@ nsIOService::NewSyncStreamListener(nsIBufferInputStream **inStream,
|
|||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIOService::NewChannelFromNativePath(const char *nativePath, nsIFileChannel **result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIProtocolHandler* handler;
|
||||
rv = GetProtocolHandler("file", &handler);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIFileProtocolHandler* fileHandler = nsnull;
|
||||
rv = handler->QueryInterface(nsIFileProtocolHandler::GetIID(),
|
||||
(void**)&fileHandler);
|
||||
NS_RELEASE(handler);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIFileChannel* channel;
|
||||
rv = fileHandler->NewChannelFromNativePath(nativePath, &channel);
|
||||
NS_RELEASE(fileHandler);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = channel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// HELPER ROUTINES
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
NS_IMETHOD NewAsyncStreamObserver(nsIStreamObserver *receiver, nsIEventQueue *eventQueue, nsIStreamObserver **_retval);
|
||||
NS_IMETHOD NewAsyncStreamListener(nsIStreamListener *receiver, nsIEventQueue *eventQueue, nsIStreamListener **_retval);
|
||||
NS_IMETHOD NewSyncStreamListener(nsIBufferInputStream **inStream, nsIBufferOutputStream **outStream, nsIStreamListener **_retval);
|
||||
NS_IMETHOD NewChannelFromNativePath(const char *nativePath, nsIFileChannel **_retval);
|
||||
|
||||
// nsIOService methods:
|
||||
nsIOService();
|
||||
|
|
Загрузка…
Ссылка в новой задаче