本文整理汇总了C++中CFileInfo::MTime方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileInfo::MTime方法的具体用法?C++ CFileInfo::MTime怎么用?C++ CFileInfo::MTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileInfo
的用法示例。
在下文中一共展示了CFileInfo::MTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFileMTime
// Return time [seconds since 1970] of the last modification to the specified file.
//
// mtime = getFileMTime(filename);
// filename: VFS filename (may include path)
double JSI_VFS::GetFileMTime(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::wstring filename)
{
CFileInfo fileInfo;
Status err = g_VFS->GetFileInfo(filename, &fileInfo);
JS_CHECK_FILE_ERR(err);
return (double)fileInfo.MTime();
}
示例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));
}
示例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);
}