26 int64 juce_fileSetPosition (
void* handle, int64 pos);
31 bufferSize (bufferSizeToUse),
32 buffer (jmax (bufferSizeToUse, (size_t) 16))
45 return currentPosition;
50 if (newPosition != currentPosition)
53 currentPosition = juce_fileSetPosition (fileHandle, newPosition);
56 return newPosition == currentPosition;
59 bool FileOutputStream::flushBuffer()
63 if (bytesInBuffer > 0)
65 ok = (writeInternal (buffer, bytesInBuffer) == (ssize_t) bytesInBuffer);
80 jassert (src !=
nullptr && ((ssize_t) numBytes) >= 0);
85 if (bytesInBuffer + numBytes < bufferSize)
87 memcpy (buffer + bytesInBuffer, src, numBytes);
88 bytesInBuffer += numBytes;
89 currentPosition += (int64) numBytes;
96 if (numBytes < bufferSize)
98 memcpy (buffer + bytesInBuffer, src, numBytes);
99 bytesInBuffer += numBytes;
100 currentPosition += (int64) numBytes;
104 auto bytesWritten = writeInternal (src, numBytes);
106 if (bytesWritten < 0)
109 currentPosition += (int64) bytesWritten;
110 return bytesWritten == (ssize_t) numBytes;
119 jassert (((ssize_t) numBytes) >= 0);
121 if (bytesInBuffer + numBytes < bufferSize)
123 memset (buffer + bytesInBuffer, byte, numBytes);
124 bytesInBuffer += numBytes;
125 currentPosition += (int64) numBytes;
int64 getPosition() override
Returns the stream's current position.
bool setPosition(int64) override
Tries to move the stream's output position.
bool write(const void *, size_t) override
Writes a block of data to the stream.
Represents a local file or directory.
void flush() override
If the stream is using a buffer, this will ensure it gets written out to the destination.
bool openedOk() const noexcept
Returns true if the stream opened without problems.
virtual bool writeRepeatedByte(uint8 byte, size_t numTimesToRepeat)
Writes a byte to the output stream a given number of times.
bool writeRepeatedByte(uint8 byte, size_t numTimesToRepeat) override
Writes a byte to the output stream a given number of times.
~FileOutputStream() override
Destructor.
FileOutputStream(const File &fileToWriteTo, size_t bufferSizeToUse=16384)
Creates a FileOutputStream.