Merge pull request #5446 from JosJuice/remove-volumecreator

DiscIO: Remove VolumeCreator
This commit is contained in:
Leo Lam 2017-05-19 21:03:58 +02:00 committed by GitHub
commit f32482b337
19 changed files with 57 additions and 142 deletions

View File

@ -37,7 +37,6 @@
#include "DiscIO/Enums.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
#include "UICommon/UICommon.h"

View File

@ -37,7 +37,6 @@
#include "DiscIO/Enums.h"
#include "DiscIO/NANDContentLoader.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
// Inserts a disc into the emulated disc drive and returns a pointer to it.
// The returned pointer must only be used while we are still booting,

View File

@ -36,7 +36,6 @@
#include "DiscIO/Enums.h"
#include "DiscIO/NANDContentLoader.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
SConfig* SConfig::m_Instance;

View File

@ -32,7 +32,6 @@
#include "DiscIO/Enums.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
#include "DiscIO/VolumeWiiCrypted.h"
// The minimum time it takes for the DVD drive to process a command (in

View File

@ -13,7 +13,6 @@ set(SRCS
NANDImporter.cpp
TGCBlob.cpp
Volume.cpp
VolumeCreator.cpp
VolumeDirectory.cpp
VolumeGC.cpp
VolumeWad.cpp

View File

@ -48,7 +48,6 @@
<ClCompile Include="NANDImporter.cpp" />
<ClCompile Include="TGCBlob.cpp" />
<ClCompile Include="Volume.cpp" />
<ClCompile Include="VolumeCreator.cpp" />
<ClCompile Include="VolumeDirectory.cpp" />
<ClCompile Include="VolumeGC.cpp" />
<ClCompile Include="VolumeWad.cpp" />
@ -70,7 +69,6 @@
<ClInclude Include="NANDImporter.h" />
<ClInclude Include="TGCBlob.h" />
<ClInclude Include="Volume.h" />
<ClInclude Include="VolumeCreator.h" />
<ClInclude Include="VolumeDirectory.h" />
<ClInclude Include="VolumeGC.h" />
<ClInclude Include="VolumeWad.h" />

View File

@ -54,9 +54,6 @@
<ClCompile Include="WbfsBlob.cpp">
<Filter>Volume\Blob</Filter>
</ClCompile>
<ClCompile Include="VolumeCreator.cpp">
<Filter>Volume</Filter>
</ClCompile>
<ClCompile Include="VolumeDirectory.cpp">
<Filter>Volume</Filter>
</ClCompile>
@ -119,9 +116,6 @@
<ClInclude Include="Volume.h">
<Filter>Volume</Filter>
</ClInclude>
<ClInclude Include="VolumeCreator.h">
<Filter>Volume</Filter>
</ClInclude>
<ClInclude Include="VolumeDirectory.h">
<Filter>Volume</Filter>
</ClInclude>

View File

@ -16,7 +16,6 @@
#include "DiscIO/DiscScrubber.h"
#include "DiscIO/Filesystem.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
namespace DiscIO
{

View File

@ -6,6 +6,7 @@
#include <algorithm>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
@ -17,7 +18,12 @@
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
#include "DiscIO/VolumeDirectory.h"
#include "DiscIO/VolumeGC.h"
#include "DiscIO/VolumeWad.h"
#include "DiscIO/VolumeWiiCrypted.h"
namespace DiscIO
{
@ -76,4 +82,49 @@ std::map<Language, std::string> IVolume::ReadWiiNames(const std::vector<u8>& dat
}
return names;
}
std::unique_ptr<IVolume> CreateVolumeFromFilename(const std::string& filename)
{
std::unique_ptr<IBlobReader> reader(CreateBlobReader(filename));
if (reader == nullptr)
return nullptr;
CBlobBigEndianReader be_reader(*reader);
// Check for Wii
u32 wii_magic = 0;
be_reader.ReadSwapped(0x18, &wii_magic);
u32 wii_container_magic = 0;
be_reader.ReadSwapped(0x60, &wii_container_magic);
if (wii_magic == 0x5D1C9EA3 && wii_container_magic != 0)
return std::make_unique<CVolumeGC>(std::move(reader));
if (wii_magic == 0x5D1C9EA3 && wii_container_magic == 0)
return std::make_unique<CVolumeWiiCrypted>(std::move(reader));
// Check for WAD
// 0x206962 for boot2 wads
u32 wad_magic = 0;
be_reader.ReadSwapped(0x02, &wad_magic);
if (wad_magic == 0x00204973 || wad_magic == 0x00206962)
return std::make_unique<CVolumeWAD>(std::move(reader));
// Check for GC
u32 gc_magic = 0;
be_reader.ReadSwapped(0x1C, &gc_magic);
if (gc_magic == 0xC2339F3D)
return std::make_unique<CVolumeGC>(std::move(reader));
// No known magic words found
return nullptr;
}
std::unique_ptr<IVolume> CreateVolumeFromDirectory(const std::string& directory, bool is_wii,
const std::string& apploader,
const std::string& dol)
{
if (CVolumeDirectory::IsValidDirectory(directory))
return std::make_unique<CVolumeDirectory>(directory, is_wii, apploader, dol);
return nullptr;
}
} // namespace

View File

@ -7,6 +7,7 @@
#include <cstring>
#include <limits>
#include <map>
#include <memory>
#include <string>
#include <vector>
@ -112,4 +113,9 @@ protected:
static const size_t NAMES_TOTAL_BYTES = NAME_BYTES_LENGTH * NUMBER_OF_LANGUAGES;
};
std::unique_ptr<IVolume> CreateVolumeFromFilename(const std::string& filename);
std::unique_ptr<IVolume> CreateVolumeFromDirectory(const std::string& directory, bool is_wii,
const std::string& apploader = "",
const std::string& dol = "");
} // namespace

View File

@ -1,102 +0,0 @@
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cstddef>
#include <cstring>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
#include "DiscIO/VolumeDirectory.h"
#include "DiscIO/VolumeGC.h"
#include "DiscIO/VolumeWad.h"
#include "DiscIO/VolumeWiiCrypted.h"
namespace DiscIO
{
enum EDiscType
{
DISC_TYPE_UNK,
DISC_TYPE_WII,
DISC_TYPE_WII_CONTAINER,
DISC_TYPE_GC,
DISC_TYPE_WAD
};
EDiscType GetDiscType(IBlobReader& _rReader);
std::unique_ptr<IVolume> CreateVolumeFromFilename(const std::string& filename)
{
std::unique_ptr<IBlobReader> reader(CreateBlobReader(filename));
if (reader == nullptr)
return nullptr;
switch (GetDiscType(*reader))
{
case DISC_TYPE_WII:
case DISC_TYPE_GC:
return std::make_unique<CVolumeGC>(std::move(reader));
case DISC_TYPE_WAD:
return std::make_unique<CVolumeWAD>(std::move(reader));
case DISC_TYPE_WII_CONTAINER:
return std::make_unique<CVolumeWiiCrypted>(std::move(reader));
case DISC_TYPE_UNK:
return nullptr;
}
return nullptr;
}
std::unique_ptr<IVolume> CreateVolumeFromDirectory(const std::string& directory, bool is_wii,
const std::string& apploader,
const std::string& dol)
{
if (CVolumeDirectory::IsValidDirectory(directory))
return std::make_unique<CVolumeDirectory>(directory, is_wii, apploader, dol);
return nullptr;
}
EDiscType GetDiscType(IBlobReader& _rReader)
{
CBlobBigEndianReader Reader(_rReader);
// Check for Wii
u32 WiiMagic = 0;
Reader.ReadSwapped(0x18, &WiiMagic);
u32 WiiContainerMagic = 0;
Reader.ReadSwapped(0x60, &WiiContainerMagic);
if (WiiMagic == 0x5D1C9EA3 && WiiContainerMagic != 0)
return DISC_TYPE_WII;
if (WiiMagic == 0x5D1C9EA3 && WiiContainerMagic == 0)
return DISC_TYPE_WII_CONTAINER;
// Check for WAD
// 0x206962 for boot2 wads
u32 WADMagic = 0;
Reader.ReadSwapped(0x02, &WADMagic);
if (WADMagic == 0x00204973 || WADMagic == 0x00206962)
return DISC_TYPE_WAD;
// Check for GC
u32 GCMagic = 0;
Reader.ReadSwapped(0x1C, &GCMagic);
if (GCMagic == 0xC2339F3D)
return DISC_TYPE_GC;
// No known magic words found
return DISC_TYPE_UNK;
}
} // namespace

View File

@ -1,19 +0,0 @@
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <string>
namespace DiscIO
{
class IVolume;
std::unique_ptr<IVolume> CreateVolumeFromFilename(const std::string& filename);
std::unique_ptr<IVolume> CreateVolumeFromDirectory(const std::string& directory, bool is_wii,
const std::string& apploader = "",
const std::string& dol = "");
} // namespace

View File

@ -25,7 +25,6 @@
#include "DiscIO/Enums.h"
#include "DiscIO/Filesystem.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
namespace DiscIO
{

View File

@ -19,7 +19,6 @@
#include "DiscIO/Enums.h"
#include "DiscIO/NANDContentLoader.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
#include "DolphinQt2/GameList/GameFile.h"
#include "DolphinQt2/Resources.h"
#include "DolphinQt2/Settings.h"

View File

@ -54,7 +54,6 @@
#include "DiscIO/NANDContentLoader.h"
#include "DiscIO/NANDImporter.h"
#include "DiscIO/VolumeCreator.h"
#include "DiscIO/VolumeWad.h"
#include "DolphinWX/AboutDolphin.h"

View File

@ -53,7 +53,6 @@
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
#include "DolphinWX/Frame.h"
#include "DolphinWX/GameListCtrl.h"
#include "DolphinWX/Globals.h"

View File

@ -33,7 +33,6 @@
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
#include "DolphinWX/ISOFile.h"
#include "DolphinWX/WxUtils.h"

View File

@ -24,7 +24,6 @@
#include "DiscIO/Enums.h"
#include "DiscIO/Filesystem.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
#include "DolphinWX/ISOFile.h"
#include "DolphinWX/WxUtils.h"

View File

@ -46,7 +46,6 @@
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
#include "DolphinWX/Cheats/ActionReplayCodesPanel.h"
#include "DolphinWX/Cheats/GeckoCodeDiag.h"
#include "DolphinWX/Config/ConfigMain.h"