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); }
static void GenerateBabySteps(ZZ_pEX& h1, const ZZ_pEX& f, const ZZ_pEX& h, long k, long verbose) { double t; if (verbose) { cerr << "generating baby steps..."; t = GetTime(); } ZZ_pEXModulus F; build(F, f); ZZ_pEXArgument H; #if 0 double n2 = sqrt(double(F.n)); double n4 = sqrt(n2); double n34 = n2*n4; long sz = long(ceil(n34/sqrt(sqrt(2.0)))); #else long sz = 2*SqrRoot(F.n); #endif build(H, h, F, sz); h1 = h; long i; if (!use_files) { BabyStepFile.kill(); BabyStepFile.SetLength(k-1); } for (i = 1; i <= k-1; i++) { if (use_files) { ofstream s; OpenWrite(s, FileName(ZZ_pEX_stem, "baby", i)); s << h1 << "\n"; s.close(); } else BabyStepFile(i) = h1; CompMod(h1, h1, H, F); if (verbose) cerr << "+"; } if (verbose) cerr << (GetTime()-t) << "\n"; }
void Errors::Warning(const std::string &msg) { if (showWarnings) { warningCount++; std::cout << "Warning "; FileName(); std::cout << msg.c_str() << std::endl; } }
std::pair<bool, FileName> Application::ParseCommandLineMap() { if(argc == 2) { FileName f = wxString(argv[1]); if(f.GetExt() == "otbm" || f.GetExt() == "otgz") { return std::make_pair(true, f); } } return std::make_pair(false, FileName()); }
void postParseCommandLine() { /* load default scene if none specified */ if (scene->size() == 0 && sceneFilename.ext() == "") { FileName file = FileName::executableFolder() + FileName("models/cornell_box.ecs"); parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path()); } g_instancing_mode = instancing_mode; }
/* main function in embree namespace */ int main(int argc, char** argv) { /* create stream for parsing */ Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv)); /* parse command line */ parseCommandLine(stream, FileName()); return 0; }
void CHlpFileEntry::GetFullNameAndPath(TDes& aName) const { TChar driveLetter = '?'; RFs::DriveToChar(Drive(), driveLetter); aName.Zero(); aName.Append(driveLetter); aName.Append(':'); aName.Append(KHlpFileSearchPath); aName.Append(FileName()); }
void Errors::Error(const std::string &msg) { std::cout << "Error "; FileName(); std::cout << msg.c_str() << std::endl; if (errorCount++ > maxErrors) { Utils::fatal("Too Many Errors"); } }
bool LyXVC::registrer() { FileName const filename = owner_->fileName(); // there must be a file to save if (!filename.isReadableFile()) { Alert::error(_("Document not saved"), _("You must save the document " "before it can be registered.")); return false; } // it is very likely here that the vcs is not created yet... if (!vcs) { //check in the root directory of the document FileName const cvs_entries(onlyPath(filename.absFileName()) + "/CVS/Entries"); FileName const svn_entries(onlyPath(filename.absFileName()) + "/.svn/entries"); FileName const git_index(onlyPath(filename.absFileName()) + "/.git/index"); if (git_index.isReadableFile()) { LYXERR(Debug::LYXVC, "LyXVC: registering " << to_utf8(filename.displayName()) << " with GIT"); vcs.reset(new GIT(git_index, owner_)); } else if (svn_entries.isReadableFile()) { LYXERR(Debug::LYXVC, "LyXVC: registering " << to_utf8(filename.displayName()) << " with SVN"); vcs.reset(new SVN(svn_entries, owner_)); } else if (cvs_entries.isReadableFile()) { LYXERR(Debug::LYXVC, "LyXVC: registering " << to_utf8(filename.displayName()) << " with CVS"); vcs.reset(new CVS(cvs_entries, owner_)); } else { LYXERR(Debug::LYXVC, "LyXVC: registering " << to_utf8(filename.displayName()) << " with RCS"); vcs.reset(new RCS(FileName(), owner_)); } } LYXERR(Debug::LYXVC, "LyXVC: registrer"); docstring response; bool ok = Alert::askForText(response, _("LyX VC: Initial description"), _("(no initial description)")); if (!ok) { LYXERR(Debug::LYXVC, "LyXVC: user cancelled"); vcs.reset(0); return false; } if (response.empty()) response = _("(no initial description)"); vcs->registrer(to_utf8(response)); return true; }
//通过匿名管道连接引擎引擎 bool CEngine::LinkEngineWithUnnamed() { status = 0;//引擎连接未就绪 SECURITY_ATTRIBUTES sa; sa.nLength=sizeof(SECURITY_ATTRIBUTES); sa.lpSecurityDescriptor=NULL;//Default security attributes sa.bInheritHandle= TRUE;//handle can be inherited if(!CreatePipe(&pde.engine_read,&pde.platform_write,&sa,BUFSIZE) ||!CreatePipe(&pde.platform_read,&pde.engine_write,&sa,BUFSIZE))//创建两个平台与引擎之间互相通信的匿名管道 { ErrorBox("CreatePipe failed"); return false; } char Filter[]="(exe files)|*.exe|(all files)|*.*||";//文件滤镜 CFileDialog FileName(true,NULL,NULL,Filter,NULL,gameSet.EngineInitDir);//定义文件对话框类实例 if(FileName.DoModal()==IDOK) { path=FileName.GetFilePath(); LPCTSTR folder=FileName.GetFolderPath(path); char EngineDir[MAX_PATH]={0}; strcpy(EngineDir,folder); STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si,sizeof(si)); si.cb=sizeof(si); si.dwFlags=STARTF_USESHOWWINDOW |STARTF_USESTDHANDLES; si.wShowWindow=SW_HIDE; si.hStdInput=pde.engine_read; si.hStdOutput=pde.engine_write; si.hStdError=pde.engine_write; if(!CreateProcess(path,"",NULL,NULL,true,0,NULL,EngineDir,&si,&pi))//打开引擎进程 { ErrorBox("CreateProcess failed"); status = -1; return false; } CloseHandle(pde.engine_read); CloseHandle(pde.engine_write); WaitForInputIdle(pi.hProcess,INFINITE); pde.hEProcess = pi.hProcess; CloseHandle(pi.hThread); SetCurrentDirectory(gameSet.CurDir);//恢复当前主应用程序的进程 CreateEngineInfoBoard(); } else { status = -1; return false; } return true; }
string FileId(SourceLocation const& l, SourceManager const& sm) { string fn = FileName(l, sm); for(size_t i = 0; i < fn.length(); ++i) switch(fn[i]) { case '/': case '\\': case '>': case '.': fn[i] = '_'; } return fn; }
/** @brief Load all Application settings in one shot from the XML file. * @remarks CoInitialize() or CoInitializeEx() must have been called before using this method. * @param _sFileName the full path name of an existing file */ bool MenuCommandSetCfg::_LoadFile(const std::string& _sFileName) { const _bstr_t XMLDOM_OBJECT= _T("Microsoft.XMLDOM"); const _bstr_t NODE_DART(_T("uicfg")); const _bstr_t NODE_COMMANDS(_T("commands")); const _bstr_t NODE_VERSION(_T("version")); const _bstr_t NODE_COMMANDLIST(_T("commandlist")); const _bstr_t NODE_MENULIST(_T("menulist")); bool bResult= false; try { MSXML::IXMLDOMDocumentPtr XMLDom; HRESULT hResult = XMLDom.CreateInstance((LPCSTR)XMLDOM_OBJECT); if(S_OK==hResult) { _ClearLists(); _bstr_t FileName(_sFileName.c_str()); if(XMLDom->load(FileName)) { MSXML::IXMLDOMNodePtr Root= XMLDom->selectSingleNode(NODE_DART); MSXML::IXMLDOMNodePtr XMLNode; MSXML::IXMLDOMNodePtr XMLNode2; if( Root != NULL ) { //load the file version XMLNode = Root->selectSingleNode(NODE_VERSION); _LoadFileVersion(XMLNode); //load the list of menu items XMLNode = Root->selectSingleNode(NODE_COMMANDS); if(XMLNode){ XMLNode2= XMLNode->selectSingleNode(NODE_COMMANDLIST); _LoadMenuItemList(XMLNode2); XMLNode2= XMLNode->selectSingleNode(NODE_MENULIST); _LoadMenuList(XMLNode2); } bResult= true; } } } else{ TRACE(_T("Failed to load XMLDom (%x)\n"), hResult); } } catch(...){ TRACE(_T("Exception while loading config file\n")); } return bResult; }
void SPics::SavePixThread( QString dir ) { QString fullpath = dir + FileName(); QFile f( fullpath ); if ( f.open( QIODevice::WriteOnly ) ) { f.write ( qUncompress( data ) ); f.close(); } }
/** * Set file information * * @v This File handle * @v Type Type of information * @v Len Buffer size * @v Data Buffer * @ret Status EFI status code */ static EFI_STATUS EFIAPI FileSetInfo(EFI_FILE_HANDLE This, EFI_GUID *Type, UINTN Len, VOID *Data) { EFI_GRUB_FILE *File = _CR(This, EFI_GRUB_FILE, EfiFile); CHAR16 GuidString[36]; GuidToString(GuidString, Type); PrintError(L"Cannot set information of type %s for file '%s'\n", GuidString, FileName(File)); return EFI_WRITE_PROTECTED; }
CObexBufObject* CBtListenBase::PutRequestIndication(void) { if(iCurrObject) DeleteObject(); TRAPD(err,iCurrObject=CObexBufObject::NewL(NULL)); if(err==KErrNone) { TRAPD(err,iCurrObject->SetDataBufL(FileName())); if(err!=KErrNone) DeleteObject(); } return iCurrObject; }
static void DoOneLib( char *lib ) /*******************************/ // process a single library { DoOptions( lib ); /* If anything is left, add it to the list of object files. */ if( *lib != '\0' ) { AddCommand( FileName( lib, LIBRARY_SLOT, false ), LIBRARY_SLOT, false ); } }
static void GetNextInput( char *buf, size_t len, prompt_slot slot ) /*****************************************************************/ { if( !is_term ) { GetLine( buf, len, slot ); DoOptions( buf ); if( *buf != '\0' ) { AddCommand( FileName( buf, slot, false ), slot, false ); } } }
void writeOneBlockXmlSpec( MultiBlock2D& multiBlock, FileName fName, plint dataSize, IndexOrdering::OrderingT ordering ) { fName.defaultExt("plb"); MultiBlockManagement2D const& management = multiBlock.getMultiBlockManagement(); std::vector<std::string> typeInfo = multiBlock.getTypeInfo(); std::string blockName = multiBlock.getBlockName(); PLB_ASSERT( !typeInfo.empty() ); XMLwriter xml; XMLwriter& xmlMultiBlock = xml["Block2D"]; xmlMultiBlock["General"]["Family"].setString(blockName); xmlMultiBlock["General"]["Datatype"].setString(typeInfo[0]); if (typeInfo.size()>1) { xmlMultiBlock["General"]["Descriptor"].setString(typeInfo[1]); } xmlMultiBlock["General"]["cellDim"].set(multiBlock.getCellDim()); bool dynamicContent = false; xmlMultiBlock["General"]["dynamicContent"].set(dynamicContent); Array<plint,4> boundingBox = multiBlock.getBoundingBox().to_plbArray(); xmlMultiBlock["Structure"]["BoundingBox"].set<plint,4>(boundingBox); xmlMultiBlock["Structure"]["EnvelopeWidth"].set(management.getEnvelopeWidth()); xmlMultiBlock["Structure"]["NumComponents"].set(1); xmlMultiBlock["Data"]["File"].setString(FileName(fName).setExt("dat")); if (ordering == IndexOrdering::forward) { xmlMultiBlock["Data"]["IndexOrdering"].setString("zIsFastest"); } else { xmlMultiBlock["Data"]["IndexOrdering"].setString("xIsFastest"); } XMLwriter& xmlBulks = xmlMultiBlock["Data"]["Component"]; xmlBulks.set<plint,4>(multiBlock.getBoundingBox().to_plbArray()); xmlMultiBlock["Data"]["Offsets"].set(dataSize); xml.print(FileName(fName).defaultPath(global::directories().getOutputDir())); }
void CRecognitionResultHashMapEntry::UpdateL(TTime aLastModified, const TDataRecognitionResult& aResult) { // since other objects might have a pointer to the CRecognitionResult object // and rely on the value not changing we need to create a new object to take // its place. CRecognitionResult* result = CRecognitionResult::NewL(FileName(), aResult); iResult->Close(); iResult = result; iLastModified = aLastModified; }
/** * Fills the list box with the cube name list * * @internal * @history 2009-01-26 Jeannie Walldren - Original version */ void QnetPointCubeNameFilter::createCubeList() { // Clear the old list and update with the entire list p_listBox->setCurrentRow(-1); p_listBox->clear(); SerialNumberList *snList = serialNumberList(); for (int i = 0; i < snList->Size(); i++) { FileName filename = FileName(snList->FileName(i)); QString tempFileName = filename.name(); p_listBox->insertItem(i, tempFileName); } }
static void FetchGiantStep(ZZ_pX& g, long gs, const ZZ_pXModulus& F) { if (use_files) { ifstream s; OpenRead(s, FileName(ZZ_pX_stem, "giant", gs)); s >> g; s.close(); } else
/** * This method removes a cube from memory, if it exists. If the cube is not * loaded into memory, nothing happens. This will cause any pointers to this * cube, obtained via OpenCube, to be invalid. * * @param cubeFileName The filename of the cube to remove from memory */ void CubeManager::CleanCubes(const QString &cubeFileName) { QString fileName(FileName(cubeFileName).expanded()); QMap<QString, Cube *>::iterator searchResult = p_cubes.find(fileName); if(searchResult == p_cubes.end()) { return; } (*searchResult)->close(); delete *searchResult; p_cubes.erase(searchResult); }
// Shows the file selection dialog and makes the choosen file path relative. virtual bool OnButtonClick(wxPropertyGrid* propGrid, wxString& value) { wxString InitialDir =MapDoc->GetGameConfig()->ModDir+SubDir; wxString FileNameStr=wxFileSelector("Please select a file", InitialDir, "", "", Filter, wxFD_OPEN | wxFD_FILE_MUST_EXIST); if (FileNameStr=="") return false; wxFileName FileName(FileNameStr); FileName.MakeRelativeTo(MapDoc->GetGameConfig()->ModDir); value=FileName.GetFullPath(wxPATH_UNIX); return true; }
/** The function is used by the SQL server. It prints out a "SQL panic" message to the console and panic the client. It gives a usefull information about the found error together with the source file name and line number where it occured. Note: this function will output information regarding the panic only if _SQL_PANIC_TRACE_ENABLED macro is defined @param aFile Source file name @param aLine Source line number @param aMessage The client message, which processing caused the panic. @param aPanicCode Error code @leave KSqlLeavePanic @return KErrNone; @internalComponent */ TInt TSqlUtil::PanicClientL(const TText* aFile, TInt aLine, const RMessage2& aMessage, TInt aPanicCode, TUint aHandle) { #if defined OST_TRACE_COMPILER_IN_USE && defined _SQL_PANIC_TRACE_ENABLED TPtrC fname(FileName(aFile)); OstTraceExt5(TRACE_FATAL, TSQLUTIL_PANICCLIENTL, "Panic;%X;%S;%d;%S;%d", aHandle, __SQLPRNSTR(fname), aLine, __SQLPRNSTR(KPanicCategory), aPanicCode); #else UNUSED_ARG(aFile); UNUSED_ARG(aLine); UNUSED_ARG(aHandle); #endif return ::SqlPanicClientL(aMessage, static_cast <TSqlPanic> (aPanicCode)); }
/* Detect if the program name is a special alias that infers a command type. */ static Command ParseAlias(const char* name) { /* TODO: cast name to lower case? */ const char* unbrotli = "unbrotli"; size_t unbrotli_len = strlen(unbrotli); name = FileName(name); /* Partial comparison. On Windows there could be ".exe" suffix. */ if (strncmp(name, unbrotli, unbrotli_len) == 0) { char terminator = name[unbrotli_len]; if (terminator == 0 || terminator == '.') return COMMAND_DECOMPRESS; } return COMMAND_COMPRESS; }
/** The function prints out a "SQL leave" message to the console and leaves with aError error code. It gives a usefull information about the found error together with the source file name and line number where it occured. Note: this function will output information regarding the panic only if _SQL_LEAVE_TRACE_ENABLED macro is defined @param aFile Source file name @param aLine Source line number @param aError Error code @param aHandle Numeric value, uniquely identfying the leaving location (the "this" pointer for example) @internalComponent */ void TSqlUtil::Leave(const TText* aFile, TInt aLine, TInt aError, TUint aHandle) { #if defined OST_TRACE_COMPILER_IN_USE && defined _SQL_LEAVE_TRACE_ENABLED TPtrC fname(FileName(aFile)); OstTraceExt4(TRACE_ERROR, TSQLUTIL_LEAVE, "Leave;0x%X;%S;%d;Error=%d", aHandle, __SQLPRNSTR(fname), aLine, aError); #else UNUSED_ARG(aFile); UNUSED_ARG(aLine); UNUSED_ARG(aHandle); #endif User::Leave(aError); }
//--------------------------------------------------------- bool CWKSP_Project::_Save_Map(CSG_MetaData &Entry, const wxString &ProjectDir, CWKSP_Map *pMap) { if( !pMap ) { return( false ); } CSG_MetaData *pEntry = Entry.Add_Child("MAP"); pEntry->Add_Child("XMIN", pMap->Get_Extent().Get_XMin()); pEntry->Add_Child("XMAX", pMap->Get_Extent().Get_XMax()); pEntry->Add_Child("YMIN", pMap->Get_Extent().Get_YMin()); pEntry->Add_Child("YMAX", pMap->Get_Extent().Get_YMax()); pMap->Get_Parameters()->Serialize(*pEntry->Add_Child("PARAMETERS"), true); pEntry = pEntry->Add_Child("LAYERS"); for(int i=pMap->Get_Count()-1; i>=0; i--) { if( pMap->Get_Item(i)->Get_Type() == WKSP_ITEM_Map_Layer ) { CSG_Data_Object *pObject = ((CWKSP_Map_Layer *)pMap->Get_Item(i))->Get_Layer()->Get_Object(); if( pObject && pObject->Get_File_Name(false) && *pObject->Get_File_Name(false) ) { wxString FileName(pObject->Get_File_Name(false)); if( FileName.Find("PGSQL") == 0 ) { pEntry->Add_Child("FILE", &FileName); } else if( wxFileExists(FileName) ) { pEntry->Add_Child("FILE", SG_File_Get_Path_Relative(&ProjectDir, &FileName)); } } } else if( pMap->Get_Item(i)->Get_Type() == WKSP_ITEM_Map_Graticule ) { ((CWKSP_Map_Graticule *)pMap->Get_Item(i))->Save(*pEntry); } else if( pMap->Get_Item(i)->Get_Type() == WKSP_ITEM_Map_BaseMap ) { ((CWKSP_Map_BaseMap *)pMap->Get_Item(i))->Save(*pEntry); } } return( true ); }
/** * Get file position * * @v This File handle * @ret Position New file position * @ret Status EFI status code */ static EFI_STATUS EFIAPI FileGetPosition(EFI_FILE_HANDLE This, UINT64 *Position) { EFI_GRUB_FILE *File = _CR(This, EFI_GRUB_FILE, EfiFile); PrintInfo(L"GetPosition(%llx|'%s', %lld)\n", This, FileName(File)); if (File->IsDir) *Position = File->DirIndex; else *Position = GrubGetFileOffset(File); return EFI_SUCCESS; }
/** * Close and delete file * * @v This File handle * @ret Status EFI status code */ static EFI_STATUS EFIAPI FileDelete(EFI_FILE_HANDLE This) { EFI_GRUB_FILE *File = _CR(This, EFI_GRUB_FILE, EfiFile); PrintError(L"Cannot delete '%s'\n", FileName(File)); /* Close file */ FileClose(This); /* Warn of failure to delete */ return EFI_WARN_DELETE_FAILURE; }
/** The function prints out a "SQL panic" message to the console and panics the thread where it is called from. It gives a useful information about the found error together with the source file name and line number where it occurred. Note: this function will output information regarding the panic only if _SQL_PANIC_TRACE_ENABLED macro is defined @param aFile Source file name @param aLine Source line number @param aPanicCode Panic code @param aHandle Numeric value, uniquely identfying the leaving location (the "this" pointer for example) @return KErrNone @internalComponent */ TInt TSqlUtil::Panic(const TText* aFile, TInt aLine, TInt aPanicCode, TUint aHandle) { #if defined OST_TRACE_COMPILER_IN_USE && defined _SQL_PANIC_TRACE_ENABLED TPtrC fname(FileName(aFile)); OstTraceExt5(TRACE_FATAL, TSQLUTIL_PANIC, "Panic;0x%X;%S;%d;%S;%d", aHandle, __SQLPRNSTR(fname), aLine, __SQLPRNSTR(KPanicCategory), aPanicCode); #else UNUSED_ARG(aFile); UNUSED_ARG(aLine); UNUSED_ARG(aHandle); #endif ::SqlPanic(static_cast <TSqlPanic> (aPanicCode)); return KErrNone; }