From fe61c37d9311a4233fc41b34cee452cdec1aba4a Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 11 Aug 2014 09:44:14 +0100 Subject: [PATCH] Updated the return types of OutputStream::writeFromInputStream and InputStream::readIntoMemoryBlock --- modules/juce_core/files/juce_File.cpp | 2 +- modules/juce_core/streams/juce_InputStream.cpp | 4 ++-- modules/juce_core/streams/juce_InputStream.h | 6 +++--- modules/juce_core/streams/juce_MemoryOutputStream.cpp | 2 +- modules/juce_core/streams/juce_MemoryOutputStream.h | 2 +- modules/juce_core/streams/juce_OutputStream.cpp | 4 ++-- modules/juce_core/streams/juce_OutputStream.h | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/juce_core/files/juce_File.cpp b/modules/juce_core/files/juce_File.cpp index 695d48e68d..d5c520a098 100644 --- a/modules/juce_core/files/juce_File.cpp +++ b/modules/juce_core/files/juce_File.cpp @@ -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 diff --git a/modules/juce_core/streams/juce_InputStream.cpp b/modules/juce_core/streams/juce_InputStream.cpp index 08ff61ccdc..07b9976da3 100644 --- a/modules/juce_core/streams/juce_InputStream.cpp +++ b/modules/juce_core/streams/juce_InputStream.cpp @@ -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() diff --git a/modules/juce_core/streams/juce_InputStream.h b/modules/juce_core/streams/juce_InputStream.h index 0c7e2dc50c..ebdc795fab 100644 --- a/modules/juce_core/streams/juce_InputStream.h +++ b/modules/juce_core/streams/juce_InputStream.h @@ -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. diff --git a/modules/juce_core/streams/juce_MemoryOutputStream.cpp b/modules/juce_core/streams/juce_MemoryOutputStream.cpp index 7d07ce627b..835b2bd793 100644 --- a/modules/juce_core/streams/juce_MemoryOutputStream.cpp +++ b/modules/juce_core/streams/juce_MemoryOutputStream.cpp @@ -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(); diff --git a/modules/juce_core/streams/juce_MemoryOutputStream.h b/modules/juce_core/streams/juce_MemoryOutputStream.h index 61cc85c34d..2e764effe5 100644 --- a/modules/juce_core/streams/juce_MemoryOutputStream.h +++ b/modules/juce_core/streams/juce_MemoryOutputStream.h @@ -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: diff --git a/modules/juce_core/streams/juce_OutputStream.cpp b/modules/juce_core/streams/juce_OutputStream.cpp index 7c6d0bd32c..c67e3fb8c2 100644 --- a/modules/juce_core/streams/juce_OutputStream.cpp +++ b/modules/juce_core/streams/juce_OutputStream.cpp @@ -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::max(); - int numWritten = 0; + int64 numWritten = 0; while (numBytesToWrite > 0) { diff --git a/modules/juce_core/streams/juce_OutputStream.h b/modules/juce_core/streams/juce_OutputStream.h index de40888fd5..102ab5a01e 100644 --- a/modules/juce_core/streams/juce_OutputStream.h +++ b/modules/juce_core/streams/juce_OutputStream.h @@ -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()