const char* FileEnumerator::CurrentPath() { if ((m_Flags & DIRENUM_CURRENT_CACHED) == 0) { m_Current = JoinPath(CurrentDir(), CurrentFileName()); m_Flags |= DIRENUM_CURRENT_CACHED; } return m_Current.c_str(); }
bool NonRecursiveFileEnumerator::MoveNext() { bool result = DoMoveNext(); // skip "." and ".." entries while (result && IsServicePath(CurrentFileName())) { result = DoMoveNext(); } return result; }
char *EiC_getClashedfname(char nspace,char *id) { symentry_t *sym; for(sym = EiC_HTAB[hashsmc(id,HSIZE)]; sym != NULL; sym = sym->next) if(sym->nspace == nspace && strcmp(id,sym->id) == 0) if((sym->sclass & c_private) && sym->fname != CurrentFileName()) { return sym->fname; } return NULL; }
symentry_t * EiC_lookup(char nspace, char *id) { symentry_t *sym; Pclash = 0; for(sym = EiC_HTAB[hashsmc(id,HSIZE)]; sym != NULL; sym = sym->next) if(sym->nspace == nspace && strcmp(id,sym->id) == 0) { if((sym->sclass & c_private) && sym->fname != CurrentFileName()) { Pclash = 1; continue; } else break; } return(sym); }
/*CUT lutInsert*/ symentry_t * EiC_insertLUT(char nspace,char *id,int type) { symentry_t *sym; auto int hashval; sym = (symentry_t *) xcalloc(1,sizeof(symentry_t)); if(sym == NULL) return(NULL); if( (sym->id = EiC_strsave(id)) == NULL) { xfree(sym); return(NULL); } sym->entry = _EnTrY_No++; hashval = hashsmc(sym->id,HSIZE); sym->next = EiC_HTAB[hashval]; EiC_HTAB[hashval] = sym; sym->nspace = nspace; sym->val.ival = -1; /* indicates unused */ sym->type = EiC_addtype(type,NULL); sym->fname = CurrentFileName(); return(sym); }
void OpenFile( const wxString& file ) { wxString command; wxString filename = file; wxFileName CurrentFileName( filename ); wxString ext, type; ext = CurrentFileName.GetExt(); wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext ); bool success = false; wxFileType::MessageParameters params( filename, type ); if( filetype ) success = filetype->GetOpenCommand( &command, params ); delete filetype; if( success && !command.IsEmpty() ) ProcessExecute( command ); }
bool CExperimentSet::compile(const CMathContainer * pMathContainer) { bool success = true; // First we need to sort the experiments so that we can make use of continued // file reading. sort(); CObjectInterface::ObjectSet DependentObjects; std::ifstream in; std::string CurrentFileName(""); size_t CurrentLineNumber = 1; std::vector< CExperiment * >::iterator it = mpExperiments->begin() + mNonExperiments; std::vector< CExperiment * >::iterator end = mpExperiments->end(); for (; it != end; ++it) { if (CurrentFileName != (*it)->getFileName()) { CurrentFileName = (*it)->getFileName(); CurrentLineNumber = 1; if (in.is_open()) { in.close(); in.clear(); } in.open(CLocaleString::fromUtf8(CurrentFileName).c_str(), std::ios::binary); if (in.fail()) { CCopasiMessage(CCopasiMessage::ERROR, MCFitting + 8, CurrentFileName.c_str()); return false; // File can not be opened. } } if (!(*it)->read(in, CurrentLineNumber)) { return false; } if (!(*it)->compile(pMathContainer)) { return false; } const std::map< const CObjectInterface *, size_t > & ExpDependentObjects = (*it)->getDependentObjectsMap(); std::map< const CObjectInterface *, size_t >::const_iterator itObject = ExpDependentObjects.begin(); std::map< const CObjectInterface *, size_t >::const_iterator endObject = ExpDependentObjects.end(); for (; itObject != endObject; ++itObject) { DependentObjects.insert(itObject->first); } } mDependentObjects.resize(DependentObjects.size()); const CObjectInterface ** ppInsert = mDependentObjects.array(); CObjectInterface::ObjectSet::const_iterator itObject = DependentObjects.begin(); CObjectInterface::ObjectSet::const_iterator endObject = DependentObjects.end(); for (; itObject != endObject; ++itObject, ++ppInsert) *ppInsert = *itObject; // Allocation and initialization of statistical information mDependentObjectiveValues.resize(mDependentObjects.size()); mDependentObjectiveValues = std::numeric_limits<C_FLOAT64>::quiet_NaN(); mDependentRMS.resize(mDependentObjects.size()); mDependentRMS = std::numeric_limits<C_FLOAT64>::quiet_NaN(); mDependentErrorMean.resize(mDependentObjects.size()); mDependentErrorMean = std::numeric_limits<C_FLOAT64>::quiet_NaN(); mDependentErrorMeanSD.resize(mDependentObjects.size()); mDependentErrorMeanSD = std::numeric_limits<C_FLOAT64>::quiet_NaN(); mDependentDataCount.resize(mDependentObjects.size()); mDependentDataCount = std::numeric_limits<size_t>::quiet_NaN(); return success; }
bool GetAssociatedDocument( wxFrame* aFrame, const wxString& aDocName, const wxPathList* aPaths) { wxString docname, fullfilename, file_ext; wxString msg; wxString command; bool success = false; // Is an internet url static const wxString url_header[3] = { wxT( "http:" ), wxT( "ftp:" ), wxT( "www." ) }; for( int ii = 0; ii < 3; ii++ ) { if( aDocName.First( url_header[ii] ) == 0 ) //. seems an internet url { wxLaunchDefaultBrowser( aDocName ); return true; } } docname = aDocName; #ifdef __WINDOWS__ docname.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP ); #else docname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); #endif /* Compute the full file name */ if( wxIsAbsolutePath( aDocName ) || aPaths == NULL) fullfilename = aDocName; /* If the file exists, this is a trivial case: return the filename * "as this". the name can be an absolute path, or a relative path * like ./filename or ../<filename> */ else if( wxFileName::FileExists( aDocName ) ) fullfilename = aDocName; else { fullfilename = aPaths->FindValidPath( aDocName ); } wxString mask( wxT( "*" ) ), extension; #ifdef __WINDOWS__ mask += wxT( ".*" ); extension = wxT( ".*" ); #endif if( wxIsWild( fullfilename ) ) { fullfilename = EDA_FileSelector( _( "Doc Files" ), wxPathOnly( fullfilename ), fullfilename, extension, mask, aFrame, wxFD_OPEN, true, wxPoint( -1, -1 ) ); if( fullfilename.IsEmpty() ) return false; } if( !wxFileExists( fullfilename ) ) { msg.Printf( _( "Doc File <%s> not found" ), GetChars( aDocName ) ); DisplayError( aFrame, msg ); return false; } wxFileName CurrentFileName( fullfilename ); file_ext = CurrentFileName.GetExt(); if( file_ext == wxT( "pdf" ) ) { success = OpenPDF( fullfilename ); return success; } /* Try to launch some browser (useful under linux) */ wxFileType* filetype; wxString type; filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext ); if( !filetype ) // 2nd attempt. { mimeDatabase = new wxMimeTypesManager; mimeDatabase->AddFallbacks( EDAfallbacks ); filetype = mimeDatabase->GetFileTypeFromExtension( file_ext ); delete mimeDatabase; mimeDatabase = NULL; } if( filetype ) { wxFileType::MessageParameters params( fullfilename, type ); success = filetype->GetOpenCommand( &command, params ); delete filetype; if( success ) success = ProcessExecute( command ); } if( !success ) { msg.Printf( _( "Unknown MIME type for doc file <%s>" ), GetChars( fullfilename ) ); DisplayError( aFrame, msg ); } return success; }