void KTestDownloadPack::TestDownloadBoundary() { int nResult = false; int nRetCode = false; KHttpDownloader Downloader; //设置同时下载的文件数为9,分别下载并验证8个、9个、10个更新包 Downloader.SetThreadCount(8); nRetCode = Download(&Downloader, 8); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = CheckAndDelZip(8); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = Download(&Downloader, 9); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = CheckAndDelZip(9); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = Download(&Downloader, 10); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = CheckAndDelZip(10); KGLOG_PROCESS_ERROR(nRetCode); nResult = true; Exit0: CPPUNIT_ASSERT(nResult); }
void CFolderItem::SaveItem(pugi::xml_node& element) const { auto file = element.append_child("Folder"); if (Download()) { AddTextElement(file, "LocalFile", GetLocalPath().GetPath() + GetLocalFile()); } else { AddTextElement(file, "RemoteFile", GetRemoteFile()); AddTextElement(file, "RemotePath", m_remotePath.GetSafePath()); } AddTextElementUtf8(file, "Download", Download() ? "1" : "0"); }
void CFolderItem::SaveItem(TiXmlElement* pElement) const { TiXmlElement *file = new TiXmlElement("Folder"); if (Download()) AddTextElement(file, "LocalFile", GetLocalPath().GetPath() + GetLocalFile()); else { AddTextElement(file, "RemoteFile", GetRemoteFile()); AddTextElement(file, "RemotePath", m_remotePath.GetSafePath()); } AddTextElementRaw(file, "Download", Download() ? "1" : "0"); pElement->LinkEndChild(file); }
void CFileItem::SaveItem(pugi::xml_node& element) const { if (m_edit != CEditHandler::none || !element) { return; } auto file = element.append_child("File"); AddTextElement(file, "LocalFile", m_localPath.GetPath() + GetLocalFile()); AddTextElement(file, "RemoteFile", GetRemoteFile()); AddTextElement(file, "RemotePath", m_remotePath.GetSafePath()); AddTextElementUtf8(file, "Download", Download() ? "1" : "0"); if (m_size != -1) { AddTextElement(file, "Size", m_size); } if (m_errorCount) { AddTextElement(file, "ErrorCount", m_errorCount); } if (m_priority != QueuePriority::normal) { AddTextElement(file, "Priority", static_cast<int>(m_priority)); } AddTextElementUtf8(file, "DataType", Ascii() ? "0" : "1"); if (m_defaultFileExistsAction != CFileExistsNotification::unknown) { AddTextElement(file, "OverwriteAction", m_defaultFileExistsAction); } }
/** * Get the job url. * * @param name Production name * @param mc Should be true for MC * @param url On return, the job url * * @return true on success */ Bool_t GetJobUrl(const TString& name, Bool_t mc, TString& url) { url = ""; TString index("raw.jsp"); if (!Download((mc ? "job_details.jsp" : "production/raw.jsp"), index)) return false; std::ifstream in(index.Data()); TString line; TString tgt(Form("<td class=\"table_row\">%s</td>", name.Data())); do { line.ReadLine(in); if (!line.Contains(tgt)) continue; line.ReadLine(in); Int_t first = line.Index("href=\""); Int_t last = line.Index("\"", first+7); url = line(first+6,last-first-6); break; } while (!in.eof()); in.close(); if (url.IsNull()) { Error("GetJobUrl", "Production %s not found", name.Data()); return false; } return true; }
transMsg::EReturnStatus COrderState<order::EOS_SHOP_EXAMINE_DURING>::_DownloadOrder(const SUserInfo& userInfo, const GL_OrderInfo_Data& statusInfo, transMsg::ETableType tableType, AStringType& buffer, PathType& orderFile, soci::session& sql) { if ( transMsg::ETT_SJ_TABLE == tableType ) { auto saveState = IOrderState::Factory(order::EOS_SAVE); return saveState->Download(userInfo, statusInfo, tableType, buffer, orderFile, sql); } else if ( transMsg::ETT_DS_TABLE == tableType ) { if ( 0 == userInfo.Rights_.count(RValue::Desgin::Examine) ) { return transMsg::ERS_WRONG_ACCESS; } if ( !_OrderVerify(userInfo, statusInfo) ) { return transMsg::ERS_WRONG_ACCESS; } transMsg::DS_Table dsTb; orderTool::DSTool tool(statusInfo, sql, dsTb); return tool.Download(buffer, orderFile); } return transMsg::ERS_ORDER_DENY; }
void Map::loadTiles(QList<Tile> &list) { QList<Download> dl; for (int i = 0; i < list.size(); ++i) { Tile &t = list[i]; QString file_base = QString("%1/"TILES_DIR"/%2/%3-%4-%5") .arg(QDir::homePath()).arg(_name).arg(t.zoom()).arg(t.xy().rx()) .arg(t.xy().ry()); QFileInfo fi_jpg(file_base + ".jpg"); QFileInfo fi_png(file_base + ".png"); if (fi_jpg.exists()) { t.pixmap().load(file_base + ".jpg"); } else if (fi_png.exists()) { t.pixmap().load(file_base + ".png"); } else { t.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE); t.pixmap().fill(); QString url(_url); url.replace("$z", QString::number(t.zoom())); url.replace("$x", QString::number(t.xy().x())); url.replace("$y", QString::number(t.xy().y())); dl.append(Download(url, file_base)); } } if (!dl.empty()) Downloader::instance().get(dl); }
void StartDownload() { isDownloading = true; const DownloadItem downloadItem = queue.front(); queue.pop_front(); const std::string& filename = downloadItem.filename; DownloadEnum::Category cat = downloadItem.cat; int ID = downloadItem.ID; if (!filename.empty()) { LOG_L(L_DEBUG, "DOWNLOADING: %s", filename.c_str()); } boost::thread {[ID, filename, cat]() { const int result = Download(ID, filename, cat); if (result == 0) { QueueDownloadFinished(ID); } else { QueueDownloadFailed(ID, result); } queueMutex.lock(); if (!queue.empty()) { queueMutex.unlock(); StartDownload(); } else { isDownloading = false; queueMutex.unlock(); } } }.detach(); }
void Map::loadTilesSync(QList<Tile> &list) { QList<Download> dl; for (int i = 0; i < list.size(); i++) { Tile &t = list[i]; QString file = tileFile(t); QFileInfo fi(file); if (!fi.exists()) dl.append(Download(tileUrl(t), file)); else loadTileFile(t, file); } if (dl.empty()) return; QEventLoop wait; connect(&Downloader::instance(), SIGNAL(finished()), &wait, SLOT(quit())); if (Downloader::instance().get(dl)) wait.exec(); for (int i = 0; i < list.size(); i++) { Tile &t = list[i]; if (t.pixmap().isNull()) { QString file = tileFile(t); QFileInfo fi(file); if (!(fi.exists() && loadTileFile(t, file))) fillTile(t); } } }
void MagnatuneService::EnsureMenuCreated() { if (context_menu_) return; context_menu_ = new QMenu; context_menu_->addActions(GetPlaylistActions()); download_ = context_menu_->addAction(IconLoader::Load("download"), tr("Download this album"), this, SLOT(Download())); context_menu_->addSeparator(); context_menu_->addAction(IconLoader::Load("download"), tr("Open %1 in browser").arg("magnatune.com"), this, SLOT(Homepage())); context_menu_->addAction(IconLoader::Load("view-refresh"), tr("Refresh catalogue"), this, SLOT(ReloadDatabase())); QAction* config_action = context_menu_->addAction( IconLoader::Load("configure"), tr("Configure Magnatune..."), this, SLOT(ShowConfig())); library_filter_ = new LibraryFilterWidget(0); library_filter_->SetSettingsGroup(kSettingsGroup); library_filter_->SetLibraryModel(library_model_); library_filter_->SetFilterHint(tr("Search Magnatune")); library_filter_->SetAgeFilterEnabled(false); library_filter_->AddMenuAction(config_action); context_menu_->addSeparator(); context_menu_->addMenu(library_filter_->menu()); }
/* virtual methods from class ActionListener */ void OnAction(int id) override { switch (id) { case DOWNLOAD: Download(); break; } }
bool CUpdater::Run() { if( state_ != UpdaterState::idle && state_ != UpdaterState::failed && state_ != UpdaterState::newversion && state_ != UpdaterState::newversion_ready ) { return false; } wxDateTime const t = wxDateTime::Now(); COptions::Get()->SetOption(OPTION_UPDATECHECK_LASTDATE, t.Format(_T("%Y-%m-%d %H:%M:%S"))); local_file_.clear(); log_ = wxString::Format(_("Started update check on %s\n"), t.Format()); wxString build = CBuildInfo::GetBuildType(); if( build.empty() ) { build = _("custom"); } log_ += wxString::Format(_("Own build type: %s\n"), build); SetState(UpdaterState::checking); m_use_internal_rootcert = true; int res = Download(GetUrl(), wxString()); if (res != FZ_REPLY_WOULDBLOCK) { SetState(UpdaterState::failed); } raw_version_information_.clear(); return state_ == UpdaterState::checking; }
UINT CCheckForUpdatesDlg::DownloadThread() { m_ctrlFiles.SetExtendedStyle(m_ctrlFiles.GetExtendedStyle() & ~LVS_EX_CHECKBOXES); m_sErrors.Empty(); BOOL result = TRUE; for (int i = 0; i < (int)m_ctrlFiles.GetItemCount(); ++i) { m_ctrlFiles.EnsureVisible(i, FALSE); CRect rect; m_ctrlFiles.GetItemRect(i, &rect, LVIR_BOUNDS); CUpdateListCtrl::Entry *data = (CUpdateListCtrl::Entry *)m_ctrlFiles.GetItemData(i); if (m_ctrlFiles.GetCheck(i) == TRUE) { data->m_status = CUpdateListCtrl::STATUS_DOWNLOADING; m_ctrlFiles.InvalidateRect(rect); if (Download(data->m_filename)) data->m_status = CUpdateListCtrl::STATUS_SUCCESS; else { data->m_status = CUpdateListCtrl::STATUS_FAIL; result = FALSE; } } else data->m_status = CUpdateListCtrl::STATUS_IGNORE; m_ctrlFiles.InvalidateRect(rect); } ::PostMessage(GetSafeHwnd(), WM_USER_ENDDOWNLOAD, 0, 0); return result; }
/** * This function update the mirror's databases, if one is supplied only that's updated, otherwise all mirrors. * @param name A database name (if NULL, then all databases) * @return If no error ocurr, 0 is returned. If the database given doesn't exists, 1 is returned. In case of error, -1 (And an error message is issued) */ int UpdateMirrorDB(char *db) { int i = 0, fd = 0; char dbpath[PATH_MAX]; char dbLink[PATH_MAX]; char dbDesc[PATH_MAX]; DIR *dip; struct dirent *dit; /* If only one database was issued */ if (db) { /* Get the path */ snprintf(dbpath, PATH_MAX, "%s/%s.kdb", MIRRORS_DIRECTORY, db); if ((fd = open(dbpath, O_RDONLY)) < 0) { fprintf(stdout, "Database %s doesn't exists\n", db); return 1; } close(fd); /* Get its data */ memset(dbLink, '\0', sizeof(dbLink)); memset(dbDesc, '\0', sizeof(dbDesc)); if (GetDataFromMirrorDatabase(dbpath, "LINK", dbLink) == -1) return -1; if (GetDataFromMirrorDatabase(dbpath, "DESC", dbDesc) == -1) return -1; /* Show comments for this database if any */ if (dbDesc[0] != '\0') fprintf(stdout, "Comments for [%s]:\n%s\n", db, dbDesc); /* Get the database! */ if (dbLink[0] != '\0') if (Download(dbLink, dbpath) == -1) return -1; return 0; } /* Get the databases from the directories */ if ((dip = opendir(MIRRORS_DIRECTORY)) == NULL) { fprintf(stderr, "Couldn't open the mirror's database directory %s (%s)\n", MIRRORS_DIRECTORY, strerror(errno)); return -1; } i = 1; while ((dit = readdir(dip)) != NULL) { /* Skip directories . and .. */ if (!strcmp(dit->d_name, ".") || !strcmp(dit->d_name, "..")) continue; if (!UpdateMirrorDB(RemoveExtension(dit->d_name))) i = 0; } closedir(dip); return i; }
wxCurlThreadError wxCurlDownloadThread::Download(const wxString &url, wxOutputStream *out) { wxCurlThreadError ret; if ((ret=SetURL(url)) != wxCTE_NO_ERROR) return ret; if ((ret=SetOutputStream(out)) != wxCTE_NO_ERROR) return ret; return Download(); }
// // Deactivate // Bool Options::Deactivate() { if (ICWindow::Deactivate()) { Download(); return (TRUE); } else { return (FALSE); } }
void* DiGLTextureDrv::LockLevel(uint32 level, uint32 surface, DiLockFlag lockflag) { DiBox lockbox(0, 0, mBuffer->GetWidth(), mBuffer->GetHeight()); AllocateBuffer(); mCurrentLockFlag = lockflag; if (lockflag != LOCK_DISCARD) { Download(*mBuffer, level, surface); } return mBuffer->data; }
void CDlgView::DownLoadPic(const string&UrpPath ,const string& strFilePath) { string picPath = strFilePath; picPath +="\\ini.bmp"; string downloadpathe = UrpPath +"/ini.bmp"; if(_access(picPath.c_str(),0) ==-1) Download(downloadpathe.c_str(),picPath.c_str()); picPath =""; picPath = strFilePath +"\\Install.bmp"; downloadpathe = UrpPath +"/Install.bmp"; if(_access(picPath.c_str(),0) ==-1) Download(downloadpathe.c_str(),picPath.c_str()); picPath =""; picPath = strFilePath +"\\UnInstall.bmp"; downloadpathe = UrpPath +"/UnInstall.bmp"; if(_access(picPath.c_str(),0) ==-1) Download(downloadpathe.c_str(),picPath.c_str()); picPath =""; picPath = strFilePath +"\\click.bmp"; downloadpathe = UrpPath +"/click.bmp"; if(_access(picPath.c_str(),0) ==-1) Download(downloadpathe.c_str(),picPath.c_str()); }
/** @brief Convert the HTTP status code to MMI status code for start. * * @param[in] HTTPStatus - HTTP streamer status code * @param[in] pUserData - Reference to the registered MMI callback iface */ void HTTPSourceMMIHelper::ProcessStartStatus ( const HTTPDownloadStatus HTTPStatus, void* pUserData ) { OMX_U32 ret = MMI_S_EFAIL; switch (HTTPStatus) { case HTTPCommon::HTTPDL_ERROR_ABORT: ret = MMI_S_EFAIL; break; case HTTPCommon::HTTPDL_TIMEOUT: ret = MMI_S_ETIMEOUT; break; case HTTPCommon::HTTPDL_OUT_OF_MEMORY: ret = MMI_S_ENOSWRES; break; case HTTPCommon::HTTPDL_UNSUPPORTED: ret = MMI_S_ENOTIMPL; break; case HTTPCommon::HTTPDL_INTERRUPTED: //Open failed break; case HTTPCommon::HTTPDL_SUCCESS: { //Start succeeded, post DOWNLOAD. Since DOWNLOAD //is an internal cmd, notify ONLY failure in //posting the cmd if (Download(pUserData)) { ret = MMI_S_PENDING; } } break; default: //Ignore other events break; } if (ret != MMI_S_PENDING) { NotifyMmi(MMI_RESP_START, ret, 0, NULL, pUserData); } }
void Main() { TextureAsset::Register(L"noise", L"Texture/noise.png"); //設定の読み込み LoadConfig(); //タイトル String Title(L"高専の敷き詰め理論ⅠB"); Point TitlePos(10, 0); //ウィンドウスタイルの設定 Window::SetStyle(WindowStyle::NonFrame); Window::Resize(960, 540); //フォントの用意 Font titlefont(30); Texture Back(L"Texture/BlackBord.png"); Rect font_size = titlefont.region(Title); //ボタンの用意 Button Download(download, 20, 100, L"・ダウンロード"); Button SelectFile(selectfile, 20, 170, L"・ファイルを選択"); Button ReAnswer(reanswer, 20, 240, L"・再度問題を解く"); Button Upload(upload, 20, 350, L"・アップロード"); //バグ除け Gout << L"準備完了\n"; while (System::Update()){ //ボタンのアップデート if (Download.end && SelectFile.end && Upload.end && ReAnswer.end){ Download.Update(); SelectFile.Update(); Upload.Update(); ReAnswer.Update(); } //描画 Back.draw(); titlefont(Title).draw(TitlePos, Palette::White); TextureAsset(L"noise").map(font_size.w, font_size.h).draw(TitlePos); Download.Draw(); SelectFile.Draw(); ReAnswer.Draw(); Upload.Draw(); Gout.Draw(); DD.Draw(); } }
void DiGLTextureDrv::CopyToMemory(const DiBox &srcBox, const DiPixelBox &dst) { DI_ASSERT(mBuffer); if (!mBuffer->Contains(srcBox)) { DI_WARNING("Source box out of range."); return; } if (mBuffer->GetWidth() != srcBox.GetWidth() || mBuffer->GetHeight() != srcBox.GetHeight()) { DI_WARNING("No scale is supported currently."); return; } Download(dst,0,0); }
void ManagedFileListWidget::OnAction(int id) { switch (id) { case DOWNLOAD: Download(); break; case ADD: Add(); break; case CANCEL: Cancel(); break; } }
/** * This function install a database in the MIRRORS_DIRECTORY * @param dbpath A database path * @return If no error ocurr, 0 is returned. In case of error, -1 (And an error message is issued). */ int InstKpkgDB(char *dbpath) { int fdi = 0, fdo = 0, i = 0; char tmp[PATH_MAX], tmpbuf[8129]; char *origdb = NULL; /* Create the destination database */ origdb = basename(dbpath); snprintf(tmp, PATH_MAX, "%s/%s", MIRRORS_DIRECTORY, origdb); /* Open the user database */ if ((fdi = open(dbpath, O_RDONLY)) < 0) { if (errno == ENOENT) { if (Download(dbpath, tmp) == -1) return -1; else return 0; } else { fprintf(stderr, "Can't open %s (%s)\n", dbpath, strerror(errno)); return -1; } } if ((fdo = open(tmp, O_WRONLY|O_TRUNC|O_CREAT, 0644)) < 0) { fprintf(stderr, "Can't open %s for writing (%s)\n", dbpath, strerror(errno)); return -1; } strncpy(fileremove, tmp, PATH_MAX-1); /* Read and write */ while ((i = read(fdi, tmpbuf, PATH_MAX)) > 0) write(fdo, tmpbuf, i); close(fdi); close(fdo); *fileremove = '\0'; /* If there was an error, show it and remove the destination database */ if (i < 0) { fprintf(stderr, "Error reading %s (%s)\n", dbpath, strerror(errno)); unlink(tmp); return -1; } return 0; }
// // Activate // // Activate this control // Bool Mission::Activate() { if (ICWindow::Activate()) { ActivateVar(defaultRule); ActivateVar(fixedRule); // Find required controls ruleList = IFace::Find<ICDropList>("RuleList", this, TRUE)->GetListBox(); ruleList->DeleteAllItems(); // Add the 'no rule' option ruleList->AddTextItem("None", NULL); // Get all rule sets if (const NBinTree<Mods::Mod> *rules = Mods::GetMods(Mods::Types::RuleSet)) { // Add each one to the list for (NBinTree<Mods::Mod>::Iterator r(rules); *r; ++r) { ruleList->AddTextItem((*r)->GetName().str, TRANSLATE(((*r)->GetDescription().str))); } } addonList = IFace::Find<ICListBox>("AddonList", this, TRUE); addonList->DeleteAllItems(); // Get all addons if (const NBinTree<Mods::Mod> *addons = Mods::GetMods(Mods::Types::Addon)) { // Add each on to the list for (NBinTree<Mods::Mod>::Iterator a(addons); *a; ++a) { addonList->AddTextItem((*a)->GetName().str, TRANSLATE(((*a)->GetDescription().str))); } } // Download the settings from the mission Download(); return (TRUE); } return (FALSE); }
/** * Get list of runs associated with production * * @param url The production URL * @param mc True of MC * @param minSize Least size of runs to use * * @return true on success */ Bool_t GetRuns(const TString& url, Bool_t mc, ULong_t minSize) { TString index("job"); if (!Download(Form("%s%s", (mc ? "" : "raw/"), url.Data()), index)) return false; std::ifstream in(index.Data()); TString tgt1(mc ? "window.open" : "runDetails"); TString line = ""; do { line.ReadLine(in); if (!line.Contains(tgt1)) continue; Int_t first = -1; Int_t last = -1; if (!mc) { first = line.Index(tgt1); last = line.Index(")", first+tgt1.Length()+1); } else { Int_t tmp = line.Index(">"); first = line.Index(">", tmp+1); last = line.Index("<", first); } if (first == kNPOS || last == kNPOS) { Error("GetDir", "Failed to get directory from %s", line.Data()); return false; } first += (mc ? 1 : tgt1.Length()+1); last -= first; TString srun = line(first, last); ULong_t runNo = srun.Atoll(); if (fDebug) Info("", "Got run %lu (%s)", runNo, srun.Data()); if (!GetSize(in, runNo, mc, minSize)) continue; if (!GetDir(in, runNo, mc)) continue; if (!fRuns.IsNull()) fRuns.Append(","); fRuns.Append(Form("%lu", runNo)); } while (!in.eof()); in.close(); if (fRuns.IsNull()) return false; return true; }
UpdaterState CUpdater::ProcessFinishedData(bool can_download) { UpdaterState s = failed; ParseData(); if( version_information_.available_.version_.empty() ) { s = idle; } else if( !version_information_.available_.url_.empty() ) { wxString const temp = GetTempFile(); wxString const local_file = GetLocalFile(version_information_.available_, true); if( !local_file.empty() && CLocalFileSystem::GetFileType(local_file) != CLocalFileSystem::unknown) { local_file_ = local_file; log_ += wxString::Format(_("Local file is %s\n"), local_file.c_str()); s = newversion_ready; } else { // We got a checksum over a secure channel already. update_options_->m_use_internal_rootcert = false; if( temp.empty() || local_file.empty() ) { s = newversion; } else { s = newversion_downloading; wxLongLong size = CLocalFileSystem::GetSize(temp); if( size >= 0 && static_cast<unsigned long long>(size.GetValue()) >= version_information_.available_.size_ ) { s = ProcessFinishedDownload(); } else if( !can_download || Download( version_information_.available_.url_, GetTempFile() ) != FZ_REPLY_WOULDBLOCK ) { s = newversion; } } } } else { s = newversion; } return s; }
void Map::loadTilesAsync(QList<Tile> &list) { QList<Download> dl; for (int i = 0; i < list.size(); i++) { Tile &t = list[i]; QString file = tileFile(t); QFileInfo fi(file); if (!fi.exists()) { fillTile(t); dl.append(Download(tileUrl(t), file)); } else loadTileFile(t, file); } if (!dl.empty()) Downloader::instance().get(dl); }
void UpdateNintendont(void) { int selected = 0; u64 delay = ticks_to_millisecs(gettime()) + 500; while(true) { ClearScreen(); PrintInfo(); PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*5, "Download Nintendont"); PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*6, "Download titles.txt"); PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*7, "Download controllers.zip"); PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 50, MENU_POS_Y + 20*8, "Return to Settings"); PrintFormat(DEFAULT_SIZE, BLACK, MENU_POS_X + 35, MENU_POS_Y + 20*(5+selected), ARROW_RIGHT); GRRLIB_Render(); FPAD_Update(); if (delay > ticks_to_millisecs(gettime())) continue; if (FPAD_Start(1)) { ClearScreen(); PrintFormat(DEFAULT_SIZE, BLACK, 212, 232, "Returning to loader..."); ExitToLoader(0); } if (FPAD_OK(1)) { if (selected <= DOWNLOAD_CONTROLLERS) Download(selected); else break; } if (FPAD_Down(1)) { delay = ticks_to_millisecs(gettime()) + 150; selected++; if (selected > 3) selected = 0; } if (FPAD_Up(1)) { delay = ticks_to_millisecs(gettime()) + 150; selected--; if (selected < 0) selected = 3; } if (FPAD_Cancel(1)) { break; } } ClearScreen(); return; }
void KTestDownloadPack::TestDownloadSeveralPack() { int nResult = false; int nRetCode = false; KHttpDownloader Downloader; //设置同时下载的文件数,从1到10共10种情况,每次进行下载11个更新包的测试 for (int nCount = 1; nCount <= 10; nCount++) { Downloader.SetThreadCount(nCount); nRetCode = Download(&Downloader, 11); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = CheckAndDelZip(11); KGLOG_PROCESS_ERROR(nRetCode); } nResult = true; Exit0: CPPUNIT_ASSERT(nResult); }
BOOL CUpdateThread::GetFileList( LPCTSTR lpszUrl, CMap<CString, LPCTSTR, AddonFile, AddonFile &> &fileList ) { CString strTempPath = theApp.GetTempPath(); TCHAR cPath[MAX_PATH] = {0}; GetTempFileName(strTempPath, _T("SITE"), 0, cPath); CString strUrl = lpszUrl; strUrl.Append(_T("filelist.xml")); SendMessage(m_hWnd, WM_UPDATE_STATUS_MSG, NULL, (LPARAM)(CString(_T("获取列表 ") + strUrl).GetString())); if (Download(strUrl, cPath)) { USES_CONVERSION; TiXmlDocument doc; if (doc.LoadFile(T2A(cPath))) { TiXmlElement *el = doc.RootElement(); TiXmlElement *fileElement = el->FirstChildElement("File"); while (fileElement) { USES_CONVERSION; const char *name = fileElement->Attribute("Path"); if (!name) return FALSE; const char *md5 = fileElement->Attribute("MD5"); if (!md5) return FALSE; int iSize = 0; if (!fileElement->Attribute("Size", &iSize)) return FALSE; int iCompressedSize = 0; if (!fileElement->Attribute("CompressedSize", &iCompressedSize)) return FALSE; CString strPath = A2T(name); fileList[strPath.MakeLower()] = AddonFile(lpszUrl, A2T(name), A2T(md5), iSize, iCompressedSize); fileElement = fileElement->NextSiblingElement("File"); } } return TRUE; } return FALSE; }