mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-03 03:30:06 +00:00
Internal refactoring of file functions and win32 com objects.
This commit is contained in:
parent
87175e988b
commit
21006fbd0a
27 changed files with 593 additions and 1285 deletions
|
|
@ -31,6 +31,8 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "juce_OutputStream.h"
|
||||
#include "../../threads/juce_ScopedLock.h"
|
||||
#include "../../containers/juce_VoidArray.h"
|
||||
#include "../../containers/juce_ScopedPointer.h"
|
||||
#include "../files/juce_FileInputStream.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -228,20 +230,19 @@ void OutputStream::writeText (const String& text, const bool asUnicode,
|
|||
}
|
||||
}
|
||||
|
||||
int OutputStream::writeFromInputStream (InputStream& source, int numBytesToWrite)
|
||||
int OutputStream::writeFromInputStream (InputStream& source, int64 numBytesToWrite)
|
||||
{
|
||||
if (numBytesToWrite < 0)
|
||||
numBytesToWrite = 0x7fffffff;
|
||||
numBytesToWrite = std::numeric_limits<int64>::max();
|
||||
|
||||
int numWritten = 0;
|
||||
|
||||
while (numBytesToWrite > 0 && ! source.isExhausted())
|
||||
{
|
||||
char buffer [8192];
|
||||
const int num = source.read (buffer, (int) jmin (numBytesToWrite, (int64) sizeof (buffer)));
|
||||
|
||||
const int num = (int) source.read (buffer, (int) jmin ((size_t) numBytesToWrite, sizeof (buffer)));
|
||||
|
||||
if (num == 0)
|
||||
if (num <= 0)
|
||||
break;
|
||||
|
||||
write (buffer, num);
|
||||
|
|
@ -276,5 +277,21 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char* const
|
|||
return stream;
|
||||
}
|
||||
|
||||
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryBlock& data)
|
||||
{
|
||||
stream.write (data.getData(), (int) data.getSize());
|
||||
return stream;
|
||||
}
|
||||
|
||||
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const File& fileToRead)
|
||||
{
|
||||
const ScopedPointer<FileInputStream> in (fileToRead.createInputStream());
|
||||
|
||||
if (in != 0)
|
||||
stream.writeFromInputStream (*in, -1);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue