当前位置: 首页>>代码示例>>C++>>正文


C++ SeekableReadStream::readUint16LE方法代码示例

本文整理汇总了C++中SeekableReadStream::readUint16LE方法的典型用法代码示例。如果您正苦于以下问题:C++ SeekableReadStream::readUint16LE方法的具体用法?C++ SeekableReadStream::readUint16LE怎么用?C++ SeekableReadStream::readUint16LE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SeekableReadStream的用法示例。


在下文中一共展示了SeekableReadStream::readUint16LE方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadHeader

void FoxPro::loadHeader(SeekableReadStream &dbf, uint32 &recordSize, uint32 &recordCount,
                        uint32 &firstRecordPos) {

	byte version = dbf.readByte();
	if (version != 0xF5)
		throw Exception("Unknown database version 0x%02X", version);

	int lastUpdateYear  = dbf.readByte() + 2000;
	int lastUpdateMonth = dbf.readByte();
	int lastUpdateDay   = dbf.readByte();

	_lastUpdate = date(lastUpdateYear, lastUpdateMonth, lastUpdateDay);

	recordCount    = dbf.readUint32LE();
	firstRecordPos = dbf.readUint16LE();
	recordSize     = dbf.readUint16LE();

	dbf.skip(16); // Reserved

	byte flags = dbf.readByte();

	_hasIndex = flags & 0x01;
	_hasMemo  = (flags & 0x02) != 0;

	if (flags & 0x04)
		throw Exception("DBC unsupported");
	if (flags & 0xF8)
		throw Exception("Unknown flags 0x%02X", flags);

	dbf.skip(1); // Codepage marker
	dbf.skip(2); // Reserved
}
开发者ID:strand,项目名称:xoreos,代码行数:32,代码来源:foxpro.cpp

示例2: getFileProperties

void ZipFile::getFileProperties(SeekableReadStream &zip, const IFile &file,
		uint16 &compMethod, uint32 &compSize, uint32 &realSize) const {

	zip.seek(file.offset);

	uint32 tag = zip.readUint32LE();
	if (tag != 0x04034B50)
		throw Exception("Unknown ZIP record %08X", tag);

	zip.skip(4);

	compMethod = zip.readUint16LE();

	zip.skip(8);

	compSize = zip.readUint32LE();
	realSize = zip.readUint32LE();

	uint16 nameLength  = zip.readUint16LE();
	uint16 extraLength = zip.readUint16LE();

	zip.skip(nameLength);
	zip.skip(extraLength);
}
开发者ID:ImperatorPrime,项目名称:xoreos,代码行数:24,代码来源:zipfile.cpp

示例3: load

void ZipFile::load(SeekableReadStream &zip) {
	size_t endPos = findCentralDirectoryEnd(zip);
	if (endPos == 0)
		throw Exception("End of central directory record not found");

	zip.seek(endPos);

	zip.skip(4); // Header, already checked

	uint16 curDisk        = zip.readUint16LE();
	uint16 centralDirDisk = zip.readUint16LE();

	uint16 curDiskDirs = zip.readUint16LE();
	uint16 totalDirs   = zip.readUint16LE();

	if ((curDisk != 0) || (curDisk != centralDirDisk) || (curDiskDirs != totalDirs))
		throw Exception("Unsupported multi-disk ZIP file");

	zip.skip(4); // Size of central directory

	uint32 centralDirPos = zip.readUint32LE();
	zip.seek(centralDirPos);

	uint32 tag = zip.readUint32LE();
	if (tag != 0x02014B50)
		throw Exception("Unknown ZIP record %08X", tag);

	_iFiles.reserve(totalDirs);
	while (tag == 0x02014B50) {
		 File  file;
		IFile iFile;

		zip.skip(20);

		iFile.size = zip.readUint32LE();

		uint16 nameLength    = zip.readUint16LE();
		uint16 extraLength   = zip.readUint16LE();
		uint16 commentLength = zip.readUint16LE();
		uint16 diskNum       = zip.readUint16LE();

		if (diskNum != 0)
			throw Exception("Unsupported multi-disk ZIP file");

		zip.skip(6); // File attributes

		iFile.offset = zip.readUint32LE();

		file.name = readStringFixed(zip, kEncodingASCII, nameLength).toLower();

		zip.skip(extraLength);
		zip.skip(commentLength);

		tag = zip.readUint32LE();
		if ((tag != 0x02014B50) && (tag != 0x06054B50))
			throw Exception("Unknown ZIP record %08X", tag);

		// Ignore empty file names
		if (!file.name.empty()) {
			// HACK: Skip any filename with a trailing slash because it's
			// a directory. The proper solution would be to interpret the
			// file attributes.

			if (*(--file.name.end()) != '/') {
				file.index = _iFiles.size();

				_files.push_back(file);
				_iFiles.push_back(iFile);
			}
		}
	}
}
开发者ID:ImperatorPrime,项目名称:xoreos,代码行数:72,代码来源:zipfile.cpp


注:本文中的SeekableReadStream::readUint16LE方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。