Go to the documentation of this file.
16 LOG(VB_GENERAL, LOG_ERR,
"Missing --infile option");
23 LOG(VB_GENERAL, LOG_ERR,
"Missing --outfile option");
28 const int readSize = 2 * 1024 * 1024;
29 char *buf =
new char[readSize];
32 LOG(VB_GENERAL, LOG_ERR,
"ERROR, unable to allocate copy buffer ");
36 LOG(VB_GENERAL, LOG_INFO, QString(
"Copying %1 to %2").arg(src,
dest));
40 LOG(VB_GENERAL, LOG_ERR,
"ERROR, couldn't create Read RingBuffer");
47 LOG(VB_GENERAL, LOG_ERR,
"ERROR, srcRB is not open");
56 LOG(VB_GENERAL, LOG_ERR,
"ERROR, couldn't create Write RingBuffer");
64 LOG(VB_GENERAL, LOG_ERR,
"ERROR, destRB is not open");
73 long long totalBytesCopied = 0;
76 while (ok && ((r = srcbuffer->
Read(buf, readSize)) > 0))
78 int ret = destbuffer->
Write(buf, r);
81 LOG(VB_GENERAL, LOG_ERR,
82 QString(
"ERROR, couldn't write at offset %1")
83 .arg(totalBytesCopied));
88 totalBytesCopied += ret;
91 int percentComplete = totalBytesCopied * 100 / totalBytes;
92 if ((percentComplete % 5) == 0)
94 LOG(VB_GENERAL, LOG_INFO,
95 QString(
"%1 bytes copied, %2%% complete")
96 .arg(totalBytesCopied).arg(percentComplete));
100 LOG(VB_GENERAL, LOG_INFO,
101 QString(
"Wrote %1 bytes total").arg(totalBytesCopied));
103 LOG(VB_GENERAL, LOG_INFO,
"Waiting for write buffer to flush");
121 LOG(VB_GENERAL, LOG_ERR,
"Missing --infile option");
128 LOG(VB_GENERAL, LOG_ERR,
"Missing --outfile option");
137 LOG(VB_GENERAL, LOG_INFO,
"Error downloading file.");
142 LOG(VB_GENERAL, LOG_INFO,
"File downloaded.");
static int DownloadFile(const MythUtilCommandLineParser &cmdline)
MythCommFlagCommandLineParser cmdline
static int CopyFile(const MythUtilCommandLineParser &cmdline)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
@ GENERIC_EXIT_OK
Exited with no error.
void registerFileUtils(UtilMap &utilMap)
bool download(const QString &url, const QString &dest, bool reload=false)
Downloads a URL to a file in blocking mode.
QMap< QString, UtilFunc > UtilMap
QString toString(const QString &key) const
Returns stored QVariant as a QString, falling to default if not provided.
@ GENERIC_EXIT_NOT_OK
Exited with error.
MythDownloadManager * GetMythDownloadManager(void)
Gets the pointer to the MythDownloadManager singleton.