DiscIO: Add a blob reader for Volume files
This commit is contained in:
parent
ca0438e26d
commit
eb1ba4b0e9
|
@ -15,6 +15,7 @@ set(SRCS
|
||||||
NANDImporter.cpp
|
NANDImporter.cpp
|
||||||
TGCBlob.cpp
|
TGCBlob.cpp
|
||||||
Volume.cpp
|
Volume.cpp
|
||||||
|
VolumeFileBlobReader.cpp
|
||||||
VolumeGC.cpp
|
VolumeGC.cpp
|
||||||
VolumeWad.cpp
|
VolumeWad.cpp
|
||||||
VolumeWii.cpp
|
VolumeWii.cpp
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
<ClCompile Include="NANDImporter.cpp" />
|
<ClCompile Include="NANDImporter.cpp" />
|
||||||
<ClCompile Include="TGCBlob.cpp" />
|
<ClCompile Include="TGCBlob.cpp" />
|
||||||
<ClCompile Include="Volume.cpp" />
|
<ClCompile Include="Volume.cpp" />
|
||||||
|
<ClCompile Include="VolumeFileBlobReader.cpp" />
|
||||||
<ClCompile Include="VolumeGC.cpp" />
|
<ClCompile Include="VolumeGC.cpp" />
|
||||||
<ClCompile Include="VolumeWad.cpp" />
|
<ClCompile Include="VolumeWad.cpp" />
|
||||||
<ClCompile Include="VolumeWii.cpp" />
|
<ClCompile Include="VolumeWii.cpp" />
|
||||||
|
@ -73,6 +74,7 @@
|
||||||
<ClInclude Include="NANDImporter.h" />
|
<ClInclude Include="NANDImporter.h" />
|
||||||
<ClInclude Include="TGCBlob.h" />
|
<ClInclude Include="TGCBlob.h" />
|
||||||
<ClInclude Include="Volume.h" />
|
<ClInclude Include="Volume.h" />
|
||||||
|
<ClInclude Include="VolumeFileBlobReader.h" />
|
||||||
<ClInclude Include="VolumeGC.h" />
|
<ClInclude Include="VolumeGC.h" />
|
||||||
<ClInclude Include="VolumeWad.h" />
|
<ClInclude Include="VolumeWad.h" />
|
||||||
<ClInclude Include="VolumeWii.h" />
|
<ClInclude Include="VolumeWii.h" />
|
||||||
|
@ -96,4 +98,4 @@
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -60,6 +60,9 @@
|
||||||
<ClCompile Include="DirectoryBlob.cpp">
|
<ClCompile Include="DirectoryBlob.cpp">
|
||||||
<Filter>Volume\Blob</Filter>
|
<Filter>Volume\Blob</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="VolumeFileBlobReader.cpp">
|
||||||
|
<Filter>Volume</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="VolumeGC.cpp">
|
<ClCompile Include="VolumeGC.cpp">
|
||||||
<Filter>Volume</Filter>
|
<Filter>Volume</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -125,6 +128,9 @@
|
||||||
<ClInclude Include="DirectoryBlob.h">
|
<ClInclude Include="DirectoryBlob.h">
|
||||||
<Filter>Volume\Blob</Filter>
|
<Filter>Volume\Blob</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="VolumeFileBlobReader.h">
|
||||||
|
<Filter>Volume</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="VolumeGC.h">
|
<ClInclude Include="VolumeGC.h">
|
||||||
<Filter>Volume</Filter>
|
<Filter>Volume</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -147,4 +153,4 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="CMakeLists.txt" />
|
<Text Include="CMakeLists.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
// Copyright 2017 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "DiscIO/VolumeFileBlobReader.h"
|
||||||
|
|
||||||
|
#include "DiscIO/Filesystem.h"
|
||||||
|
#include "DiscIO/Volume.h"
|
||||||
|
|
||||||
|
namespace DiscIO
|
||||||
|
{
|
||||||
|
std::unique_ptr<VolumeFileBlobReader> VolumeFileBlobReader::Create(const Volume& volume,
|
||||||
|
const FileSystem& file_system,
|
||||||
|
const std::string& file_path)
|
||||||
|
{
|
||||||
|
if (!file_system.IsValid())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
std::unique_ptr<FileInfo> file_info = file_system.FindFileInfo(file_path);
|
||||||
|
if (!file_info || file_info->IsDirectory())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return std::unique_ptr<VolumeFileBlobReader>{
|
||||||
|
new VolumeFileBlobReader(volume, file_system, std::move(file_info))};
|
||||||
|
}
|
||||||
|
|
||||||
|
VolumeFileBlobReader::VolumeFileBlobReader(const Volume& volume, const FileSystem& file_system,
|
||||||
|
std::unique_ptr<FileInfo> file_info)
|
||||||
|
: m_volume(volume), m_file_system(file_system), m_file_info(std::move(file_info))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 VolumeFileBlobReader::GetDataSize() const
|
||||||
|
{
|
||||||
|
return m_file_info->GetSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 VolumeFileBlobReader::GetRawSize() const
|
||||||
|
{
|
||||||
|
return GetDataSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VolumeFileBlobReader::Read(u64 offset, u64 length, u8* out_ptr)
|
||||||
|
{
|
||||||
|
if (offset + length > m_file_info->GetSize())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return m_volume.Read(m_file_info->GetOffset() + offset, length, out_ptr,
|
||||||
|
m_file_system.GetPartition());
|
||||||
|
}
|
||||||
|
} // namespace
|
|
@ -0,0 +1,38 @@
|
||||||
|
// Copyright 2017 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "DiscIO/Blob.h"
|
||||||
|
|
||||||
|
namespace DiscIO
|
||||||
|
{
|
||||||
|
class FileInfo;
|
||||||
|
class FileSystem;
|
||||||
|
class Volume;
|
||||||
|
|
||||||
|
class VolumeFileBlobReader final : public BlobReader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static std::unique_ptr<VolumeFileBlobReader>
|
||||||
|
Create(const Volume& volume, const FileSystem& file_system, const std::string& file_path);
|
||||||
|
|
||||||
|
BlobType GetBlobType() const override { return BlobType::PLAIN; }
|
||||||
|
u64 GetDataSize() const override;
|
||||||
|
u64 GetRawSize() const override;
|
||||||
|
bool Read(u64 offset, u64 length, u8* out_ptr) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
VolumeFileBlobReader(const Volume& volume, const FileSystem& file_system,
|
||||||
|
std::unique_ptr<FileInfo> file_info);
|
||||||
|
|
||||||
|
const Volume& m_volume;
|
||||||
|
const FileSystem& m_file_system;
|
||||||
|
std::unique_ptr<FileInfo> m_file_info;
|
||||||
|
};
|
||||||
|
} // namespace
|
Loading…
Reference in New Issue