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


C++ CFileInfo::Size方法代码示例

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


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

示例1: GetFileSize

// Return current size of file.
//
// size = getFileSize(filename);
//   filename: VFS filename (may include path)
unsigned int JSI_VFS::GetFileSize(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::wstring filename)
{
	CFileInfo fileInfo;
	Status err = g_VFS->GetFileInfo(filename, &fileInfo);
	JS_CHECK_FILE_ERR(err);

	return (unsigned int)fileInfo.Size();
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例2: PrepareCacheKey

	/**
	 * Creates MD5 hash key from skeletons.xml info and COLLADA converter version,
	 * used to invalidate cached .pmd/psas
	 *
	 * @param[out] hash resulting MD5 hash
	 * @param[out] version version passed to CCacheLoader, used if code change should force
	 *		  cache invalidation
	 */
	void PrepareCacheKey(MD5& hash, u32& version)
	{
		// Add converter version to the hash
		version = COLLADA_CONVERTER_VERSION;

		// Cache the skeleton files hash data
		if (m_skeletonHashInvalidated)
		{
			VfsPaths paths;
			if (vfs::GetPathnames(m_VFS, L"art/skeletons/", L"*.xml", paths) != INFO::OK)
			{
				LOGWARNING("Failed to load skeleton definitions");
				return;
			}

			// Sort the paths to not invalidate the cache if mods are mounted in different order
			// (No need to stable_sort as the VFS gurantees that we have no duplicates)
			std::sort(paths.begin(), paths.end());

			// We need two u64s per file
			m_skeletonHashes.clear();
			m_skeletonHashes.reserve(paths.size()*2);

			CFileInfo fileInfo;
			for (const VfsPath& path : paths)
			{
				// This will cause an assertion failure if *it doesn't exist,
				//	because fileinfo is not a NULL pointer, which is annoying but that
				//	should never happen, unless there really is a problem
				if (m_VFS->GetFileInfo(path, &fileInfo) != INFO::OK)
				{
					LOGERROR("Failed to stat '%s' for DAE caching", path.string8());
				}
				else
				{
					m_skeletonHashes.push_back((u64)fileInfo.MTime() & ~1); //skip lowest bit, since zip and FAT don't preserve it
					m_skeletonHashes.push_back((u64)fileInfo.Size());
				}
			}

			// Check if we were able to load any skeleton files
			if (m_skeletonHashes.empty())
				LOGERROR("Failed to stat any skeleton definitions for DAE caching");
				// We can continue, something else will break if we try loading a skeletal model

			m_skeletonHashInvalidated = false;
		}

		for (const u64& h : m_skeletonHashes)
			hash.Update((const u8*)&h, sizeof(h));
	}
开发者ID:2asoft,项目名称:0ad,代码行数:59,代码来源:ColladaManager.cpp

示例3: LooseCachePath

VfsPath CCacheLoader::LooseCachePath(const VfsPath& sourcePath, const MD5& initialHash, u32 version)
{
	CFileInfo fileInfo;
	if (m_VFS->GetFileInfo(sourcePath, &fileInfo) < 0)
	{
		debug_warn(L"source file disappeared"); // this should never happen
		return VfsPath();
	}

	u64 mtime = (u64)fileInfo.MTime() & ~1; // skip lowest bit, since zip and FAT don't preserve it
	u64 size = (u64)fileInfo.Size();

	// Construct a hash of the file data and settings.

	MD5 hash = initialHash;
	hash.Update((const u8*)&mtime, sizeof(mtime));
	hash.Update((const u8*)&size, sizeof(size));
	hash.Update((const u8*)&version, sizeof(version));
	// these are local cached files, so we don't care about endianness etc

	// Use a short prefix of the full hash (we don't need high collision-resistance),
	// converted to hex
	u8 digest[MD5::DIGESTSIZE];
	hash.Final(digest);
	std::wstringstream digestPrefix;
	digestPrefix << std::hex;
	for (size_t i = 0; i < 8; ++i)
		digestPrefix << std::setfill(L'0') << std::setw(2) << (int)digest[i];

	// Get the mod path
	OsPath path;
	m_VFS->GetRealPath(sourcePath, path);

	// Construct the final path
	return VfsPath("cache") / path_name_only(path.BeforeCommon(sourcePath).Parent().string().c_str()) / sourcePath.ChangeExtension(sourcePath.Extension().string() + L"." + digestPrefix.str() + m_FileExtension);
}
开发者ID:Valvador,项目名称:PyroSpaceFork,代码行数:36,代码来源:CacheLoader.cpp


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