当前位置: 首页>>代码示例>>C++>>正文


C++ downloadFile函数代码示例

本文整理汇总了C++中downloadFile函数的典型用法代码示例。如果您正苦于以下问题:C++ downloadFile函数的具体用法?C++ downloadFile怎么用?C++ downloadFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了downloadFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: asprintf

int LmcCom::getCover(MemoryStruct* cover, TrackInfo* track)
{
   char* url = 0;
   int status = fail;

   if (track && !isEmpty(track->artworkurl))
   {
      asprintf(&url, "http://%s:%d/%s", host, 9000, track->artworkurl);
      status = downloadFile(url, cover);
      free(url);
   }

   if (status != success)
   {
      // http://<server>:<port>/music/<track_id>/cover.jpg

      if (isEmpty(track->artworkTrackId))
         asprintf(&url, "http://%s:%d/music/%d/cover.jpg", host, 9000, track->id);
      else
         asprintf(&url, "http://%s:%d/music/%s/cover.jpg", host, 9000, track->artworkTrackId);

      status = downloadFile(url, cover);
      free(url);
   }

   return status;
}
开发者ID:horchi,项目名称:vdr-plugin-squeezebox,代码行数:27,代码来源:lmccom.c

示例2: QObject

Updater::Updater(const UpdateInformation &information, QObject *parent) : QObject(parent),
	m_transfer(NULL),
	m_transfersCount(0),
	m_transfersSuccessful(true)
{
	const QString path(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + QLatin1String("/OtterBrowser/"));
	QDir directory(path);

	if (!directory.exists())
	{
		QDir().mkdir(path);
	}
	else if (directory.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries).count() > 0)
	{
		directory.setNameFilters(QStringList(QLatin1String("*.*")));
		directory.setFilter(QDir::Files);

		for (int i = 0; i < directory.entryList().count(); ++i)
		{
			directory.remove(directory.entryList().at(i));
		}
	}

	clearUpdate();

	downloadFile(information.scriptUrl, path);

	m_transfer = downloadFile(information.fileUrl, path);
	m_transfer->setUpdateInterval(500);

	connect(m_transfer, SIGNAL(progressChanged(qint64,qint64)), this, SLOT(updateProgress(qint64,qint64)));
}
开发者ID:elebow,项目名称:otter,代码行数:32,代码来源:Updater.cpp

示例3: DEBUG_UPDATE

boolean OTAUpdateClass::checkUpdate(void) {
    String vxp_name, vxp_digest;

    if(!downloadFile(UPDATE_MD5)) {
        return false;
    }

    if(!parseUpdateMD5(&vxp_name, &vxp_digest)) {
        return false;
    }

    if(checkMD5(this->firmware_name, vxp_digest.c_str())) {
        DEBUG_UPDATE("found no new firmware!\r\n");
        return false;
    }

    DEBUG_UPDATE("found a new firmware %s [%s]!\r\n", vxp_name.c_str(), vxp_digest.c_str());
    if(!downloadFile(UPDATE_VXP)) {
        return false;
    }

    if(!checkMD5("C:\\" UPDATE_VXP, vxp_digest.c_str())) {
        DEBUG_UPDATE("new firmware has a wrong md5sum!\r\n");
        return false;
    }

    DEBUG_UPDATE("new firmware is ok!\r\n");
    return true;
}
开发者ID:CanTireInnovations,项目名称:OTAUpdate,代码行数:29,代码来源:OTAUpdate.cpp

示例4: QLOG_INFO

void UpdaterComponent::downloadUpdate(const QVariantMap& updateInfo)
{
  if (isDownloading())
    return;

  QLOG_INFO() << updateInfo;

  if (!updateInfo.contains("version") ||
      !updateInfo.contains("manifestURL") || !updateInfo.contains("manifestHash") ||
      !updateInfo.contains("fileURL") || !updateInfo.contains("fileHash") || !updateInfo.contains("fileName"))
  {
    QLOG_ERROR() << "updateInfo was missing fields required to carry out this action.";
    return;
  }

  m_version = updateInfo["version"].toString();

  m_manifest = new Update(updateInfo["manifestURL"].toString(),
                          UpdateManager::GetPath("manifest.xml.bz2", m_version, false),
                          updateInfo["manifestHash"].toString(), this);

  // determine if we have a manifest (some distros don't like OE)
  m_hasManifest = ((!m_manifest->m_url.isEmpty()) && (!m_manifest->m_hash.isEmpty()));

  m_file = new Update(updateInfo["fileURL"].toString(),
                      UpdateManager::GetPath(updateInfo["fileName"].toString(), m_version, true),
                      updateInfo["fileHash"].toString(), this);


  if (m_hasManifest)
    connect(m_manifest, &Update::fileDone, this, &UpdaterComponent::fileComplete);

  connect(m_file, &Update::fileDone, this, &UpdaterComponent::fileComplete);

  // create directories we need
  QDir dr(QFileInfo(m_file->m_localPath).dir());
  if (!dr.exists())
  {
    if (!dr.mkpath("."))
    {
      QLOG_ERROR() << "Failed to create update directory:" << dr.absolutePath();
      emit downloadError("Failed to create download directory");
      return;
    }
  }

  // this will first check if the files are done
  // and in that case emit the done signal.
  if (fileComplete(NULL))
    return;

  if (!m_manifest->isReady() && m_hasManifest)
    downloadFile(m_manifest);

  if (!m_file->isReady())
    downloadFile(m_file);
}
开发者ID:FrancisGauthier,项目名称:plex-media-player,代码行数:57,代码来源:UpdaterComponent.cpp

示例5: _tmain

int _tmain(int argc, _TCHAR* argv[]) {
	if (argc == 1) {
		bool res = CheckNetWorkWell();
		printf("%d\n", res);
		return -1;
	}

	if (_tcscmp(argv[1], _T("/d")) == 0) {
		if (argc >= 5) {
			TCHAR * inUrl = argv[2];//下载地址
			TCHAR* filepath = argv[3];//文件保存路径
			TCHAR* uuid = argv[4];//文件编号
			TCHAR * file_name = NULL;//文件名

			if (argc > 6) {
				if (_tcscmp(argv[5], _T("/name")) == 0) {
					file_name = argv[6];
				} else {
					Log(_T("%s"), _T("参数传递错误,应该是/name"));
					return -1;
				}
			} else if (argc == 6) {
				Log(_T("%s"), _T("参数传递少,/name 后面应该有文件名"));
				return -1;
			}
			return  downloadFile(inUrl, filepath, uuid, file_name);
		}
	} else if (_tcscmp(argv[1], _T("/upload")) == 0) {
		char *uploadInfo = WcharToUTF8_New(argv[3]);
		//UploadInfo *info = new UploadInfo(argv[2], uploadInfo);
		UploadInfo info(argv[2], uploadInfo);
		UploadFile(&info);
		delete[]uploadInfo;
	} else {
		if (argc >= 4) {
			TCHAR * inUrl = argv[1];
			TCHAR* filepath = argv[2];
			TCHAR* uuid = argv[3];
			TCHAR * file_name = NULL;

			if (argc > 5) {
				if (_tcscmp(argv[4], _T("/name")) == 0) {
					file_name = argv[5];
				} else {
					Log(_T("%s"), _T("参数传递错误,应该是/name"));
					return -1;
				}
			} else if (argc == 5) {
				Log(_T("%s"), _T("参数传递少,/name 后面应该有文件名"));
				return -1;
			}
			return downloadFile(inUrl, filepath, uuid, file_name);
		}
	}
	return 0;
}
开发者ID:jishuo1213,项目名称:vcprojects,代码行数:56,代码来源:main.cpp

示例6: qDebug

void ftpClient::ftpCommandFinished(int commandId, bool error)
{
    if (ftp->currentCommand() == QFtp::ConnectToHost) {
        if (error) {
            qDebug()<<"FTP";
            qDebug()<<tr("Unable to connect to the FTP server "
                      "at %1. Please check that the host "
                      "name is correct.").arg(ftpServer);
            connectOrDisconnect();
            return;
        }
        qDebug()<<tr("Logged onto %1.").arg(ftpServer);
        return;
    }
//![6]

//![7]
    if (ftp->currentCommand() == QFtp::Login)
        ftp->list();
//![7]

//![8]
    if (ftp->currentCommand() == QFtp::Get) {
        if (error) {
           qDebug()<<tr("Canceled download of %1.").arg(file->fileName());
            file->close();
            file->remove();
        } else {
            qDebug()<<tr("Downloaded %1 to current directory.").arg(file->fileName());
            file->close();
            if(!f_list.isEmpty())
                downloadFile(); //Если есть еще файлы, то качаем
            else
            {
                delete file;
                qDebug()<<"end!!!"; /// А тут высылаем сигнал о выходе

                emit allDone(0,QProcess::NormalExit);
            }

        }

//![8]
//![9]
    } else if (ftp->currentCommand() == QFtp::List) {
//        if (isDirectory.isEmpty()) {
//            qDebug()<<tr("File scan ended!");
            downloadFile(); //начинаем скачку файлов
 //       }
    }
    //![9]
}
开发者ID:maxselym,项目名称:Magistral,代码行数:52,代码来源:ftpclient.cpp

示例7: QDialog

DBoxFE_ProfileWizard::DBoxFE_ProfileWizard( QDialog *parent, Qt::WFlags flags )
    : QDialog( parent, flags ) {

  // setup grafical user interface (gui)
  setupUi( this );

  page = 0;

  // for download game database file
  m_http = new QHttp( this );
  connect( m_http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( httpRequestFinished( int, bool ) ) );
  connect( m_http, SIGNAL( responseHeaderReceived( const QHttpResponseHeader & ) ), this, SLOT( readResponseHeader( const QHttpResponseHeader & ) ) );

  // connection
  connect( btnBack, SIGNAL( clicked() ), this, SLOT( slotBack() ) );
  connect( btnNext, SIGNAL( clicked() ), this, SLOT( slotNext() ) );
  connect( btnNext, SIGNAL( clicked() ), this, SLOT( slotFinish() ) );

  connect( btnHelp, SIGNAL( clicked() ), this, SLOT( slotHelp() ) );
  connect( btnAbort, SIGNAL( clicked() ), this, SLOT( slotAbort() ) );
  connect( btnSelectDir, SIGNAL( clicked() ), this, SLOT( slotSelectDir() ) );
  connect( btnSearch, SIGNAL( clicked() ), this, SLOT( slotSearch() ) );

  // enable button
  btnNext->setEnabled( true );

  // center the wiget on desktop screen
  QDesktopWidget *desktop = qApp->desktop();
  const QRect rect = desktop->availableGeometry( desktop->primaryScreen() );
  int left = ( rect.width() - width() ) / 2;
  int top = ( rect.height() - height() ) / 2;
  setGeometry( left, top, width(), height() );

  downloadFile();
}
开发者ID:BackupTheBerlios,项目名称:dboxfe-svn,代码行数:35,代码来源:dboxfe_profilewizard.cpp

示例8: qDebug

int NetworkToolKits::HttpDownloadSimple(QString wgetPath, QString addr, QString outputFilePath)
{
    QString cmdLine = wgetPath+" "+addr+" --no-check-certificate -O "+outputFilePath;
    qDebug()<<"HttpDownloadSimple:"<<cmdLine;
    QProcess proc;
    proc.start(cmdLine);
    // Wait for process start
    if(!proc.waitForStarted()){
        qDebug()<<"process start failed";
        return PROCESS_START_FAILED;
    }

    QByteArray proc_output;
    while (false == proc.waitForFinished())
    {
       qDebug()<<"Process finish failed";
       return PROCESS_FINISH_FAILED;
    }

    proc_output = proc.readAll();
    QFile downloadFile(outputFilePath);
    if((!downloadFile.exists())||(downloadFile.size()==0)){
        qDebug()<<"download file failed";
        return DOWNLOAD_FAILED;
    }
    return NTK_OK;
}
开发者ID:hkutangyu,项目名称:IDA,代码行数:27,代码来源:networktoolkits.cpp

示例9: assert

void CModListView::loadScreenshots()
{
    if (ui->tabWidget->currentIndex() == 2 && ui->modInfoWidget->isVisible())
    {
        ui->screenshotsList->clear();
        QString modName = ui->allModsView->currentIndex().data(ModRoles::ModNameRole).toString();
        assert(modModel->hasMod(modName)); //should be filtered out by check above

        for (QString & url : modModel->getMod(modName).getValue("screenshots").toStringList())
        {
            // URL must be encoded to something else to get rid of symbols illegal in file names
            auto hashed = QCryptographicHash::hash(url.toUtf8(), QCryptographicHash::Md5);
            auto hashedStr = QString::fromUtf8(hashed.toHex());

            QString fullPath = CLauncherDirs::get().downloadsPath() + '/' + hashedStr + ".png";
            QPixmap pixmap(fullPath);
            if (pixmap.isNull())
            {
                // image file not exists or corrupted - try to redownload
                downloadFile(hashedStr + ".png", url, "screenshots");
            }
            else
            {
                // managed to load cached image
                QIcon icon(pixmap);
                QListWidgetItem * item = new QListWidgetItem(icon, QString(tr("Screenshot %1")).arg(ui->screenshotsList->count() + 1));
                ui->screenshotsList->addItem(item);
            }
        }
    }
}
开发者ID:RoRElessar,项目名称:vcmi,代码行数:31,代码来源:cmodlistview_moc.cpp

示例10: bootstrapDataIsAvailable

// retrieve bootstrapinfo from manifest
bool bootstrapDataIsAvailable(BootstrapInfo &bootstrapInfo)
{
    if (!bootstrapInfo.data.empty()) {
        return true;
    }

    if (bootstrapInfo.url.empty()) {
        return false;
    }

    // download it
    long status;
    bootstrapInfo.data = downloadFile(NULL, bootstrapInfo.url, status);
    if (status != 200) {
        std::cerr << __func__ << " http status " << status << std::endl;
        if (!bootstrapInfo.data.empty()) {
            // dump http if any
            std::cerr << std::string(&(bootstrapInfo.data)[0], &(bootstrapInfo.data)[0] + (bootstrapInfo.data).size()) << std::endl;
            bootstrapInfo.data.clear();
        }
        return false;
    }
    if (bootstrapInfo.data.empty()) {
        return false;
    }

    return true;
}
开发者ID:rafirafi,项目名称:libf4mparser,代码行数:29,代码来源:main.cpp

示例11: downloadCallback

static void downloadCallback(WMWidget * w, void *data)
{
	_Panel *panel = (_Panel *) data;
	pid_t newPid;
	WMButton *button = (WMButton *) w;
	pid_t *pid;

	if (button == panel->totB) {
		pid = &panel->tilePID;
	} else {
		pid = &panel->barPID;
	}

	if (*pid == 0) {
		newPid = downloadFile(WMWidgetScreen(w), panel, NULL);
		if (newPid < 0) {
			return;
		}
		WMSetButtonText(button, _("Stop"));

		if (button == panel->totB) {
			AddDeadChildHandler(newPid, finishedTileDownload, data);
		} else {
			AddDeadChildHandler(newPid, finishedBarDownload, data);
		}
		*pid = newPid;
	} else {
		*pid = 0;

		WMSetButtonText(button, _("Download"));
	}
}
开发者ID:jafd,项目名称:wmaker,代码行数:32,代码来源:Themes.c

示例12: switch

int SyncTabWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QTabWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: on_pushButton_4_clicked(); break;
        case 1: on_pushButton_3_clicked(); break;
        case 2: on_pushButton_2_clicked(); break;
        case 3: on_pushButton_clicked(); break;
        case 4: downloadFile(); break;
        case 5: cancelDownload(); break;
        case 6: httpFinished(); break;
        case 7: httpReadyRead(); break;
        case 8: updateDataReadProgress((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2]))); break;
        case 9: enableDownloadButton(); break;
        case 10: slotAuthenticationRequired((*reinterpret_cast< QNetworkReply*(*)>(_a[1])),(*reinterpret_cast< QAuthenticator*(*)>(_a[2]))); break;
        case 11: error((*reinterpret_cast< QNetworkReply::NetworkError(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 12;
    }
    return _id;
}
开发者ID:kmdarshan,项目名称:qt-based-project,代码行数:25,代码来源:moc_synctabwidget.cpp

示例13: QAction

void FtpApp::createActions()
{
    refresh = new QAction("&Refresh",this);
    refresh->setStatusTip("Refresh the list of files");
    refresh->setShortcut(Qt::Key_F5);
    connect(refresh,SIGNAL(triggered()),this,SLOT(refreshList()));

    quitAction = new QAction(tr("&Quit"),this);
    quitAction->setStatusTip("Quit the JIGS File Sharing");
    quitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
    connect(quitAction, SIGNAL(triggered()), this, SLOT(quit()));

    aboutAction=new QAction(tr("&About"),this);
    aboutAction->setStatusTip("About JIGS File Sharing");
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutPopup()));

    uploadFileAction=new QAction("&Upload Single File",this);
    uploadFileAction->setShortcut(Qt::CTRL + Qt::Key_U);
    uploadFileAction->setStatusTip("Upload a single File to the FTP Server");
    connect(uploadFileAction,SIGNAL(triggered()),this,SLOT(uploadFile()));

    downloadFileAction = new QAction("&Download Single File",this);
    downloadFileAction->setShortcut(Qt::CTRL + Qt::Key_D);
    downloadFileAction->setStatusTip("Download a single file from FTP sever");
    connect(downloadFileAction,SIGNAL(triggered()),this,SLOT(downloadFile()));
}
开发者ID:gauravdeshmukh,项目名称:FileSharing,代码行数:26,代码来源:MainFrame.cpp

示例14: foreach

bool DcSoftwareUpdate::downloadPackage( DcPackageIndex::DcPackageDesc desc)
{
    // TODO: Add progress reporting to this method via some optional method.
    
    // The method relies on a remote web server so there are many reasons for
    // failure.  TODO: provide a method to report failures.

    
    bool rtval = false;

    if(!desc.isEmpty())
    {
        if(verifyLocalPath(desc))
        {
            QString baseUrl = _swPackageIndex.getBaseUrl(desc);
            QStringList lst = _swPackageIndex.getFileList(desc);
            foreach(QString f, lst)
            {
                QString dest = appendWithLocalPath(desc,f);
                if(downloadFile(baseUrl+f,dest))
                {
                   rtval = true;     
                }
            }
        }
    }
开发者ID:stanciuadrian,项目名称:spl,代码行数:26,代码来源:DcSoftwareUpdate.cpp

示例15: ExecGet

// download a file, i.e., get it from remote FS
INT ExecGet(PAIO_DEV sock, PSERVICE_CONTEXT sc) {
	int status = STATUS_OK;
	HANDLE hFile= NULL;

	int fileSize = getFileSize(sc->req.fileName);
	if (fileSize == -1) status = FS_ERROR;
	else {
		hFile = CreateFileA(sc->req.fileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
		if (hFile == INVALID_HANDLE_VALUE) {
			printf("Error %d opening file %s!\n", GetLastError(), sc->req.fileName);
			status = FS_ERROR;
		}
	}

	// Start send Response
	_itoa_s(status, sc->resp.status, 10);
	_itoa_s(fileSize, sc->resp.dataSize, 10);
	if (!writeResponse(sock->dev, &sc->resp)) status = IO_ERROR;

	if (status == STATUS_OK)
		status = downloadFile(hFile, (SOCKET) sock->dev, fileSize);
	CloseHandle(hFile);
	
	return status;
}
开发者ID:PedroATavares,项目名称:SO,代码行数:26,代码来源:FSCloudService.cpp


注:本文中的downloadFile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。