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


C++ VfsPath::Extension方法代码示例

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


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

示例1: tex_write

// write the specified texture to disk.
// note: <t> cannot be made const because the image may have to be
// transformed to write it out in the format determined by <fn>'s extension.
Status tex_write(Tex* t, const VfsPath& filename)
{
    DynArray da;
    RETURN_STATUS_IF_ERR(t->encode(filename.Extension(), &da));

    // write to disk
    Status ret = INFO::OK;
    {
        shared_ptr<u8> file = DummySharedPtr(da.base);
        const ssize_t bytes_written = g_VFS->CreateFile(filename, file, da.pos);
        if(bytes_written > 0)
            ENSURE(bytes_written == (ssize_t)da.pos);
        else
            ret = (Status)bytes_written;
    }

    (void)da_free(&da);
    return ret;
}
开发者ID:krichter722,项目名称:0ad,代码行数:22,代码来源:Util.cpp

示例2: GetFallbackToAvailableDictLocale

Status L10n::ReloadChangedFile(const VfsPath& path)
{
	if (!boost::algorithm::starts_with(path.string(), L"l10n/"))
		return INFO::OK;

	if (path.Extension() != L".po")
		return INFO::OK;

	// If the file was deleted, ignore it
	if (!VfsFileExists(path))
		return INFO::OK;

	std::wstring dictName = GetFallbackToAvailableDictLocale(currentLocale);
	if (useLongStrings)
		dictName = L"long";
	if (dictName.empty())
		return INFO::OK;

	// Only the currently used language is loaded, so ignore all others
	if (path.string().rfind(dictName) == std::string::npos)
		return INFO::OK;

	LOGMESSAGE("Hotloading translations from '%s'", path.string8());

	CVFSFile file;
	if (file.Load(g_VFS, path) != PSRETURN_OK)
	{
		LOGERROR("Failed to read translations from '%s'", path.string8());
		return ERR::FAIL;
	}

	std::string content = file.DecodeUTF8();
	ReadPoIntoDictionary(content, dictionary);

	if (g_GUI)
		g_GUI->ReloadAllPages();

	return INFO::OK;
}
开发者ID:Rektosauros,项目名称:0ad,代码行数:39,代码来源:L10n.cpp

示例3: ReloadChangedFile

	Status ReloadChangedFile(const VfsPath& path)
	{
		// Ignore files that aren't in the right path
		if (!boost::algorithm::starts_with(path.string(), L"art/skeletons/"))
			return INFO::OK;

		if (path.Extension() != L".xml")
			return INFO::OK;

		m_skeletonHashInvalidated = true;

		// If the file doesn't exist (e.g. it was deleted), don't bother reloading
		// or 'unloading' since that isn't possible
		if (!VfsFileExists(path))
			return INFO::OK;

		if (!dll.IsLoaded() && !TryLoadDLL())
			return ERR::FAIL;

		LOGMESSAGE("Hotloading skeleton definitions from '%s'", path.string8());
		// Set the filename for the logger to report
		set_logger(ColladaLog, const_cast<void*>(static_cast<const void*>(&path)));

		CVFSFile skeletonFile;
		if (skeletonFile.Load(m_VFS, path) != PSRETURN_OK)
		{
			LOGERROR("Failed to read skeleton defintions from '%s'", path.string8());
			return ERR::FAIL;
		}

		int ok = set_skeleton_definitions((const char*)skeletonFile.GetBuffer(), (int)skeletonFile.GetBufferSize());
		if (ok < 0)
		{
			LOGERROR("Failed to load skeleton definitions from '%s'", path.string8());
			return ERR::FAIL;
		}

		return INFO::OK;
	}
开发者ID:2asoft,项目名称:0ad,代码行数:39,代码来源:ColladaManager.cpp

示例4: 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

示例5: ArchiveCachePath

VfsPath CCacheLoader::ArchiveCachePath(const VfsPath& sourcePath)
{
	return sourcePath.ChangeExtension(sourcePath.Extension().string() + L".cached" + m_FileExtension);
}
开发者ID:Valvador,项目名称:PyroSpaceFork,代码行数:4,代码来源:CacheLoader.cpp


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