本文整理汇总了C++中CFileWriter::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileWriter::Close方法的具体用法?C++ CFileWriter::Close怎么用?C++ CFileWriter::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileWriter
的用法示例。
在下文中一共展示了CFileWriter::Close方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//---------------------------------------------------------------------------
// @function:
// CIOUtils::Dump
//
// @doc:
// Dump given string to output file
//
//---------------------------------------------------------------------------
void
CIOUtils::Dump
(
CHAR *file_name,
CHAR *sz
)
{
CAutoSuspendAbort asa;
const ULONG ulWrPerms = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
GPOS_TRY
{
CFileWriter fw;
fw.Open(file_name, ulWrPerms);
const BYTE *pb = reinterpret_cast<const BYTE*>(sz);
ULONG_PTR ulpLength = (ULONG_PTR) clib::Strlen(sz);
fw.Write(pb, ulpLength);
fw.Close();
}
GPOS_CATCH_EX(ex)
{
// ignore exceptions during dumping
GPOS_RESET_EX;
}
GPOS_CATCH_END;
// reset time slice
#ifdef GPOS_DEBUG
CWorker::Self()->ResetTimeSlice();
#endif // GPOS_DEBUG
}
示例2:
//================================================================================================================
CreateGameDirectory::CreateGameDirectory(GameDirectory3D* gd)
{
_mkdir(gd->GAME_FOLDER.c_str());
_mkdir(gd->m_required_textures.c_str());
_mkdir(gd->m_menu_sprites_path.c_str());
_mkdir(gd->m_hud_path.c_str());
_mkdir(gd->m_scripts_path.c_str());
_mkdir(gd->m_music_path.c_str());
_mkdir(gd->m_materials_path.c_str());
_mkdir(gd->m_heightmaps_path.c_str());
_mkdir(gd->m_template_poly_path.c_str());
_mkdir(gd->m_models_path.c_str());
_mkdir(gd->m_textures_path.c_str());
_mkdir(gd->m_xml_path.c_str());
//_mkdir(gd->m_xml_menu_path.c_str());
//_mkdir(gd->m_xml_hud_path.c_str());
_mkdir(gd->m_xml_maps_path.c_str());
CFileWriter fileWriter;
fileWriter.Open(gd->m_game_ini_path);
fileWriter.Write("[GAME]\n");
fileWriter.Write("\n");
fileWriter.Write(";Game can either be Topdown or Platformer, 3D for 3D game\n");
fileWriter.Write("GameType=3D\n");
fileWriter.Close();
CFileWriter fileMainMenuWriter;
fileMainMenuWriter.Open(gd->m_xml_main_menu_path);
fileMainMenuWriter.Close();
CFileWriter fileInGameMenuWriter;
fileInGameMenuWriter.Open(gd->m_xml_ingame_menu_path);
fileInGameMenuWriter.Close();
CFileWriter fileHUDWriter;
fileHUDWriter.Open(gd->m_xml_hud_path);
fileHUDWriter.Close();
CopyFolder("RequiredTextures", gd->m_required_textures);
CopyFolder("RequiredScripts", gd->m_scripts_path);
CopyFolder("TemplatePolys", gd->m_template_poly_path);
}
示例3: if
//================================================================================================================
//================================================================================================================
CreateGameDirectory::CreateGameDirectory(GameDirectory2D* gd, GameType2D gameType)
{
_mkdir(gd->GAME_FOLDER.c_str());
_mkdir(gd->m_required_textures.c_str());
_mkdir(gd->m_sprites_path.c_str());
_mkdir(gd->m_menu_sprites_path.c_str());
_mkdir(gd->m_hud_path.c_str());
_mkdir(gd->m_tiles_path.c_str());
_mkdir(gd->m_scripts_path.c_str());
_mkdir(gd->m_music_path.c_str());
_mkdir(gd->m_animation_profiles_path.c_str());
_mkdir(gd->m_animation_profile_sprites_path.c_str());
_mkdir(gd->m_animation_profile_tiles_path.c_str());
_mkdir(gd->m_xml_path.c_str());
_mkdir(gd->m_xml_maps_path.c_str());
_mkdir(gd->m_xml_sprites_path.c_str());
//_mkdir(gd->m_xml_menu_path.c_str());
//_mkdir(gd->m_xml_hud_path.c_str());
_mkdir(gd->m_xml_worlds_path.c_str());
if (gameType == TOPDOWN)
{
CFileWriter fileWriter;
fileWriter.Open(gd->m_game_ini_path);
fileWriter.Write("[GAME]\n");
fileWriter.Write("\n");
fileWriter.Write(";Game can either be Topdown or Platformer, 3D for 3D game\n");
fileWriter.Write("GameType=Topdown\n");
fileWriter.Close();
}
else if (gameType == PLATFORMER)
{
CFileWriter fileWriter;
fileWriter.Open(gd->m_game_ini_path);
fileWriter.Write("[GAME]\n");
fileWriter.Write("\n");
fileWriter.Write(";Game can either be Topdown or Platformer, 3D for 3D game\n");
fileWriter.Write("GameType=Platformer\n");
fileWriter.Close();
}
CFileWriter fileMainMenuWriter;
fileMainMenuWriter.Open(gd->m_xml_main_menu_path);
fileMainMenuWriter.Close();
CFileWriter fileInGameMenuWriter;
fileInGameMenuWriter.Open(gd->m_xml_ingame_menu_path);
fileInGameMenuWriter.Close();
CFileWriter fileHUDWriter;
fileHUDWriter.Open(gd->m_xml_hud_path);
fileHUDWriter.Close();
CFileWriter fileInventoryWriter;
fileInventoryWriter.Open(gd->m_xml_inventory_path);
fileInventoryWriter.Close();
CopyFolder("RequiredTextures", gd->m_required_textures);
CopyFolder("RequiredScripts", gd->m_scripts_path);
}
示例4: textToString
Datum
DumpQueryToFile(PG_FUNCTION_ARGS)
{
char *szSql = textToString(PG_GETARG_TEXT_P(0));
char *szFilename = textToString(PG_GETARG_TEXT_P(1));
size_t iQueryStringLen = -1;
char *pcQuery = getQueryBinary(szSql, &iQueryStringLen);
CFileWriter fw;
fw.Open(szFilename, S_IRUSR | S_IWUSR);
fw.Write(reinterpret_cast<const BYTE*>(&iQueryStringLen), sizeof(iQueryStringLen));
fw.Write(reinterpret_cast<const BYTE*>(pcQuery), iQueryStringLen);
fw.Close();
PG_RETURN_UINT32( (ULONG) iQueryStringLen);
}
示例5: getPlannedStmtBinary
Datum
DumpPlanToFile(PG_FUNCTION_ARGS)
{
char *szSql = text_to_cstring(PG_GETARG_TEXT_P(0));
char *szFilename = text_to_cstring(PG_GETARG_TEXT_P(1));
size_t iBinaryLen = -1;
char *pcBinary = getPlannedStmtBinary(szSql, &iBinaryLen);
CFileWriter fw;
fw.Open(szFilename, S_IRUSR | S_IWUSR);
fw.Write(reinterpret_cast<const BYTE*>(&iBinaryLen), sizeof(iBinaryLen));
fw.Write(reinterpret_cast<const BYTE*>(pcBinary), iBinaryLen);
fw.Close();
PG_RETURN_UINT32((ULONG) iBinaryLen);
}
示例6: parseSQL
static int translateQueryToFile
(
char *szSqlText,
char *szFilename
)
{
Query *pquery = parseSQL(szSqlText);
Assert(pquery);
char *szXmlString = COptTasks::SzDXL(pquery);
int iLen = (int) gpos::clib::UlStrLen(szXmlString);
CFileWriter fw;
fw.Open(szFilename, S_IRUSR | S_IWUSR);
fw.Write(reinterpret_cast<const BYTE*>(szXmlString), iLen + 1);
fw.Close();
return iLen;
}
示例7: OnButton
void CShowOneDescriptionDlg::OnButton(wxCommandEvent& event)
{
if (event.GetId()==wxID_OK)
{
int err;
wxString CurrentDir = wxGetCwd();
if (!m_descr)
return;
wxFileDialog dialog(GetParent(),
wxT("Save current text"),
wxT(""),
wxT(""),
wxT(SZ_ALL_FILES),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
err = dialog.ShowModal();
wxSetWorkingDirectory(CurrentDir);
if (wxID_OK == err)
{
CFileWriter F;
if (F.Open(dialog.GetPath().mb_str()))
{
F.WriteBuf(m_descr, strlen(m_descr));
F.Close();
}
else
wxMessageBox(wxT("Can not open file"));
}
}
else if (event.GetId()==wxID_CANCEL)
{
StoreSize();
EndModal(wxID_CANCEL);
}
}
示例8: SaveAs
void CShowDescriptionListDlg::SaveAs()
{
int err, i;
CBaseObject * pObj;
CStr S(128);
wxString CurrentDir = wxGetCwd();
wxFileDialog dialog(GetParent(),
wxT("Save current text"),
wxT(""),
wxT(""),
wxT(SZ_ALL_FILES),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
err = dialog.ShowModal();
wxSetWorkingDirectory(CurrentDir);
if (wxID_OK == err)
{
CFileWriter F;
if (F.Open(dialog.GetPath().mb_str()))
{
for (i=0; i<m_pItems->Count(); i++)
{
pObj = (CBaseObject*)m_pItems->At(i);
S = pObj->Description;
S.TrimRight(TRIM_ALL);
S << EOL_FILE;
F.WriteBuf(S.GetData(), S.GetLength());
}
F.Close();
}
else
wxMessageBox(wxT("Can not open file"));
}
}