这篇教程C++ FileOpen函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中FileOpen函数的典型用法代码示例。如果您正苦于以下问题:C++ FileOpen函数的具体用法?C++ FileOpen怎么用?C++ FileOpen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了FileOpen函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: handleFilestatic voidhandleFile(TSession * const sessionP, const char * const fileName, time_t const fileModTime, MIMEType * const mimeTypeP) {/*---------------------------------------------------------------------------- This is an HTTP request handler for a GET. It does the classic web server thing: send the file named in the URL to the client.-----------------------------------------------------------------------------*/ TFile * fileP; bool success; success = FileOpen(&fileP, fileName, O_BINARY | O_RDONLY); if (!success) ResponseStatusErrno(sessionP); else { if (notRecentlyModified(sessionP, fileModTime)) { ResponseStatus(sessionP, 304); ResponseWriteStart(sessionP); } else sendFileAsResponse(sessionP, fileP, fileName, fileModTime, mimeTypeP); FileClose(fileP); }}
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:26,
示例2: getFileNameint mtFile::runRead( mtThreadWork::DataUser* pkDataUser ){ char* pcFile = getFileName(pkDataUser->pcAccount); if (NULL == pcFile) { return mtProtocol::E_RESULT_FALT_FILE_INVALIDE_PATH; } if (0 == FileOpen(&pkDataUser->hFile, pcFile)) { return mtProtocol::E_RESULT_FALT_FILE_NOT_EXIST; } pkDataUser->iFileOffset = getFileOffset(pkDataUser->pcAccount); pkDataUser->ulTransferBytes = getDataFileBytes(); pkDataUser->kOverlapped.Offset = pkDataUser->iFileOffset; pkDataUser->eOverlappedType = mtThread::E_OLT_LOCKFILEEx; pkDataUser->iFileRunType = E_FILE_RUN_READ_FILE; if (0 == FileLock(pkDataUser->hFile, pkDataUser->ulTransferBytes, &pkDataUser->kOverlapped)) { FileClose(&pkDataUser->hFile); return mtProtocol::E_RESULT_FALT_FILE_LOCK; } return mtProtocol::E_RESULT_SUCCESS;}
开发者ID:Michael-Z,项目名称:mtLandlord,代码行数:29,
示例3: BlockDiskChunkReaderIteraror::DiskChunkReaderIteraror(const ChunkID& chunk_id,unsigned& chunk_size,const unsigned& block_size):ChunkReaderIterator(chunk_id,block_size,chunk_size){ block_buffer_=new Block(block_size_); fd_=FileOpen(chunk_id_.partition_id.getPathAndName().c_str(),O_RDONLY); if(fd_==-1){ printf("Failed to open file [%s], reason:%s/n",chunk_id_.partition_id.getPathAndName().c_str(),strerror(errno)); number_of_blocks_=0; } else{ const unsigned start_pos=CHUNK_SIZE*chunk_id_.chunk_off; const unsigned long length=lseek(fd_,0,SEEK_END); if(length<=start_pos){ printf("fails to set the start offset %d for [%s]/n",start_pos,chunk_id.partition_id.getName().c_str()); number_of_blocks_=0; } else{ const unsigned offset=lseek(fd_,start_pos,SEEK_SET); printf("The file is set to be %d/n",offset);// sleep(1); if(start_pos+CHUNK_SIZE<length){ number_of_blocks_=CHUNK_SIZE/block_size_; } else{ number_of_blocks_=(length-start_pos)/block_size_; printf("This chunk has only %d blocks!/n",number_of_blocks_); } } }}
开发者ID:FishYoung,项目名称:CLAIMS,代码行数:31,
示例4: DumpNandPartitionsvoid DumpNandPartitions(){ int isEmuNand = checkEmuNAND() ? NandSwitch() : 0; if(isEmuNand == -1) return; char* p_name[] = { "twln.bin", "twlp.bin", "agb_save.bin", "firm0.bin", "firm1.bin", "ctrnand.bin" }; unsigned int p_size[] = { 0x08FB5200, 0x020B6600, 0x00030000, 0x00400000, 0x00400000, 0x2F3E3600}; unsigned int p_addr[] = { TWLN, TWLP, AGB_SAVE, FIRM0, FIRM1, CTRNAND }; int sect_row = 0x80; ConsoleInit(); ConsoleAddText(isEmuNand ? "EmuNAND Partitions Decryptor/n /n" : "NAND Partitions Decryptor/n /n"); for(int i = 3; i < 6; i++){ //Cutting out twln, twlp and agb_save. Todo: Properly decrypt them File out; sprintf(myString, isEmuNand ? "nand/emu_%s" : "nand/%s", p_name[i]); FileOpen(&out, myString, 1); sprintf(myString, "Dumping %s ...", p_name[i]); ConsoleAddText(myString); ConsoleShow(); for(int j = 0; j*0x200 < p_size[i]; j += sect_row){ sprintf(myString, "%08X / %08X", j*0x200, p_size[i]); int x, y; ConsoleGetXY(&x, &y); y += CHAR_WIDTH * 4; x += CHAR_WIDTH*2; DrawString(TOP_SCREEN, myString, x, y, ConsoleGetTextColor(), ConsoleGetBackgroundColor()); if(isEmuNand) emunand_readsectors(j, sect_row, BUF1, p_addr[i]); else nand_readsectors(j, sect_row, BUF1, p_addr[i]); FileWrite(&out, BUF1, sect_row*0x200, j*0x200); } FileClose(&out); } ConsoleAddText("/nPress A to exit"); ConsoleShow(); WaitForButton(BUTTON_A);}
开发者ID:LITTOMA,项目名称:rxTools,代码行数:33,
示例5: OnDropFilevoid OnDropFile (DWORD wParam) { TCHAR FileName [FilePathLen + 1] ; LPTSTR pFileNameStart ; HANDLE hFindFile ; WIN32_FIND_DATA FindFileInfo ; int NameOffset ; int NumOfFiles = 0 ; NumOfFiles = DragQueryFile ((HDROP) wParam, 0xffffffff, NULL, 0) ; if (NumOfFiles > 0) { // we only open the first file for now DragQueryFile((HDROP) wParam, 0, FileName, FilePathLen) ; pFileNameStart = ExtractFileName (FileName) ; NameOffset = pFileNameStart - FileName ; // convert short filename to long NTFS filename if necessary hFindFile = FindFirstFile (FileName, &FindFileInfo) ; if (hFindFile && hFindFile != INVALID_HANDLE_VALUE) { // append the file name back to the path name lstrcpy (&FileName[NameOffset], FindFileInfo.cFileName) ; FindClose (hFindFile) ; } FileOpen (hWndMain, (int)0, (LPTSTR)FileName) ; PrepareMenu (GetMenu (hWndMain)); } DragFinish ((HDROP) wParam) ; }
开发者ID:mingpen,项目名称:OpenNT,代码行数:33,
示例6: WriteInActionItemsBOOLEAN WriteInActionItems(STR fileName){ HWFILE hFile; //Debug code; make sure that what we got from the file is the same as what's there // Open a new file hFile = FileOpen( fileName, FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE ); if ( !hFile ) return( FALSE ); { UINT32 cnt; FilePrintf(hFile,"<ACTION_ITEM_LIST>/r/n"); for(cnt = 0;cnt < /*501*/NUM_ACTIONITEMS;cnt++) { FilePrintf(hFile,"/t<ACTION_ITEM>/r/n"); FilePrintf(hFile,"/t/t<uiIndex>%d</uiIndex>/r/n", cnt); FilePrintf(hFile,"/t/t<Name>Empty action</Name>/r/n"); FilePrintf(hFile,"/t/t<ActionID>%d</ActionID>/r/n", ActionItemsValues[cnt].ActionID); FilePrintf(hFile,"/t/t<Blow_up>%d</Blow_up>/r/n", ActionItemsValues[cnt].BlowUp); FilePrintf(hFile,"/t/t<BombItem>%d</BombItem>/r/n", ActionItemsValues[cnt].BombItem); FilePrintf(hFile,"/t</ACTION_ITEM>/r/n"); } FilePrintf(hFile,"</ACTION_ITEM_LIST>/r/n"); } FileClose( hFile ); return( TRUE );}
开发者ID:RadekSimkanic,项目名称:JA2-1.13,代码行数:30,
示例7: IsSTCIETRLEFileBOOLEAN IsSTCIETRLEFile( CHAR8 * ImageFile ){ HWFILE hFile; STCIHeader Header; UINT32 uiBytesRead; CHECKF( FileExists( ImageFile ) ); // Open the file and read the header hFile = FileOpen( ImageFile, FILE_ACCESS_READ, FALSE ); CHECKF( hFile ); if (!FileRead( hFile, &Header, STCI_HEADER_SIZE, &uiBytesRead ) || uiBytesRead != STCI_HEADER_SIZE || memcmp( Header.cID, STCI_ID_STRING, STCI_ID_LEN ) != 0 ) { DbgMessage( TOPIC_HIMAGE, DBG_LEVEL_3, "Problem reading STCI header." ); FileClose( hFile ); return( FALSE ); } FileClose( hFile ); if (Header.fFlags & STCI_ETRLE_COMPRESSED) { return( TRUE ); } else { return( FALSE ); }}
开发者ID:RadekSimkanic,项目名称:JA2-1.13,代码行数:28,
示例8: DoDumpSTATICEFI_STATUSDoDump( IN EFI_DEVICE_PATH_PROTOCOL *Device ){ EFI_STATUS Status; EFI_FILE_PROTOCOL *File; Status = FileOpen (Device, mFvInstance->MappedFile, &File, EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ); if (EFI_ERROR (Status)) { return Status; } Status = FileWrite (File, mFvInstance->Offset, mFvInstance->FvBase, mFvInstance->FvLength); FileClose (File); return Status;}
开发者ID:FUZZINEXT,项目名称:RaspberryPiPkg,代码行数:25,
示例9: WriteInGarrisonInfoBOOLEAN WriteInGarrisonInfo(STR fileName){ HWFILE hFile; hFile = FileOpen( fileName, FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE ); if ( !hFile ) return( FALSE ); { INT8 cnt; FilePrintf(hFile,"<GARRISON_INFO>/r/n"); for(cnt = 0; cnt < 57; cnt++) { FilePrintf(hFile,"/t<GARRISON>/r/n"); FilePrintf(hFile,"/t/t<Sector>%c%d</Sector>/r/n", (gOrigGarrisonGroup[cnt].ubSectorID / 16 + 0x41), (gOrigGarrisonGroup[cnt].ubSectorID % 16 + 1)); FilePrintf(hFile,"/t/t<Composition>%d</Composition>/r/n", gOrigGarrisonGroup[cnt].ubComposition); FilePrintf(hFile,"/t</GARRISON>/r/n"); } FilePrintf(hFile,"</GARRISON_INFO>/r/n"); } FileClose( hFile ); return TRUE;}
开发者ID:RadekSimkanic,项目名称:JA2-1.13,代码行数:32,
示例10: loadFromDiskint BlockManager::loadFromDisk(const ChunkID& chunk_id,void* const &desc,const unsigned & length)const{ int ret; unsigned offset=chunk_id.chunk_off; int fd=FileOpen(chunk_id.partition_id.getPathAndName().c_str(),O_RDONLY); if(fd==-1){ logging_->elog("Fail to open file [%s].Reason:%s",chunk_id.partition_id.getPathAndName().c_str(),strerror(errno)); return -1; } else{ logging_->log("file [%s] is opened for offset[%d]/n",chunk_id.partition_id.getPathAndName().c_str(),offset); } long int file_length=lseek(fd,0,SEEK_END); long start_pos=CHUNK_SIZE*offset; logging_->log("start_pos=%ld**********/n",start_pos); lseek(fd,start_pos,SEEK_SET); if(start_pos<file_length){ ret=read(fd,desc,length); } else{ ret=0; } FileClose(fd); return ret;}
开发者ID:Jackson1992,项目名称:CLAIMS,代码行数:26,
示例11: WriteLoadScreenHintsBOOLEAN WriteLoadScreenHints( STR fileName){ HWFILE hFile; //Debug code; make sure that what we got from the file is the same as what's there // Open a new file hFile = FileOpen( fileName, FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE ); if ( !hFile ) return( FALSE ); { UINT32 cnt; FilePrintf(hFile,"<LOADSCREENHINTS>/r/n"); for(cnt = 0; cnt < num_found_loadscreenhints; ++cnt) { FilePrintf(hFile,"/t<LOADSCREENHINT>/r/n"); FilePrintf(hFile,"/t/t<uiIndex>%d</uiIndex>/r/n", cnt); FilePrintf(hFile,"/t/t<usFlags>%d</usFlags>/r/n", zLoadScreenHint[cnt].usFlags); FilePrintf(hFile,"/t</LOADSCREENHINT>/r/n"); } FilePrintf(hFile,"</LOADSCREENHINTS>/r/n"); } FileClose( hFile ); return( TRUE );}
开发者ID:jikuja,项目名称:JA2-1.13,代码行数:28,
示例12: WriteIncompatibleAttachmentStatsBOOLEAN WriteIncompatibleAttachmentStats(){ HWFILE hFile; //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//IncompatibleAttachments out.xml", FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE ); if ( !hFile ) return( FALSE ); { UINT32 cnt; FilePrintf(hFile,"<INCOMPATIBLEATTACHMENTLIST>/r/n"); for(cnt = 0;cnt < MAXATTACHMENTS;cnt++) { FilePrintf(hFile,"/t<INCOMPATIBLEATTACHMENT>/r/n"); FilePrintf(hFile,"/t/t<itemIndex>%d</itemIndex>/r/n", IncompatibleAttachments[cnt][0]); FilePrintf(hFile,"/t/t<incompatibleattachmentIndex>%d</incompatibleattachmentIndex>/r/n", IncompatibleAttachments[cnt][1]); FilePrintf(hFile,"/t</INCOMPATIBLEATTACHMENT>/r/n"); } FilePrintf(hFile,"</INCOMPATIBLEATTACHMENTLIST>/r/n"); } FileClose( hFile ); return( TRUE );}
开发者ID:RadekSimkanic,项目名称:JA2-1.13,代码行数:29,
示例13: WriteFoodStatsBOOLEAN WriteFoodStats(){ //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"writefoodsstats"); HWFILE hFile; //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//Food out.xml", FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE ); if ( !hFile ) return( FALSE ); { UINT32 cnt; FilePrintf(hFile,"<FOODSLIST>/r/n"); for(cnt = 0; cnt < FOOD_TYPE_MAX; ++cnt) { FilePrintf(hFile,"/t<FOOD>/r/n"); FilePrintf(hFile,"/t/t<uiIndex>%d</uiIndex>/r/n", cnt ); FilePrintf(hFile,"/t/t<bFoodPoints>%d</bFoodPoints>/r/n", Food[cnt].bFoodPoints ); FilePrintf(hFile,"/t/t<bDrinkPoints>%d</bDrinkPoints>/r/n", Food[cnt].bDrinkPoints ); FilePrintf(hFile,"/t/t<usDecayRate>%4.2f</usDecayRate>/r/n", Food[cnt].usDecayRate ); FilePrintf(hFile,"/t</FOOD>/r/n"); } FilePrintf(hFile,"</FOODSLIST>/r/n"); } FileClose( hFile ); return( TRUE );}
开发者ID:fedya,项目名称:ja2_v1.13,代码行数:32,
示例14: OpenFcbDatavi_rc OpenFcbData( file *f ){ int handle; vi_rc rc; fcb *cfcb; /* * open file handle if we need to */ rc = ERR_NO_ERR; if( !f->is_stdio ) { handle = -1; ConditionalChangeDirectory( f->home ); rc = FileOpen( f->name, false, O_BINARY | O_RDONLY, 0, &handle ); if( rc != ERR_NO_ERR ) { return( ERR_FILE_OPEN ); } if( handle == -1 ) { rc = ERR_FILE_NOT_FOUND; } else if( f->size == 0 ) { close( handle ); rc = END_OF_FILE; } else { f->handle = handle; } if( rc != ERR_NO_ERR ) { cfcb = FcbAlloc( f ); AddLLItemAtEnd( (ss **)&(f->fcbs.head), (ss **)&(f->fcbs.tail), (ss *)cfcb ); CreateNullLine( cfcb ); } } return( rc );}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:33,
示例15: CheckInstallationDataint CheckInstallationData(){ File file; char str[32]; if(!FileOpen(&file, "rxTools/data/0004013800000002.bin", 0)) return -1; FileClose(&file); if(!FileOpen(&file, "rxTools/data/0004013800000202.bin", 0)) return -2; FileClose(&file); if(!FileOpen(&file, "rxTools/data/0004013800000102.bin", 0)) return -3; FileClose(&file); if(!FileOpen(&file, "rxTools/data/data.bin", 0)) return -4; FileRead(&file, str, 32, 0); FileClose(&file); if(memcmp(str, __DATE__, 11)) return -5; if(memcmp(&str[12], __TIME__, 8)) return -5; return 0;}
开发者ID:nastys,项目名称:rxTools,代码行数:16,
示例16: ShowMessage//---------------------------------------------------------------------------void __fastcall TMainForm::LabeledEditKeyDown(TObject *Sender, WORD &Key, TShiftState Shift){ if (Key !=0x0D) return; RichEditPrintTicket->Clear(); LabeledEdit->ReadOnly =true; AnsiString binFileStr =controller->config->BinFileDir +"ticket//" +LabeledEdit->Text +".bin"; if (!FileExists(binFileStr)){ ShowMessage("票号搞错了吧,没有找到这张票的数据,重新输入吧!"); return; } int hBinFile = FileOpen(binFileStr, fmOpenRead); char bin[16384] ={0}; int nRead =FileRead(hBinFile, bin, sizeof(bin)); //解密文件 char *srcBin =new char[nRead]; controller->Decrypt(bin, nRead, srcBin); FileClose(hBinFile); char stubTxt[16384] ={0}; //借用个对象,计算一下 if (controller->terminalGroup->Count ==0) return; CTerminal *terminal =(CTerminal *)controller->terminalGroup->Objects[0]; terminal->ParserVerifyStub(nRead, srcBin, stubTxt); delete srcBin; //显示票根,转换一下,避免单行超过1024字节,控件限制的错误 TStringList *text =new TStringList(); text->Text =AnsiString(stubTxt); RichEditPrintTicket->Clear(); RichEditPrintTicket->Lines->AddStrings(text); RichEditPrintTicket->Perform(WM_VSCROLL, SB_TOP, 0); //光标归位,免得滚下去难看 delete text; SpeedButtonPrinterPrint->Enabled =true;}
开发者ID:limitee,项目名称:bot,代码行数:32,
示例17: applyPatchint applyPatch(void *file, const char *patch, const FirmInfo *info){ File fd; Elf32_Ehdr ehdr; Elf32_Shdr shdr; unsigned int cur, off; if (!FileOpen(&fd, patch, 0)) return 1; if (FileRead(&fd, &ehdr, sizeof(ehdr), 0) < 0) return 1; cur = ehdr.e_shoff; for (; ehdr.e_shnum; ehdr.e_shnum--, cur += sizeof(shdr)) { if (FileRead(&fd, &shdr, sizeof(shdr), cur) < 0) continue; if (shdr.sh_type != SHT_PROGBITS || !(shdr.sh_flags & SHF_ALLOC)) continue; off = addrToOff(shdr.sh_addr, info); if (off == 0) continue; FileRead(&fd, (void *)((uintptr_t)file + off), shdr.sh_size, shdr.sh_offset); } return 0;}
开发者ID:nastys,项目名称:rxTools,代码行数:30,
示例18: SavePackvoid SavePack(){ File FilePack; FileOpen(&FilePack, "rxTools.dat", 0); DecryptPartition(&packInfo); FileWrite(&FilePack, FILEPACK_ADDR, FILEPACK_SIZE, FILEPACK_OFF); FileClose(&FilePack); DecryptPartition(&packInfo);}
开发者ID:javitu,项目名称:rxTools,代码行数:7,
示例19: UploadKickstart//// UploadKickstart() ////char UploadKickstart(char *name){ int keysize=0; char filename[12]; strncpy(filename, name, 8); // copy base name strcpy(&filename[8], "ROM"); // add extension BootPrint("Checking for Amiga Forever key file:"); if(FileOpen(&file,"ROM KEY")) { keysize=file.size; if(file.size<sizeof(romkey)) { int c=0; while(c<keysize) { FileRead(&file, &romkey[c]); c+=512; FileNextSector(&file); } BootPrint("Loaded Amiga Forever key file"); } else { BootPrint("Amiga Forever keyfile is too large!"); } } BootPrint("Loading file: "); BootPrint(filename); if (RAOpen(&romfile, filename)) { if (romfile.size == 0x100000) { // 1MB Kickstart ROM BootPrint("Uploading 1MB Kickstart ..."); SendFileV2(&romfile, NULL, 0, 0xe00000, romfile.size>>10); SendFileV2(&romfile, NULL, 0, 0xf80000, romfile.size>>10); return(1); } else if(romfile.size == 0x80000) {
开发者ID:UIKit0,项目名称:mist-firmware,代码行数:35,
示例20: wxLogTextCtrlMultiViewerMain::MultiViewerMain( wxWindow* parent ):MainFrame( parent ){ m_nGridEventRow = m_nGridEventCol = 0; m_eProgramState = eStateInit; m_eGridState = eGridCommon; m_bDirty = false; m_nSelectedTable = 0; m_pSQLReader = NULL; m_nEditRow = -1; m_nEditRowCount = 0; m_nAddRow = -1; m_nCancelRow = -1; ////// Trace C++ FilePath函数代码示例 C++ FileNotFoundException函数代码示例
|