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


C++ FilePtr::seek方法代码示例

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


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

示例1: load

// --------------------------------------------------------------------------
void Property::load(const FileGroupPtr &db, const BitArray &objMask) {
    // Open the chunk specified by "P$" + mChunkName
    FilePtr fprop;

    string pchn = "P$" + mChunkName;

    try {
        fprop = db->getFile(pchn);

        const DarkDBChunkHeader &hdr = db->getFileHeader(pchn);

        // compare the versions, log differences
        if (hdr.version_high != mVerMaj || hdr.version_low != mVerMin) {
            LOG_ERROR("Property %s version mismatch : %d.%d expected, %d.%d "
                      "encountered",
                      pchn.c_str(), mVerMaj, mVerMin, hdr.version_high,
                      hdr.version_low);
        }
    } catch (const BasicException &) {
        LOG_ERROR("Property::load : Could not find the property chunk %s",
                  pchn.c_str());
        return;
    }

    // Can't calculate the count of the properties, as they can have any size
    // load. Each record has: OID, size (32 bit uint's)
    int id = 0xDEADBABE;

    while (!fprop->eof()) {
        // load the id
        fprop->readElem(&id, sizeof(uint32_t));

        // if the object is not in the mask, skip the property
        if (!objMask[id]) {
            LOG_DEBUG("Property::load: skipping object %d, not in bitmap", id);
            // prop has length and data - so skip according to that
            uint32_t size;
            fprop->read(&size, sizeof(uint32_t));
            fprop->seek(size, File::FSEEK_CUR);
            continue;
        }

        // Use property storage to load the property
        if (mPropertyStorage->readFromFile(fprop, id, true)) {
            _addProperty(id);
        } else {
            LOG_ERROR("There was an error loading property %s for object %d. "
                      "Property was not loaded",
                      mName.c_str(), id);
        }
    }
}
开发者ID:volca02,项目名称:openDarkEngine,代码行数:53,代码来源:Property.cpp

示例2: readFromFile

	// --------------------------------------------------------------------------
	bool StructuredDataStorage::readFromFile(FilePtr& file, int objID, bool sizeStored) {
		DTypePtr pd = getDataForObject(objID);
		
		if (pd.isNull()) {
			uint32_t size;
			
			// Read the size
			if (sizeStored)
				file->readElem(&size, sizeof(uint32_t));
			else
				size = mTypeDef->size();
			
			// compare sizes
			if (size != mTypeDef->size())
				LOG_ERROR("Data size mismatch: %d definition, %d file source", mTypeDef->size(), size);
			
			// create a new data
			pd = _create(objID);

			pd->read(file, size);
			
			mDataMap.insert(std::make_pair(objID, pd));
			
			return true;
		} else {
			// still have to at least skip the data
			uint32_t size;
			
			// Read the size
			file->readElem(&size, sizeof(uint32_t));
			
			file->seek(size, File::FSEEK_CUR);
			
			LOG_ERROR("Data already defined for object %d", objID);
		}
		
		return false;
	}
开发者ID:Painpillow,项目名称:openDarkEngine,代码行数:39,代码来源:DataStorage.cpp


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