26 int64 juce_fileSetPosition (
void* handle, int64 pos);
50 jassert (buffer !=
nullptr && bytesToRead >= 0);
52 auto num = readInternal (buffer, (
size_t) bytesToRead);
53 currentPosition += (int64) num;
65 return currentPosition;
73 if (pos != currentPosition)
74 currentPosition = juce_fileSetPosition (fileHandle, pos);
76 return currentPosition == pos;
82 struct FileInputStreamTests :
public UnitTest 84 FileInputStreamTests()
85 :
UnitTest (
"FileInputStream",
"Streams")
88 void runTest()
override 90 const MemoryBlock data (
"abcdefghijklmnopqrstuvwxyz", 26);
102 size_t numBytesRead = 0;
105 while (numBytesRead < data.
getSize())
107 numBytesRead += (size_t) stream.
read (&readBuffer[numBytesRead], 3);
109 expectEquals (stream.
getPosition(), (int64) numBytesRead);
118 expect (readBuffer == data);
129 const int numBytesToSkip = 5;
131 while (numBytesRead < data.
getSize())
134 numBytesRead += numBytesToSkip;
135 numBytesRead = std::min (numBytesRead, data.
getSize());
137 expectEquals (stream.
getPosition(), (int64) numBytesRead);
150 static FileInputStreamTests fileInputStreamTests;
size_t getSize() const noexcept
Returns the block's current allocated size, in bytes.
bool appendData(const void *dataToAppend, size_t numberOfBytes) const
Appends a block of binary data to the end of the file.
bool deleteFile() const
Deletes a file.
This is a base class for classes that perform a unit test.
void * getData() const noexcept
Returns a void pointer to the data.
int64 getSize() const
Returns the size of the file in bytes.
Represents a local file or directory.
static File createTempFile(StringRef fileNameEnding)
Returns a temporary file in the system's temp directory.
A class to hold a resizable block of raw data.