Song::GetFileHash cleanup
Implement a range-based loop instead of a big list of if statements. & prefer ssc to sm to all else Song::GetFileHash: Fix indentation
This commit is contained in:
+13
-19
@@ -1767,27 +1767,21 @@ RString Song::GetCacheFile(RString sType)
|
|||||||
|
|
||||||
RString Song::GetFileHash()
|
RString Song::GetFileHash()
|
||||||
{
|
{
|
||||||
|
static const std::vector<RString> extensions = {
|
||||||
|
"ssc", "sm", "dwi", "sma", "bms", "ksf", "json", "jso"
|
||||||
|
};
|
||||||
|
|
||||||
if (m_sFileHash.empty()) {
|
if (m_sFileHash.empty()) {
|
||||||
RString sPath = SetExtension(GetSongFilePath(), "sm");
|
for (const RString& ext : extensions) {
|
||||||
if (!IsAFile(sPath))
|
RString sPath = SetExtension(GetSongFilePath(), ext);
|
||||||
sPath = SetExtension(GetSongFilePath(), "dwi");
|
if (IsAFile(sPath)) {
|
||||||
if (!IsAFile(sPath))
|
m_sFileHash = BinaryToHex(CRYPTMAN->GetSHA1ForFile(sPath));
|
||||||
sPath = SetExtension(GetSongFilePath(), "sma");
|
return m_sFileHash;
|
||||||
if (!IsAFile(sPath))
|
}
|
||||||
sPath = SetExtension(GetSongFilePath(), "bms");
|
}
|
||||||
if (!IsAFile(sPath))
|
|
||||||
sPath = SetExtension(GetSongFilePath(), "ksf");
|
|
||||||
if (!IsAFile(sPath))
|
|
||||||
sPath = SetExtension(GetSongFilePath(), "json");
|
|
||||||
if (!IsAFile(sPath))
|
|
||||||
sPath = SetExtension(GetSongFilePath(), "jso");
|
|
||||||
if (!IsAFile(sPath))
|
|
||||||
sPath = SetExtension(GetSongFilePath(), "ssc");
|
|
||||||
if (IsAFile(sPath))
|
|
||||||
m_sFileHash = BinaryToHex(CRYPTMAN->GetSHA1ForFile(sPath));
|
|
||||||
else
|
|
||||||
m_sFileHash = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_sFileHash = "";
|
||||||
return m_sFileHash;
|
return m_sFileHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user