Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/CacheLoader.cpp
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | VfsPath CCacheLoader::LooseCachePath(const VfsPath& sourcePath, const MD5& initialHash, u32 version) | ||||
hash.Update((const u8*)&version, sizeof(version)); | hash.Update((const u8*)&version, sizeof(version)); | ||||
// these are local cached files, so we don't care about endianness etc | // these are local cached files, so we don't care about endianness etc | ||||
u8 digest[MD5::DIGESTSIZE]; | u8 digest[MD5::DIGESTSIZE]; | ||||
hash.Final(digest); | hash.Final(digest); | ||||
// Get the mod path | // Get the mod path | ||||
OsPath path; | OsPath path; | ||||
m_VFS->GetRealPath(sourcePath, path); | m_VFS->GetOriginalPath(sourcePath, path); | ||||
return VfsPath("cache") / | return VfsPath("cache") / | ||||
path_name_only(path.BeforeCommon(sourcePath).Parent().string().c_str()) / | path_name_only(path.BeforeCommon(sourcePath).Parent().string().c_str()) / | ||||
sourcePath.ChangeExtension(sourcePath.Extension().string() + | sourcePath.ChangeExtension(sourcePath.Extension().string() + | ||||
L"." + | L"." + | ||||
// Use a short prefix of the full hash (we don't need high collision-resistance) | // Use a short prefix of the full hash (we don't need high collision-resistance) | ||||
wstring_from_utf8(Hexify(digest, 8)) + | wstring_from_utf8(Hexify(digest, 8)) + | ||||
m_FileExtension); | m_FileExtension); | ||||
} | } |
Wildfire Games · Phabricator