mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added an overloaded read method to InputStream which takes a size_t as the size parameter, rather than an int
This commit is contained in:
parent
01f0ed3067
commit
f746672c19
3 changed files with 25 additions and 3 deletions
|
|
@ -33,6 +33,26 @@ int64 InputStream::getNumBytesRemaining()
|
|||
return len;
|
||||
}
|
||||
|
||||
ssize_t InputStream::read (void* destBuffer, size_t size)
|
||||
{
|
||||
ssize_t totalRead = 0;
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
auto numToRead = (int) std::min (size, (size_t) 0x70000000);
|
||||
auto numRead = read (juce::addBytesToPointer (destBuffer, totalRead), numToRead);
|
||||
jassert (numRead <= numToRead);
|
||||
|
||||
if (numRead < 0) return (ssize_t) numRead;
|
||||
if (numRead == 0) break;
|
||||
|
||||
size -= (size_t) numRead;
|
||||
totalRead += numRead;
|
||||
}
|
||||
|
||||
return totalRead;
|
||||
}
|
||||
|
||||
char InputStream::readByte()
|
||||
{
|
||||
char temp = 0;
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ public:
|
|||
*/
|
||||
virtual int read (void* destBuffer, int maxBytesToRead) = 0;
|
||||
|
||||
ssize_t read (void* destBuffer, size_t maxBytesToRead);
|
||||
|
||||
/** Reads a byte from the stream.
|
||||
If the stream is exhausted, this will return zero.
|
||||
@see OutputStream::writeByte
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue