本文整理汇总了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);
}
}
示例2: SaveMeshToFile
void CGlobalMshLoader::SaveMeshToFile(const CMesh::TMeshContainer &mesh, const nstring &file)
{
CFileStream sfile;
sfile.Open(file, true, false);
SaveMeshToStream(mesh, &sfile);
sfile.Close();
}
示例3:
CMesh::TMeshContainer &CGlobalMshLoader::LoadMeshFromFile(const nstring &file)
{
CFileStream sfile;
sfile.Open(file);
LoadMeshFromStream(&sfile);
sfile.Close();
return gMeshBuffer;
}
示例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;
}
示例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;
}