Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
52
libs/platform/downloader_defines.hpp
Normal file
52
libs/platform/downloader_defines.hpp
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#pragma once
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace downloader
|
||||
{
|
||||
enum class DownloadStatus
|
||||
{
|
||||
InProgress,
|
||||
Completed,
|
||||
Failed,
|
||||
FileNotFound,
|
||||
FailedSHA,
|
||||
};
|
||||
|
||||
inline std::string DebugPrint(DownloadStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case DownloadStatus::InProgress: return "In progress";
|
||||
case DownloadStatus::Completed: return "Completed";
|
||||
case DownloadStatus::Failed: return "Failed";
|
||||
case DownloadStatus::FileNotFound: return "File not found";
|
||||
case DownloadStatus::FailedSHA: return "Failed SHA check";
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
struct Progress
|
||||
{
|
||||
static int64_t constexpr kUnknownTotalSize = -1;
|
||||
|
||||
static Progress constexpr Unknown() { return {0, kUnknownTotalSize}; }
|
||||
|
||||
bool IsUnknown() const { return m_bytesTotal == kUnknownTotalSize; }
|
||||
|
||||
int64_t m_bytesDownloaded = 0;
|
||||
/// Total can be kUnknownTotalSize if size is unknown.
|
||||
int64_t m_bytesTotal = 0;
|
||||
};
|
||||
|
||||
inline std::string DebugPrint(Progress const & progress)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "(downloaded " << progress.m_bytesDownloaded << " bytes out of " << progress.m_bytesTotal << " bytes)";
|
||||
return out.str();
|
||||
}
|
||||
} // namespace downloader
|
||||
Loading…
Add table
Add a link
Reference in a new issue