Родитель
45fc9dc2ed
Коммит
798f3859c5
|
@ -4172,10 +4172,10 @@ nsresult nsDocShell::DoURILoad(nsIURI * aURI,
|
|||
// XXX it's a bit of a hack to rewind the postdata stream here but
|
||||
// it has to be done in case the post data is being reused multiple
|
||||
// times.
|
||||
nsCOMPtr<nsISeekableStream>
|
||||
nsCOMPtr<nsIRandomAccessStore>
|
||||
postDataRandomAccess(do_QueryInterface(aPostData));
|
||||
if (postDataRandomAccess) {
|
||||
postDataRandomAccess->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
postDataRandomAccess->Seek(PR_SEEK_SET, 0);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel));
|
||||
|
|
|
@ -1188,10 +1188,10 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress,
|
|||
httpChannel->GetUploadStream(getter_AddRefs(inputStream));
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsISeekableStream> postDataRandomAccess(do_QueryInterface(inputStream));
|
||||
nsCOMPtr<nsIRandomAccessStore> postDataRandomAccess(do_QueryInterface(inputStream));
|
||||
if (postDataRandomAccess)
|
||||
{
|
||||
postDataRandomAccess->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
postDataRandomAccess->Seek(PR_SEEK_SET, 0);
|
||||
}
|
||||
InternalLoad(url, // URI
|
||||
referrer, // Refering URI
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#undef NO_XPCOM_FILE_STREAMS
|
||||
|
||||
#include "nsIFileStreams.h" // New Necko file streams
|
||||
#include "nsISeekableStream.h"
|
||||
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIFileTransportService.h"
|
||||
|
@ -484,11 +483,11 @@ nsresult nsWebBrowserPersist::SaveURIInternal(
|
|||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(inputChannel));
|
||||
if (httpChannel)
|
||||
{
|
||||
nsCOMPtr<nsISeekableStream> stream(do_QueryInterface(aPostData));
|
||||
nsCOMPtr<nsIRandomAccessStore> stream(do_QueryInterface(aPostData));
|
||||
if (stream)
|
||||
{
|
||||
// Rewind the postdata stream
|
||||
stream->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
stream->Seek(PR_SEEK_SET, 0);
|
||||
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel));
|
||||
NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel");
|
||||
// Attach the postdata to the http channel
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include "nsIMsgAccountManager.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsLocalFolderSummarySpec.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsITransport.h"
|
||||
|
@ -590,9 +589,9 @@ NS_IMETHODIMP nsMsgDBFolder::GetOfflineStoreOutputStream(nsIOutputStream **outpu
|
|||
rv = NS_NewIOFileStream(getter_AddRefs(supports), fileSpec, PR_WRONLY | PR_CREATE_FILE, 00700);
|
||||
supports->QueryInterface(NS_GET_IID(nsIOutputStream), (void **) outputStream);
|
||||
|
||||
nsCOMPtr <nsISeekableStream> seekable = do_QueryInterface(supports);
|
||||
if (seekable)
|
||||
seekable->Seek(nsISeekableStream::NS_SEEK_END, 0);
|
||||
nsCOMPtr <nsIRandomAccessStore> randomStore = do_QueryInterface(supports);
|
||||
if (randomStore)
|
||||
randomStore->Seek(PR_SEEK_END, 0);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -1302,23 +1301,23 @@ nsresult nsMsgDBFolder::WriteStartOfNewLocalMessage()
|
|||
result += ct;
|
||||
result += MSG_LINEBREAK;
|
||||
|
||||
nsCOMPtr <nsISeekableStream> seekable;
|
||||
PRUint32 curStorePos;
|
||||
nsCOMPtr <nsIRandomAccessStore> randomStore;
|
||||
PRInt32 curStorePos;
|
||||
|
||||
if (m_offlineHeader)
|
||||
seekable = do_QueryInterface(m_tempMessageStream);
|
||||
randomStore = do_QueryInterface(m_tempMessageStream);
|
||||
|
||||
if (seekable)
|
||||
if (randomStore)
|
||||
{
|
||||
seekable->Tell(&curStorePos);
|
||||
randomStore->Tell(&curStorePos);
|
||||
m_offlineHeader->SetMessageOffset(curStorePos);
|
||||
}
|
||||
m_tempMessageStream->Write(result.get(), result.Length(),
|
||||
&writeCount);
|
||||
if (seekable)
|
||||
if (randomStore)
|
||||
{
|
||||
m_tempMessageStream->Flush();
|
||||
seekable->Tell(&curStorePos);
|
||||
randomStore->Tell(&curStorePos);
|
||||
m_offlineHeader->SetStatusOffset(curStorePos);
|
||||
}
|
||||
|
||||
|
@ -1343,21 +1342,21 @@ nsresult nsMsgDBFolder::StartNewOfflineMessage()
|
|||
|
||||
nsresult nsMsgDBFolder::EndNewOfflineMessage()
|
||||
{
|
||||
nsCOMPtr <nsISeekableStream> seekable;
|
||||
PRUint32 curStorePos;
|
||||
nsCOMPtr <nsIRandomAccessStore> randomStore;
|
||||
PRInt32 curStorePos;
|
||||
PRUint32 messageOffset;
|
||||
nsMsgKey messageKey;
|
||||
|
||||
m_offlineHeader->GetMessageKey(&messageKey);
|
||||
if (m_tempMessageStream)
|
||||
seekable = do_QueryInterface(m_tempMessageStream);
|
||||
randomStore = do_QueryInterface(m_tempMessageStream);
|
||||
|
||||
mDatabase->MarkOffline(messageKey, PR_TRUE, nsnull);
|
||||
if (seekable)
|
||||
if (randomStore)
|
||||
{
|
||||
m_tempMessageStream->Flush();
|
||||
|
||||
seekable->Tell(&curStorePos);
|
||||
randomStore->Tell(&curStorePos);
|
||||
m_offlineHeader->GetMessageOffset(&messageOffset);
|
||||
m_offlineHeader->SetOfflineMessageSize(curStorePos - messageOffset);
|
||||
m_offlineHeader->SetLineCount(m_numOfflineMsgLines);
|
||||
|
|
|
@ -4850,29 +4850,29 @@ nsresult nsImapMailFolder::CopyOfflineMsgBody(nsIMsgFolder *srcFolder, nsIMsgDBH
|
|||
{
|
||||
nsCOMPtr<nsIOutputStream> outputStream;
|
||||
nsresult rv = GetOfflineStoreOutputStream(getter_AddRefs(outputStream));
|
||||
nsCOMPtr <nsISeekableStream> seekable;
|
||||
PRUint32 curStorePos;
|
||||
nsCOMPtr <nsIRandomAccessStore> randomStore;
|
||||
PRInt32 curStorePos;
|
||||
|
||||
seekable = do_QueryInterface(outputStream);
|
||||
randomStore = do_QueryInterface(outputStream);
|
||||
|
||||
if (seekable)
|
||||
if (randomStore)
|
||||
{
|
||||
nsMsgKey messageOffset;
|
||||
PRUint32 messageSize;
|
||||
origHdr->GetMessageOffset(&messageOffset);
|
||||
origHdr->GetOfflineMessageSize(&messageSize);
|
||||
|
||||
seekable->Tell(&curStorePos);
|
||||
randomStore->Tell(&curStorePos);
|
||||
destHdr->SetMessageOffset(curStorePos);
|
||||
nsCOMPtr <nsIInputStream> offlineStoreInputStream;
|
||||
rv = srcFolder->GetOfflineStoreInputStream(getter_AddRefs(offlineStoreInputStream));
|
||||
if (NS_SUCCEEDED(rv) && offlineStoreInputStream)
|
||||
{
|
||||
nsCOMPtr<nsISeekableStream> seekStream = do_QueryInterface(offlineStoreInputStream);
|
||||
nsCOMPtr<nsIRandomAccessStore> seekStream = do_QueryInterface(offlineStoreInputStream);
|
||||
NS_ASSERTION(seekStream, "non seekable stream - can't read from offline msg");
|
||||
if (seekStream)
|
||||
{
|
||||
rv = seekStream->Seek(nsISeekableStream::NS_SEEK_SET, messageOffset);
|
||||
rv = seekStream->Seek(PR_SEEK_SET, messageOffset);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
// now, copy the dest folder offline store msg to the temp file
|
||||
|
@ -5661,9 +5661,9 @@ nsresult nsImapMailFolder::GetOfflineStoreOutputStream(nsIOutputStream **outputS
|
|||
rv = NS_NewIOFileStream(getter_AddRefs(supports), fileSpec, PR_WRONLY | PR_CREATE_FILE, 00700);
|
||||
supports->QueryInterface(NS_GET_IID(nsIOutputStream), (void **) outputStream);
|
||||
|
||||
nsCOMPtr <nsISeekableStream> seekable = do_QueryInterface(supports);
|
||||
if (seekable)
|
||||
seekable->Seek(nsISeekableStream::NS_SEEK_END, 0);
|
||||
nsCOMPtr <nsIRandomAccessStore> randomStore = do_QueryInterface(supports);
|
||||
if (randomStore)
|
||||
randomStore->Seek(PR_SEEK_END, 0);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -48,8 +48,6 @@
|
|||
#include "nsIRequestObserver.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsISeekableStream.h"
|
||||
|
||||
static NS_DEFINE_CID(kMsgAccountManagerCID, NS_MSGACCOUNTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
|
@ -305,11 +303,11 @@ nsImapOfflineSync::ProcessAppendMsgOperation(nsIMsgOfflineImapOperation *current
|
|||
rv = destFolder->GetOfflineStoreInputStream(getter_AddRefs(offlineStoreInputStream));
|
||||
if (NS_SUCCEEDED(rv) && offlineStoreInputStream)
|
||||
{
|
||||
nsCOMPtr<nsISeekableStream> seekStream = do_QueryInterface(offlineStoreInputStream);
|
||||
nsCOMPtr<nsIRandomAccessStore> seekStream = do_QueryInterface(offlineStoreInputStream);
|
||||
NS_ASSERTION(seekStream, "non seekable stream - can't read from offline msg");
|
||||
if (seekStream)
|
||||
{
|
||||
rv = seekStream->Seek(nsISeekableStream::NS_SEEK_SET, messageOffset);
|
||||
rv = seekStream->Seek(PR_SEEK_SET, messageOffset);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
// now, copy the dest folder offline store msg to the temp file
|
||||
|
|
|
@ -82,7 +82,6 @@
|
|||
#include "nsIInputStream.h"
|
||||
#include "nsICopyMsgStreamListener.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsIMsgParseMailMsgState.h"
|
||||
#include "nsMsgLineBuffer.h"
|
||||
#include "nsMsgLocalCID.h"
|
||||
|
@ -2142,10 +2141,10 @@ nsresult nsImapService::OfflineAppendFromFile(nsIFileSpec* aFileSpec,
|
|||
|
||||
if (NS_SUCCEEDED(rv) && offlineStore)
|
||||
{
|
||||
PRUint32 curOfflineStorePos = 0;
|
||||
nsCOMPtr <nsISeekableStream> seekable = do_QueryInterface(offlineStore);
|
||||
if (seekable)
|
||||
seekable->Tell(&curOfflineStorePos);
|
||||
PRInt32 curOfflineStorePos = 0;
|
||||
nsCOMPtr <nsIRandomAccessStore> randomStore = do_QueryInterface(offlineStore);
|
||||
if (randomStore)
|
||||
randomStore->Tell(&curOfflineStorePos);
|
||||
else
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "needs to be a random store!");
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
#include "nsIIOService.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsIFileStream.h" // for nsIRandomAccessStore
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIDocument.h"
|
||||
|
@ -5324,10 +5324,10 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
|
|||
// XXX it's a bit of a hack to rewind the postdata stream
|
||||
// here but it has to be done in case the post data is
|
||||
// being reused multiple times.
|
||||
nsCOMPtr<nsISeekableStream>
|
||||
nsCOMPtr<nsIRandomAccessStore>
|
||||
postDataRandomAccess(do_QueryInterface(postDataStream));
|
||||
if (postDataRandomAccess)
|
||||
postDataRandomAccess->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
postDataRandomAccess->Seek(PR_SEEK_SET, 0);
|
||||
|
||||
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel));
|
||||
NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel");
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
@ -1299,6 +1300,12 @@ nsHttpChannel::ProcessAuthentication(PRUint32 httpStatus)
|
|||
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mUploadStream);
|
||||
if (seekable)
|
||||
seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
else {
|
||||
// try nsIRandomAccessStore
|
||||
nsCOMPtr<nsIRandomAccessStore> ras = do_QueryInterface(mUploadStream);
|
||||
if (ras)
|
||||
ras->Seek(PR_SEEK_SET, 0);
|
||||
}
|
||||
}
|
||||
|
||||
rv = nsHttpHandler::get()->InitiateTransaction(mTransaction, mConnectionInfo);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "nsHttpResponseHead.h"
|
||||
#include "nsHttpChunkedDecoder.h"
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsISocketTransportService.h"
|
||||
#include "pratom.h"
|
||||
#include "plevent.h"
|
||||
|
@ -312,12 +312,12 @@ nsHttpTransaction::Restart()
|
|||
LOG(("restarting transaction @%x\n", this));
|
||||
|
||||
// rewind streams in case we already wrote out the request
|
||||
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mReqHeaderStream);
|
||||
if (seekable)
|
||||
seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
seekable = do_QueryInterface(mReqUploadStream);
|
||||
if (seekable)
|
||||
seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
nsCOMPtr<nsIRandomAccessStore> ras = do_QueryInterface(mReqHeaderStream);
|
||||
if (ras)
|
||||
ras->Seek(PR_SEEK_SET, 0);
|
||||
ras = do_QueryInterface(mReqUploadStream);
|
||||
if (ras)
|
||||
ras->Seek(PR_SEEK_SET, 0);
|
||||
|
||||
// just in case the connection is holding the last reference to us...
|
||||
NS_ADDREF_THIS();
|
||||
|
|
|
@ -76,6 +76,8 @@ PRInt32 nsInputStream::read(void* s, PRInt32 n)
|
|||
return 0;
|
||||
PRInt32 result = 0;
|
||||
mInputStream->Read((char*)s, n, (PRUint32*)&result);
|
||||
if (result == 0)
|
||||
set_at_eof(PR_TRUE);
|
||||
return result;
|
||||
} // nsInputStream::read
|
||||
|
||||
|
|
|
@ -107,7 +107,6 @@
|
|||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsISeekableStream.h"
|
||||
|
||||
// Defined elsewhere
|
||||
class nsFileSpec;
|
||||
|
@ -184,6 +183,7 @@ class NS_COM nsInputStream
|
|||
public:
|
||||
nsInputStream(nsIInputStream* inStream)
|
||||
: mInputStream(do_QueryInterface(inStream))
|
||||
, mEOF(PR_FALSE)
|
||||
{}
|
||||
virtual ~nsInputStream();
|
||||
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
{
|
||||
return mInputStream;
|
||||
}
|
||||
PRBool eof() { return at_eof(); }
|
||||
PRBool eof() const { return get_at_eof(); }
|
||||
char get();
|
||||
nsresult close()
|
||||
{
|
||||
|
@ -217,9 +217,14 @@ protected:
|
|||
|
||||
// These certainly need to be overridden, they give the best shot we can at detecting
|
||||
// eof in a simple nsIInputStream.
|
||||
virtual void set_eof() { }
|
||||
virtual PRBool at_eof() { return PR_FALSE; }
|
||||
|
||||
virtual void set_at_eof(PRBool atEnd)
|
||||
{
|
||||
mEOF = atEnd;
|
||||
}
|
||||
virtual PRBool get_at_eof() const
|
||||
{
|
||||
return mEOF;
|
||||
}
|
||||
private:
|
||||
|
||||
nsInputStream& operator >> (char* buf); // TOO DANGEROUS. DON'T DEFINE.
|
||||
|
@ -231,6 +236,7 @@ private:
|
|||
// DATA
|
||||
protected:
|
||||
nsCOMPtr<nsIInputStream> mInputStream;
|
||||
PRBool mEOF;
|
||||
}; // class nsInputStream
|
||||
|
||||
typedef nsInputStream nsBasicInStream; // historic support for this name
|
||||
|
@ -376,7 +382,7 @@ public:
|
|||
nsRandomAccessStoreClient() // for delayed opening
|
||||
{
|
||||
}
|
||||
nsRandomAccessStoreClient(const nsCOMPtr<nsISeekableStream>& inStore)
|
||||
nsRandomAccessStoreClient(const nsCOMPtr<nsIRandomAccessStore>& inStore)
|
||||
: mStore(do_QueryInterface(inStore))
|
||||
{
|
||||
}
|
||||
|
@ -389,12 +395,13 @@ public:
|
|||
|
||||
void seek(PRSeekWhence whence, PRInt32 offset)
|
||||
{
|
||||
set_at_eof(PR_FALSE);
|
||||
if (mStore)
|
||||
mResult = mStore->Seek(whence, offset);
|
||||
}
|
||||
PRUint32 tell()
|
||||
PRIntn tell()
|
||||
{
|
||||
PRUint32 result = 0;
|
||||
PRIntn result = -1;
|
||||
if (mStore)
|
||||
mResult = mStore->Tell(&result);
|
||||
return result;
|
||||
|
@ -402,10 +409,18 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
virtual void set_eof()
|
||||
virtual PRBool get_at_eof() const
|
||||
{
|
||||
PRBool result = PR_TRUE;
|
||||
if (mStore)
|
||||
mStore->GetAtEOF(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual void set_at_eof(PRBool atEnd)
|
||||
{
|
||||
if (mStore)
|
||||
mStore->SetEOF();
|
||||
mStore->SetAtEOF(atEnd);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -416,7 +431,7 @@ private:
|
|||
|
||||
// DATA
|
||||
protected:
|
||||
nsCOMPtr<nsISeekableStream> mStore;
|
||||
nsCOMPtr<nsIRandomAccessStore> mStore;
|
||||
}; // class nsRandomAccessStoreClient
|
||||
|
||||
//========================================================================================
|
||||
|
@ -450,9 +465,14 @@ protected:
|
|||
{
|
||||
}
|
||||
|
||||
virtual void set_eof()
|
||||
virtual PRBool get_at_eof() const
|
||||
{
|
||||
nsRandomAccessStoreClient::set_eof();
|
||||
return nsRandomAccessStoreClient::get_at_eof();
|
||||
}
|
||||
|
||||
virtual void set_at_eof(PRBool atEnd)
|
||||
{
|
||||
nsRandomAccessStoreClient::set_at_eof(atEnd);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
@ -58,7 +57,7 @@
|
|||
|
||||
//========================================================================================
|
||||
class FileImpl
|
||||
: public nsISeekableStream
|
||||
: public nsIRandomAccessStore
|
||||
, public nsIFileSpecOutputStream
|
||||
, public nsIFileSpecInputStream
|
||||
, public nsIOpenFile
|
||||
|
@ -75,9 +74,9 @@ class FileImpl
|
|||
// nsIOpenFile interface
|
||||
NS_IMETHOD Open(const nsFileSpec& inFile, int nsprMode, PRIntn accessMode);
|
||||
NS_IMETHOD Close();
|
||||
NS_IMETHOD Seek(PRSeekWhence whence, PRInt32 offset);
|
||||
NS_IMETHOD GetIsOpen(PRBool* outOpen);
|
||||
|
||||
NS_DECL_NSISEEKABLESTREAM
|
||||
NS_IMETHOD Tell(PRIntn* outWhere);
|
||||
|
||||
// nsIInputStream interface
|
||||
NS_IMETHOD Available(PRUint32 *aLength);
|
||||
|
@ -95,6 +94,8 @@ class FileImpl
|
|||
NS_IMETHOD SetNonBlocking(PRBool aNonBlocking);
|
||||
NS_IMETHOD GetObserver(nsIOutputStreamObserver * *aObserver);
|
||||
NS_IMETHOD SetObserver(nsIOutputStreamObserver * aObserver);
|
||||
NS_IMETHOD GetAtEOF(PRBool* outAtEOF);
|
||||
NS_IMETHOD SetAtEOF(PRBool inAtEOF);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -123,7 +124,7 @@ NS_IMPL_ADDREF(FileImpl)
|
|||
|
||||
NS_IMPL_QUERY_HEAD(FileImpl)
|
||||
NS_IMPL_QUERY_BODY(nsIOpenFile)
|
||||
NS_IMPL_QUERY_BODY(nsISeekableStream)
|
||||
NS_IMPL_QUERY_BODY(nsIRandomAccessStore)
|
||||
NS_IMPL_QUERY_BODY(nsIOutputStream)
|
||||
NS_IMPL_QUERY_BODY(nsIInputStream)
|
||||
NS_IMPL_QUERY_BODY(nsIFileSpecInputStream)
|
||||
|
@ -277,7 +278,7 @@ NS_IMETHODIMP FileImpl::Open(
|
|||
err = FSpOpenDF(&spec, perm, &refnum);
|
||||
|
||||
if (err == noErr && (nsprMode & PR_TRUNCATE))
|
||||
err = ::SetEOF(refnum, 0);
|
||||
err = SetEOF(refnum, 0);
|
||||
if (err == noErr && (nsprMode & PR_APPEND))
|
||||
err = SetFPos(refnum, fsFromLEOF, 0);
|
||||
if (err != noErr)
|
||||
|
@ -320,7 +321,7 @@ NS_IMETHODIMP FileImpl::GetIsOpen(PRBool* outOpen)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP FileImpl::Seek(PRInt32 whence, PRInt32 offset)
|
||||
NS_IMETHODIMP FileImpl::Seek(PRSeekWhence whence, PRInt32 offset)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mFileDesc==PR_STDIN || mFileDesc==PR_STDOUT || mFileDesc==PR_STDERR || !mFileDesc)
|
||||
|
@ -529,7 +530,7 @@ FileImpl::SetObserver(nsIOutputStreamObserver * aObserver)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP FileImpl::Tell(PRUint32* outWhere)
|
||||
NS_IMETHODIMP FileImpl::Tell(PRIntn* outWhere)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mFileDesc==PR_STDIN || mFileDesc==PR_STDOUT || mFileDesc==PR_STDERR || !mFileDesc)
|
||||
|
@ -603,11 +604,20 @@ NS_IMETHODIMP FileImpl::Flush()
|
|||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP FileImpl::SetEOF()
|
||||
NS_IMETHODIMP FileImpl::GetAtEOF(PRBool* outAtEOF)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("FileImpl::SetEOF");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*outAtEOF = mEOF;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP FileImpl::SetAtEOF(PRBool inAtEOF)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mEOF = inAtEOF;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
|
|
@ -67,6 +67,27 @@ public:
|
|||
|
||||
}; // class nsIOpenFile
|
||||
|
||||
/* a6cf90e8-15b3-11d2-932e-00805f8add32 */
|
||||
#define NS_IRANDOMACCESS_IID \
|
||||
{ 0xa6cf90eb, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
//========================================================================================
|
||||
class nsIRandomAccessStore
|
||||
// Supports Seek, Tell etc.
|
||||
//========================================================================================
|
||||
: public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRANDOMACCESS_IID; return iid; }
|
||||
NS_IMETHOD Seek(PRSeekWhence whence, PRInt32 offset) = 0;
|
||||
NS_IMETHOD Tell(PRIntn* outWhere) = 0;
|
||||
|
||||
/* "PROTECTED" */
|
||||
NS_IMETHOD GetAtEOF(PRBool* outAtEOF) = 0;
|
||||
NS_IMETHOD SetAtEOF(PRBool inAtEOF) = 0;
|
||||
}; // class nsIRandomAccessStore
|
||||
|
||||
|
||||
#ifndef NO_XPCOM_FILE_STREAMS // hack to work around duplicate class definitions in here
|
||||
// and mozilla/netwerks/base/nsIFileStreams.idl
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsISeekableStream.h"
|
||||
|
||||
#include "prerror.h"
|
||||
#include "nsFileSpec.h"
|
||||
|
@ -48,16 +47,17 @@
|
|||
class BasicStringImpl
|
||||
: public nsIOutputStream
|
||||
, public nsIInputStream
|
||||
, public nsISeekableStream
|
||||
, public nsIRandomAccessStore
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
BasicStringImpl();
|
||||
virtual ~BasicStringImpl();
|
||||
|
||||
NS_IMETHOD Seek(PRInt32 whence, PRInt32 offset);
|
||||
NS_IMETHOD Tell(PRUint32* outWhere);
|
||||
NS_IMETHOD SetEOF();
|
||||
NS_IMETHOD Seek(PRSeekWhence whence, PRInt32 offset);
|
||||
NS_IMETHOD Tell(PRIntn* outWhere);
|
||||
NS_IMETHOD GetAtEOF(PRBool* outAtEOF);
|
||||
NS_IMETHOD SetAtEOF(PRBool inAtEOF);
|
||||
NS_IMETHOD Available(PRUint32 *aLength);
|
||||
NS_IMETHOD Read(char* aBuf,
|
||||
PRUint32 aCount,
|
||||
|
@ -123,7 +123,7 @@ BasicStringImpl::~BasicStringImpl()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP BasicStringImpl::Seek(PRInt32 whence, PRInt32 offset)
|
||||
NS_IMETHODIMP BasicStringImpl::Seek(PRSeekWhence whence, PRInt32 offset)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mLastResult = NS_OK; // reset on a seek.
|
||||
|
@ -151,7 +151,7 @@ NS_IMETHODIMP BasicStringImpl::Seek(PRInt32 whence, PRInt32 offset)
|
|||
} // StringImpl::Seek
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP BasicStringImpl::Tell(PRUint32* outWhere)
|
||||
NS_IMETHODIMP BasicStringImpl::Tell(PRIntn* outWhere)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*outWhere = mOffset;
|
||||
|
@ -159,11 +159,19 @@ NS_IMETHODIMP BasicStringImpl::Tell(PRUint32* outWhere)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP BasicStringImpl::SetEOF()
|
||||
NS_IMETHODIMP BasicStringImpl::GetAtEOF(PRBool* outAtEOF)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("BasicStringImpl::SetEOF");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*outAtEOF = mEOF;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP BasicStringImpl::SetAtEOF(PRBool inAtEOF)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mEOF = inAtEOF;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
@ -196,6 +204,8 @@ NS_IMETHODIMP BasicStringImpl::Read(char* aBuf, PRUint32 aCount, PRUint32 *aRead
|
|||
return mLastResult;
|
||||
}
|
||||
*aReadCount = bytesRead;
|
||||
if (bytesRead < (PRInt32)aCount)
|
||||
SetAtEOF(PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -485,7 +495,7 @@ NS_IMPL_THREADSAFE_ADDREF(BasicStringImpl)
|
|||
NS_IMPL_THREADSAFE_RELEASE(BasicStringImpl)
|
||||
|
||||
NS_IMPL_QUERY_HEAD(BasicStringImpl)
|
||||
NS_IMPL_QUERY_BODY(nsISeekableStream)
|
||||
NS_IMPL_QUERY_BODY(nsIRandomAccessStore)
|
||||
NS_IMPL_QUERY_BODY(nsIOutputStream)
|
||||
NS_IMPL_QUERY_BODY(nsIInputStream)
|
||||
NS_IMPL_QUERY_TAIL(nsIOutputStream)
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "nsICachingChannel.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsIFileStream.h"
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
|
@ -210,9 +210,9 @@ nsStreamTransfer::SelectFileAndTransferLocationSpec( char const *aURL,
|
|||
nsCOMPtr<nsIHttpChannel> httpChannel( do_QueryInterface( channel ) );
|
||||
if ( httpChannel ) {
|
||||
// Rewind stream and attach to channel.
|
||||
nsCOMPtr<nsISeekableStream> seekable( do_QueryInterface( postData ) );
|
||||
if ( seekable ) {
|
||||
seekable->Seek( nsISeekableStream::NS_SEEK_SET, 0 );
|
||||
nsCOMPtr<nsIRandomAccessStore> stream( do_QueryInterface( postData ) );
|
||||
if ( stream ) {
|
||||
stream->Seek( PR_SEEK_SET, 0 );
|
||||
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel));
|
||||
NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel");
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче