std::shared_future<Package> PackagesManager::getPackage(const std::string& packageName) const { cleanFuturePackages(); if(m_alreadyRequestedPackages.count(packageName) == 0) { //The package is not downloading, so add the (down)loading task m_alreadyRequestedPackages[packageName] = std::async([&]() -> Package { //TODO: Download if needed for(const auto& packagesPath : m_packagesPaths) { try { return Package(fs::canonical(fs::path(packageName), packagesPath)); } catch(...) {} //Ignore the package exceptions } throw Package::BadPackagePath(packageName + " is not available locally!"); }) .share(); } return m_alreadyRequestedPackages.at(packageName); }
void CUpdataDownload::OnBnClickedButtonUpdata() { // TODO: 在此添加控件通知处理程序代码 int nSendLeng = 0; int nPos = 0; string strUpataFileName(CGlobalData::m_strHttpFilePath); nPos = strUpataFileName.find_last_of('\\'); memcpy(m_strDownloadName,strUpataFileName.c_str()+(nPos+1),strUpataFileName.length()-nPos); Package(m_pStrData,'U',m_strDownloadName,nSendLeng); SendData(m_pStrData,nSendLeng); int nWiatResult = WaitForSingleObject(m_hEvent,15*1000); if(WAIT_OBJECT_0 == nWiatResult) { memset(m_strDownloadName,0,sizeof(m_strDownloadName)); strUpataFileName.empty(); nPos = 0; strUpataFileName = CGlobalData::m_strPackRulePath; nPos = strUpataFileName.find_last_of('\\'); memcpy(m_strDownloadName,strUpataFileName.c_str()+(nPos+1),strUpataFileName.length()-nPos); Package(m_pStrData,'U',m_strDownloadName,nSendLeng); SendData(m_pStrData,nSendLeng); //Xt: 更新版本号 HKEY hKey; CRegistryOperate RegOpt; if(RegOpt.OpenRegistry(HKEY_LOCAL_MACHINE,"SOFTWARE\\CaptureTest",&hKey)) { RegOpt.SetRegistryValue("Version",CGlobalData::m_strServerVersionNum,&hKey); RegCloseKey(hKey); memcpy(CGlobalData::m_strClientVersionNum,CGlobalData::m_strServerVersionNum,sizeof(CGlobalData::m_strClientVersionNum)); CString strClientVersion(_T("客户端当前版本号为: ")); strClientVersion += CGlobalData::m_strClientVersionNum; GetDlgItem(IDC_STATIC_CLIENT_ID)->SetWindowText(strClientVersion); GetDlgItem(ID_BUTTON_UPDATA)->EnableWindow(FALSE); MessageBox(_T("升级成功已是最新版本!")); } } else if(WAIT_TIMEOUT == nWiatResult) { m_bRun = false; CGlobalData::PrintLogInfo("CUpdataDownload","更新失败下载时间超时!",'E'); MessageBox(_T("更新失败下载时间超时!")); } }
Plasma::Package Package::fallbackPackage() const { if (d->fallbackPackage) { return (*d->fallbackPackage); } else { return Package(); } }
Package PluginLoader::loadPackage(const QString &packageFormat, const QString &specialization) { if (!d->isDefaultLoader) { Package p = internalLoadPackage(packageFormat, specialization); if (p.hasValidStructure()) { return p; } } if (packageFormat.isEmpty()) { return Package(); } const QString hashkey = packageFormat + '%' + specialization; PackageStructure *structure = d->structures.value(hashkey).data(); if (structure) { return Package(structure); } KPackage::PackageStructure *internalStructure = KPackage::PackageLoader::self()->loadPackageStructure(packageFormat); if (internalStructure) { structure = new PackageStructure(); structure->d->internalStructure = internalStructure; //fallback to old structures } else { const QString constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(packageFormat); structure = KPluginTrader::createInstanceFromQuery<Plasma::PackageStructure>(PluginLoaderPrivate::s_packageStructurePluginDir, QStringLiteral("Plasma/PackageStructure"), constraint, 0); if (structure) { structure->d->internalStructure = new PackageStructureWrapper(structure); } } if (structure) { d->structures.insert(hashkey, structure); return Package(structure); } #ifndef NDEBUG // qCDebug(LOG_PLASMA) << "Couldn't load Package for" << packageFormat << "! reason given: " << error; #endif return Package(); }
IResource *PackageResourceLoader(const char *filename, ResourceManager *res, IMemoryPool *pool) { Package *pkg = New(Package()); BOOL loaded = pkg->Load(filename, res, pool); if (!loaded) { Delete(pkg); } return pkg; }
package_vec System::get_installed_packages() { package_vec vp; string_vec files = get_files(PATH_INSTALLED_PACKAGES); for (string_vec::iterator i = files.begin(); i != files.end(); i++) { vp.push_back(Package(*i)); /* BOOM */ } return vp; }
package_vec System::get_removed_packages() { package_vec vp; string_vec files = get_files(PATH_REMOVED_PACKAGES); for (string_vec::iterator i = files.begin(); i != files.end(); i++) { vp.push_back(Package(*i)); } return vp; }
void sendData(int len, int no, float mess, wchar_t end) { //加载套接字 WSADATA wsaData; char buff[1024]; memset(buff, 0, sizeof(buff)); if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { printf("Failed to load Winsock"); return; } SOCKADDR_IN addrSrv; addrSrv.sin_family = AF_INET; addrSrv.sin_port = htons(20101); addrSrv.sin_addr.S_un.S_addr = inet_addr("202.115.13.252"); //创建套接字 SOCKET sockClient = socket(AF_INET, SOCK_STREAM, 0); if(SOCKET_ERROR == sockClient) { printf("Socket() error:%d", WSAGetLastError()); return; } //向服务器发出连接请求 if(connect(sockClient, (struct sockaddr*)&addrSrv, sizeof(addrSrv)) == INVALID_SOCKET) { printf("Connect failed:%d", WSAGetLastError()); return; } //封装数据包 Package package = Package(); package.packageLen = len; package.deviceNo = no; package.message = mess; package.pend = end; //发送数据 send(sockClient, (const char*)&(package), sizeof(package), 0); //接收服务器回应 recv(sockClient, buff, sizeof(buff), 0); printf("%s\n", buff); //关闭套接字 closesocket(sockClient); WSACleanup(); }
void Server :: readLocalIpks( Server *local ) { cleanUp(); #ifdef QWS // First, get any local IPKGs in the documents area // Only applicable to Qtopie/Opie DocLnkSet files; Global::findDocuments( &files, "application/ipkg" ); // Now add the items to the list QListIterator<DocLnk> it( files.children() ); for ( ; it.current() ; ++it ) { // OK, we have a local IPK file, I think the standard naming conventions // for these are packagename_version_arm.ipk QString file = (*it)->file(); // Changed to display the filename (excluding the path) QString packageName = Utils::getPackageNameFromIpkFilename( file ); QString ver = Utils::getPackageVersionFromIpkFilename( file ); Package *package = new Package( packageName ); package->setVersion( ver ); package->setFilename( file ); package->setPackageStoredLocally( true ); packageList.append( package ); } #else QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" }; for ( int i = 0 ; i < 4 ; ++i ) { // OK, we have a local IPK file, I think the standard naming conventions // for these are packagename_version_arm.ipk QString file = names[i]; int p = file.find( "_" ); QString tmp = file.mid( 0, p ); packageList.push_back( Package( tmp ) ); int p2 = file.find( "_", p+1 ); tmp = file.mid( p+1, p2-(p+1) ); packageList.back().setVersion( tmp ); packageList.back().setPackageStoredLocally( true ); } #endif // build local packages buildLocalPackages( local ); }
// CUpdataDownload 消息处理程序 BOOL CUpdataDownload::OnInitDialog() { CDialog::OnInitDialog(); if(!LinkService(CGlobalData::m_strServiceIP,CGlobalData::m_nServicePort)) { CGlobalData::PrintLogInfo("CUpdataDownload","连接服务程序错误或服务程序没有启动!",'E'); MessageBox(_T("连接服务程序错误或服务器没有启动!")); } int nSendLeng = 0; Package(m_pStrData,'V',"",nSendLeng); SendData(m_pStrData,nSendLeng); CString strVersion(_T("客户端当前版本号为: ")); strVersion += CGlobalData::m_strClientVersionNum; GetDlgItem(IDC_STATIC_CLIENT_ID)->SetWindowText(strVersion); GetDlgItem(ID_BUTTON_UPDATA)->EnableWindow(FALSE); return TRUE; }
void FResourceGroup::LoadPackage(const std::string& Filename) { FResourcePackage Package(Filename); const TVector<FResource>& Resources = Package.GetResources(); for (auto Resource : Resources) { IArchive* Archive = Resource.GetResourceArchive(&Package); if (Resource.GetType() == "Texture") { LoadTexture(Resource.GetPath(), Archive); } else if (Resource.GetType() == "3D Model") { LoadModel(Resource.GetPath(), Archive); } delete Archive; } }
/////////////////////////////////////////////////////////////////////////// // C'tor /////////////////////////////////////////////////////////////////////////// Binpressor::Binpressor(int argc, char* argv[]) { // Set up console. SetConsoleTitle("Binpressor"); std::cout << "Binpressor - V" << MAJOR_VERSION << "." << MINOR_VERSION; #if defined (_WIN64) std::cout << " - (x64)"; #endif std::cout << std::endl; std::cout << "Proprietary binary packaging tool." << std::endl; std::cout << "Copyright (C) 2012 Johan Rensenbrink." << std::endl; std::cout << "----------------------------------" << std::endl; // Grab files and folders. for(int i = 1; i < argc; i++) { if (IsFileOrFolder(argv[i]) == 1) { if (boost::filesystem::extension(argv[i]) != ".bin") m_filePaths.push_back(argv[i]); else m_packages.push_back(argv[i]); } else if (IsFileOrFolder(argv[i]) == 2) CollectFilePaths(argv[i]); } CollectFileInfo(); Package(); ReadFiles(); Unpackage(); if (!m_filePaths.empty()) PrintFilePaths(); if (!m_descriptors.empty()) PrintFileDescriptors(); }
Package PackagesManager::getLocalPackage(const std::string& packageName) const { cleanFuturePackages(); //If the package is being downloaded, it may have its folder created. //However, we still need to ignore it to avoid incomplete packages. if(m_alreadyRequestedPackages.count(packageName) > 0) throw Package::BadPackagePath(packageName + " is not avaible locally!"); //Search for the package in the directories for(const auto& packagesPath : m_packagesPaths) { try { return Package(fs::canonical(fs::path(packageName), packagesPath)); } catch(...) {} //Ignore the package exceptions } //Not found locally! throw Package::BadPackagePath(packageName + " is not available locally!"); }
void DPAlgo() { int W[8]={0,10,40,30,50,35,40,30}; //物品权重 int C[8]={0,35,30,60,50,40,10,25}; //物品大小 int result=Package(W,C,N,V); if(result>0) { std::cout<<std::endl; std::cout<<"the opt value:"<<result<<std::endl; int i=N,j=V; while(i) { if(f[i][j]==(f[i-1][j-C[i]]+W[i])) { std::cout<<i<<":"<<"w="<<W[i]<<",c="<<C[i]<<std::endl; j-=C[i]; } i--; } } else std::cout<<"can not find the opt value"<<std::endl; }
TwoDayPackage::TwoDayPackage() : Package(){ // default constructor Package(); perOunceIncrease = 0; }
Package *CreatePackage(const wchar_t *pwszName){ xKey Key(pwszName, std::wcslen(pwszName)); const auto iterHint = xm_mapPackages.upper_bound(Key); return &(xm_mapPackages.emplace_hint(iterHint, std::move(Key), Package())->second); }
Package Interpreter::package(const char* name) const { return Package(interp, name); }
Package Exporter_helper::get_package() { return Package(interp, package_name); }
Package PluginLoader::loadPackage(const QString &packageFormat, const QString &specialization) { if (!d->isDefaultLoader) { Package p = internalLoadPackage(packageFormat, specialization); if (p.hasValidStructure()) { return p; } } if (packageFormat.isEmpty()) { return Package(); } const QString hashkey = packageFormat + '%' + specialization; PackageStructure *structure = d->structures.value(hashkey).data(); KPackage::PackageStructure *internalStructure = 0; if (structure) { return Package(structure); } if (packageFormat.startsWith(QLatin1String("Plasma"))) { if (packageFormat.endsWith(QLatin1String("/Applet"))) { internalStructure = new PlasmoidPackage(); } else if (packageFormat.endsWith(QLatin1String("/DataEngine"))) { internalStructure = new DataEnginePackage(); } else if (packageFormat.endsWith(QLatin1String("/Theme"))) { internalStructure = new ThemePackage(); } else if (packageFormat.endsWith(QLatin1String("/ContainmentActions"))) { internalStructure = new ContainmentActionsPackage(); } else if (packageFormat.endsWith(QLatin1String("/Generic"))) { internalStructure = new GenericPackage(); } if (internalStructure) { structure = new PackageStructure(); structure->d->internalStructure = internalStructure; d->structures.insert(hashkey, structure); return Package(structure); } } internalStructure = KPackage::PackageLoader::self()->loadPackageStructure(packageFormat); if (internalStructure) { structure = new PackageStructure(); structure->d->internalStructure = internalStructure; //fallback to old structures } else { const QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(packageFormat); structure = KPluginTrader::createInstanceFromQuery<Plasma::PackageStructure>(PluginLoaderPrivate::s_packageStructurePluginDir, "Plasma/PackageStructure", constraint, 0); if (structure) { structure->d->internalStructure = new PackageStructureWrapper(structure); } } if (structure) { d->structures.insert(hashkey, structure); return Package(structure); } #ifndef NDEBUG // qCDebug(LOG_PLASMA) << "Couldn't load Package for" << packageFormat << "! reason given: " << error; #endif return Package(); }
Package ScriptEngine::package() const { return Package(); }
void ComponentImplementation::install() throw(Components::CreateFailure) { // // if already installed increment counter only // if (installation_count_) { installation_count_++; DEBUG_OUT3( "..... already installed (", installation_count_, ")" ); return; } // // if without package increment counter only // if (package_.empty()) { installation_count_++; return; } // // create directories for the component implementation // makeDir(data_.installation_dir); makeDir(build_dir_); // // package may be component or composition // Package archive = Package( package_ ); std::string xmlfile_name = archive.getFileNameWithSuffix( ".cad" ); if ( xmlfile_name != std::string( "" ) ) { // // get info from the assembly package // CADReader reader; try { reader.readCAD( package_, &(data_.assembly), build_path_ ); } catch( CADReadException ) { std::cerr << "!!!!! Error during reading .cad" << std::endl; removeFileOrDirectory(data_.installation_dir); removeFileOrDirectory(build_dir_); throw Components::CreateFailure(); } data_.assembly.cad = getFileName( xmlfile_name ); } else { xmlfile_name = archive.getFileNameWithSuffix( ".csd" ); // // get info from the software package // CSDReader reader; try { reader.readCSD( package_, &data_, build_path_ ); } catch( CSDReadException ) { std::cerr << "!!!!! Error during reading .csd" << std::endl; removeFileOrDirectory(data_.installation_dir); removeFileOrDirectory(build_dir_); throw Components::CreateFailure(); } data_.csd = getFileName( xmlfile_name ); } // // install any code // try { installCode(); } catch( Components::CreateFailure ) { removeFileOrDirectory(data_.installation_dir); removeFileOrDirectory(build_dir_); throw Components::CreateFailure(); } // increment installation counter ( to 1 ) installation_count_++; }
FReply FCurveColorCustomization::OnCreateButtonClicked() { if (CurveWidget.IsValid()) { FString DefaultAsset = FPackageName::GetLongPackagePath(Owner->GetOutermost()->GetName()) + TEXT("/") + Owner->GetName() + TEXT("_ExternalCurve"); TSharedRef<SDlgPickAssetPath> NewCurveDlg = SNew(SDlgPickAssetPath) .Title(LOCTEXT("NewCurveDialogTitle", "Choose Location for External Curve Asset")) .DefaultAssetPath(FText::FromString(DefaultAsset)); if (NewCurveDlg->ShowModal() != EAppReturnType::Cancel) { FString Package(NewCurveDlg->GetFullAssetPath().ToString()); FString Name(NewCurveDlg->GetAssetName().ToString()); FString Group(TEXT("")); // Find (or create!) the desired package for this object UPackage* Pkg = CreatePackage(NULL, *Package); UPackage* OutermostPkg = Pkg->GetOutermost(); TArray<UPackage*> TopLevelPackages; TopLevelPackages.Add( OutermostPkg ); if (!PackageTools::HandleFullyLoadingPackages(TopLevelPackages, LOCTEXT("CreateANewObject", "Create a new object"))) { // User aborted. return FReply::Handled(); } if (!PromptUserIfExistingObject(Name, Package, Group, Pkg)) { return FReply::Handled(); } // PromptUserIfExistingObject may have GCed and recreated our outermost package - re-acquire it here. OutermostPkg = Pkg->GetOutermost(); // Create a new asset and set it as the external curve FName AssetName = *Name; UCurveLinearColor* NewCurve = Cast<UCurveLinearColor>(CurveWidget->CreateCurveObject(UCurveLinearColor::StaticClass(), Pkg, AssetName)); if( NewCurve ) { // run through points of editor data and add to external curve for (int32 Index = 0; Index < 4; Index++) { CopyCurveData(&RuntimeCurve->ColorCurves[Index], &NewCurve->FloatCurves[Index]); } // Set the new object as the sole selection. USelection* SelectionSet = GEditor->GetSelectedObjects(); SelectionSet->DeselectAll(); SelectionSet->Select( NewCurve ); // Notify the asset registry FAssetRegistryModule::AssetCreated(NewCurve); // Mark the package dirty... OutermostPkg->MarkPackageDirty(); // Make sure expected type of pointer passed to SetValue, so that it's not interpreted as a bool ExternalCurveHandle->SetValue(NewCurve); } } } return FReply::Handled(); }
Package TParser :: execute(int & pos) { deque<TScanner :: TToken> & lst(*generated_tokens); switch (lst[pos].token_name) { case TScanner :: assign : if (lst[pos] == token_round_bracket_l || lst[pos] == token_rect_bracket_l || lst[pos] == token_italian_bracket_l) { auto tmp = execute(++pos); if (tmp.code_seg == NULL || tmp.code_seg -> title == "") Error.message("Invalid expression occured."); string title = tmp.code_seg -> title; auto target = keyword_vtable.find(title); if (target != keyword_vtable.end()) { TProcessor * op = target -> second; auto t = op -> proc(pos, lst); return t; } else { TSeq_arg in_pending; Package next; while (true) { next = execute(pos); if (next.empty()) break; // std :: cerr << next << ' '; in_pending.push_back(next); } //std :: cerr << "for function #" << title << "#" << std :: endl; arg_stack.push_back(in_pending); int p; Package ret_p; bool is_static; bool is_renewable = true; long long x; long long y; if (tmp.code_seg -> l == 0 && tmp.code_seg -> r == 0) { auto tg = symbol_table.find(title); if (tg == symbol_table.end()) Error.message("Invalid operator #" + title + "# found."); auto static_flag = static_def_list.find(title); is_static = (static_flag != static_def_list.end()); x = (in_pending.size() > 0 && in_pending[0].int_val != NULL) ? (*in_pending[0].int_val) : 0; y = (in_pending.size() > 1 && in_pending[1].int_val != NULL) ? (*in_pending[1].int_val) : 0; if (is_static) { if (in_pending[0].int_val != NULL) { auto saved_valuex = static_flag -> second.find(*in_pending[0].int_val); if (saved_valuex != static_flag -> second.end()) { auto saved_value = saved_valuex -> second.find(y); if (saved_value != saved_valuex -> second.end()) { is_renewable = false; ret_p = saved_value -> second; } } } else { Error.message("Fatal : A non-staticizeable function is under such a attempt."); } } p = tg -> second.l; } else { p = tmp.code_seg -> l; } if (ret_p.empty()) ret_p = execute(p); if (is_static && is_renewable) { static_def_list[title][x][y] = ret_p; } arg_stack.pop_back(); return ret_p; } } else { pos++; return Package(); } break; case TScanner :: id : ++pos; if (arg_symbol_stack.empty() || arg_symbol_stack[arg_symbol_stack.size() - 1].find(Scanner.seq_identifier[lst[pos - 1].attribute_value]) == arg_symbol_stack[arg_symbol_stack.size() - 1].end()) return Package(Scanner.seq_identifier[lst[pos - 1].attribute_value], 0, 0); else return get_arg(arg_symbol_stack[arg_symbol_stack.size() - 1][Scanner.seq_identifier[lst[pos - 1].attribute_value]]); break; case TScanner :: immediate_int : return Package(Scanner.seq_imm_int[lst[pos++].attribute_value]); break; case TScanner :: immediate_str : return Package(Scanner.seq_imm_str[lst[pos++].attribute_value]); break; } return Package(); }