Closed
Bug 319636
Opened 19 years ago
Closed 19 years ago
Provide convenience function for consuming an entire nsIInputStream
Categories
(Core :: XPCOM, enhancement)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla1.9alpha1
People
(Reporter: darin.moz, Assigned: darin.moz)
References
Details
(Keywords: fixed1.8.1)
Attachments
(2 files)
10.68 KB,
patch
|
Biesinger
:
review+
bzbarsky
:
superreview+
|
Details | Diff | Splinter Review |
10.61 KB,
patch
|
Details | Diff | Splinter Review |
Provide convenience function for consuming an entire nsIInputStream
Assignee | ||
Comment 1•19 years ago
|
||
Simple patch. This is something the places project wants to use.
Attachment #205355 -
Flags: superreview?(bzbarsky)
Attachment #205355 -
Flags: review?(cbiesinger)
Assignee | ||
Updated•19 years ago
|
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.9alpha
Comment 2•19 years ago
|
||
Comment on attachment 205355 [details] [diff] [review]
v1 patch
>Index: io/nsStreamUtils.h
>Index: io/nsStreamUtils.cpp
>+NS_ConsumeStream(nsIInputStream *stream, nsACString &result)
>+ char *buf = result.BeginWriting();
Shouldn't you add |length| here? Otherwise you're always reading into the beginning of the string...
sr=bzbarsky with that fixed.
Attachment #205355 -
Flags: superreview?(bzbarsky) → superreview+
Assignee | ||
Comment 3•19 years ago
|
||
Yes, indeed. My testcase was apparently not comprehensive enough :-(
Comment 4•19 years ago
|
||
The stream in the testcase just handed back all the data in a single chunk is all... ;)
Comment 5•19 years ago
|
||
Comment on attachment 205355 [details] [diff] [review]
v1 patch
heh, the other day I was thinking that a function like this would be useful :)
should the comments say that the stream needs to be blocking for reasonable behaviour? (at least I think that's the case...)
shouldn't you truncate the string at the beginning of this function?
Attachment #205355 -
Flags: review?(cbiesinger) → review+
Assignee | ||
Comment 6•19 years ago
|
||
I decided to let this function work with non-blocking streams as well. The comments say that the function will append to the buffer and return a failure if it encountered an error at some point, but any data in the buffer will remain in the buffer. This allows the function to be used with either type of stream.
I can make the function Truncate up front I suppose. That makes the function a little less useful, but it perhaps makes its behavior a bit more predictable. Hmm...
Assignee | ||
Comment 7•19 years ago
|
||
Here's the version of the patch that I checked in.
Assignee | ||
Updated•19 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Comment 8•19 years ago
|
||
This patch is giving me the following error on WinXP/cygwin/Mingw
e:/mozilla/source/mozilla/xpcom/build/dlldeps.cpp: In function `void XXXNeverCal
led()':
e:/mozilla/source/mozilla/xpcom/build/dlldeps.cpp:122: error: cannot convert `ns
CString' to `PRUint32' for argument `2' to `nsresult NS_ConsumeStream(nsIInputSt
ream*, PRUint32, nsACString_internal&)'
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 9•19 years ago
|
||
> CString' to `PRUint32' for argument `2' to `nsresult
> NS_ConsumeStream(nsIInputSt
crap, the line in dlldeps.cpp needs to have a "0" in the second parameter to NS_ConsumeStream. It looks like the CVS servers are down for the count, so I won't be able to fix this until they come back online.
Comment 10•19 years ago
|
||
(In reply to comment #9)
> crap, the line in dlldeps.cpp needs to have a "0" in the second parameter to
> NS_ConsumeStream. It looks like the CVS servers are down for the count, so I
> won't be able to fix this until they come back online.
I tried to build Sunbird from trunk today (dlldeps.cpp,v1.137 with "0") and get the following error:
c:/dev/moz_build/mozilla/xpcom/build/dlldeps.cpp:
In function `void XXXNeverCalled()':
c:/dev/moz_build/mozilla/xpcom/build/dlldeps.cpp:122:
error: invalid initialization of non-const reference of type
'nsACString_internal&' from a temporary of type 'nsCString'
c:/dev/moz_build/mozilla/xpcom/build/../io/nsStreamUtils.h:136:
error: in passing argument 3 of `nsresult NS_ConsumeStream(nsIInputStream*,
PRUint32, nsACString_internal&)'
Assignee | ||
Comment 11•19 years ago
|
||
I applied a fix for this. Please update dlldeps.cpp
Assignee | ||
Updated•19 years ago
|
Status: REOPENED → RESOLVED
Closed: 19 years ago → 19 years ago
Resolution: --- → FIXED
Updated•19 years ago
|
Keywords: fixed1.8.1
You need to log in
before you can comment on or make changes to this bug.
Description
•