Reduce the use of string objects slightly. Add Delete ISO feature.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@610 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
a0eb4ad055
commit
38f04809f1
|
@ -19,6 +19,7 @@
|
||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
#include <shlobj.h> // for SHGetFolderPath
|
#include <shlobj.h> // for SHGetFolderPath
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <commdlg.h> // for GetSaveFileName
|
#include <commdlg.h> // for GetSaveFileName
|
||||||
|
@ -29,23 +30,24 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool File::Exists(const std::string &filename)
|
bool File::Exists(const char *filename)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return GetFileAttributes(filename.c_str()) != INVALID_FILE_ATTRIBUTES;
|
return GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES;
|
||||||
#else
|
#else
|
||||||
struct stat file_info;
|
struct stat file_info;
|
||||||
int result = stat(filename.c_str(), &file_info);
|
int result = stat(filename, &file_info);
|
||||||
return result == 0;
|
return result == 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::IsDirectory(const std::string &filename) {
|
bool File::IsDirectory(const char *filename)
|
||||||
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return (GetFileAttributes(filename.c_str()) & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
return (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
#else
|
#else
|
||||||
struct stat file_info;
|
struct stat file_info;
|
||||||
int result = stat(filename.c_str(), &file_info);
|
int result = stat(filename, &file_info);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
return S_ISDIR(file_info.st_mode);
|
return S_ISDIR(file_info.st_mode);
|
||||||
else
|
else
|
||||||
|
@ -53,7 +55,22 @@ bool File::IsDirectory(const std::string &filename) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SanitizePath(const std::string &filename) {
|
bool File::Delete(const char *filename)
|
||||||
|
{
|
||||||
|
if (!File::Exists(filename))
|
||||||
|
return false;
|
||||||
|
if (File::IsDirectory(filename))
|
||||||
|
return false;
|
||||||
|
#ifdef _WIN32
|
||||||
|
DeleteFile(filename);
|
||||||
|
#else
|
||||||
|
unlink(filename);
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SanitizePath(const char *filename)
|
||||||
|
{
|
||||||
std::string copy = filename;
|
std::string copy = filename;
|
||||||
for (size_t i = 0; i < copy.size(); i++)
|
for (size_t i = 0; i < copy.size(); i++)
|
||||||
if (copy[i] == '/')
|
if (copy[i] == '/')
|
||||||
|
@ -61,7 +78,7 @@ std::string SanitizePath(const std::string &filename) {
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void File::Launch(const std::string &filename)
|
void File::Launch(const char *filename)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::string win_filename = SanitizePath(filename);
|
std::string win_filename = SanitizePath(filename);
|
||||||
|
@ -76,7 +93,7 @@ void File::Launch(const std::string &filename)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void File::Explore(const std::string &path)
|
void File::Explore(const char *path)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::string win_path = SanitizePath(path);
|
std::string win_path = SanitizePath(path);
|
||||||
|
@ -92,27 +109,27 @@ void File::Explore(const std::string &path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if successful, or path already exists.
|
// Returns true if successful, or path already exists.
|
||||||
bool File::CreateDir(const std::string &path)
|
bool File::CreateDir(const char *path)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (::CreateDirectory(path.c_str(), NULL))
|
if (::CreateDirectory(path, NULL))
|
||||||
return true;
|
return true;
|
||||||
DWORD error = GetLastError();
|
DWORD error = GetLastError();
|
||||||
if (error == ERROR_ALREADY_EXISTS)
|
if (error == ERROR_ALREADY_EXISTS)
|
||||||
{
|
{
|
||||||
PanicAlert("%s already exists", path.c_str());
|
PanicAlert("%s already exists", path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PanicAlert("Error creating directory: %i", error);
|
PanicAlert("Error creating directory: %i", error);
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
if (mkdir(path.c_str(), 0644) == 0)
|
if (mkdir(path, 0644) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int err = errno;
|
int err = errno;
|
||||||
|
|
||||||
if (err == EEXIST) {
|
if (err == EEXIST) {
|
||||||
PanicAlert("%s already exists", path.c_str());
|
PanicAlert("%s already exists", path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +139,7 @@ bool File::CreateDir(const std::string &path)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetUserDirectory() {
|
std::string File::GetUserDirectory() {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char path[MAX_PATH];
|
char path[MAX_PATH];
|
||||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, path)))
|
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, path)))
|
||||||
|
@ -137,3 +154,12 @@ std::string GetUserDirectory() {
|
||||||
return dir;
|
return dir;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u64 File::GetSize(const char *filename)
|
||||||
|
{
|
||||||
|
FILE *f = fopen(filename, "rb");
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
u64 pos = ftell(f);
|
||||||
|
fclose(f);
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
|
@ -20,14 +20,18 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "Common.h"
|
||||||
|
|
||||||
class File
|
class File
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static bool Exists(const std::string &filename);
|
static bool Exists(const char *filename);
|
||||||
static void Launch(const std::string &filename);
|
static void Launch(const char *filename);
|
||||||
static void Explore(const std::string &path);
|
static void Explore(const char *path);
|
||||||
static bool IsDirectory(const std::string &filename);
|
static bool IsDirectory(const char *filename);
|
||||||
static bool CreateDir(const std::string &filename);
|
static bool CreateDir(const char *filename);
|
||||||
|
static bool Delete(const char *filename);
|
||||||
|
static u64 GetSize(const char *filename);
|
||||||
static std::string GetUserDirectory();
|
static std::string GetUserDirectory();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBios _BootBios)
|
||||||
m_strMemoryCardA = BaseDataPath + "/MemoryCardA.raw";
|
m_strMemoryCardA = BaseDataPath + "/MemoryCardA.raw";
|
||||||
m_strMemoryCardB = BaseDataPath + "/MemoryCardB.raw";
|
m_strMemoryCardB = BaseDataPath + "/MemoryCardB.raw";
|
||||||
m_strSRAM = BaseDataPath + "/SRAM.raw";
|
m_strSRAM = BaseDataPath + "/SRAM.raw";
|
||||||
if (!File::Exists(m_strBios)) {
|
if (!File::Exists(m_strBios.c_str())) {
|
||||||
LOG(BOOT, "BIOS file %s not found - using HLE.", m_strBios.c_str());
|
LOG(BOOT, "BIOS file %s not found - using HLE.", m_strBios.c_str());
|
||||||
bHLEBios = true;
|
bHLEBios = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ void CEXIMemoryCard::Flush(bool exiting)
|
||||||
{
|
{
|
||||||
std::string dir;
|
std::string dir;
|
||||||
SplitPath(m_strFilename, &dir, 0, 0);
|
SplitPath(m_strFilename, &dir, 0, 0);
|
||||||
File::CreateDir(dir);
|
File::CreateDir(dir.c_str());
|
||||||
pFile = fopen(m_strFilename.c_str(), "wb");
|
pFile = fopen(m_strFilename.c_str(), "wb");
|
||||||
}
|
}
|
||||||
if (!pFile) //Note - pFile changed inside above if
|
if (!pFile) //Note - pFile changed inside above if
|
||||||
|
|
|
@ -373,7 +373,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IDM_LOADMAPFILE:
|
case IDM_LOADMAPFILE:
|
||||||
if (!File::Exists(mapfile))
|
if (!File::Exists(mapfile.c_str()))
|
||||||
{
|
{
|
||||||
g_symbolDB.Clear();
|
g_symbolDB.Clear();
|
||||||
PPCAnalyst::FindFunctions(0x80000000, 0x80400000, &g_symbolDB);
|
PPCAnalyst::FindFunctions(0x80000000, 0x80400000, &g_symbolDB);
|
||||||
|
|
|
@ -462,7 +462,7 @@ void CFrame::OnPluginGFX(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
CPluginManager::GetInstance().OpenConfig(
|
CPluginManager::GetInstance().OpenConfig(
|
||||||
GetHandle(),
|
GetHandle(),
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ void CFrame::OnPluginDSP(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
CPluginManager::GetInstance().OpenConfig(
|
CPluginManager::GetInstance().OpenConfig(
|
||||||
GetHandle(),
|
GetHandle(),
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,14 +480,14 @@ void CFrame::OnPluginPAD(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
CPluginManager::GetInstance().OpenConfig(
|
CPluginManager::GetInstance().OpenConfig(
|
||||||
GetHandle(),
|
GetHandle(),
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin.c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
void CFrame::OnPluginWiiMote(wxCommandEvent& WXUNUSED (event))
|
void CFrame::OnPluginWiiMote(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
CPluginManager::GetInstance().OpenConfig(
|
CPluginManager::GetInstance().OpenConfig(
|
||||||
GetHandle(),
|
GetHandle(),
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin.c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
#include "../resources/Flag_USA.xpm"
|
#include "../resources/Flag_USA.xpm"
|
||||||
#endif // USE_XPM_BITMAPS
|
#endif // USE_XPM_BITMAPS
|
||||||
|
|
||||||
/////////////////////////////////
|
|
||||||
int currentColumn ;
|
int currentColumn ;
|
||||||
bool operator < (const CISOFile &one, const CISOFile &other)
|
bool operator < (const CISOFile &one, const CISOFile &other)
|
||||||
{
|
{
|
||||||
|
@ -50,7 +49,6 @@ bool operator < (const CISOFile &one, const CISOFile &other)
|
||||||
default: return strcasecmp(one.GetName().c_str(), other.GetName().c_str()) < 0;
|
default: return strcasecmp(one.GetName().c_str(), other.GetName().c_str()) < 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/////////////////////////////////
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(CGameListCtrl, wxListCtrl)
|
BEGIN_EVENT_TABLE(CGameListCtrl, wxListCtrl)
|
||||||
|
|
||||||
|
@ -66,6 +64,7 @@ EVT_MENU(IDM_OPENCONTAININGFOLDER, CGameListCtrl::OnOpenContainingFolder)
|
||||||
EVT_MENU(IDM_SETDEFAULTGCM, CGameListCtrl::OnSetDefaultGCM)
|
EVT_MENU(IDM_SETDEFAULTGCM, CGameListCtrl::OnSetDefaultGCM)
|
||||||
EVT_MENU(IDM_FILESYSTEMVIEWER, CGameListCtrl::OnFilesystemViewer)
|
EVT_MENU(IDM_FILESYSTEMVIEWER, CGameListCtrl::OnFilesystemViewer)
|
||||||
EVT_MENU(IDM_COMPRESSGCM, CGameListCtrl::OnCompressGCM)
|
EVT_MENU(IDM_COMPRESSGCM, CGameListCtrl::OnCompressGCM)
|
||||||
|
EVT_MENU(IDM_DELETEGCM, CGameListCtrl::OnDeleteGCM)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
||||||
|
@ -465,16 +464,18 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event)
|
||||||
wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
|
wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
|
||||||
}
|
}
|
||||||
const CISOFile *selected_iso = GetSelectedISO();
|
const CISOFile *selected_iso = GetSelectedISO();
|
||||||
if (selected_iso) {
|
if (selected_iso)
|
||||||
|
{
|
||||||
std::string unique_id = selected_iso->GetUniqueID();
|
std::string unique_id = selected_iso->GetUniqueID();
|
||||||
wxMenu popupMenu;
|
wxMenu popupMenu;
|
||||||
std::string menu_text = StringFromFormat("Edit &patch file: %s.ini", unique_id.c_str());
|
std::string menu_text = StringFromFormat("Edit &patch file: %s.ini", unique_id.c_str());
|
||||||
popupMenu.Append(IDM_EDITPATCHFILE, wxString::FromAscii(menu_text.c_str())); //Pretty much everything in wxwidgets is a wxString, try to convert to those first!
|
popupMenu.Append(IDM_EDITPATCHFILE, wxString::FromAscii(menu_text.c_str())); //Pretty much everything in wxwidgets is a wxString, try to convert to those first!
|
||||||
popupMenu.Append(IDM_OPENCONTAININGFOLDER, wxString::FromAscii("Open &containing folder"));
|
popupMenu.Append(IDM_OPENCONTAININGFOLDER, wxString::FromAscii("Open &containing folder"));
|
||||||
popupMenu.Append(IDM_SETDEFAULTGCM, wxString::FromAscii("Set as &default ISO"));
|
|
||||||
popupMenu.Append(IDM_FILESYSTEMVIEWER, wxString::FromAscii("Open in ISO viewer/dumper"));
|
popupMenu.Append(IDM_FILESYSTEMVIEWER, wxString::FromAscii("Open in ISO viewer/dumper"));
|
||||||
|
popupMenu.Append(IDM_SETDEFAULTGCM, wxString::FromAscii("Set as &default ISO"));
|
||||||
|
popupMenu.AppendSeparator();
|
||||||
|
popupMenu.Append(IDM_DELETEGCM, wxString::FromAscii("&Delete ISO..."));
|
||||||
|
|
||||||
// F|RES: compression doesn't work and will be rewritten ... if it is fixed the gui is ready :D
|
|
||||||
if (selected_iso->IsCompressed())
|
if (selected_iso->IsCompressed())
|
||||||
popupMenu.Append(IDM_COMPRESSGCM, wxString::FromAscii("Decompress ISO... (UNTESTED)"));
|
popupMenu.Append(IDM_COMPRESSGCM, wxString::FromAscii("Decompress ISO... (UNTESTED)"));
|
||||||
else
|
else
|
||||||
|
@ -516,7 +517,7 @@ void CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event)) {
|
||||||
return;
|
return;
|
||||||
std::string path;
|
std::string path;
|
||||||
SplitPath(iso->GetFileName(), &path, 0, 0);
|
SplitPath(iso->GetFileName(), &path, 0, 0);
|
||||||
File::Explore(path);
|
File::Explore(path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
|
void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
|
||||||
|
@ -527,6 +528,16 @@ void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
|
||||||
SConfig::GetInstance().SaveSettings();
|
SConfig::GetInstance().SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event)) {
|
||||||
|
const CISOFile *iso = GetSelectedISO();
|
||||||
|
if (!iso)
|
||||||
|
return;
|
||||||
|
if (wxMessageBox("Are you sure you want to delete this file?", wxMessageBoxCaptionStr, wxYES_NO) == wxYES)
|
||||||
|
{
|
||||||
|
File::Delete(iso->GetFileName().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CGameListCtrl::OnFilesystemViewer(wxCommandEvent& WXUNUSED (event)) {
|
void CGameListCtrl::OnFilesystemViewer(wxCommandEvent& WXUNUSED (event)) {
|
||||||
const CISOFile *iso = GetSelectedISO();
|
const CISOFile *iso = GetSelectedISO();
|
||||||
if (!iso)
|
if (!iso)
|
||||||
|
@ -617,7 +628,7 @@ void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
|
||||||
if (!iso)
|
if (!iso)
|
||||||
return;
|
return;
|
||||||
std::string filename = "Patches/" + iso->GetUniqueID() + ".ini";
|
std::string filename = "Patches/" + iso->GetUniqueID() + ".ini";
|
||||||
if (!File::Exists(filename)) {
|
if (!File::Exists(filename.c_str())) {
|
||||||
if (AskYesNo("%s.ini does not exist. Do you want to create it?", iso->GetUniqueID().c_str())) {
|
if (AskYesNo("%s.ini does not exist. Do you want to create it?", iso->GetUniqueID().c_str())) {
|
||||||
FILE *f = fopen(filename.c_str(), "w");
|
FILE *f = fopen(filename.c_str(), "w");
|
||||||
fprintf(f, "# %s - %s\r\n\r\n", iso->GetUniqueID().c_str(), iso->GetName().c_str());
|
fprintf(f, "# %s - %s\r\n\r\n", iso->GetUniqueID().c_str(), iso->GetName().c_str());
|
||||||
|
@ -628,7 +639,7 @@ void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File::Launch(filename);
|
File::Launch(filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameListCtrl::OnSelected(wxListEvent& WXUNUSED (event))
|
void CGameListCtrl::OnSelected(wxListEvent& WXUNUSED (event))
|
||||||
|
|
|
@ -74,6 +74,7 @@ class CGameListCtrl : public wxListCtrl
|
||||||
void OnEditPatchFile(wxCommandEvent& event);
|
void OnEditPatchFile(wxCommandEvent& event);
|
||||||
void OnOpenContainingFolder(wxCommandEvent& event);
|
void OnOpenContainingFolder(wxCommandEvent& event);
|
||||||
void OnSetDefaultGCM(wxCommandEvent& event);
|
void OnSetDefaultGCM(wxCommandEvent& event);
|
||||||
|
void OnDeleteGCM(wxCommandEvent& event);
|
||||||
void OnCompressGCM(wxCommandEvent& event);
|
void OnCompressGCM(wxCommandEvent& event);
|
||||||
void OnFilesystemViewer(wxCommandEvent& event);
|
void OnFilesystemViewer(wxCommandEvent& event);
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ enum
|
||||||
IDM_EDITPATCHFILE,
|
IDM_EDITPATCHFILE,
|
||||||
IDM_OPENCONTAININGFOLDER,
|
IDM_OPENCONTAININGFOLDER,
|
||||||
IDM_SETDEFAULTGCM,
|
IDM_SETDEFAULTGCM,
|
||||||
|
IDM_DELETEGCM,
|
||||||
IDM_FILESYSTEMVIEWER,
|
IDM_FILESYSTEMVIEWER,
|
||||||
IDM_COMPRESSGCM,
|
IDM_COMPRESSGCM,
|
||||||
IDM_PLUGIN_OPTIONS,
|
IDM_PLUGIN_OPTIONS,
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
#include "FileUtil.h"
|
||||||
#include "ISOFile.h"
|
#include "ISOFile.h"
|
||||||
|
|
||||||
#include "VolumeCreator.h"
|
#include "VolumeCreator.h"
|
||||||
|
@ -44,7 +45,8 @@ CISOFile::CISOFile(const std::string& _rFileName)
|
||||||
{
|
{
|
||||||
m_Name = _rFileName;
|
m_Name = _rFileName;
|
||||||
m_Country = pVolume->GetCountry();
|
m_Country = pVolume->GetCountry();
|
||||||
m_FileSize = pVolume->GetSize();
|
m_FileSize = File::GetSize(_rFileName.c_str());
|
||||||
|
m_VolumeSize = pVolume->GetSize();
|
||||||
m_Name = pVolume->GetName();
|
m_Name = pVolume->GetName();
|
||||||
m_UniqueID = pVolume->GetUniqueID();
|
m_UniqueID = pVolume->GetUniqueID();
|
||||||
m_BlobCompressed = DiscIO::IsCompressedBlob(_rFileName.c_str());
|
m_BlobCompressed = DiscIO::IsCompressedBlob(_rFileName.c_str());
|
||||||
|
|
|
@ -23,32 +23,22 @@
|
||||||
class CISOFile
|
class CISOFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CISOFile(const std::string& _rFileName);
|
CISOFile(const std::string& _rFileName);
|
||||||
~CISOFile();
|
~CISOFile();
|
||||||
|
|
||||||
bool IsValid() const {return(m_Valid);}
|
bool IsValid() const {return m_Valid;}
|
||||||
|
const std::string& GetFileName() const {return m_FileName;}
|
||||||
const std::string& GetFileName() const {return(m_FileName);}
|
const std::string& GetName() const {return m_Name;}
|
||||||
|
const std::string& GetCompany() const {return m_Company;}
|
||||||
const std::string& GetName() const {return(m_Name);}
|
const std::string& GetDescription() const {return m_Description;}
|
||||||
|
const std::string& GetUniqueID() const {return m_UniqueID;}
|
||||||
const std::string& GetCompany() const {return(m_Company);}
|
DiscIO::IVolume::ECountry GetCountry() const {return m_Country;}
|
||||||
|
bool IsCompressed() const {return m_BlobCompressed;}
|
||||||
const std::string& GetDescription() const {return(m_Description);}
|
u64 GetFileSize() const {return m_FileSize;}
|
||||||
|
u64 GetVolumeSize() const {return m_VolumeSize;}
|
||||||
const std::string& GetUniqueID() const {return(m_UniqueID);}
|
const wxImage& GetImage() const {return m_Image;}
|
||||||
|
|
||||||
DiscIO::IVolume::ECountry GetCountry() const {return(m_Country);}
|
|
||||||
|
|
||||||
bool IsCompressed() const {return(m_BlobCompressed); }
|
|
||||||
|
|
||||||
u64 GetFileSize() const {return(m_FileSize);}
|
|
||||||
|
|
||||||
const wxImage& GetImage() const {return(m_Image);}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string m_FileName;
|
std::string m_FileName;
|
||||||
std::string m_Name;
|
std::string m_Name;
|
||||||
std::string m_Company;
|
std::string m_Company;
|
||||||
|
@ -56,6 +46,7 @@ class CISOFile
|
||||||
std::string m_UniqueID;
|
std::string m_UniqueID;
|
||||||
|
|
||||||
u64 m_FileSize;
|
u64 m_FileSize;
|
||||||
|
u64 m_VolumeSize;
|
||||||
|
|
||||||
DiscIO::IVolume::ECountry m_Country;
|
DiscIO::IVolume::ECountry m_Country;
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,7 @@ CPluginManager::~CPluginManager()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
void
|
void CPluginManager::ScanForPlugins(wxWindow* _wxWindow)
|
||||||
CPluginManager::ScanForPlugins(wxWindow* _wxWindow)
|
|
||||||
{
|
{
|
||||||
m_PluginInfos.clear();
|
m_PluginInfos.clear();
|
||||||
|
|
||||||
|
@ -91,7 +90,7 @@ CPluginManager::ScanForPlugins(wxWindow* _wxWindow)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginInfo PluginInfo(orig_name);
|
CPluginInfo PluginInfo(orig_name.c_str());
|
||||||
if (PluginInfo.IsValid())
|
if (PluginInfo.IsValid())
|
||||||
{
|
{
|
||||||
m_PluginInfos.push_back(PluginInfo);
|
m_PluginInfos.push_back(PluginInfo);
|
||||||
|
@ -100,11 +99,9 @@ CPluginManager::ScanForPlugins(wxWindow* _wxWindow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPluginManager::OpenAbout(void* _Parent, const char *_rFilename)
|
||||||
void
|
|
||||||
CPluginManager::OpenAbout(void* _Parent, const std::string& _rFilename)
|
|
||||||
{
|
{
|
||||||
if (Common::CPlugin::Load(_rFilename.c_str()))
|
if (Common::CPlugin::Load(_rFilename))
|
||||||
{
|
{
|
||||||
Common::CPlugin::About((HWND)_Parent);
|
Common::CPlugin::About((HWND)_Parent);
|
||||||
Common::CPlugin::Release();
|
Common::CPlugin::Release();
|
||||||
|
@ -112,40 +109,34 @@ CPluginManager::OpenAbout(void* _Parent, const std::string& _rFilename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename)
|
||||||
CPluginManager::OpenConfig(void* _Parent, const std::string& _rFilename)
|
|
||||||
{
|
{
|
||||||
if (Common::CPlugin::Load(_rFilename.c_str()))
|
if (Common::CPlugin::Load(_rFilename))
|
||||||
{
|
{
|
||||||
Common::CPlugin::Config((HWND)_Parent);
|
Common::CPlugin::Config((HWND)_Parent);
|
||||||
Common::CPlugin::Release();
|
Common::CPlugin::Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CPluginInfo::CPluginInfo(const char *_rFileName)
|
||||||
CPluginInfo::CPluginInfo(const std::string& _rFileName)
|
|
||||||
: m_FileName(_rFileName)
|
: m_FileName(_rFileName)
|
||||||
, m_Valid(false)
|
, m_Valid(false)
|
||||||
{
|
{
|
||||||
if (Common::CPlugin::Load(_rFileName.c_str()))
|
if (Common::CPlugin::Load(_rFileName))
|
||||||
{
|
{
|
||||||
if (Common::CPlugin::GetInfo(m_PluginInfo))
|
if (Common::CPlugin::GetInfo(m_PluginInfo))
|
||||||
{
|
|
||||||
m_Valid = true;
|
m_Valid = true;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
PanicAlert("Could not get info about plugin %s", _rFileName);
|
||||||
PanicAlert("Could not get info about plugin %s", _rFileName.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
Common::CPlugin::Release();
|
Common::CPlugin::Release();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!File::Exists(_rFileName)) {
|
if (!File::Exists(_rFileName)) {
|
||||||
PanicAlert("Could not load plugin %s - file does not exist", _rFileName.c_str());
|
PanicAlert("Could not load plugin %s - file does not exist", _rFileName);
|
||||||
} else {
|
} else {
|
||||||
PanicAlert("Failed to load plugin %s - unknown error.\n", _rFileName.c_str());
|
PanicAlert("Failed to load plugin %s - unknown error.\n", _rFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,24 +23,14 @@
|
||||||
class CPluginInfo
|
class CPluginInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
CPluginInfo(const char *_rFileName);
|
||||||
CPluginInfo(const std::string& _rFileName);
|
|
||||||
|
|
||||||
bool IsValid() const {return(m_Valid);}
|
bool IsValid() const {return(m_Valid);}
|
||||||
|
|
||||||
|
|
||||||
const PLUGIN_INFO& GetPluginInfo() const {return(m_PluginInfo);}
|
const PLUGIN_INFO& GetPluginInfo() const {return(m_PluginInfo);}
|
||||||
|
|
||||||
|
|
||||||
const std::string& GetFileName() const {return(m_FileName);}
|
const std::string& GetFileName() const {return(m_FileName);}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
PLUGIN_INFO m_PluginInfo;
|
PLUGIN_INFO m_PluginInfo;
|
||||||
|
|
||||||
std::string m_FileName;
|
std::string m_FileName;
|
||||||
|
|
||||||
bool m_Valid;
|
bool m_Valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,30 +39,19 @@ typedef std::vector<CPluginInfo>CPluginInfos;
|
||||||
class CPluginManager
|
class CPluginManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static CPluginManager& GetInstance() {return(m_Instance);}
|
static CPluginManager& GetInstance() {return(m_Instance);}
|
||||||
|
|
||||||
|
|
||||||
void ScanForPlugins(wxWindow* _wxWindow);
|
void ScanForPlugins(wxWindow* _wxWindow);
|
||||||
|
void OpenAbout(void* _Parent, const char *_rFilename);
|
||||||
void OpenAbout(void* _Parent, const std::string& _rFilename);
|
void OpenConfig(void* _Parent, const char *_rFilename);
|
||||||
|
|
||||||
void OpenConfig(void* _Parent, const std::string& _rFilename);
|
|
||||||
|
|
||||||
|
|
||||||
const CPluginInfos& GetPluginInfos() {return(m_PluginInfos);}
|
const CPluginInfos& GetPluginInfos() {return(m_PluginInfos);}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static CPluginManager m_Instance;
|
static CPluginManager m_Instance;
|
||||||
|
|
||||||
bool m_Initialized;
|
bool m_Initialized;
|
||||||
|
|
||||||
CPluginInfos m_PluginInfos;
|
CPluginInfos m_PluginInfos;
|
||||||
|
|
||||||
CPluginManager();
|
CPluginManager();
|
||||||
|
|
||||||
~CPluginManager();
|
~CPluginManager();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -252,9 +252,7 @@ void CPluginOptions::CallConfig(wxChoice* _pChoice)
|
||||||
const CPluginInfo* pInfo = static_cast<CPluginInfo*>(_pChoice->GetClientData(Index));
|
const CPluginInfo* pInfo = static_cast<CPluginInfo*>(_pChoice->GetClientData(Index));
|
||||||
|
|
||||||
if (pInfo != NULL)
|
if (pInfo != NULL)
|
||||||
{
|
CPluginManager::GetInstance().OpenConfig((HWND) this->GetHandle(), pInfo->GetFileName().c_str());
|
||||||
CPluginManager::GetInstance().OpenConfig((HWND) this->GetHandle(), pInfo->GetFileName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,9 +266,7 @@ void CPluginOptions::CallAbout(wxChoice* _pChoice)
|
||||||
const CPluginInfo* pInfo = static_cast<CPluginInfo*>(_pChoice->GetClientData(Index));
|
const CPluginInfo* pInfo = static_cast<CPluginInfo*>(_pChoice->GetClientData(Index));
|
||||||
|
|
||||||
if (pInfo != NULL)
|
if (pInfo != NULL)
|
||||||
{
|
CPluginManager::GetInstance().OpenAbout((HWND) this->GetHandle(), pInfo->GetFileName().c_str());
|
||||||
CPluginManager::GetInstance().OpenAbout((HWND) this->GetHandle(), pInfo->GetFileName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,4 +301,3 @@ bool CPluginOptions::GetFilename(wxChoice* _pChoice, std::string& _rFilename)
|
||||||
|
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue