diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index fc2c69f7e5..06cde64c6c 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -1,3 +1,4 @@ +#include #include "stdafx.h" #include "VFS.h" #include "Emu/HDD/HDD.h" @@ -260,35 +261,35 @@ void VFS::Init(const wxString& path) { UnMountAll(); - Array entries; + std::vector entries; SaveLoadDevices(entries, true); - for(uint i=0; i& res, bool is_load) +void VFS::SaveLoadDevices(std::vector& res, bool is_load) { IniEntry entries_count; entries_count.Init("count", "VFSManager"); @@ -300,61 +301,25 @@ void VFS::SaveLoadDevices(Array& res, bool is_load) if(!count) { - int idx; - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_hdd0/"; - res[idx].mount = "/dev_hdd0/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_hdd1/"; - res[idx].mount = "/dev_hdd1/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_flash/"; - res[idx].mount = "/dev_flash/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_usb000/"; - res[idx].mount = "/dev_usb000/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_usb000/"; - res[idx].mount = "/dev_usb/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(GameDir)"; - res[idx].mount = "/app_home/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(GameDir)/../"; - res[idx].mount = "/dev_bdvd/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = ""; - res[idx].mount = "/host_root/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(GameDir)"; - res[idx].mount = "/"; - res[idx].device = vfsDevice_LocalFile; + res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_hdd0/", "/dev_hdd0/"); + res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_hdd1/", "/dev_hdd1/"); + res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_flash/", "/dev_flash/"); + res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_usb000/", "/dev_usb000/"); + res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_usb000/", "/dev_usb/"); + res.emplace_back(vfsDevice_LocalFile, "$(GameDir)", "/app_home/"); + res.emplace_back(vfsDevice_LocalFile, "$(GameDir)/../", "/dev_bdvd/"); + res.emplace_back(vfsDevice_LocalFile, "", "/host_root/"); + res.emplace_back(vfsDevice_LocalFile, "$(GameDir)", "/"); return; } - res.SetCount(count); + res.resize(count); } else { - count = res.GetCount(); - entries_count.SaveValue(res.GetCount()); + count = res.size(); + entries_count.SaveValue(res.size()); } for(int i=0; i& res, bool is_load) if(is_load) { - new (res + i) VFSManagerEntry(); + res[i] = VFSManagerEntry(); res[i].path = strdup(entry_path.LoadValue(wxEmptyString).c_str()); res[i].device_path = strdup(entry_device_path.LoadValue(wxEmptyString).c_str()); res[i].mount = strdup(entry_mount.LoadValue(wxEmptyString).c_str()); diff --git a/rpcs3/Emu/FS/VFS.h b/rpcs3/Emu/FS/VFS.h index 8876726bb8..93eba76873 100644 --- a/rpcs3/Emu/FS/VFS.h +++ b/rpcs3/Emu/FS/VFS.h @@ -1,4 +1,6 @@ #pragma once + +#include #include "vfsDevice.h" enum vfsDeviceType @@ -15,10 +17,10 @@ static const char* vfsDeviceTypeNames[] = struct VFSManagerEntry { - char* device_path; - char* path; - char* mount; vfsDeviceType device; + const char* device_path; + const char* path; + const char* mount; VFSManagerEntry() : device(vfsDevice_LocalFile) @@ -27,6 +29,15 @@ struct VFSManagerEntry , mount("") { } + + VFSManagerEntry(const vfsDeviceType& device, const char* path, const char* mount) + : device(device) + , device_path("") + , path(path) + , mount(mount) + + { + } }; struct VFS @@ -51,5 +62,5 @@ struct VFS vfsDevice* GetDeviceLocal(const wxString& local_path, wxString& path) const; void Init(const wxString& path); - void SaveLoadDevices(Array& res, bool is_load); + void SaveLoadDevices(std::vector& res, bool is_load); }; \ No newline at end of file diff --git a/rpcs3/Gui/VFSManager.cpp b/rpcs3/Gui/VFSManager.cpp index 9b61daf0c5..594063645a 100644 --- a/rpcs3/Gui/VFSManager.cpp +++ b/rpcs3/Gui/VFSManager.cpp @@ -2,15 +2,15 @@ #include "VFSManager.h" VFSEntrySettingsDialog::VFSEntrySettingsDialog(wxWindow* parent, VFSManagerEntry& entry) - : wxDialog(parent, wxID_ANY, "Mount configuration", wxDefaultPosition) + : wxDialog(parent, wxID_ANY, "Mount configuration") , m_entry(entry) { - m_tctrl_dev_path = new wxTextCtrl(this, wxID_ANY); - m_btn_select_dev_path = new wxButton(this, wxID_ANY, "..."); - m_tctrl_path = new wxTextCtrl(this, wxID_ANY); - m_btn_select_path = new wxButton(this, wxID_ANY, "..."); - m_tctrl_mount = new wxTextCtrl(this, wxID_ANY); - m_ch_type = new wxChoice(this, wxID_ANY); + m_tctrl_dev_path = new wxTextCtrl(this, wxID_ANY); + m_btn_select_dev_path = new wxButton(this, wxID_ANY, "..."); + m_tctrl_path = new wxTextCtrl(this, wxID_ANY); + m_btn_select_path = new wxButton(this, wxID_ANY, "..."); + m_tctrl_mount = new wxTextCtrl(this, wxID_ANY); + m_ch_type = new wxChoice(this, wxID_ANY); wxBoxSizer& s_type(*new wxBoxSizer(wxHORIZONTAL)); s_type.Add(m_ch_type, 1, wxEXPAND); @@ -48,10 +48,10 @@ VFSEntrySettingsDialog::VFSEntrySettingsDialog(wxWindow* parent, VFSManagerEntry m_ch_type->Append(i); } - Connect(m_ch_type->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectType)); - Connect(m_btn_select_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectPath)); - Connect(m_btn_select_dev_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectDevPath)); - Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnOk)); + Connect(m_ch_type->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectType)); + Connect(m_btn_select_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectPath)); + Connect(m_btn_select_dev_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectDevPath)); + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnOk)); m_tctrl_dev_path->SetValue(m_entry.device_path); m_tctrl_path->SetValue(m_entry.path); @@ -111,7 +111,7 @@ enum }; VFSManagerDialog::VFSManagerDialog(wxWindow* parent) - : wxDialog(parent, wxID_ANY, "Virtual File System Manager", wxDefaultPosition) + : wxDialog(parent, wxID_ANY, "Virtual File System Manager") { m_list = new wxListView(this); @@ -126,11 +126,11 @@ VFSManagerDialog::VFSManagerDialog(wxWindow* parent) m_list->InsertColumn(2, "Path to Device"); m_list->InsertColumn(3, "Device"); - Connect(m_list->GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxCommandEventHandler(VFSManagerDialog::OnEntryConfig)); - Connect(m_list->GetId(), wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(VFSManagerDialog::OnRightClick)); - Connect(id_add, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnAdd)); - Connect(id_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnRemove)); - Connect(id_config, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnEntryConfig)); + Connect(m_list->GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxCommandEventHandler(VFSManagerDialog::OnEntryConfig)); + Connect(m_list->GetId(), wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(VFSManagerDialog::OnRightClick)); + Connect(id_add, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnAdd)); + Connect(id_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnRemove)); + Connect(id_config, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnEntryConfig)); Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VFSManagerDialog::OnClose)); LoadEntries(); @@ -141,7 +141,7 @@ void VFSManagerDialog::UpdateList() { m_list->Freeze(); m_list->DeleteAllItems(); - for(uint i=0; iInsertItem(i, m_entries[i].mount); m_list->SetItem(i, 1, m_entries[i].path); @@ -171,18 +171,19 @@ void VFSManagerDialog::OnRightClick(wxCommandEvent& event) int idx = m_list->GetFirstSelected(); menu->Append(id_add, "Add"); - menu->Append(id_remove, "Remove")->Enable(idx != wxNOT_FOUND); + menu->Append(id_remove, "Remove")->Enable(idx != wxNOT_FOUND); menu->AppendSeparator(); - menu->Append(id_config, "Config")->Enable(idx != wxNOT_FOUND); + menu->Append(id_config, "Config")->Enable(idx != wxNOT_FOUND); PopupMenu( menu ); } void VFSManagerDialog::OnAdd(wxCommandEvent& event) { - u32 idx = m_entries.Move(new VFSManagerEntry()); + m_entries.emplace_back(VFSManagerEntry()); UpdateList(); + u32 idx = m_entries.size() - 1; for(int i=0; iGetItemCount(); ++i) { m_list->SetItemState(i, i == idx ? wxLIST_STATE_SELECTED : ~wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); @@ -196,7 +197,7 @@ void VFSManagerDialog::OnRemove(wxCommandEvent& event) { for(int sel = m_list->GetNextSelected(-1), offs = 0; sel != wxNOT_FOUND; sel = m_list->GetNextSelected(sel), --offs) { - m_entries.RemoveAt(sel + offs); + m_entries.erase(m_entries.begin() + (sel + offs)); } UpdateList(); @@ -210,7 +211,7 @@ void VFSManagerDialog::OnClose(wxCloseEvent& event) void VFSManagerDialog::LoadEntries() { - m_entries.Clear(); + m_entries.clear(); Emu.GetVFS().SaveLoadDevices(m_entries, true); } diff --git a/rpcs3/Gui/VFSManager.h b/rpcs3/Gui/VFSManager.h index e46f4911af..aaff731a8d 100644 --- a/rpcs3/Gui/VFSManager.h +++ b/rpcs3/Gui/VFSManager.h @@ -1,5 +1,7 @@ #pragma once +#include + class VFSEntrySettingsDialog : public wxDialog { wxTextCtrl* m_tctrl_dev_path; @@ -21,7 +23,7 @@ public: class VFSManagerDialog : public wxDialog { wxListView* m_list; - Array m_entries; + std::vector m_entries; public: VFSManagerDialog(wxWindow* parent);