示例#1
0
文件: File.cpp 项目: erenik/engine
/// 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;
}
示例#2
0
文件: File.cpp 项目: erenik/engine
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;
}