Bug 661529: Add NS_ReadInputStreamToBuffer to complement NS_ReadInputStreamToString. r=biesi

--HG--
extra : rebase_source : 81b8876a34a2ec8c6fd0c2092b697fb8e2472a4a
This commit is contained in:
Kyle Huey 2011-06-08 11:11:41 -07:00
Родитель e44f63ef14
Коммит 56b2bcdf35
1 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -1171,16 +1171,19 @@ NS_NewPostDataStream(nsIInputStream **result,
}
inline nsresult
NS_ReadInputStreamToString(nsIInputStream *aInputStream,
nsACString &aDest,
NS_ReadInputStreamToBuffer(nsIInputStream *aInputStream,
void** aDest,
PRUint32 aCount)
{
nsresult rv;
aDest.SetLength(aCount);
if (aDest.Length() != aCount)
return NS_ERROR_OUT_OF_MEMORY;
char * p = aDest.BeginWriting();
if (!*aDest) {
*aDest = malloc(aCount);
if (!*aDest)
return NS_ERROR_OUT_OF_MEMORY;
}
char * p = reinterpret_cast<char*>(*aDest);
PRUint32 bytesRead;
PRUint32 totalRead = 0;
while (1) {
@ -1197,6 +1200,18 @@ NS_ReadInputStreamToString(nsIInputStream *aInputStream,
return rv;
}
inline nsresult
NS_ReadInputStreamToString(nsIInputStream *aInputStream,
nsACString &aDest,
PRUint32 aCount)
{
aDest.SetLength(aCount);
if (aDest.Length() != aCount)
return NS_ERROR_OUT_OF_MEMORY;
void* dest = aDest.BeginWriting();
return NS_ReadInputStreamToBuffer(aInputStream, &dest, aCount);
}
inline nsresult
NS_LoadPersistentPropertiesFromURI(nsIPersistentProperties **result,
nsIURI *uri,