Remove duplicate MemoryCard implementation.

This commit is contained in:
Jean-Philip Desjardins 2018-01-03 08:21:44 -05:00
parent 0bd4243e3e
commit e28622d7df
8 changed files with 5 additions and 106 deletions

View file

@ -2,7 +2,7 @@
#include <memory>
#include <boost/filesystem/path.hpp>
#include "../saves/Save.h"
#include "Save.h"
class CMemoryCard
{

View file

@ -1,71 +0,0 @@
#include <boost/filesystem/operations.hpp>
#include "MemoryCard.h"
namespace filesystem = boost::filesystem;
CMemoryCard::CMemoryCard(const filesystem::path& basePath)
: m_basePath(basePath)
{
ScanSaves();
}
CMemoryCard::~CMemoryCard()
{
}
size_t CMemoryCard::GetSaveCount() const
{
return m_saves.size();
}
const CSave* CMemoryCard::GetSaveByIndex(size_t index) const
{
return m_saves[index].get();
}
filesystem::path CMemoryCard::GetBasePath() const
{
return m_basePath;
}
void CMemoryCard::RefreshContents()
{
m_saves.clear();
ScanSaves();
}
void CMemoryCard::ScanSaves()
{
try
{
filesystem::directory_iterator endIterator;
for(filesystem::directory_iterator elementIterator(m_basePath);
elementIterator != endIterator; elementIterator++)
{
filesystem::path element(*elementIterator);
if(filesystem::is_directory(element))
{
filesystem::path iconSysPath = element / "icon.sys";
//Check if 'icon.sys' exists in this directory
if(filesystem::exists(iconSysPath))
{
try
{
m_saves.push_back(std::make_shared<CSave>(element));
}
catch(const std::exception& exception)
{
printf("Failed to create save: %s\r\n", exception.what());
}
}
}
}
}
catch(const std::exception& exception)
{
printf("Exception caught in CMemoryCard::ScanSaves: %s\r\n", exception.what());
}
}

View file

@ -1,29 +0,0 @@
#pragma once
#include <memory>
#include <boost/filesystem/path.hpp>
#include "../saves/Save.h"
class CMemoryCard
{
public:
typedef std::shared_ptr<CSave> SavePtr;
typedef std::vector<SavePtr> SaveList;
CMemoryCard(const boost::filesystem::path&);
virtual ~CMemoryCard();
size_t GetSaveCount() const;
const CSave* GetSaveByIndex(size_t) const;
boost::filesystem::path GetBasePath() const;
void RefreshContents();
private:
void ScanSaves();
SaveList m_saves;
boost::filesystem::path m_basePath;
};

View file

@ -6,7 +6,7 @@
#include <boost/filesystem.hpp>
#include "saves/SaveImporter.h"
#include "saves/SaveExporter.h"
#include "MemoryCard.h"
#include "saves/MemoryCard.h"
namespace Ui {
class MemoryCardManagerDialog;

View file

@ -4,10 +4,10 @@
#include "win32/ComboBox.h"
#include "win32/Button.h"
#include "win32/Layouts.h"
#include "MemoryCard.h"
#include "MemoryCardView.h"
#include "SaveView.h"
#include "../saves/SaveImporter.h"
#include "../saves/MemoryCard.h"
class CMcManagerWnd : public Framework::Win32::CModalWindow, public boost::signals2::trackable
{

View file

@ -4,9 +4,9 @@
#include <map>
#include "win32/Window.h"
#include "win32/ClientDeviceContext.h"
#include "MemoryCard.h"
#include "IconMesh.h"
#include "../MailBox.h"
#include "../saves/MemoryCard.h"
class CMemoryCardView : public Framework::Win32::CWindow
{

View file

@ -537,6 +537,7 @@ set(COMMON_SRC_FILES
../Source/saves/Icon.h
../Source/saves/MaxSaveImporter.cpp
../Source/saves/MaxSaveImporter.h
../Source/saves/MemoryCard.cpp
../Source/saves/PsuSaveImporter.cpp
../Source/saves/PsuSaveImporter.h
../Source/saves/Save.cpp
@ -613,7 +614,6 @@ if(TARGET_PLATFORM_UNIX)
../Source/ui_unix/settingsdialog.cpp
../Source/ui_unix/openglwindow.cpp
../Source/ui_unix/memorycardmanagerdialog.cpp
../Source/ui_unix/MemoryCard.cpp
../Source/ui_unix/vfsmanagerdialog.cpp
../Source/ui_unix/vfsmodel.cpp
../Source/ui_unix/vfsdiscselectordialog.cpp
@ -965,7 +965,6 @@ if(TARGET_PLATFORM_WIN32)
../Source/ui_win32/Main.cpp
../Source/ui_win32/MainWindow.cpp
../Source/ui_win32/McManagerWnd.cpp
../Source/ui_win32/MemoryCard.cpp
../Source/ui_win32/MemoryCardView.cpp
../Source/ui_win32/MemoryView.cpp
../Source/ui_win32/MemoryViewMIPS.cpp