//============================================================================== void getStateInformation (MemoryBlock& destData) { destData.setSize (sizeof (float) * getNumParameters()); destData.fillWith (0); float* const p = (float*) ((char*) destData.getData()); for (int i = 0; i < getNumParameters(); ++i) p[i] = getParameter(i); }
void FileLogger::trimFileSize (int maxFileSizeBytes) const { if (maxFileSizeBytes <= 0) { logFile.deleteFile(); } else { const int64 fileSize = logFile.getSize(); if (fileSize > maxFileSizeBytes) { ScopedPointer <FileInputStream> in (logFile.createInputStream()); jassert (in != nullptr); if (in != nullptr) { in->setPosition (fileSize - maxFileSizeBytes); String content; { MemoryBlock contentToSave; contentToSave.setSize ((size_t) maxFileSizeBytes + 4); contentToSave.fillWith (0); in->read (contentToSave.getData(), maxFileSizeBytes); in = nullptr; content = contentToSave.toString(); } int newStart = 0; while (newStart < fileSize && content[newStart] != '\n' && content[newStart] != '\r') ++newStart; logFile.deleteFile(); logFile.appendText (content.substring (newStart), false, false); } } } }