QString LongStream::detach() { QString detachedName = fileName(); delete ts; tmpFile->setAutoRemove(false); tmpFile->close(); delete tmpFile; QString tmpName( LongStream::tempDir() + QLatin1String( "/qtopiamail" ) ); tmpFile = new QTemporaryFile( tmpName + QLatin1String( ".XXXXXX" )); tmpFile->open(); tmpFile->setPermissions(QFile::ReadOwner | QFile::WriteOwner); ts = new QDataStream( tmpFile ); len = 0; appendedBytes = minCheck; c = QChar::Null; resetStatus(); return detachedName; }
void Job::SetCategory( const char *categoryName, ThrottleByCategory &catThrottles ) { MyString tmpName( categoryName ); if ( (_throttleInfo != NULL) && (tmpName != *(_throttleInfo->_category)) ) { debug_printf( DEBUG_NORMAL, "Warning: new category %s for node %s " "overrides old value %s\n", categoryName, GetJobName(), _throttleInfo->_category->Value() ); check_warning_strictness( DAG_STRICT_3 ); } // Note: we must assign a ThrottleInfo here even if the name // already matches, for the case of lifting splices. ThrottleByCategory::ThrottleInfo *oldInfo = _throttleInfo; ThrottleByCategory::ThrottleInfo *throttleInfo = catThrottles.GetThrottleInfo( &tmpName ); if ( throttleInfo != NULL ) { _throttleInfo = throttleInfo; } else { _throttleInfo = catThrottles.AddCategory( &tmpName ); } if ( oldInfo != _throttleInfo ) { if ( oldInfo != NULL ) { oldInfo->_totalJobs--; } _throttleInfo->_totalJobs++; } }
// HINT: This information remains static throughout the object's lifetime inline VmbErrorType Interface::GetName( std::string &rStrName ) const { VmbErrorType res; VmbUint32_t nLength; res = GetName( NULL, nLength ); if ( VmbErrorSuccess == res ) { if( 0 != nLength ) { try { std::vector<std::string::value_type> tmpName( nLength + 1, '\0' ); res = GetName( &tmpName[0], nLength ); if( VmbErrorSuccess == res ) { rStrName = &*tmpName.begin(); } } catch(...) { return VmbErrorResources; } } else { rStrName.clear(); } } return res; }
bool CdipClientManager::subscribeDPE(CdpeWrapper & dpeID){ CharString name=dpeID.getDipAddress(); // First of all extract the publication and tags names CharString pubName; CharString tagName; int pos1 = 0; int pos2 = 0; int pos = 0; pos1 = name.indexOf(pubNameDelimiter[0],0); // Search for the character [SUB] pos2 = name.indexOf(pubNameDelimiter[1],0); // Search for the character ! if ((pos1 == -1) && (pos2 == -1)) { //None of the delimiters was found, report problem. PVSSERROR("None of the configuration string delimiters "<<pubNameDelimiter[0]<<" and "<<pubNameDelimiter[1]<<" were found for Subscriptions."); } else if ((pos1 != -1) && (pos2 == -1)) { //The delimiter 1 is used, its ok. pos = pos1; } else if ((pos1 == -1) && (pos2 != -1)) { //The delimiter 2 is used, its ok. pos = pos2; } else { //Well this is tricky, both delimiters are present //while they should be mutually exclusive, report problem. PVSSERROR("Configuration string delimiters "<<pubNameDelimiter[0]<<" and "<<pubNameDelimiter[1]<<" are both present for Subscriptions, take first one."); pos = pos1; } if (pos == std::string::npos){ //tagName.clear(); pubName = name; } else { std::string tmpName(name); // CharString has no substr like function tagName = tmpName.substr(pos+1).c_str(); pubName = tmpName.substr(0, pos).c_str(); } // Now see if we are already have subscribers to that publication. std::map<const CharString *, CdipSubscription *, CharStringLess>::iterator it = dipPubsSubscribedTo.find(&pubName); CdipSubscription * pubSubscription = NULL; bool subscriptionPreviouslyExisted = true; if (it == dipPubsSubscribedTo.end()){ pubSubscription = createDipSubscription(pubName); subscriptionPreviouslyExisted = false; } else { pubSubscription = it->second; } // now add to tag-DPE mapping // TODO error if no tag or tag added to sub that is already the opposite pubSubscription->createMapping(tagName, name, dpeID); if (subscriptionPreviouslyExisted){ // request data resend at end of config mapping update. pubSubscription->markForGetLastPubValue(); } return true; }
string PrintToTextField(vector<Stat>::iterator iter) { string tmpName(iter->name); int tmpScore(iter->score); char tmp2[10]; _itoa_s(tmpScore, tmp2, 10, 10); string tmp = tmpName + " " + tmp2; return tmp; }
bool atomImport::replaceNameAndFindPlug(const MString& origName, atomNodeNameReplacer& replacer, MPlug& replacedPlug) { bool rtn = false; // get the node name // MStringArray nameParts; origName.split('.', nameParts); // Perform any necessary replacement // MString tmpName(nameParts[0]); // TODO: type & hierarchy info -- does the replacer store enough info // to help us find that out since in the case of export edits we don't // have that info for sources // if (replacer.findNode(atomNodeNameReplacer::eDag,tmpName,0,0)) { MString newName(tmpName); newName += ("."); // add the attribute name(s) back on again // unsigned int ii; MString attrName; for (ii = 1; ii < nameParts.length(); ++ii) { if (ii > 1) { attrName += ("."); } attrName += nameParts[ii]; } newName += attrName; MSelectionList tmpList; if (MS::kSuccess == tmpList.add(newName)) { tmpList.getPlug(0,replacedPlug); rtn = !replacedPlug.isNull(); if (!rtn) { // test for the special case of the pivot component // MDagPath path; MObject component; if (MS::kSuccess == tmpList.getDagPath(0,path,component) && component.apiType() == MFn::kPivotComponent) { MObject node; tmpList.getDependNode(0,node); MFnDependencyNode fnNode(node); replacedPlug = fnNode.findPlug(attrName,false); rtn = !replacedPlug.isNull(); } } } } return rtn; }
bool Preferences_Save_Safe( PreferenceDictionary& preferences, const char* filename ){ Array<char> tmpName( filename, filename + strlen( filename ) + 1 + 3 ); *( tmpName.end() - 4 ) = 'T'; *( tmpName.end() - 3 ) = 'M'; *( tmpName.end() - 2 ) = 'P'; *( tmpName.end() - 1 ) = '\0'; return Preferences_Save( preferences, tmpName.data() ) && ( !file_exists( filename ) || file_remove( filename ) ) && file_move( tmpName.data(), filename ); }
void FSMDescrip::addTransition(const std::string& name, Transition* trans) { std::string tmpName(name); size_t n = tmpName.find_first_of(','); while (n != std::string::npos) { std::string sName = tmpName.substr(0, n); _transitions[sName].push_back(trans->copy()); tmpName = tmpName.substr(n + 1); n = tmpName.find_first_of(','); } _transitions[tmpName].push_back(trans); }
/************************************************************************* Destroys the Imageset with the specified name *************************************************************************/ void ImagesetManager::destroyImageset(const String& name) { ImagesetRegistry::iterator pos = d_imagesets.find(name); if (pos != d_imagesets.end()) { String tmpName(name); delete pos->second; d_imagesets.erase(pos); Logger::getSingleton().logEvent((utf8*)"Imageset '" + tmpName +"' has been destroyed.", Informative); } }
/************************************************************************* Destroy the named font *************************************************************************/ void FontManager::destroyFont(const String& name) { FontRegistry::iterator pos = d_fonts.find(name); if (pos != d_fonts.end()) { String tmpName(name); delete pos->second; d_fonts.erase(pos); Logger::getSingleton().logEvent((utf8*)"Font '" + tmpName +"' has been destroyed."); } }
/* Helper class to reduce memory usage while downloading large mails */ LongStream::LongStream() { QString tmpName( LongStream::tempDir() + QLatin1String( "/qtopiamail" ) ); len = 0; appendedBytes = minCheck; tmpFile = new QTemporaryFile( tmpName + QLatin1String( ".XXXXXX" )); if (tmpFile->open()) { tmpFile->setPermissions(QFile::ReadOwner | QFile::WriteOwner); ts = new QDataStream( tmpFile ); } else { qWarning() << "Unable to open temporary file:" << tmpFile->fileName(); ts = 0; setStatus( LongStream::OutOfSpace ); } }
int FileMcIDAS::Close(int channel){ if (Bin[channel]) { bufFlush(channel); if(GlobalComment) write(Doc[channel],GlobalComment,strlen(GlobalComment)); if(ChannelComment[channel]) write(Doc[channel],ChannelComment[channel],strlen(ChannelComment[channel])); close(Bin[channel]); close(Doc[channel]); rename(tmpName(FileName(channel)), FileName(channel)); if(linkLatest()) MakeLink(channel); } return(0); }
/************************************************************************* Un-Loads a scheme *************************************************************************/ void SchemeManager::unloadScheme(const String& scheme_name) { SchemeRegistry::iterator pos = d_schemes.find(scheme_name); if (pos != d_schemes.end()) { String tmpName(scheme_name); delete pos->second; d_schemes.erase(pos); Logger::getSingleton().logEvent((utf8*)"Scheme '" + tmpName + "' has been unloaded."); } else { Logger::getSingleton().logEvent((utf8*)"Unable to unload non-existant scheme '" + scheme_name + "'.", Errors); } }
int FileMcIDAS::Open(int channel){ if (!Bin) { Bin = new fildes [Channels]; Doc = new fildes [Channels]; for ( int c = 0; c < (int)Channels; c++) { Bin[c] = 0; Doc[c] = 0; } } if ( ! Bin[channel]){ Bin[channel] = open(tmpName(FileName(channel)), O_RDWR | O_CREAT, S_IROTH| S_IRUSR |S_IWUSR |S_IRGRP ); Doc[channel] = open(FileName(channel,(char*)"info"), O_RDWR | O_CREAT , S_IROTH| S_IRUSR |S_IWUSR |S_IRGRP ); InitMcIDAS(imagerDoc,channel); write(Bin[channel],&mcidas,(64+640+128)*sizeof(int)); } return(0); }
int VirtualMachine::openFileInWorkingDirectory(std::FILE*& f, std::string& baseName_, const char *mode, bool createOnly_) { f = (std::FILE *) 0; try { std::string fullName; bool haveFileName = false; if (baseName_.length() > 0) { haveFileName = true; // convert file name to lower case, replace invalid characters with '_' std::string baseName(baseName_); stringToLowerCase(baseName); for (size_t i = 0; i < baseName.length(); i++) { const std::string& s = baseName; if (!((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= '0' && s[i] <= '9') || s[i] == '.' || s[i] == '+' || s[i] == '-' || s[i] == '_')) baseName[i] = '_'; } fullName = fileIOWorkingDirectory + baseName; } else { if (fileNameCallback) fileNameCallback(fileNameCallbackUserData, fullName); if (fullName.length() == 0) return -2; // error: invalid file name baseName_ = fullName; } // attempt to stat() file #ifndef WIN32 struct stat st; std::memset(&st, 0, sizeof(struct stat)); int err = stat(fullName.c_str(), &st); if (err != 0 && haveFileName) { // not found, try case insensitive file search std::string tmpName(fullName); tmpName[0] = tmpName.c_str()[0]; // unshare string DIR *dir_; dir_ = opendir(fileIOWorkingDirectory.c_str()); if (dir_) { do { struct dirent *ent_ = readdir(dir_); if (!ent_) break; bool foundMatch = true; size_t offs = fileIOWorkingDirectory.length(); const char *s1 = fullName.c_str() + offs; const char *s2 = &(ent_->d_name[0]); size_t i = 0; while (!(s1[i] == '\0' && s2[i] == '\0')) { if (s1[i] != s2[i]) { if (!(s2[i] >= 'A' && s2[i] <= 'Z' && s1[i] == (s2[i] + ('a' - 'A')))) { foundMatch = false; break; } } tmpName[offs + i] = s2[i]; i++; } if (foundMatch) { std::memset(&st, 0, sizeof(struct stat)); err = stat(tmpName.c_str(), &st); } } while (err != 0); closedir(dir_); } if (err == 0) fullName = tmpName; } #else struct _stat st; std::memset(&st, 0, sizeof(struct _stat)); int err = _stat(fullName.c_str(), &st); #endif if (err != 0) { if (mode == (char *) 0 || mode[0] != 'w') return -3; // error: cannot find file } else { #ifndef WIN32 if (!(S_ISREG(st.st_mode))) return -4; // error: not a regular file #else if (!(st.st_mode & _S_IFREG)) return -4; // error: not a regular file #endif if (createOnly_) return -6; // error: the file already exists } // FIXME: the file may possibly be created, changed, or removed between // calling stat() and fopen() f = std::fopen(fullName.c_str(), mode); if (!f) return -5; // error: cannot open file } catch (...) { if (f) { std::fclose(f); f = (std::FILE *) 0; } return -1; } return 0; }
bool GPA_CounterGeneratorDX12::GenerateInternalCounters(GPA_HardwareCounters* pHardwareCounters, GDT_HW_GENERATION generation) { pHardwareCounters->m_counters.clear(); GPA_HardwareCounterDescExt counter; #if defined(_DEBUG) && defined(AMDT_INTERNAL) // Debug builds will generate a file that lists the counter names in a format that can be // easily copy/pasted into the GPUPerfAPIUnitTests project FILE* pFile = nullptr; fopen_s(&pFile, "HardwareCounterNamesDX12.txt", "w"); #endif unsigned int globalCounterIndex = 0; // for each group, get the group name, number of counters, and max counters (and maybe validate them) for (unsigned int g = 0; g < pHardwareCounters->m_groupCount; g++) { GPA_HardwareCounterDesc* pGroupCounters = pHardwareCounters->m_ppCounterGroupArray[g]; GPA_CounterGroupDesc group = pHardwareCounters->m_pGroups[g]; // calculate per-block values outside the for loop UINT blockId = CalculateBlockIdDX12(generation, &group); // only add the number of counters that are supported; but no more than the number that we expect const gpa_uint64 numCountersInGroup = pHardwareCounters->m_pGroups[g].m_numCounters; for (int c = 0; c < numCountersInGroup; c++) { counter.m_groupIndex = g; counter.m_pHardwareCounter = &(pGroupCounters[c]); counter.m_groupIdDriver = blockId; #if defined(_DEBUG) && defined(AMDT_INTERNAL) if (nullptr != pFile) { fwrite(" \"", 1, 5, pFile); std::string tmpName(counter.m_pHardwareCounter->m_pName); size_t size = tmpName.size(); fwrite(counter.m_pHardwareCounter->m_pName, 1, size, pFile); fwrite("\",", 1, 2, pFile); #ifdef EXTRA_COUNTER_INFO // this can be useful for debugging counter definitions std::stringstream ss; ss << " " << counter.m_groupIndex << ", " << counter.m_groupIdDriver << ", " << counter.m_pHardwareCounter->m_counterIndexInGroup << ", " << counter.m_counterIdDriver; std::string tmpCounterInfo(ss.str()); size = tmpCounterInfo.size(); fwrite(tmpCounterInfo.c_str(), 1, size, pFile); #endif fwrite("\n", 1, 1, pFile); } #endif pHardwareCounters->m_counters.push_back(counter); ++globalCounterIndex; } } #if defined(_DEBUG) && defined(AMDT_INTERNAL) if (nullptr != pFile) { fclose(pFile); } #endif; pHardwareCounters->m_countersGenerated = true; return true; }
void drawLoop( TDirectory *target, TList *sourcelist, TCanvas *c1 ) { TString path( (char*)strstr( target->GetPath(), ":" ) ); path.Remove( 0, 2 ); TString sysString(path);sysString.Prepend(baseName->Data()); TFile *first_source = (TFile*)sourcelist->First(); first_source->cd( path ); TDirectory *current_sourcedir = gDirectory; //gain time, do not add the objects in the list in memory Bool_t status = TH1::AddDirectoryStatus(); TH1::AddDirectory(kFALSE); // loop over all keys in this directory TIter nextkey( current_sourcedir->GetListOfKeys() ); TKey *key, *oldkey=0; while ( (key = (TKey*)nextkey())) { //keep only the highest cycle number for each key if (oldkey && !strcmp(oldkey->GetName(),key->GetName())) continue; // read object from first source file first_source->cd( path ); TObject *obj = key->ReadObj(); if ( obj->IsA()->InheritsFrom( "TH1" ) && !obj->IsA()->InheritsFrom("TH2") ) { // descendant of TH1 -> merge it gLegend = new TLegend(.7,.15,.95,.4,""); gLegend->SetHeader(gDirectory->GetName()); Color_t color = 1; Style_t style = 22; TH1 *h1 = (TH1*)obj; h1->SetLineColor(color); h1->SetMarkerStyle(style); h1->SetMarkerColor(color); h1->Draw(); TString tmpName(first_source->GetName()); gLegend->AddEntry(h1,tmpName,"LP"); c1->Update(); // loop over all source files and add the content of the // correspondant histogram to the one pointed to by "h1" TFile *nextsource = (TFile*)sourcelist->After( first_source ); while ( nextsource ) { // make sure we are at the correct directory level by cd'ing to path nextsource->cd( path ); TKey *key2 = (TKey*)gDirectory->GetListOfKeys()->FindObject(h1->GetName()); if (key2) { TH1 *h2 = (TH1*)key2->ReadObj(); color++; style++; h2->SetLineColor(color); h2->SetMarkerStyle(style); h2->SetMarkerColor(color); h2->Draw("same"); TString tmpName(nextsource->GetName()); gLegend->AddEntry(h2,tmpName,"LP"); gLegend->Draw("same"); c1->Update(); //- delete h2; } nextsource = (TFile*)sourcelist->After( nextsource ); } } else if ( obj->IsA()->InheritsFrom( "TH2" ) ) { // descendant of TH2 -> merge it gLegend = new TLegend(.85,.15,1.0,.30,""); gLegend->SetHeader(gDirectory->GetName()); Color_t color = 1; Style_t style = 22; TH2 *h1 = (TH2*)obj; h1->SetLineColor(color); h1->SetMarkerStyle(style); h1->SetMarkerColor(color); h1->Draw(); TString tmpName(first_source->GetName()); gLegend->AddEntry(h1,tmpName,"LP"); c1->Update(); // loop over all source files and add the content of the // correspondant histogram to the one pointed to by "h1" TFile *nextsource = (TFile*)sourcelist->After( first_source ); while ( nextsource ) { // make sure we are at the correct directory level by cd'ing to path nextsource->cd( path ); TKey *key2 = (TKey*)gDirectory->GetListOfKeys()->FindObject(h1->GetName()); if (key2) { TH2 *h2 = (TH2*)key2->ReadObj(); color++; style++; h2->SetLineColor(color); h2->SetMarkerStyle(style); h2->SetMarkerColor(color); h2->Draw("same"); TString tmpName(nextsource->GetName()); gLegend->AddEntry(h2,tmpName,"LP"); gLegend->Draw("same"); c1->Update(); //- delete h2; } nextsource = (TFile*)sourcelist->After( nextsource ); } } else if ( obj->IsA()->InheritsFrom( "TGraph" ) ) { obj->IsA()->Print(); gLegend = new TLegend(.7,.15,.95,.4,""); gLegend->SetHeader(gDirectory->GetName()); Color_t color = 1; Style_t style = 22; TGraph *h1 =(TGraph*)obj; h1->SetLineColor(color); h1->SetMarkerStyle(style); h1->SetMarkerColor(color); h1->GetHistogram()->Draw(); h1->Draw(); TString tmpName(first_source->GetName()); gLegend->AddEntry(h1,tmpName,"LP"); c1->Update(); // loop over all source files and add the content of the // correspondant histogram to the one pointed to by "h1" TFile *nextsource = (TFile*)sourcelist->After( first_source ); while ( nextsource ) { // make sure we are at the correct directory level by cd'ing to path nextsource->cd( path ); TKey *key2 = (TKey*)gDirectory->GetListOfKeys()->FindObject(h1->GetName()); if (key2) { TGraph *h2 = (TGraph*)key2->ReadObj(); color++; style++; h2->SetLineColor(color); h2->SetMarkerStyle(style); h2->SetMarkerColor(color); h2->Draw("same"); TString tmpName(nextsource->GetName()); gLegend->AddEntry(h2,tmpName,"LP"); gLegend->Draw("same"); c1->Update(); //- delete h2; } nextsource = (TFile*)sourcelist->After( nextsource ); } } else if ( obj->IsA()->InheritsFrom( "TTree" ) ) { std::cout << "I don't draw trees" << std::endl; } else if ( obj->IsA()->InheritsFrom( "TDirectory" ) ) { // it's a subdirectory std::cout << "Found subdirectory " << obj->GetName() << std::endl; // create a new subdir of same name and title in the target file target->cd(); TDirectory *newdir = target->mkdir( obj->GetName(), obj->GetTitle() ); // create a new subdir of same name in the file system TString newSysString(sysString+"/"+obj->GetName()); if(makeGraphic) gSystem->mkdir(newSysString.Data(),kTRUE); // newdir is now the starting point of another round of merging // newdir still knows its depth within the target file via // GetPath(), so we can still figure out where we are in the recursion drawLoop( newdir, sourcelist, c1 ); } else { // object is of no type that we know or can handle std::cout << "Unknown object type, name: " << obj->GetName() << " title: " << obj->GetTitle() << std::endl; } // now write the merged TCanvas (which is "in" obj) to the target file // note that this will just store obj in the current directory level, // which is not persistent until the complete directory itself is stored // by "target->Write()" below if ( obj ) { target->cd(); if ( obj->IsA()->InheritsFrom( "TH1") || obj->IsA()->InheritsFrom("TGraph")) { // && !obj->IsA()->InheritsFrom("TH2") ) { TString newName(obj->GetName()); newName.ReplaceAll("(",1,"_",1); newName.ReplaceAll(")",1,"_",1); c1->SetName(newName); c1->Write( c1->GetName(),TObject::kOverwrite ); if(makeGraphic) { if (gROOT->IsBatch()) { c1->Print("temp.eps"); gSystem->Exec("pstopnm -ppm -xborder 0 -yborder 0 -portrait temp.eps"); char tempCommand[200]; sprintf(tempCommand,"ppmtogif temp.eps001.ppm > %s/%s.gif",sysString.Data(),c1->GetName()); gSystem->Exec(tempCommand); } else { c1->Print(sysString + "/" + TString(c1->GetName())+".gif"); } } } } //if(gLegend) delete gLegend; } // while ( ( TKey *key = (TKey*)nextkey() ) ) // save modifications to target file target->SaveSelf(kTRUE); TH1::AddDirectory(status); }
ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* /*options*/) const { std::string ext( osgDB::getLowerCaseFileExtension(fileName) ); if( !acceptsExtension(ext) ) return ReadResult::FILE_NOT_HANDLED; osg::notify(osg::INFO) << "ReaderWriterGLOBE( \"" << fileName << "\" )" << std::endl; // strip the ".globe" pseudo-loader extension std::string tmpName( osgDB::getNameLessExtension(fileName) ); // get the next "extension", which actually contains the globe radius parameter std::string params( osgDB::getFileExtension(tmpName) ); if( params.empty() ) { osg::notify(osg::WARN) << "Missing parameters for " EXTENSION_NAME " pseudo-loader" << std::endl; return ReadResult::FILE_NOT_HANDLED; } // strip the "params extension", which must leave an image subfilename. std::string subFileName( osgDB::getNameLessExtension(tmpName) ); if( subFileName.empty() || subFileName == tmpName ) { osg::notify(osg::WARN) << "Missing image subfilename for " EXTENSION_NAME " pseudo-loader" << std::endl; return ReadResult::FILE_NOT_HANDLED; } osg::notify(osg::INFO) << EXTENSION_NAME " params = \"" << params << "\"" << std::endl; int radius; int count( sscanf( params.c_str(), "%d", &radius ) ); if( count != 1 ) { osg::notify(osg::WARN) << "Bad parameters for " EXTENSION_NAME " pseudo-loader: \"" << params << "\"" << std::endl; return ReadResult::FILE_NOT_HANDLED; } // recursively load the image subfile. osg::Image *image( osgDB::readImageFile(subFileName) ); if( !image ) { // propagate the read failure upwards osg::notify(osg::WARN) << "Image file \"" << subFileName << "\" could not be loaded" << std::endl; return ReadResult::FILE_NOT_HANDLED; } // create an osg::Sphere for the globe geometry osg::Geode* geode( new osg::Geode() ); geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0,0,0), radius))); // apply the image as a texture to the globe osg::Texture2D* tex2d( new osg::Texture2D ); tex2d->setImage( image ); tex2d->setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT ); tex2d->setWrap( osg::Texture::WRAP_T, osg::Texture::REPEAT ); osg::StateSet* stateset( geode->getOrCreateStateSet() ); stateset->setTextureAttributeAndModes( 0, tex2d, osg::StateAttribute::ON ); return geode; }
static void _doReplicate(CActivityBase *activity, IPartDescriptor &partDesc, ICopyFileProgress *iProgress) { StringBuffer primaryName; getPartFilename(partDesc, 0, primaryName);; RemoteFilename rfn; IFileDescriptor &fileDesc = partDesc.queryOwner(); unsigned copies = partDesc.numCopies(); unsigned c=1; for (; c<copies; c++) { unsigned replicateCopy; unsigned clusterNum = partDesc.copyClusterNum(c, &replicateCopy); rfn.clear(); partDesc.getFilename(c, rfn); StringBuffer dstName; rfn.getPath(dstName); assertex(dstName.length()); if (replicateCopy>0 ) { try { queryThor().queryBackup().backup(dstName.str(), primaryName.str()); } catch (IException *e) { Owned<IThorException> re = MakeActivityWarning(activity, e, "Failed to create replicate file '%s'", dstName.str()); e->Release(); activity->fireException(re); } } else // another primary { ActPrintLog(activity, "Copying to primary %s", dstName.str()); StringBuffer tmpName(dstName.str()); tmpName.append(".tmp"); OwnedIFile tmpIFile = createIFile(tmpName.str()); OwnedIFile srcFile = createIFile(primaryName.str()); CFIPScope fipScope(tmpName.str()); try { try { ensureDirectoryForFile(dstName.str()); ::copyFile(tmpIFile, srcFile, 0x100000, iProgress); } catch (IException *e) { IThorException *re = MakeActivityException(activity, e, "Failed to copy to tmp file '%s' from source file '%s'", tmpIFile->queryFilename(), srcFile->queryFilename()); e->Release(); throw re; } try { OwnedIFile dstIFile = createIFile(dstName.str()); dstIFile->remove(); tmpIFile->rename(pathTail(dstName.str())); } catch (IException *e) { IThorException *re = ThorWrapException(e, "Failed to rename '%s' to '%s'", tmpName.str(), dstName.str()); e->Release(); throw re; } } catch (IException *) { try { tmpIFile->remove(); } catch (IException *e) { ActPrintLog(&activity->queryContainer(), e, NULL); e->Release(); } throw; } } } }
void CWidgetBackupRegistryXml::GetSubtreeAsStringL (RFs& aFileSession, xmlDocPtr aDoc, xmlNode* aNode, HBufC** aBuf, TInt& aLen) { xmlNode* node = aNode; switch (node->type) { case XML_ELEMENT_NODE: { const xmlChar* name = node->name; TPtrC8 tmpName(name); if (aBuf) { HBufC* tmpBuf = NULL; ToUnicodeL( KCharacterSetIdentifierUtf8, 2, tmpName, &tmpBuf, aFileSession ); CleanupStack::PushL(tmpBuf); (*aBuf)->Des().Append(_L("<")); (*aBuf)->Des().Append(*tmpBuf); (*aBuf)->Des().Append(_L(">")); if (node->children) { GetSubtreeAsStringL (aFileSession, aDoc, node->children, aBuf, aLen); } (*aBuf)->Des().Append(_L("</")); (*aBuf)->Des().Append(*tmpBuf); (*aBuf)->Des().Append(_L(">")); CleanupStack::PopAndDestroy(tmpBuf); } else { aLen += (5 + 2 * tmpName.Length()); if (node->children) { GetSubtreeAsStringL (aFileSession, aDoc, node->children, aBuf, aLen); } } break; } //case XML_ATTRIBUTE_NODE: case XML_TEXT_NODE: { xmlChar* content = node->content; TPtrC8 tmpContent(content); if (aBuf) { HBufC* tmpBuf = NULL; xmlChar* encodedContent = EncodeStringL(aDoc, content); CleanupStack::PushL( encodedContent ); TPtrC8 encodedContentPtr(encodedContent); ToUnicodeL( KCharacterSetIdentifierUtf8, 2, encodedContentPtr, &tmpBuf, aFileSession ); CleanupStack::PushL(tmpBuf); (*aBuf)->Des().Append(*tmpBuf); CleanupStack::PopAndDestroy(2); // encodedContent, tmpBuf } else { aLen += EncodedStringLength(tmpContent); } break; } case XML_CDATA_SECTION_NODE: { xmlChar* content = node->content; TPtrC8 tmpContent(content); if (aBuf) { HBufC* tmpBuf = NULL; ToUnicodeL( KCharacterSetIdentifierUtf8, 2, content, &tmpBuf, aFileSession); CleanupStack::PushL(tmpBuf); (*aBuf)->Des().Append(_L("<![CDATA[")); (*aBuf)->Des().Append(*tmpBuf); (*aBuf)->Des().Append(_L("]]>")); CleanupStack::PopAndDestroy(); // tmpBuf } else { aLen += (12 + tmpContent.Length()); } break; } //case XML_ENTITY_REF_NODE: //case XML_ENTITY_NODE: //case XML_PI_NODE: //case XML_COMMENT_NODE: //case XML_DOCUMENT_NODE: //case XML_DOCUMENT_TYPE_NODE: //case XML_DOCUMENT_FRAG_NODE: //case XML_NOTATION_NODE: //case XML_HTML_DOCUMENT_NODE: //case XML_DTD_NODE: //case XML_ELEMENT_DECL: //case XML_ATTRIBUTE_DECL: //case XML_ENTITY_DECL: //case XML_NAMESPACE_DECL: //case XML_XINCLUDE_START: //case XML_XINCLUDE_END: } if (node->next) { node = node->next; GetSubtreeAsStringL(aFileSession, aDoc, node, aBuf, aLen); } }
void CProfileOptions::AddOption(const char* name, const char* value, const char* cvar /*= NULL*/, const bool preview /*= false*/, const bool confirmation /*= false*/, const bool restart /*= false*/, const bool writeToConfig /*= false*/) { if(!name || !name[0]) return; if(!value) return; ScopedSwitchToGlobalHeap globalHeap; COption* pOption = NULL; CryFixedStringT<64> tmpName(name); CryFixedStringT<64> compareName("SysSpec"); if(tmpName.find(compareName.c_str())==0) { if(compareName.length() == tmpName.length()) { pOption = new CSysSpecAllOption(name, value, cvar); } else { pOption = new CSysSpecOption(name, value, cvar); } } else if(IsCVar(cvar)) { pOption = new CCVarOption(name, value, cvar); } else if(!strcmp(name, "Resolution")) { pOption = new CScreenResolutionOption(name, value); } else { pOption = new COption(name, value); } pOption->SetPreview(preview); pOption->SetConfirmation(confirmation); pOption->SetRequiresRestart(restart); pOption->SetWriteToConfig(writeToConfig); if(pOption) { if(IPlayerProfileManager* profileManager = g_pGame->GetIGameFramework()->GetIPlayerProfileManager()) { if(IPlayerProfile *profile = profileManager->GetCurrentProfile(profileManager->GetCurrentUser())) { pOption->SetPlayerProfile(profile); pOption->InitializeFromProfile(); } if(!m_bLoadingProfile) { m_allOptions.push_back(pOption); } else { CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "Adding \"%s\" option while loading values from profile, option might not be initialized properly. Consider adding to attributes.xml", name); } } } }