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


C++ IF_FileSystem::createFile方法代码示例

本文整理汇总了C++中IF_FileSystem::createFile方法的典型用法代码示例。如果您正苦于以下问题:C++ IF_FileSystem::createFile方法的具体用法?C++ IF_FileSystem::createFile怎么用?C++ IF_FileSystem::createFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IF_FileSystem的用法示例。


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

示例1: write

/****************************************************************************
Desc:	Copies the data stored in the INI_LINE structs to the ini file
****************************************************************************/
RCODE FTKAPI F_IniFile::write( void)
{
	RCODE					rc = NE_FLM_OK;
	FLMUINT				uiBytesWritten;
	INI_LINE *			pCurLine = NULL;
	FLMUINT				uiFileOffset = 0;		
	IF_FileSystem *	pFileSystem = f_getFileSysPtr();

	f_assert( m_bReady);
	
	if (!m_bModified)
	{
		// Nothing needs to be written
		
		goto Exit;
	}

	// Open the file
	
	f_assert( !m_pFileHdl);
	
	if (RC_BAD( rc = pFileSystem->createFile( m_pszFileName,
								FLM_IO_RDWR, &m_pFileHdl)))
	{
		goto Exit;
	}

	pCurLine = m_pFirstLine;
	while (pCurLine)
	{
		if (pCurLine->pszParamName)
		{
			// Output the param name
			
			if (RC_BAD (rc = m_pFileHdl->write( uiFileOffset,
				f_strlen( pCurLine->pszParamName), pCurLine->pszParamName,
				&uiBytesWritten)))
			{
				goto Exit;
			}
			uiFileOffset += uiBytesWritten;
			
			if (pCurLine->pszParamValue)
			{
				// Output the "=" and the value
				
				if (RC_BAD (rc = m_pFileHdl->write( uiFileOffset, 1,
					(void *)"=", &uiBytesWritten)))
				{
					goto Exit;
				}

				uiFileOffset += uiBytesWritten;

				if (RC_BAD (rc = m_pFileHdl->write( uiFileOffset,
					f_strlen( pCurLine->pszParamValue), pCurLine->pszParamValue,
					&uiBytesWritten)))
				{
					goto Exit;
				}
				uiFileOffset += uiBytesWritten;
			}
		}
	

		if (pCurLine->pszComment)
		{
			// Output the comment
			
			if (pCurLine->pszParamName)
			{
				if (RC_BAD (rc = m_pFileHdl->write( uiFileOffset, 2,
					(void *)" #", &uiBytesWritten)))
				{
					goto Exit;
				}
			}
			else
			{
				if (RC_BAD (rc = m_pFileHdl->write( uiFileOffset, 1,
					(void *)"#", &uiBytesWritten)))
				{
					goto Exit;
				}
			}

			uiFileOffset += uiBytesWritten;

			if (RC_BAD (rc = m_pFileHdl->write( uiFileOffset,
				f_strlen( pCurLine->pszComment), pCurLine->pszComment,
				&uiBytesWritten)))
			{
				goto Exit;
			}

			uiFileOffset += uiBytesWritten;

//.........这里部分代码省略.........
开发者ID:Tyrion-Lannister-274AL,项目名称:flaim,代码行数:101,代码来源:ftkini.cpp

示例2: dumpToFile

/****************************************************************************
Desc:
*****************************************************************************/
RCODE F_DynamicList::dumpToFile()
{
	RCODE					rc = NE_FLM_OK;
	DLIST_NODE *		pTmp;
	FLMUINT				uiLoop;
	IF_FileHdl *		pFileHdl = NULL;
#define DLST_RESP_SIZE 256
	char					szResponse[ DLST_RESP_SIZE];
	FLMUINT				uiTermChar;
	FTX_SCREEN *		pScreen;
	IF_FileSystem *	pFileSystem = NULL;
	
	if( RC_BAD( rc = FlmGetFileSystem( &pFileSystem)))
	{
		goto Exit;
	}

	f_strcpy( szResponse, (const char *)DLIST_DUMPFILE_PATH);

	FTXWinGetScreen( m_pListWin, &pScreen);
	FTXGetInput(
		pScreen,
 		"enter filename to dump to",
		szResponse,
		DLST_RESP_SIZE-1,
		&uiTermChar);

	if ( uiTermChar != FKB_ENTER)
	{
		goto Exit;
	}

	if (RC_BAD( rc = pFileSystem->doesFileExist( szResponse)))
	{
		//create file if it doesn't already exist
		if ( rc == NE_FLM_IO_PATH_NOT_FOUND)
		{
			rc = pFileSystem->createFile( szResponse, FLM_IO_RDWR, &pFileHdl);
		}
		else
		{
			goto Exit_local;
		}
	}
	else
	{
		rc = pFileSystem->openFile( szResponse, FLM_IO_RDWR, &pFileHdl);
	}

	TEST_RC_LOCAL( rc);

	{
		FLMUINT64	ui64FileSize = 0;
		FLMUINT		uiBytesWritten = 0;

		//figure out size of file currently, so you can append to it
		
		pFileHdl->size( &ui64FileSize);
		pTmp = m_pFirst;

		uiLoop = 0;
		while( pTmp)
		{
			FLMBYTE * pszNextLine = (FLMBYTE*)(pTmp->pvData);

			TEST_RC_LOCAL( rc = pFileHdl->write(
				ui64FileSize,					//offset to current file size
				f_strlen( (const char *)pszNextLine),
				pszNextLine,
				&uiBytesWritten));

			ui64FileSize += uiBytesWritten;

			TEST_RC_LOCAL( rc = pFileHdl->write(
				ui64FileSize,					//add in newline
				1,
				(FLMBYTE*)"\n",
				&uiBytesWritten));

			ui64FileSize += uiBytesWritten;
			pTmp = pTmp->pNext;
		}

		(void)pFileHdl->closeFile();

	}

Exit_local:
	{//give success/fail message

		char				szMessage[ 256];
		FLMUINT			uiChar;

		FTXWinGetScreen( m_pListWin, &pScreen);
		if ( RC_OK( rc))
		{
			f_sprintf( szMessage,
//.........这里部分代码省略.........
开发者ID:Tyrion-Lannister-274AL,项目名称:flaim,代码行数:101,代码来源:flm_dlst.cpp

示例3: getFileHdl

/****************************************************************************
Desc: Returns the requested file handle
****************************************************************************/
RCODE F_MultiFileHdl::getFileHdl(
	FLMUINT				uiFileNum,
	FLMBOOL				bGetForWrite,
	IF_FileHdl **		ppFileHdl)
{
	RCODE					rc	= NE_FLM_OK;
	IF_FileSystem *	pFileSystem = f_getFileSysPtr();
	FLMUINT				uiSlot;
	IF_FileHdl *		pTmpHdl;
	char					szPath[ F_PATH_MAX_SIZE];

	f_assert( m_bOpen);

	*ppFileHdl = NULL;

	uiSlot = uiFileNum % F_MULTI_FHDL_LIST_SIZE;
	pTmpHdl = m_pFileHdlList[ uiSlot].pFileHdl;

	if( pTmpHdl && m_pFileHdlList[ uiSlot].uiFileNum != uiFileNum)
	{
		if( RC_BAD( rc = pTmpHdl->flush()))
		{
			goto Exit;
		}

		pTmpHdl->closeFile();
		pTmpHdl->Release();
		pTmpHdl = NULL;

		f_memset( &m_pFileHdlList[ uiSlot], 0, sizeof( FH_INFO));
	}

	if( !pTmpHdl)
	{
		dataFilePath( uiFileNum, szPath);
		if( RC_BAD( rc = pFileSystem->openFile( szPath, 
			FLM_IO_RDWR, &pTmpHdl)))
		{
			if( rc == NE_FLM_IO_PATH_NOT_FOUND && bGetForWrite)
			{
				if( RC_BAD( rc = pFileSystem->createFile( szPath,
 					FLM_IO_RDWR, &pTmpHdl)))
				{
					goto Exit;
				}
			}
			else
			{
				goto Exit;
			}
		}

		m_pFileHdlList[ uiSlot].pFileHdl = pTmpHdl;
		m_pFileHdlList[ uiSlot].uiFileNum = uiFileNum;
		f_assert( !m_pFileHdlList[ uiSlot].bDirty);
	}

	*ppFileHdl = m_pFileHdlList[ uiSlot].pFileHdl;
	if( bGetForWrite)
	{
		m_pFileHdlList[ uiSlot].bDirty = TRUE;
	}

Exit:

	return( rc);
}
开发者ID:ajumi2,项目名称:libflaim,代码行数:70,代码来源:ftkmfh.cpp


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