Text TextArray::asText() const throw() { Text result = "[\""; const int length = this->length(); for (int i = 0; i < length - 1; ++i) { result.add (this->at (i)); result.add ("\", "); } result.add (this->at (length - 1)); result.add ("\"]"); return result; }
Text TextFileInternal::readAll() throw() { Text buffer (Text::emptyWithAllocatedSize (512)); ResultCode result = PlankResult_OK; int bytesRead; char temp[17]; while (result == PlankResult_OK) { result = pl_File_Read (getPeerRef(), temp, 16, &bytesRead); temp[bytesRead] = '\0'; buffer.add (temp); } return buffer; }
Text TextFileInternal::read (const int numBytes) throw() { Text buffer (Text::emptyWithAllocatedSize (numBytes)); ResultCode result = PlankResult_OK; int bytesRead, bytesRemaining, bytesThisTime; char temp[17]; bytesRemaining = numBytes; while ((result == PlankResult_OK) && (bytesRemaining > 0)) { bytesThisTime = plonk::min (bytesRemaining, 16); result = pl_File_Read (getPeerRef(), temp, bytesThisTime, &bytesRead); temp[bytesRead] = '\0'; buffer.add (temp); bytesRemaining -= bytesRead; } return buffer; }