Esempio n. 1
0
//---------------------------------------------------------------------------
//	@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
}
//================================================================================================================
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);
}
//================================================================================================================
//================================================================================================================
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);
}
Esempio n. 4
0
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);
}
Esempio n. 5
0
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);
}
Esempio n. 6
0
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;
}
Esempio n. 7
0
Datum
DumpPlanToDXLFile(PG_FUNCTION_ARGS)
{
	char *szSql = textToString(PG_GETARG_TEXT_P(0));
	char *szFilename = textToString(PG_GETARG_TEXT_P(1));

	PlannedStmt *pplstmt = planQuery(szSql);
	Assert(pplstmt);

	char *szXmlString = COptTasks::SzDXL(pplstmt);

	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();

	PG_RETURN_INT32(iLen);

}
Esempio n. 8
0
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);
    }
}
Esempio n. 9
0
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"));

    }

}