bool DesuraJSSettings::isValidLinkBinary(gcString path)
{
	if (!UTIL::FS::isValidFile(path))
		return false;

#ifdef WIN32
	return (path.find_last_of(".exe") == path.size()-1);
#else
	char magicBytes[5] = {0};

	try
	{
		UTIL::FS::FileHandle fh(path.c_str(), UTIL::FS::FILE_READ);
		fh.read(magicBytes, 5);
	}
	catch (...)
	{
		return false;
	}

	return UTIL::LIN::getFileType(magicBytes, 5) != UTIL::LIN::BT_UNKNOWN;
#endif
}
Exemple #2
0
McfViewerForm::McfViewerForm(wxWindow* parent, gcString mcf) : gcFrame(parent, wxID_ANY, PRODUCT_NAME_CATW(L": Mcf Viewer"), wxDefaultPosition, wxSize(370,500), wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL)
{
	Bind(wxEVT_COMMAND_BUTTON_CLICKED, &McfViewerForm::onButtonClicked, this); 
	Bind(wxEVT_CLOSE_WINDOW, &McfViewerForm::onClose, this);

	this->SetSizeHints( wxSize( 370,400 ), wxDefaultSize );
	
	wxStaticText* m_staticText26 = new wxStaticText( this, wxID_ANY, wxT("Item Id"), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText27 = new wxStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_labId = new wxStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText14 = new wxStaticText( this, wxID_ANY, wxT("File Version"), wxDefaultPosition, wxSize( 80,-1 ), 0 );
	wxStaticText* m_staticText15 = new wxStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_labVersion = new wxStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText23 = new wxStaticText( this, wxID_ANY, wxT("Type"), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText24 = new wxStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_labType = new wxStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText16 = new wxStaticText( this, wxID_ANY, wxT("Build"), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText17 = new wxStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_labMCFVers = new wxStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText18 = new wxStaticText( this, wxID_ANY, wxT("Flags"), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText19 = new wxStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_labPatch = new wxStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText20 = new wxStaticText( this, wxID_ANY, wxT("Branch"), wxDefaultPosition, wxDefaultSize, 0 );
	wxStaticText* m_staticText21 = new wxStaticText( this, wxID_ANY, wxT(":"), wxDefaultPosition, wxDefaultSize, 0 );
	m_labBranch = new wxStaticText( this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );

	m_tcFileTree = new wxTreeCtrl( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxTR_DEFAULT_STYLE );

	m_butOpen = new gcButton(this, wxID_ANY, L"Open", wxDefaultPosition, wxSize(75,22));

	wxFlexGridSizer* fgSizer11;
	fgSizer11 = new wxFlexGridSizer( 20, 3, 0, 0 );
	fgSizer11->SetFlexibleDirection( wxBOTH );
	fgSizer11->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
	
	fgSizer11->Add( m_staticText26, 0, 0, 5 );
	fgSizer11->Add( m_staticText27, 0, 0, 5 );
	fgSizer11->Add( m_labId, 0, wxLEFT, 5 );
	
	fgSizer11->Add( m_staticText14, 0, 0, 5 );
	fgSizer11->Add( m_staticText15, 0, 0, 5 );
	fgSizer11->Add( m_labVersion, 0, wxLEFT, 5 );
	
	fgSizer11->Add( m_staticText23, 0, 0, 5 );
	fgSizer11->Add( m_staticText24, 0, 0, 5 );
	fgSizer11->Add( m_labType, 0, wxLEFT, 5 );
	
	fgSizer11->Add( m_staticText16, 0, 0, 5 );
	fgSizer11->Add( m_staticText17, 0, 0, 5 );
	fgSizer11->Add( m_labMCFVers, 0, wxLEFT, 5 );
	
	fgSizer11->Add( m_staticText18, 0, 0, 5 );
	fgSizer11->Add( m_staticText19, 0, 0, 5 );
	fgSizer11->Add( m_labPatch, 0, wxLEFT, 5 );
	
	fgSizer11->Add( m_staticText20, 0, 0, 5 );
	fgSizer11->Add( m_staticText21, 0, 0, 5 );
	fgSizer11->Add( m_labBranch, 0, wxLEFT, 5 );


	wxFlexGridSizer* fgSizer12;
	fgSizer12 = new wxFlexGridSizer( 1, 2, 0, 0 );
	fgSizer12->AddGrowableCol( 0 );
	fgSizer12->AddGrowableRow( 0 );
	fgSizer12->SetFlexibleDirection( wxBOTH );
	fgSizer12->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL );

	fgSizer12->Add( fgSizer11, 1, wxEXPAND, 7 );
	fgSizer12->Add( m_butOpen, 1, 0, 5 );

	wxFlexGridSizer* fgSizer10;
	fgSizer10 = new wxFlexGridSizer( 2, 1, 0, 0 );
	fgSizer10->AddGrowableCol( 0 );
	fgSizer10->AddGrowableRow( 1 );
	fgSizer10->SetFlexibleDirection( wxBOTH );
	fgSizer10->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL );

	fgSizer10->Add( fgSizer12, 1, wxEXPAND|wxALL, 7 );
	fgSizer10->Add( m_tcFileTree, 1, wxALL|wxEXPAND, 5 );
	
	this->SetSizer( fgSizer10 );
	this->Layout();

	Centre(wxBOTH);

	if (mcf.size() > 0)
		loadMcf(mcf.c_str());
}
gcString DesuraJSBinding::base64encode(gcString data)
{
	return UTIL::STRING::base64_encode(data.c_str(), data.size());
}