• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ FlushFileBuffers函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中FlushFileBuffers函数的典型用法代码示例。如果您正苦于以下问题:C++ FlushFileBuffers函数的具体用法?C++ FlushFileBuffers怎么用?C++ FlushFileBuffers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了FlushFileBuffers函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: bt_mgrclose

void bt_mgrclose (BtMgr *mgr)
{
BtPool *pool;
uint slot;

	// release mapped pages
	//	note that slot zero is never used

	for( slot = 1; slot < mgr->poolmax; slot++ ) {
		pool = mgr->pool + slot;
		if( pool->slot )
#ifdef unix
			munmap (pool->map, (mgr->poolmask+1) << mgr->page_bits);
#else
		{
			FlushViewOfFile(pool->map, 0);
			UnmapViewOfFile(pool->map);
			CloseHandle(pool->hmap);
		}
#endif
	}

#ifdef unix
	close (mgr->idx);
	free (mgr->pool);
	free (mgr->hash);
	free (mgr->latch);
	free (mgr->pooladvise);
	free (mgr);
#else
	FlushFileBuffers(mgr->idx);
	CloseHandle(mgr->idx);
	GlobalFree (mgr->pool);
	GlobalFree (mgr->hash);
	GlobalFree (mgr->latch);
	GlobalFree (mgr);
#endif
}
开发者ID:IMCG,项目名称:ura-tree,代码行数:38,代码来源:threads2h.c


示例2: _wfopen

bool FileSystem::FlushDirBuffers(const char* filename, CString& errmsg)
{
#ifdef WIN32
	FILE* file = _wfopen(UtfPathToWidePath(filename), WString(FOPEN_RBP));
#else
	BString<1024> parentPath = filename;
	char* p = (char*)strrchr(parentPath, PATH_SEPARATOR);
	if (p)
	{
		*p = '\0';
	}
	FILE* file = fopen(parentPath, FOPEN_RB);
#endif

	if (!file)
	{
		errmsg = GetLastErrorMessage();
		return false;
	}
	bool ok = FlushFileBuffers(fileno(file), errmsg);
	fclose(file);
	return ok;
}
开发者ID:outtahere,项目名称:nzbget,代码行数:23,代码来源:FileSystem.cpp


示例3: SendAck

bool SendAck(HANDLE pipe)
{
	DWORD written, ack = 0;
	if (!WriteFile(pipe, &ack, sizeof(DWORD), &written, NULL) && written != sizeof(DWORD)) {
#ifdef DEBUG_IPC
		CUtils::Log(_T("SendAck: WriteFile failed. (%d)"), GetLastError());
#endif
		return false;
	}
	if (!FlushFileBuffers(pipe)) {
#ifdef DEBUG_IPC
		CUtils::Log(_T("SendAck: FlushFileBuffers failed. (%d)"), GetLastError());
#endif
		return false;
	}
	if (!DisconnectNamedPipe(pipe)) {
#ifdef DEBUG_IPC
		CUtils::Log(_T("SendAck: DisconnectNamedPipe failed. (%d)"), GetLastError());
#endif
		return false;
	}
	return true;
}
开发者ID:FREEWING-JP,项目名称:xkeymacs,代码行数:23,代码来源:xkeymacs64.cpp


示例4: LbFileFlush

/**
 * Flushes the file buffers, writing all data immediately.
 * @return Returns 1 on success, 0 on error.
*/
short LbFileFlush(TbFileHandle handle)
{
#if defined(WIN32)
  int result;
  // Crappy Windows has its own
  result = FlushFileBuffers((HANDLE)handle);
  // It returns 'invalid handle' error sometimes for no reason.. so disabling this error
  if (result != 0)
      return 1;
  result = GetLastError();
  return ((result == 0) || (result == 6));
#else
#if defined(DOS)||defined(GO32)
  // No idea how to do this on old systems
  return 1;
#else
  // For normal POSIX systems
  // (should also work on Win, as its IEEE standard... but it currently isn't)
  return (ioctl(handle,I_FLUSH,FLUSHRW) != -1);
#endif
#endif

}
开发者ID:ommmmmmm,项目名称:keeperfx,代码行数:27,代码来源:bflib_fileio.c


示例5: FlushFileBuffers

bool PipeReader::CheckATR() {
	//SectionLocker lock(dataSection);

	if (pipe==NULL)
		return false;
	DWORD read=0;
	DWORD command=1;
	if (!WriteFile(pipe,&command,sizeof(DWORD),&read,NULL)) {
		return false;
	}
	FlushFileBuffers(pipe);
	DWORD size=0;
	if (!ReadFile(pipe,&size,sizeof(DWORD),&read,NULL)) {
		return false;
	}
	if (size==0)
		return false;
	BYTE ATR[100];
	if (!ReadFile(pipe,ATR,size,&read,NULL)) {
		return false;
	}
	return true;
}
开发者ID:M-Yussef,项目名称:vsmartcard,代码行数:23,代码来源:PipeReader.cpp


示例6: sizeof

bool EtfArduinoService::SendMessage(LPVOID lpvMessage, DWORD bufferSize) {
	if (hPipe == 0)
		if (!OpenPipeConnection())
			return false;
	DWORD cbToWrite = bufferSize * sizeof(message_t);
	DWORD cbWritten = 0;
	BOOL fSuccess = WriteFile( 
		hPipe,               // pipe handle 
		lpvMessage,             // message 
		cbToWrite,              // message length 
		&cbWritten,             // bytes written 
		NULL);                  // not overlapped 
	// Make sure the message got through the pipe before returning.
	FlushFileBuffers(hPipe);
	if (!fSuccess) {
		_tprintf(TEXT("WriteFile to pipe failed. GLE=%d\n"), GetLastError()); 
		return false;
	}
	if (cbWritten != cbToWrite) {
		return false;
	}
	return true;
}
开发者ID:mlalic,项目名称:etfarduino,代码行数:23,代码来源:EtfArduinoService.cpp


示例7: rs232_flush

RS232_LIB unsigned int
rs232_flush(struct rs232_port_t *p)
{
	struct rs232_windows_t *wx = p->pt;

	DBG("p=%p p->pt=%p\n", (void *)p, p->pt);

	if (!rs232_port_open(p))
		return RS232_ERR_PORT_CLOSED;

	if (!FlushFileBuffers(wx->fd)) {
		DBG("FlushFileBuffers() %s\n", last_error());
		return RS232_ERR_FLUSH;
	}

	if (!PurgeComm(wx->fd, PURGE_TXABORT | PURGE_RXABORT |
		       PURGE_TXCLEAR | PURGE_RXCLEAR)) {
		DBG("PurgeComm() %s\n", last_error());
		return RS232_ERR_FLUSH;
	}

	return RS232_ERR_NOERROR;
}
开发者ID:tiantik,项目名称:librs232,代码行数:23,代码来源:rs232_windows.c


示例8: ADIOI_NTFS_Flush

void ADIOI_NTFS_Flush(ADIO_File fd, int *error_code)
{
    int err;
    static char myname[] = "ADIOI_NTFS_Flush";

    err = (fd->access_mode & ADIO_RDONLY) ? TRUE :
	FlushFileBuffers(fd->fd_sys);

    /* --BEGIN ERROR HANDLING-- */
    if (err == FALSE)
    {
    char errMsg[ADIOI_NTFS_ERR_MSG_MAX];
	err = GetLastError();
    ADIOI_NTFS_Strerror(err, errMsg, ADIOI_NTFS_ERR_MSG_MAX);
	*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
					   myname, __LINE__, MPI_ERR_IO,
					   "**io",
					   "**io %s", errMsg);
	return;
    }
    /* --END ERROR HANDLING-- */
    *error_code = MPI_SUCCESS;
}
开发者ID:00datman,项目名称:ompi,代码行数:23,代码来源:ad_ntfs_flush.c


示例9: CreateFile

int CTreeHandler::Dbg_DumpTree()
{
	HANDLE hfile;
	int ret = 0;
	CTreeElem* rootelem = 0;
	int errcnt = 0;

	hfile = CreateFile( (LPCTSTR)"dbgdump.txt", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
		FILE_FLAG_SEQUENTIAL_SCAN, NULL );
	if( hfile == INVALID_HANDLE_VALUE ){
		return 1;
	}

	
	rootelem = (*this)( 0 );

	if( rootelem ){
		rootelem->Dbg_DumpReq( hfile, errcnt );
		_ASSERT( !errcnt );
		if( errcnt ){
			DbgOut( "CTreeHandler : Dbg_DumpTree : Dbg_DumpReq error !!!\n" );
			return 1;
		}
	}else{
		DbgOut( "CTreeHandler : Dbg_DumpTree : rootelem error !!!\n" );
		return 1;
	}
	

	FlushFileBuffers( hfile );
	CloseHandle( hfile );
	
	DbgOut( "CTreeHandler : DumpTree : CloseHandle\n" );

	return ret;

}
开发者ID:toughie88,项目名称:Easy3D-1,代码行数:37,代码来源:treehandler.cpp


示例10: OS_IpcClose

/*
 *----------------------------------------------------------------------
 *
 * OS_IpcClose
 *
 *	OS IPC routine to close an IPC connection.
 *
 * Results:
 *
 *
 * Side effects:
 *      IPC connection is closed.
 *
 *----------------------------------------------------------------------
 */
int OS_IpcClose(int ipcFd, int shutdown)
{
    if (ipcFd == -1) return 0;

    /*
     * Catch it if fd is a bogus value
     */
    ASSERT((ipcFd >= 0) && (ipcFd < WIN32_OPEN_MAX));
    ASSERT(fdTable[ipcFd].type != FD_UNUSED);

    switch (listenType) 
    {
    case FD_PIPE_SYNC:
	    /*
	     * Make sure that the client (ie. a Web Server in this case) has
	     * read all data from the pipe before we disconnect.
	     */
	    if (! FlushFileBuffers(fdTable[ipcFd].fid.fileHandle)) return -1;

	    if (! DisconnectNamedPipe(fdTable[ipcFd].fid.fileHandle)) return -1;

        /* fall through */

    case FD_SOCKET_SYNC:

	    OS_Close(ipcFd, shutdown);
	    break;

    case FD_UNUSED:
    default:

	    exit(106);
	    break;
    }

    return 0; 
}
开发者ID:BlueBrain,项目名称:FastCGI,代码行数:52,代码来源:os_win32.c


示例11: BasepCrossVolumeMoveHelper

DWORD
APIENTRY
BasepCrossVolumeMoveHelper(
    LARGE_INTEGER TotalFileSize,
    LARGE_INTEGER TotalBytesTransferred,
    LARGE_INTEGER StreamSize,
    LARGE_INTEGER StreamBytesTransferred,
    DWORD dwStreamNumber,
    DWORD dwCallbackReason,
    HANDLE SourceFile,
    HANDLE DestinationFile,
    LPVOID lpData OPTIONAL
    )
{
    PHELPER_CONTEXT Context = (PHELPER_CONTEXT)lpData;

    if ( dwCallbackReason == CALLBACK_STREAM_SWITCH ) {
#ifdef _CAIRO_
        OBJECTID *poid;

        if ( poid = Context->pObjectId ) {
            RtlSetObjectId(DestinationFile, poid);
            Context->pObjectId = NULL;
            }
#endif
        if ( !(Context->dwFlags & MOVEFILE_WRITE_THROUGH) ) {
            return PROGRESS_QUIET;
            }
        }
    else if ( dwCallbackReason == CALLBACK_CHUNK_FINISHED ) {
        if ( StreamBytesTransferred.QuadPart == StreamSize.QuadPart ) {
            FlushFileBuffers(DestinationFile);
            }
        }

    return PROGRESS_CONTINUE;
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:37,代码来源:filemisc.c


示例12: while

void PackFile::closePakFile(void)
{
	//清空所有打开的文件
	while(!m_listStream.empty())
	{
		(*m_listStream.begin())->close();
	}

	//remove edit flag
	if(m_fileHead.nEditFlag != 0)
	{
		m_fileHead.nEditFlag = 0;
		writeFileHead();
	}

	//Close handle
	if(m_hPakFile)
	{
		FlushFileBuffers(m_hPakFile);
		CloseHandle(m_hPakFile); m_hPakFile = 0;
	}

	//清空Stream打开的文件句柄
	FileHandleMap::iterator it;
	for(it=m_mapFileHandle.begin(); it!=m_mapFileHandle.end(); it++)
	{
		::CloseHandle(it->second);
	}
	m_mapFileHandle.clear();

	//清空表
	memset(&m_fileHead, 0, sizeof(FILE_HEAD));
	memset(m_hashTable, 0, sizeof(FILE_HASHNODE)*HASH_TABLE_SIZE);
	m_blockTable.clear();
	m_mapFreeBlock.clear();
	m_bConst = true;
}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:37,代码来源:AXPPackFile.cpp


示例13: ThrowHr

/*----------------------------------------------------------------------------------------------
	Flush the file's buffer. Since we are dealing with a file opened in director mode, we
	just flush the buffer and ignore the grfCommitFlags.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP FileStream::Commit(DWORD grfCommitFlags)
{
	BEGIN_COM_METHOD;
#if WIN32
		// FlushFileBuffers may return an error if m_hfile doesn't have GENERIC_WRITE access.
	if (!(m_grfstgm & (kfstgmReadWrite | kfstgmWrite)))
		ThrowHr(WarnHr(STG_E_INVALIDFUNCTION));

	if (!FlushFileBuffers(m_hfile))
	{
		// REVIEW JohnL: Should we check for medium full before returning this code?
		ThrowHr(WarnHr(STG_E_MEDIUMFULL));
	}
#else
	// FlushFileBuffers may return an error if m_hfile doesn't have GENERIC_WRITE access.
	if (!(m_flags & (O_RDWR | O_WRONLY)))
		ThrowHr(WarnHr(STG_E_INVALIDFUNCTION));

	if (fsync(m_file))
		return S_OK;
#endif

	END_COM_METHOD(g_fact, IID_IStream);
}
开发者ID:FieldDB,项目名称:FieldWorks,代码行数:28,代码来源:FileStrm.cpp


示例14: close

bool SerialPort::openPort(const char *device, int baudrate, bool bXonXoff, int DTRtime)
{
    close();
    d->m_time	  = DTRtime;
    d->m_baudrate = baudrate;
    d->m_bXonXoff = bXonXoff;
    string port; // = "\\\\.\\";
    port += device;
    port += ":";
    d->hPort = CreateFileA(port.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
    if (d->hPort == INVALID_HANDLE_VALUE){
        close();
        log(L_WARN, "Can' open %s", port.c_str());
        return false;
    }
    FlushFileBuffers(d->hPort);
    if (!EscapeCommFunction(d->hPort, CLRDTR)){
        close();
        log(L_WARN, "Clear DTR error");
        return false;
    }
    d->m_timer->start(d->m_time, true);
    return true;
}
开发者ID:BackupTheBerlios,项目名称:sim-im-svn,代码行数:24,代码来源:serial.cpp


示例15: diag_tty_write

ssize_t diag_tty_write(struct diag_l0_device *dl0d, const void *buf, const size_t count) {
    DWORD byteswritten;
    OVERLAPPED *pOverlap;
    struct tty_int *wti = (struct tty_int *)dl0d->tty_int;
    pOverlap=NULL;		//note : if overlap is eventually enabled, the CreateFile flags should be adjusted

    if (wti->fd == INVALID_HANDLE_VALUE) {
        fprintf(stderr, FLFMT "Error. Is the port open ?\n", FL);
        return diag_iseterr(DIAG_ERR_GENERAL);
    }

    if (count <= 0)
        return diag_iseterr(DIAG_ERR_BADLEN);

    if (! WriteFile(wti->fd, buf, count, &byteswritten, pOverlap)) {
        fprintf(stderr, FLFMT "WriteFile error:%s. %u bytes written, %u requested\n", FL, diag_os_geterr(0), (unsigned int) byteswritten, count);
        return diag_iseterr(DIAG_ERR_GENERAL);
    }
    if (!FlushFileBuffers(wti->fd)) {
        fprintf(stderr, FLFMT "tty_write : could not flush buffers, %s\n", FL, diag_os_geterr(0));
        return diag_iseterr(DIAG_ERR_GENERAL);
    }
    return byteswritten;
} //diag_tty_write
开发者ID:shirou,项目名称:freediag,代码行数:24,代码来源:diag_tty_win.c


示例16: Open_ProIn

int Open_ProIn()
{
 	char com_str[10];
	sprintf(com_str,"%s:",DeviceNameIN); 
	LPSTR lpszPortName = _T(com_str);
	com_handle_IN = CreateFile(
		lpszPortName, 
		GENERIC_READ | GENERIC_WRITE, 
		0,								// DWORD dwShareMode, 
		NULL,							// LPSECURITY_ATTRIBUTES lpSecurityAttributes, 
		OPEN_EXISTING,					// DWORD dwCreationDispostion, 
		0, //FILE_FLAG_OVERLAPPED,		// DWORD dwFlagsAndAttributes, 
		NULL							// HANDLE hTemplateFile
	);
	
	int iRetIn = (int)(com_handle_IN );
	
	if (iRetIn<0)
	{
    com_handle_IN = NULL;
	sprintf(string_display_dmx_params,"Impossible to open interface, is it PLUGGED ?");
    return(0);
	}
	 else {sprintf(string_display_dmx_params,"Enttec Pro IN  %s is now Open",DeviceNameIN);} 

	// SetCommState & Timeout
    Enttec_Pro_SetCommParamsIN();

	// flush rx & tx buffers
	resIn = FlushFileBuffers(com_handle_IN);
	if (!resIn)
	{ 
    sprintf(string_display_dmx_params,"\ENTTEC PRO IN %s: Flush file buffers failed...",DeviceNameIN);
	CloseHandle(com_handle_IN); com_handle_IN = NULL;
	return(0);
	}
开发者ID:ChristophGuillermet,项目名称:WHITECAT_opensource,代码行数:36,代码来源:dmx_enttec_pro.cpp


示例17: FlushFileBuffers

void Channel::Destroy()
{

    if (m_creator)
    {
        FlushFileBuffers(m_pipe);
        DisconnectNamedPipe(m_pipe);
        m_creator = false;
    }

    if (m_doneEvent != INVALID_HANDLE_VALUE)
    {
        
        // Signal the done event so that if we're currently blocked reading,
        // we'll stop.

        SetEvent(m_doneEvent);

        CloseHandle(m_doneEvent);
        m_doneEvent = INVALID_HANDLE_VALUE;

    }

    if (m_readEvent != INVALID_HANDLE_VALUE)
    {
        CloseHandle(m_readEvent);
        m_readEvent = INVALID_HANDLE_VALUE;
    }

    if (m_pipe != INVALID_HANDLE_VALUE)
    {
        CloseHandle(m_pipe);
        m_pipe = INVALID_HANDLE_VALUE;
    }

}
开发者ID:dansen,项目名称:luacode,代码行数:36,代码来源:Channel.cpp


示例18: omrfile_sync

int32_t
omrfile_sync(struct OMRPortLibrary *portLibrary, intptr_t fd)
{
	HANDLE handle = toHandle(portLibrary, fd);

	Trc_PRT_file_sync_Entry(fd);

	/*
	 * According to MSDN:
	 * 1) If hFile is a handle to the server end of a named pipe, the function does not return until the client has read all buffered data from the pipe.
	 * 2) The function fails if hFile is a handle to the console output. That is because the console output is not buffered. The function returns FALSE, and GetLastError returns ERROR_INVALID_HANDLE.
	 *
	 * This behaviour caused JAZZ 44899 defect: Test_SimpleTenantLimitXmt would freeze while waiting for process to terminate while child
	 * was waiting for parent to read from STDIN and STDOUT streams of a child.
	 *
	 * Manual testing showed that even if we called System.out.print('X') and System.err.print('Y') a parent process would still get receive 'X' and 'Y'
	 * (with and without flushing) after child process in terminated.
	 *
	 * This check does not modify original behaviour of the port library because we never actually flushed STDIN and STDOUT handles but
	 * some arbitrary handles 1 & 2.
	 */
	if (((HANDLE)OMRPORT_TTY_OUT == (HANDLE)fd) || ((HANDLE)OMRPORT_TTY_ERR == (HANDLE)fd)) {
		Trc_PRT_file_sync_Exit(0);
		return 0;
	}

	if (FlushFileBuffers(handle)) {
		Trc_PRT_file_sync_Exit(0);
		return 0;
	} else {
		int32_t error = GetLastError();
		error = portLibrary->error_set_last_error(portLibrary, error, findError(error));
		Trc_PRT_file_sync_Exit(error);
		return -1;
	}
}
开发者ID:dinogun,项目名称:omr,代码行数:36,代码来源:omrfile.c


示例19: FlushFileBuffers

bool PipeReader::QueryATR(BYTE *ATR,DWORD *ATRsize,bool reset) {
	if (pipe==NULL)
		return false;
	DWORD command=reset ? 0 : 1;
	DWORD read=0;
	if (!WriteFile(pipe,&command,sizeof(DWORD),&read,NULL)) {
		pipe=NULL;
		return false;
	}
	FlushFileBuffers(pipe);
	DWORD size=0;
	if (!ReadFile(pipe,&size,sizeof(DWORD),&read,NULL)) {
		pipe=NULL;
		return false;
	}
	if (size==0)
		return false;
	if (!ReadFile(pipe,ATR,size,&read,NULL)) {
		pipe=NULL;
		return false;
	}
	(*ATRsize)=size;
	return true;
}
开发者ID:frankmorgner,项目名称:vsmartcard,代码行数:24,代码来源:PipeReader.cpp


示例20: FlushPlatformFile

 bool FlushPlatformFile(PlatformFile file)
 {
     ThreadRestrictions::AssertIOAllowed();
     return ((file!=kInvalidPlatformFileValue) && FlushFileBuffers(file));
 }
开发者ID:abyvaltsev,项目名称:putty-nd3.x,代码行数:5,代码来源:platform_file.cpp



注:本文中的FlushFileBuffers函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FlushInstructionCache函数代码示例发布时间:2022-05-30
下一篇:
C++ FlushConsoleInputBuffer函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap