mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-21 01:24:21 +00:00
Refactored some code to cut down on warnings from automatic code-analysis tools.
This commit is contained in:
parent
3213bec481
commit
b83e97a6f7
40 changed files with 594 additions and 637 deletions
|
|
@ -47,7 +47,8 @@ FileOutputStream::FileOutputStream (const File& f, const int bufferSize_)
|
|||
|
||||
FileOutputStream::~FileOutputStream()
|
||||
{
|
||||
flush();
|
||||
flushBuffer();
|
||||
flushInternal();
|
||||
closeHandle();
|
||||
}
|
||||
|
||||
|
|
@ -60,21 +61,29 @@ bool FileOutputStream::setPosition (int64 newPosition)
|
|||
{
|
||||
if (newPosition != currentPosition)
|
||||
{
|
||||
flush();
|
||||
flushBuffer();
|
||||
currentPosition = juce_fileSetPosition (fileHandle, newPosition);
|
||||
}
|
||||
|
||||
return newPosition == currentPosition;
|
||||
}
|
||||
|
||||
void FileOutputStream::flush()
|
||||
bool FileOutputStream::flushBuffer()
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
if (bytesInBuffer > 0)
|
||||
{
|
||||
writeInternal (buffer, bytesInBuffer);
|
||||
ok = writeInternal (buffer, bytesInBuffer);
|
||||
bytesInBuffer = 0;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
void FileOutputStream::flush()
|
||||
{
|
||||
flushBuffer();
|
||||
flushInternal();
|
||||
}
|
||||
|
||||
|
|
@ -88,15 +97,8 @@ bool FileOutputStream::write (const void* const src, const int numBytes)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (bytesInBuffer > 0)
|
||||
{
|
||||
// flush the reservoir
|
||||
const bool wroteOk = (writeInternal (buffer, bytesInBuffer) == bytesInBuffer);
|
||||
bytesInBuffer = 0;
|
||||
|
||||
if (! wroteOk)
|
||||
return false;
|
||||
}
|
||||
if (! flushBuffer())
|
||||
return false;
|
||||
|
||||
if (numBytes < bufferSize)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue