Files
dnf-utils/sgutil/sgu_mode_download.cpp
T
2025-09-01 20:47:58 +08:00

33 lines
723 B
C++

#include "sgu_stdafx.h"
#include "sgu_mode_download.h"
#include "sgu_download_ant.h"
#include "sgu_utils.h"
#include "sgu_download_cos.h"
bool downloadFile(const char* szDownloadUrl, const char* szLocalFile)
{
if (szDownloadUrl == nullptr || szLocalFile == nullptr)
{
printf("Error: download url or local file is null.\n");
return false;
}
std::string urlStr = szDownloadUrl;
if (_stricmp(urlStr.substr(0, 6).c_str(), "cos://") == 0)
{
downloadFileFromCOS(urlStr.substr(6).c_str(), szLocalFile);
}
else
{
CDownloadAnt ant;
ant.init(convertAnsiStringToWide(szDownloadUrl).c_str(), convertAnsiStringToWide(szLocalFile).c_str());
// Wait for download to finish
ant.begin(true);
}
return true;
}