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


C++ CFileStream::Close方法代码示例

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


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

示例1: OnSave

void CRIFFChunkTreeDlg::OnSave() 
{
	OPENFILENAME ofn;

	PrepareSimpleDialog(&ofn, *this, "*.txt");
	ofn.lpstrFilter = "Text files (*.txt)|*.txt||";
	ofn.Flags |= OFN_OVERWRITEPROMPT;
	if (!GetOpenSaveFileNameUTF8(&ofn, false)) 
		return;

	CFileStream* destFile = new CFileStream();
	if (STREAM_OK == destFile->Open(ofn.lpstrFile, StreamMode::Write))
	{
		CACHE* cache = new CACHE(4, 1<<18);
		cache->Open(destFile, CACHE_OPEN_WRITE);
		cache->Write(cUTF8Hdr, 3);

		RenderItem(cache, m_Tree.GetRootItem(), 0);

		cache->Close();
		delete cache;
		destFile->Close();
		delete destFile;
	}
	else
	{
		MessageBoxHelper::CouldNotOpenFileForWrite(ofn.lpstrFile);
	}
}
开发者ID:BrunoReX,项目名称:avimuxgui,代码行数:29,代码来源:RIFFChunkTreeDlg.cpp

示例2: SaveMeshToFile

void CGlobalMshLoader::SaveMeshToFile(const CMesh::TMeshContainer &mesh, const nstring &file)
{
	CFileStream sfile;

	sfile.Open(file, true, false);
	SaveMeshToStream(mesh, &sfile);

	sfile.Close();
}
开发者ID:Siriuscoder,项目名称:NovaEngine,代码行数:9,代码来源:nova_msh_loader.cpp

示例3:

CMesh::TMeshContainer &CGlobalMshLoader::LoadMeshFromFile(const nstring &file)
{
	CFileStream sfile;
	
	sfile.Open(file);
	LoadMeshFromStream(&sfile);

	sfile.Close();

	return gMeshBuffer;
}
开发者ID:Siriuscoder,项目名称:NovaEngine,代码行数:11,代码来源:nova_msh_loader.cpp

示例4: LoadFileToBuffer

DWORD CDataServer::LoadFileToBuffer(const nString& FileName, char*& Buffer)
{
	CFileStream File;

	int BytesRead;

	if (File.Open(FileName, SAM_READ, SAP_SEQUENTIAL))
	{
		int FileSize = File.GetSize();
		Buffer = (char*)n_malloc(FileSize);
		BytesRead = File.Read(Buffer, FileSize);
		File.Close();
	}
	else
	{
		Buffer = NULL;
		BytesRead = 0;
	}

	return BytesRead;
}
开发者ID:moltenguy1,项目名称:deusexmachina,代码行数:21,代码来源:DataServer.cpp

示例5: _tmain


//.........这里部分代码省略.........
		// Load the input file
		CProfileFile file;
		for (int i=0; i<vecDefines.GetSize(); i++)
		{
			CUniString strName, strValue;
			SplitString(vecDefines[i], L"=", strName, strValue);
			wprintf(L"#define %s %s\n", strName, strValue);
			file.Define(strName, strValue);
		}

		if (!file.Load(strInputFile, &fp))
		{
			HRESULT hr=HRESULT_FROM_WIN32(GetLastError());
			wprintf(file.GetParseError());
			return 7;
		}

		// Extract encryption key
		DWORD dwEncryptionKey=0;
		CProfileSection* pSection=file.FindSection(L"Sinic");
		if (pSection)
		{
			// Save the key
			dwEncryptionKey=pSection->GetIntValue(L"EncryptionKey", 0);

			// Remove the "sinic" section
			file.Remove(pSection);
		}

		// Create output file
		CFileStream OutStream;
		if (!OutStream.Create(strOutputFile))
		{
			HRESULT hr=HRESULT_FROM_WIN32(GetLastError());
			wprintf(L"Failed to create '%s' - %s (0x%.8x)\n\n", strOutputFile, FormatError(hr), hr);
			return 7;
		}

		// Save as binary file
		HRESULT hr;
		if (dwEncryptionKey)
		{
			CAutoPtr<IStream, SRefCounted> spEncStream;
			CreateCryptorStream(&OutStream, CCryptorKey(dwEncryptionKey), &spEncStream);
			hr=SaveBinaryProfile(file, spEncStream);
		}
		else
		{
			hr=SaveBinaryProfile(file, &OutStream);
		}
		OutStream.Close();
		if (FAILED(hr))
		{
			HRESULT hr=HRESULT_FROM_WIN32(GetLastError());
			wprintf(L"Failed to save '%s' - %s (0x%.8x)\n\n", strOutputFile, FormatError(hr), hr);
			DeleteFile(strOutputFile);
			return 7;
		}
	}
	else
	{
		// Open stream
		CFileStream InStream;
		if (!InStream.Open(strInputFile))
		{
			HRESULT hr=HRESULT_FROM_WIN32(GetLastError());
			wprintf(L"Failed to open '%s' - %s (0x%.8x)\n\n", strInputFile, FormatError(hr), hr);
			return 7;
		}

		// Load profile
		CProfileFile file;
		HRESULT hr=LoadBinaryProfile(file, &InStream);
		if (FAILED(hr))
		{
			if (hr!=E_UNEXPECTED)
			{
				wprintf(L"Failed to load '%s' - %s (0x%.8x)\n\n", strInputFile, FormatError(hr), hr);
				return 7;
			}
			else
			{
				wprintf(L"Failed to load '%s' - not a binary profile file\n\n", strInputFile);
				return 7;
			}
		}

		// Save as heirarchial
		if (!file.Save(strOutputFile, bUnicode, !bFlat))
		{
			HRESULT hr=HRESULT_FROM_WIN32(GetLastError());
			wprintf(L"Failed to save '%s' - %s (0x%.8x)\n\n", strInputFile, FormatError(hr), hr);
			return 7;
		}
	}

	wprintf(L"%s - OK\n\n", strOutputFile);

	return 0;
}
开发者ID:adhawkins,项目名称:SimpleLib,代码行数:101,代码来源:Sinic.cpp


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