/// Reads x bytes into the file, continuing from previous location (or start if newly opened). bool File::ReadBytes(DataStream & intoStream, int numBytes) { if (!this->IsOpen()) return false; if (numBytes <= 0) return false; uchar * bytes = intoStream.GetData(); this->fileStream.read((char*)bytes, numBytes); intoStream.SetBytesUsed(numBytes); return true; }
bool File::ReadAllBytes(DataStream & intoStream) { if (!this->IsOpen()) return false; /// Check required size. int fileSize = FileSize(); /// Allocated stream to required size. intoStream.Allocate(fileSize); /// uchar * bytes = intoStream.GetData(); this->fileStream.read((char*)bytes, fileSize); intoStream.SetBytesUsed(fileSize); return true; }