mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-20 23:44:08 +00:00
Remove helper function FileSize
Use std::filesystem at caller site instead. Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
@@ -62,20 +62,6 @@ bool FileExists(const OsPath& pathname)
|
||||
}
|
||||
|
||||
|
||||
u64 FileSize(const OsPath& pathname)
|
||||
{
|
||||
try
|
||||
{
|
||||
return static_cast<u64>(std::filesystem::file_size(pathname.string()));
|
||||
}
|
||||
catch (std::filesystem::filesystem_error& err)
|
||||
{
|
||||
debug_printf("FileSize: failed to get filesize for '%s', reason: %s\n", pathname.string8().c_str(), err.what());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Status GetFileInfo(const OsPath& pathname, CFileInfo* pPtrInfo)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@@ -38,9 +38,6 @@
|
||||
bool DirectoryExists(const OsPath& path);
|
||||
bool FileExists(const OsPath& pathname);
|
||||
|
||||
u64 FileSize(const OsPath& pathname);
|
||||
|
||||
|
||||
// (bundling size and mtime avoids a second expensive call to stat())
|
||||
class CFileInfo
|
||||
{
|
||||
|
||||
+7
-2
@@ -558,8 +558,13 @@ bool ModIo::VerifyDownloadedFile(std::string& err)
|
||||
{
|
||||
// Verify filesize, as a first basic download check.
|
||||
{
|
||||
u64 filesize = std::stoull(m_ModData[m_DownloadModID].properties.at("filesize"));
|
||||
if (filesize != FileSize(m_DownloadFilePath))
|
||||
std::error_code ec{};
|
||||
const u64 fileSize{static_cast<u64>(std::filesystem::file_size(std::filesystem::path(m_DownloadFilePath.string()), ec))};
|
||||
if (ec)
|
||||
LOGERROR("Failed to get filesize for '%s', reason: %s", m_DownloadFilePath.string8().c_str(), ec.message());
|
||||
const u64 expectedFileSize{std::stoull(m_ModData[m_DownloadModID].properties.at("filesize"))};
|
||||
|
||||
if (ec || fileSize != expectedFileSize)
|
||||
{
|
||||
err = g_L10n.Translate("Mismatched filesize.");
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user