当前位置: 首页>>代码示例>>C++>>正文


C++ FlushFileBuffers函数代码示例

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


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


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