FileSystemGCWii: Replace m_Wii with m_offset_shift
I replaced m_OffsetShift with m_Wii in bb93336
to support
the decrypt parameter for read functions. Doing that is no
longer necessary, so m_offset_shift is now used like before.
This commit is contained in:
parent
19b8f1c10a
commit
639ce6c484
|
@ -21,7 +21,7 @@
|
||||||
namespace DiscIO
|
namespace DiscIO
|
||||||
{
|
{
|
||||||
CFileSystemGCWii::CFileSystemGCWii(const IVolume* _rVolume, const Partition& partition)
|
CFileSystemGCWii::CFileSystemGCWii(const IVolume* _rVolume, const Partition& partition)
|
||||||
: IFileSystem(_rVolume, partition), m_Initialized(false), m_Valid(false), m_Wii(false)
|
: IFileSystem(_rVolume, partition), m_Initialized(false), m_Valid(false), m_offset_shift(0)
|
||||||
{
|
{
|
||||||
m_Valid = DetectFileSystem();
|
m_Valid = DetectFileSystem();
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ u64 CFileSystemGCWii::GetBootDOLOffset() const
|
||||||
{
|
{
|
||||||
u32 offset = 0;
|
u32 offset = 0;
|
||||||
m_rVolume->ReadSwapped(0x420, &offset, m_partition);
|
m_rVolume->ReadSwapped(0x420, &offset, m_partition);
|
||||||
return static_cast<u64>(offset) << GetOffsetShift();
|
return static_cast<u64>(offset) << m_offset_shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CFileSystemGCWii::GetBootDOLSize(u64 dol_offset) const
|
u32 CFileSystemGCWii::GetBootDOLSize(u64 dol_offset) const
|
||||||
|
@ -253,12 +253,12 @@ bool CFileSystemGCWii::DetectFileSystem()
|
||||||
u32 magic_bytes;
|
u32 magic_bytes;
|
||||||
if (m_rVolume->ReadSwapped(0x18, &magic_bytes, m_partition) && magic_bytes == 0x5D1C9EA3)
|
if (m_rVolume->ReadSwapped(0x18, &magic_bytes, m_partition) && magic_bytes == 0x5D1C9EA3)
|
||||||
{
|
{
|
||||||
m_Wii = true;
|
m_offset_shift = 2; // Wii file system
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (m_rVolume->ReadSwapped(0x1c, &magic_bytes, m_partition) && magic_bytes == 0xC2339F3D)
|
else if (m_rVolume->ReadSwapped(0x1c, &magic_bytes, m_partition) && magic_bytes == 0xC2339F3D)
|
||||||
{
|
{
|
||||||
m_Wii = false;
|
m_offset_shift = 0; // GameCube file system
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,13 +268,12 @@ bool CFileSystemGCWii::DetectFileSystem()
|
||||||
void CFileSystemGCWii::InitFileSystem()
|
void CFileSystemGCWii::InitFileSystem()
|
||||||
{
|
{
|
||||||
m_Initialized = true;
|
m_Initialized = true;
|
||||||
u32 const shift = GetOffsetShift();
|
|
||||||
|
|
||||||
// read the whole FST
|
// read the whole FST
|
||||||
u32 fst_offset_unshifted;
|
u32 fst_offset_unshifted;
|
||||||
if (!m_rVolume->ReadSwapped(0x424, &fst_offset_unshifted, m_partition))
|
if (!m_rVolume->ReadSwapped(0x424, &fst_offset_unshifted, m_partition))
|
||||||
return;
|
return;
|
||||||
u64 FSTOffset = static_cast<u64>(fst_offset_unshifted) << shift;
|
u64 FSTOffset = static_cast<u64>(fst_offset_unshifted) << m_offset_shift;
|
||||||
|
|
||||||
// read all fileinfos
|
// read all fileinfos
|
||||||
u32 name_offset, offset, size;
|
u32 name_offset, offset, size;
|
||||||
|
@ -282,7 +281,7 @@ void CFileSystemGCWii::InitFileSystem()
|
||||||
!m_rVolume->ReadSwapped(FSTOffset + 0x4, &offset, m_partition) ||
|
!m_rVolume->ReadSwapped(FSTOffset + 0x4, &offset, m_partition) ||
|
||||||
!m_rVolume->ReadSwapped(FSTOffset + 0x8, &size, m_partition))
|
!m_rVolume->ReadSwapped(FSTOffset + 0x8, &size, m_partition))
|
||||||
return;
|
return;
|
||||||
SFileInfo root = {name_offset, static_cast<u64>(offset) << shift, size};
|
SFileInfo root = {name_offset, static_cast<u64>(offset) << m_offset_shift, size};
|
||||||
|
|
||||||
if (!root.IsDirectory())
|
if (!root.IsDirectory())
|
||||||
return;
|
return;
|
||||||
|
@ -313,7 +312,7 @@ void CFileSystemGCWii::InitFileSystem()
|
||||||
m_rVolume->ReadSwapped(read_offset + 0x4, &offset, m_partition);
|
m_rVolume->ReadSwapped(read_offset + 0x4, &offset, m_partition);
|
||||||
size = 0;
|
size = 0;
|
||||||
m_rVolume->ReadSwapped(read_offset + 0x8, &size, m_partition);
|
m_rVolume->ReadSwapped(read_offset + 0x8, &size, m_partition);
|
||||||
m_FileInfoVector.emplace_back(name_offset, static_cast<u64>(offset) << shift, size);
|
m_FileInfoVector.emplace_back(name_offset, static_cast<u64>(offset) << m_offset_shift, size);
|
||||||
NameTableOffset += 0xC;
|
NameTableOffset += 0xC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,9 +350,4 @@ size_t CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _
|
||||||
return CurrentIndex;
|
return CurrentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CFileSystemGCWii::GetOffsetShift() const
|
|
||||||
{
|
|
||||||
return m_Wii ? 2 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
private:
|
private:
|
||||||
bool m_Initialized;
|
bool m_Initialized;
|
||||||
bool m_Valid;
|
bool m_Valid;
|
||||||
bool m_Wii;
|
u32 m_offset_shift;
|
||||||
std::vector<SFileInfo> m_FileInfoVector;
|
std::vector<SFileInfo> m_FileInfoVector;
|
||||||
|
|
||||||
std::string GetStringFromOffset(u64 _Offset) const;
|
std::string GetStringFromOffset(u64 _Offset) const;
|
||||||
|
@ -46,7 +46,6 @@ private:
|
||||||
void InitFileSystem();
|
void InitFileSystem();
|
||||||
size_t BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex,
|
size_t BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex,
|
||||||
const std::string& _szDirectory, u64 _NameTableOffset);
|
const std::string& _szDirectory, u64 _NameTableOffset);
|
||||||
u32 GetOffsetShift() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Reference in New Issue