这篇教程C++ FileClose函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中FileClose函数的典型用法代码示例。如果您正苦于以下问题:C++ FileClose函数的具体用法?C++ FileClose怎么用?C++ FileClose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了FileClose函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: LibError_SetExtErrorMessageLibFileIoClass::~LibFileIoClass(void){ LibError_SetExtErrorMessage(""); FileClose();}
开发者ID:flake123p,项目名称:ProjectH,代码行数:5,
示例2: WriteSoundArrayBOOLEAN WriteSoundArray(){ HWFILE hFile; DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("WriteSoundArray")); //Debug code; make sure that what we got from the file is the same as what's there // Open a new file hFile = FileOpen( "TABLEDATA//Sounds out.xml", FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE ); if ( !hFile ) return( FALSE ); UINT32 cnt; FilePrintf(hFile,"<SOUNDLIST>/r/n"); for(cnt = 0;cnt < NUM_SAMPLES;cnt++) { FilePrintf(hFile,"/t<SOUND>"); STR8 szRemainder = szSoundEffects[cnt]; //the remaining string to be output (for making valid XML) while(szRemainder[0] != '/0') { UINT32 uiCharLoc = strcspn(szRemainder,"&<>/'/"/0"); char invChar = szRemainder[uiCharLoc]; if(uiCharLoc) { szRemainder[uiCharLoc] = '/0'; FilePrintf(hFile,"%s",szRemainder); szRemainder[uiCharLoc] = invChar; } szRemainder += uiCharLoc; switch(invChar) { case '&': FilePrintf(hFile,"&"); szRemainder++; break; case '<': FilePrintf(hFile,"<"); szRemainder++; break; case '>': FilePrintf(hFile,">"); szRemainder++; break; case '/'': FilePrintf(hFile,"'"); szRemainder++; break; case '/"': FilePrintf(hFile,"""); szRemainder++; break; } } FilePrintf(hFile,"</SOUND>/r/n"); } FilePrintf(hFile,"</SOUNDLIST>/r/n"); FileClose( hFile ); return( TRUE );}
开发者ID:RadekSimkanic,项目名称:JA2-1.13,代码行数:62,
示例3: FileClosevoid CEtsEodManagerDoc::DeleteContents(){ FileClose(); CDocument::DeleteContents();}
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:5,
示例4: Main//.........这里部分代码省略......... is_custom = (Boolean)(myargs[2].intvalue); if (myargs[3].intvalue) /* show progress */ { pmon = MonitorStrNew("CdScan", 40); } outputfile = myargs[4].strvalue; /* output file name */ if (pmon != NULL) MonitorStrValue(pmon, "Reading Parse Trees"); if (! SeqEntryLoad() || ! SubmitAsnLoad()) /* read ASN.1 parse trees */ { Message(MSG_ERROR, "Can't open parse trees"); goto ret; } if (! PrintTemplateSetLoad ("asn2ff.prt")) { Message(MSG_ERROR, "Can't load print templates"); goto ret; } if (pmon != NULL) MonitorStrValue(pmon, "Initializing Entrez"); if (! EntrezInit ("cdscan", FALSE, &is_network)) /* init Entrez */ { Message(MSG_ERROR, "Can't initialize Entrez"); goto ret; } did_init = TRUE; if (is_network) { Message (MSG_ERROR, "Network service does not allow scanning"); goto ret; } if (pmon != NULL) MonitorStrValue(pmon, "Building File List"); eip = EntrezGetInfo (); /* set up the file lists */ if ((eip == NULL) || (eip->div_info == NULL)) { Message(MSG_ERROR, "Can't find Entrez file info"); goto ret; } flp = FileListNew (NULL, INT2_MIN, NULL, NULL); if (flp == NULL) { Message(MSG_ERROR, "Can't allocate file list"); goto ret; } div_info = eip->div_info; for (i = 0; i < eip->div_count; i++) { StringNCpy (div, div_info [i].tag, sizeof (div) - 1); if (! is_na) { CdEnumFiles (CdDir_rec, TYP_AA, div, EnumerateFiles, &flp); } else { CdEnumFiles (CdDir_rec, TYP_NT, div, EnumerateFiles, &flp); } } fp = FileOpen (outputfile, "w"); /* test that we can open output file */ if (fp == NULL) { Message(MSG_ERROR, "Can't open [%s]", outputfile); goto ret; } FileClose (fp); /* will be reopened for each input file */ ProcessFileList (flp, outputfile); /* process the file list */ret: /* clean up */ if (pmon != NULL) /* close the progress monitor */ MonitorFree(pmon); if (did_init) EntrezFini(); /* close entrez */ while (flp != NULL) /* free file list */ { next = flp->next; MemFree (flp->fdir); MemFree (flp->fname); MemFree (flp); flp = next; } return 0;}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:101,
示例5: CfgSaveExW3bool CfgSaveExW3(CFG_RW *rw, FOLDER *f, wchar_t *name, UINT *written_size, bool write_binary){ wchar_t tmp[MAX_SIZE]; bool text = !write_binary; UCHAR hash[SHA1_SIZE]; BUF *b; IO *o; bool ret = true; UINT dummy_int = 0; // Validate arguments if (name == NULL || f == NULL) { return false; } if (written_size == NULL) { written_size = &dummy_int; } // Convert to buffer b = CfgFolderToBuf(f, text); if (b == NULL) { return false; } // Hash the contents Hash(hash, b->Buf, b->Size, true); // Compare the contents to be written with the content which was written last if (rw != NULL) { if (Cmp(hash, rw->LashHash, SHA1_SIZE) == 0) { // Contents are not changed ret = false; } else { Copy(rw->LashHash, hash, SHA1_SIZE); } } if (ret || OS_IS_UNIX(GetOsInfo()->OsType)) { // Generate a temporary file name UniFormat(tmp, sizeof(tmp), L"%s.log", name); // Copy the file that currently exist to a temporary file FileCopyW(name, tmp); // Save the new file o = FileCreateW(name); if (o != NULL) { if (FileWrite(o, b->Buf, b->Size) == false) { // File saving failure FileClose(o); FileDeleteW(name); FileRenameW(tmp, name); if (rw != NULL) { Zero(rw->LashHash, sizeof(rw->LashHash)); } } else { // Successful saving file FileClose(o); // Delete the temporary file FileDeleteW(tmp); } } else { // File saving failure FileRenameW(tmp, name); if (rw != NULL) { Zero(rw->LashHash, sizeof(rw->LashHash)); } } } *written_size = b->Size; // Release memory FreeBuf(b); return ret;}
开发者ID:BIGbozi,项目名称:SoftEtherVPN,代码行数:92,
示例6: ReadInBurstSoundArrayBOOLEAN ReadInBurstSoundArray(STR fileName){ HWFILE hFile; UINT32 uiBytesRead; UINT32 uiFSize; CHAR8 * lpcBuffer; XML_Parser parser = XML_ParserCreate(NULL); burstSoundParseData pData; DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("Loading %s",SOUNDSFILENAME ) ); // Open sounds file hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE ); if ( !hFile ) return( FALSE ); uiFSize = FileGetSize(hFile); lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1); //Read in block if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) ) { MemFree(lpcBuffer); return( FALSE ); } lpcBuffer[uiFSize] = 0; //add a null terminator FileClose( hFile ); XML_SetElementHandler(parser, burstSoundStartElementHandle, burstSoundEndElementHandle); XML_SetCharacterDataHandler(parser, burstSoundCharacterDataHandle); memset(&pData,0,sizeof(pData)); pData.maxArraySize = MAX_SAMPLES; pData.curIndex = -1; XML_SetUserData(parser, &pData); if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE)) { CHAR8 errorBuf[511]; sprintf(errorBuf, "XML Parser Error in %s.xml: %s at line %d", SOUNDSFILENAME, XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser)); LiveMessage(errorBuf); MemFree(lpcBuffer); return FALSE; } MemFree(lpcBuffer); XML_ParserFree(parser); return( TRUE );}
开发者ID:RadekSimkanic,项目名称:JA2-1.13,代码行数:61,
示例7: loadStringsint loadStrings(){ const size_t tokenNum = 1 + STR_NUM * 2; jsmntok_t t[tokenNum]; char buf[8192]; wchar_t path[_MAX_LFN]; jsmn_parser p; unsigned int i, j, k; const char *s; int l, r, len; File fd; swprintf(path, _MAX_LFN, L"%ls/%s", langPath, fontIsLoaded ? cfgs[CFG_LANG].val.s : "en.json"); if (!FileOpen(&fd, path, 0)) return 1; len = FileGetSize(&fd); if (len > sizeof(buf)) return 1; FileRead(&fd, buf, len, 0); FileClose(&fd); jsmn_init(&p); r = jsmn_parse(&p, buf, len, t, tokenNum); if (r < 0) return r; for (i = 1; i < r; i++) { for (j = 0; j < STR_NUM; j++) { s = buf + t[i].start; len = t[i].end - t[i].start; if (!memcmp(s, keys[j], len) && !keys[j][len]) { i++; len = t[i].end - t[i].start; s = buf + t[i].start; for (k = 0; k + 1 < STR_MAX_LEN && len > 0; k++) { if (s[0] == '//' && s[1] == 'n') { strings[j][k] = '/n'; l = 2; } else { l = mbtowc(strings[j] + k, s, len); if (l < 0) break; } len -= l; s += l; } strings[j][k] = 0; mbtowc(NULL, NULL, 0); break; } } } return 0;}
开发者ID:mazkt-rake,项目名称:rxTools,代码行数:61,
示例8: TPASmartBioseqFetchFuncstatic Int2 LIBCALLBACK TPASmartBioseqFetchFunc (Pointer data){ BioseqPtr bsp; Char cmmd [256]; Pointer dataptr; Uint2 datatype; Uint2 entityID; FILE* fp; OMProcControlPtr ompcp; ObjMgrProcPtr ompp; Char path [PATH_MAX]; Char err_path [PATH_MAX]; SeqEntryPtr sep = NULL; SeqIdPtr sip; TextSeqIdPtr tsip; ompcp = (OMProcControlPtr) data; if (ompcp == NULL) return OM_MSG_RET_ERROR; ompp = ompcp->proc; if (ompp == NULL) return OM_MSG_RET_ERROR; sip = (SeqIdPtr) ompcp->input_data; if (sip == NULL) return OM_MSG_RET_ERROR; if (sip->choice != SEQID_TPG) return OM_MSG_RET_ERROR; tsip = (TextSeqIdPtr) sip->data.ptrvalue; if (tsip == NULL || StringHasNoText (tsip->accession)) return OM_MSG_RET_ERROR; if (tpasmartfetchcmd == NULL) { if (GetAppParam ("SEQUIN", "TPASMART", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) { tpasmartfetchcmd = StringSaveNoNull (cmmd); } } if (tpasmartfetchcmd == NULL) return OM_MSG_RET_ERROR; TmpNam (path);#ifdef OS_UNIX sprintf (err_path, "%s.err", path); sprintf (cmmd, "csh %s %s > %s 2>%s", tpasmartfetchcmd, tsip->accession, path, err_path); system (cmmd);#endif#ifdef OS_MSWIN sprintf (cmmd, "%s %s -o %s", tpasmartfetchcmd, tsip->accession, path); system (cmmd);#endif fp = FileOpen (path, "r"); if (fp == NULL) { FileRemove (path);#ifdef OS_UNIX FileRemove (err_path);#endif return OM_MSG_RET_ERROR; } dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, &entityID, FALSE, FALSE, TRUE, FALSE); FileClose (fp); FileRemove (path);#ifdef OS_UNIX FileRemove (err_path);#endif if (dataptr == NULL) return OM_MSG_RET_OK; sep = GetTopSeqEntryForEntityID (entityID); if (sep == NULL) return OM_MSG_RET_ERROR; bsp = BioseqFindInSeqEntry (sip, sep); ompcp->output_data = (Pointer) bsp; ompcp->output_entityID = ObjMgrGetEntityIDForChoice (sep); return OM_MSG_RET_DONE;}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:71,
示例9: DosInitializestatic VOID WINAPI DosInitialize(LPWORD Stack){ /* Get the DOS BIOS file name (NULL-terminated) */ // FIXME: Isn't it possible to use some DS:SI instead?? LPCSTR DosBiosFileName = (LPCSTR)SEG_OFF_TO_PTR(getCS(), getIP()); setIP(getIP() + strlen(DosBiosFileName) + 1); // Skip it DPRINT("DosInitialize('%s')/n", DosBiosFileName); /* * We succeeded, deregister the DOS Loading BOP * so that no app will be able to call us back. */ RegisterBop(BOP_LOAD_DOS, NULL); /* Register the DOS BOPs */ RegisterBop(BOP_DOS, DosSystemBop ); RegisterBop(BOP_CMD, DosCmdInterpreterBop); if (DosBiosFileName[0] != '/0') { BOOLEAN Success = FALSE; HANDLE hDosBios; ULONG ulDosBiosSize = 0; /* Open the DOS BIOS file */ hDosBios = FileOpen(DosBiosFileName, &ulDosBiosSize); if (hDosBios == NULL) goto Quit; /* Attempt to load the DOS BIOS into memory */ Success = FileLoadByHandle(hDosBios, REAL_TO_PHYS(TO_LINEAR(0x0070, 0x0000)), ulDosBiosSize, &ulDosBiosSize); DPRINT1("DOS BIOS file '%s' loading %s at %04X:%04X, size 0x%X (Error: %u)./n", DosBiosFileName, (Success ? "succeeded" : "failed"), 0x0070, 0x0000, ulDosBiosSize, GetLastError()); /* Close the DOS BIOS file */ FileClose(hDosBios);Quit: if (!Success) { BiosDisplayMessage("DOS BIOS file '%s' loading failed (Error: %u). The VDM will shut down./n", DosBiosFileName, GetLastError()); return; } } else { /* Load the 16-bit startup code for DOS32 and register its Starting BOP */ RtlCopyMemory(SEG_OFF_TO_PTR(0x0070, 0x0000), Startup, sizeof(Startup)); // This is the equivalent of BOP_LOAD_DOS, function 0x11 "Load the DOS kernel" // for the Windows NT DOS. RegisterBop(BOP_START_DOS, DosStart); } /* Position execution pointers for DOS startup and return */ setCS(0x0070); setIP(0x0000);}
开发者ID:GYGit,项目名称:reactos,代码行数:67,
示例10: MainInt2 Main(void){ Char app [64]; Int4 rval = 0; CharPtr id_file; ValNodePtr fetch_list = NULL; ValNodePtr field_list = NULL; ValNodePtr table; Boolean meta_mode = FALSE; FILE *fp; /* standard setup */ ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); UseLocalAsnloadDataAndErrMsg (); ErrPathReset (); /* finish resolving internal connections in ASN.1 parse tables */ if (! AllObjLoad ()) { Message (MSG_FATAL, "AllObjLoad failed"); return 1; } if (! SubmitAsnLoad ()) { Message (MSG_FATAL, "SubmitAsnLoad failed"); return 1; } if (! FeatDefSetLoad ()) { Message (MSG_FATAL, "FeatDefSetLoad failed"); return 1; } if (! SeqCodeSetLoad ()) { Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 1; } if (! GeneticCodeTableLoad ()) { Message (MSG_FATAL, "GeneticCodeTableLoad failed"); return 1; }#ifdef INTERNAL_NCBI_TBL_CHK SmartFetchEnable (); TPASmartFetchEnable (); if (! PUBSEQBioseqFetchEnable ("tbl_chk", FALSE)) { Message (MSG_POSTERR, "PUBSEQBioseqFetchEnable failed"); return 1; } #else PubSeqFetchEnable ();#endif /* process command line arguments */ sprintf (app, "tbl_chk %s", TBL_CHK_APPLICATION); if (! GetArgs (app, sizeof (myargs) / sizeof (Args), myargs)) { return 0; } id_file = (CharPtr) myargs [i_argInputFile].strvalue; debug_mode = (Boolean) myargs [D_argDebugMode].intvalue; meta_mode = (Boolean) myargs [m_argMetaMode].intvalue; fp = FileOpen (id_file, "r"); if (fp == NULL) { Message (MSG_ERROR, "Unable to open %s", id_file); return 1; } table = ReadTabTableFromFile (fp); FileClose (fp); if (table == NULL || table->next == NULL) { Message (MSG_ERROR, "Table must have at least two rows, one header and one data"); return 1; } field_list = GetFieldListFromHeader(table->data.ptrvalue); if (field_list == NULL) { Message (MSG_ERROR, "Unable to read table header"); table = FreeTabTable (table); return 1; } fetch_list = FetchItemListFromTable (table); MakeFetchItemIndex(fetch_list); fp = FileOpen ((CharPtr) myargs [o_argOutputFile].strvalue, "w"); if (fp == NULL) { Message (MSG_ERROR, "Unable to open %s", (CharPtr) myargs [o_argOutputFile].strvalue); rval = 1; } else { if (meta_mode) { fprintf (fp, "Accession/tField/tOld Value/tNew Value/n"); } ProcessBioseqsWithCaching (fetch_list, field_list, table, meta_mode, fp); } FileClose (fp); field_list = FieldTypeListFree (field_list); fetch_list = FetchItemListFree (fetch_list); MakeFetchItemIndex(NULL);//.........这里部分代码省略.........
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:101,
示例11: FetchBioseqFromSmartNotIdstatic BioseqPtr FetchBioseqFromSmartNotId (CharPtr accn, Uint2Ptr pEntityID){ BioseqPtr bsp; Char cmmd [256]; Pointer dataptr; Uint2 datatype; Uint2 entityID; FILE* fp; OMProcControlPtr ompcp; ObjMgrProcPtr ompp; Char path [PATH_MAX]; Char err_path [PATH_MAX]; SeqEntryPtr sep = NULL; SeqIdPtr sip; TextSeqIdPtr tsip; Int4 gi = 0; ValNodePtr vnp; time_t t1, t2; if (srcchkfetchcmd == NULL) { if (GetAppParam ("SEQUIN", "TBL_CHK", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) { srcchkfetchcmd = StringSaveNoNull (cmmd); } } if (srcchkfetchcmd == NULL) { if (GetAppParam ("SEQUIN", "SMART", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) { srcchkfetchcmd = StringSaveNoNull (cmmd); } } if (srcchkfetchcmd == NULL) return NULL; TmpNam (path); t1 = time(NULL);#ifdef OS_UNIX sprintf (err_path, "%s.err", path); sprintf (cmmd, "csh %s %s > %s 2>%s", srcchkfetchcmd, accn, path, err_path); system (cmmd);#endif#ifdef OS_MSWIN sprintf (cmmd, "%s %s -o %s", srcchkfetchcmd, accn, path); system (cmmd);#endif fp = FileOpen (path, "r"); if (fp == NULL) { FileRemove (path);#ifdef OS_UNIX FileRemove (err_path);#endif return OM_MSG_RET_ERROR; } dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, &entityID, FALSE, FALSE, TRUE, FALSE); FileClose (fp); FileRemove (path);#ifdef OS_UNIX FileRemove (err_path);#endif if (dataptr == NULL) return NULL; sep = GetTopSeqEntryForEntityID (entityID); if (sep == NULL) return NULL; sip = SmartGuessMakeId (accn); bsp = BioseqFindInSeqEntry (sip, sep); sip = SeqIdFree (sip); if (debug_mode) { t2 = time(NULL); if (t2 - t1 > 1) { printf("Time to download %s from SMART:%d/n", accn, t2 - t1); } } if (pEntityID != NULL) { *pEntityID = entityID; } return bsp;}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:78,
|