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;
84 struct FileInputStreamTests :
public UnitTest 86 FileInputStreamTests()
87 :
UnitTest (
"FileInputStream", UnitTestCategories::streams)
90 void runTest()
override 92 const MemoryBlock data (
"abcdefghijklmnopqrstuvwxyz", 26);
104 size_t numBytesRead = 0;
107 while (numBytesRead < data.
getSize())
109 numBytesRead += (size_t) stream.
read (&readBuffer[numBytesRead], 3);
111 expectEquals (stream.
getPosition(), (int64) numBytesRead);
120 expect (readBuffer == data);
131 const int numBytesToSkip = 5;
133 while (numBytesRead < data.
getSize())
136 numBytesRead += numBytesToSkip;
137 numBytesRead = std::min (numBytesRead, data.
getSize());
139 expectEquals (stream.
getPosition(), (int64) numBytesRead);
152 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.
int64 getSize() const
Returns the size of the file in bytes.
void * getData() noexcept
Returns a void pointer to the data.
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.