1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Updated the return types of OutputStream::writeFromInputStream and InputStream::readIntoMemoryBlock

This commit is contained in:
jules 2014-08-11 09:44:14 +01:00
parent 43cac64c42
commit fe61c37d93
7 changed files with 11 additions and 11 deletions

View file

@ -476,7 +476,7 @@ bool File::loadFileAsData (MemoryBlock& destBlock) const
return false;
FileInputStream in (*this);
return in.openedOk() && getSize() == in.readIntoMemoryBlock (destBlock);
return in.openedOk() && getSize() == (int64) in.readIntoMemoryBlock (destBlock);
}
String File::loadFileAsString() const

View file

@ -209,10 +209,10 @@ String InputStream::readNextLine()
return String::fromUTF8 (data, (int) i);
}
int InputStream::readIntoMemoryBlock (MemoryBlock& block, ssize_t numBytes)
size_t InputStream::readIntoMemoryBlock (MemoryBlock& block, ssize_t numBytes)
{
MemoryOutputStream mo (block, true);
return mo.writeFromInputStream (*this, numBytes);
return (size_t) mo.writeFromInputStream (*this, numBytes);
}
String InputStream::readEntireStreamAsString()

View file

@ -211,7 +211,7 @@ public:
/** Tries to read the whole stream and turn it into a string.
This will read from the stream's current position until the end-of-stream.
It can read from either UTF-16 or UTF-8 formats.
It can read from UTF-8 data, or UTF-16 if it detects suitable header-bytes.
*/
virtual String readEntireStreamAsString();
@ -223,8 +223,8 @@ public:
will be read until the stream is exhausted.
@returns the number of bytes that were added to the memory block
*/
virtual int readIntoMemoryBlock (MemoryBlock& destBlock,
ssize_t maxNumBytesToRead = -1);
virtual size_t readIntoMemoryBlock (MemoryBlock& destBlock,
ssize_t maxNumBytesToRead = -1);
//==============================================================================
/** Returns the offset of the next byte that will be read from the stream.

View file

@ -175,7 +175,7 @@ bool MemoryOutputStream::setPosition (int64 newPosition)
return false;
}
int MemoryOutputStream::writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite)
int64 MemoryOutputStream::writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite)
{
// before writing from an input, see if we can preallocate to make it more efficient..
int64 availableData = source.getTotalLength() - source.getPosition();

View file

@ -116,7 +116,7 @@ public:
bool write (const void*, size_t) override;
int64 getPosition() override { return (int64) position; }
bool setPosition (int64) override;
int writeFromInputStream (InputStream&, int64 maxNumBytesToWrite) override;
int64 writeFromInputStream (InputStream&, int64 maxNumBytesToWrite) override;
bool writeRepeatedByte (uint8 byte, size_t numTimesToRepeat) override;
private:

View file

@ -252,12 +252,12 @@ bool OutputStream::writeText (const String& text, const bool asUTF16,
return true;
}
int OutputStream::writeFromInputStream (InputStream& source, int64 numBytesToWrite)
int64 OutputStream::writeFromInputStream (InputStream& source, int64 numBytesToWrite)
{
if (numBytesToWrite < 0)
numBytesToWrite = std::numeric_limits<int64>::max();
int numWritten = 0;
int64 numWritten = 0;
while (numBytesToWrite > 0)
{

View file

@ -221,7 +221,7 @@ public:
is exhausted)
@returns the number of bytes written
*/
virtual int writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite);
virtual int64 writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite);
//==============================================================================
/** Sets the string that will be written to the stream when the writeNewLine()