本文整理汇总了C++中FileOpen函数的典型用法代码示例。如果您正苦于以下问题:C++ FileOpen函数的具体用法?C++ FileOpen怎么用?C++ FileOpen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FileOpen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleFile
static void
handleFile(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);
}
}
示例2: getFileName
int 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;
}
示例3: Block
DiskChunkReaderIteraror::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_);
}
}
}
}
示例4: DumpNandPartitions
void 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);
}
示例5: OnDropFile
void 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) ;
}
示例6: WriteInActionItems
BOOLEAN 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 );
}
示例7: IsSTCIETRLEFile
BOOLEAN 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 );
}
}
示例8: DoDump
STATIC
EFI_STATUS
DoDump(
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;
}
示例9: WriteInGarrisonInfo
BOOLEAN 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;
}
示例10: loadFromDisk
int 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;
}
示例11: WriteLoadScreenHints
BOOLEAN 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 );
}
示例12: WriteIncompatibleAttachmentStats
BOOLEAN 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 );
}
示例13: WriteFoodStats
BOOLEAN 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 );
}
示例14: OpenFcbData
vi_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 );
}
示例15: CheckInstallationData
int 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;
}