2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:09:55 -06:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2013-03-03 15:51:26 -07:00
|
|
|
#include <algorithm>
|
2013-10-26 03:55:41 -06:00
|
|
|
#include <cinttypes>
|
2014-02-20 17:47:53 -07:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstring>
|
2014-02-17 03:18:15 -07:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-09-07 19:06:58 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/FileUtil.h"
|
2015-09-26 15:13:07 -06:00
|
|
|
#include "Common/MsgHandler.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/StringUtil.h"
|
2015-09-26 15:13:07 -06:00
|
|
|
#include "Common/Logging/Log.h"
|
2014-02-20 17:47:53 -07:00
|
|
|
#include "DiscIO/Filesystem.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "DiscIO/FileSystemGCWii.h"
|
2014-02-20 17:47:53 -07:00
|
|
|
#include "DiscIO/Volume.h"
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
namespace DiscIO
|
|
|
|
{
|
|
|
|
CFileSystemGCWii::CFileSystemGCWii(const IVolume *_rVolume)
|
2013-03-03 15:51:26 -07:00
|
|
|
: IFileSystem(_rVolume)
|
|
|
|
, m_Initialized(false)
|
|
|
|
, m_Valid(false)
|
2014-12-28 02:35:48 -07:00
|
|
|
, m_Wii(false)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-06-03 14:37:32 -06:00
|
|
|
m_Valid = DetectFileSystem();
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
CFileSystemGCWii::~CFileSystemGCWii()
|
|
|
|
{
|
2010-02-14 07:06:33 -07:00
|
|
|
m_FileInfoVector.clear();
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
u64 CFileSystemGCWii::GetFileSize(const std::string& _rFullPath)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
|
|
|
if (!m_Initialized)
|
2010-06-03 14:37:32 -06:00
|
|
|
InitFileSystem();
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
|
|
|
|
2014-03-09 14:14:26 -06:00
|
|
|
if (pFileInfo != nullptr && !pFileInfo->IsDirectory())
|
2008-12-07 22:30:24 -07:00
|
|
|
return pFileInfo->m_FileSize;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-14 21:38:14 -06:00
|
|
|
const std::string CFileSystemGCWii::GetFileName(u64 _Address)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-06-03 14:37:32 -06:00
|
|
|
if (!m_Initialized)
|
|
|
|
InitFileSystem();
|
|
|
|
|
2013-10-28 23:09:01 -06:00
|
|
|
for (auto& fileInfo : m_FileInfoVector)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2013-10-28 23:09:01 -06:00
|
|
|
if ((fileInfo.m_Offset <= _Address) &&
|
|
|
|
((fileInfo.m_Offset + fileInfo.m_FileSize) > _Address))
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2013-10-28 23:09:01 -06:00
|
|
|
return fileInfo.m_FullPath;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-23 21:29:30 -06:00
|
|
|
return "";
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2015-04-28 08:47:03 -06:00
|
|
|
u64 CFileSystemGCWii::ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64 _MaxBufferSize, u64 _OffsetInFile)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
|
|
|
if (!m_Initialized)
|
2010-06-03 14:37:32 -06:00
|
|
|
InitFileSystem();
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
2014-03-09 14:14:26 -06:00
|
|
|
if (pFileInfo == nullptr)
|
2008-12-07 22:30:24 -07:00
|
|
|
return 0;
|
|
|
|
|
2015-04-28 08:47:03 -06:00
|
|
|
if (_OffsetInFile >= pFileInfo->m_FileSize)
|
2008-12-07 22:30:24 -07:00
|
|
|
return 0;
|
|
|
|
|
2015-04-28 08:47:03 -06:00
|
|
|
u64 read_length = std::min(_MaxBufferSize, pFileInfo->m_FileSize - _OffsetInFile);
|
2010-01-10 22:07:56 -07:00
|
|
|
|
2015-09-07 23:44:37 -06:00
|
|
|
DEBUG_LOG(DISCIO, "Reading %" PRIx64 " bytes at %" PRIx64 " from file %s. Offset: %" PRIx64 " Size: %" PRIx64,
|
2015-04-28 08:47:03 -06:00
|
|
|
read_length, _OffsetInFile, _rFullPath.c_str(), pFileInfo->m_Offset, pFileInfo->m_FileSize);
|
|
|
|
|
|
|
|
m_rVolume->Read(pFileInfo->m_Offset + _OffsetInFile, read_length, _pBuffer, m_Wii);
|
|
|
|
return read_length;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
bool CFileSystemGCWii::ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-06-03 14:37:32 -06:00
|
|
|
if (!m_Initialized)
|
|
|
|
InitFileSystem();
|
|
|
|
|
2010-05-30 11:57:56 -06:00
|
|
|
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2013-01-09 00:16:23 -07:00
|
|
|
if (!pFileInfo)
|
2008-12-07 22:30:24 -07:00
|
|
|
return false;
|
|
|
|
|
2010-05-30 11:57:56 -06:00
|
|
|
u64 remainingSize = pFileInfo->m_FileSize;
|
|
|
|
u64 fileOffset = pFileInfo->m_Offset;
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2011-03-11 03:21:46 -07:00
|
|
|
File::IOFile f(_rExportFilename, "wb");
|
2010-05-30 11:57:56 -06:00
|
|
|
if (!f)
|
2008-12-07 22:30:24 -07:00
|
|
|
return false;
|
|
|
|
|
2010-05-30 11:57:56 -06:00
|
|
|
bool result = true;
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2010-05-30 11:57:56 -06:00
|
|
|
while (remainingSize)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-05-30 11:57:56 -06:00
|
|
|
// Limit read size to 128 MB
|
2014-07-14 07:38:05 -06:00
|
|
|
size_t readSize = (size_t)std::min(remainingSize, (u64)0x08000000);
|
2010-05-30 11:57:56 -06:00
|
|
|
|
2013-01-09 00:16:23 -07:00
|
|
|
std::vector<u8> buffer(readSize);
|
2010-05-30 11:57:56 -06:00
|
|
|
|
2014-12-28 02:35:48 -07:00
|
|
|
result = m_rVolume->Read(fileOffset, readSize, &buffer[0], m_Wii);
|
2010-05-30 11:57:56 -06:00
|
|
|
|
|
|
|
if (!result)
|
|
|
|
break;
|
|
|
|
|
2013-01-09 00:16:23 -07:00
|
|
|
f.WriteBytes(&buffer[0], readSize);
|
2010-05-30 11:57:56 -06:00
|
|
|
|
|
|
|
remainingSize -= readSize;
|
|
|
|
fileOffset += readSize;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2010-05-30 11:57:56 -06:00
|
|
|
return result;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2009-09-13 16:03:18 -06:00
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
bool CFileSystemGCWii::ExportApploader(const std::string& _rExportFolder) const
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2015-10-03 05:24:13 -06:00
|
|
|
u32 apploader_size;
|
|
|
|
u32 trailer_size;
|
|
|
|
const u32 header_size = 0x20;
|
|
|
|
if (!m_rVolume->ReadSwapped(0x2440 + 0x14, &apploader_size, m_Wii) ||
|
|
|
|
!m_rVolume->ReadSwapped(0x2440 + 0x18, &trailer_size, m_Wii))
|
|
|
|
return false;
|
|
|
|
apploader_size += trailer_size + header_size;
|
|
|
|
DEBUG_LOG(DISCIO, "Apploader size -> %x", apploader_size);
|
|
|
|
|
|
|
|
std::vector<u8> buffer(apploader_size);
|
|
|
|
if (m_rVolume->Read(0x2440, apploader_size, buffer.data(), m_Wii))
|
2009-09-13 03:03:38 -06:00
|
|
|
{
|
2014-10-28 11:41:34 -06:00
|
|
|
std::string exportName(_rExportFolder + "/apploader.img");
|
2011-03-11 03:21:46 -07:00
|
|
|
|
|
|
|
File::IOFile AppFile(exportName, "wb");
|
2009-10-11 10:06:02 -06:00
|
|
|
if (AppFile)
|
|
|
|
{
|
2015-10-03 05:24:13 -06:00
|
|
|
AppFile.WriteBytes(buffer.data(), apploader_size);
|
2009-10-11 10:06:02 -06:00
|
|
|
return true;
|
|
|
|
}
|
2009-09-13 03:03:38 -06:00
|
|
|
}
|
2009-09-13 16:03:18 -06:00
|
|
|
|
2009-10-11 10:06:02 -06:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-03 05:24:13 -06:00
|
|
|
u64 CFileSystemGCWii::GetBootDOLOffset() const
|
2009-10-11 10:06:02 -06:00
|
|
|
{
|
2015-10-03 05:24:13 -06:00
|
|
|
u32 offset = 0;
|
|
|
|
m_rVolume->ReadSwapped(0x420, &offset, m_Wii);
|
|
|
|
return static_cast<u64>(offset) << GetOffsetShift();
|
2015-10-17 12:52:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 CFileSystemGCWii::GetBootDOLSize(u64 dol_offset) const
|
|
|
|
{
|
2015-10-03 05:24:13 -06:00
|
|
|
// The dol_offset value is usually obtained by calling GetBootDOLOffset.
|
|
|
|
// If GetBootDOLOffset fails by returning 0, GetBootDOLSize should also fail.
|
|
|
|
if (dol_offset == 0)
|
|
|
|
return 0;
|
|
|
|
|
2015-10-17 12:52:26 -06:00
|
|
|
u32 dol_size = 0;
|
|
|
|
u32 offset = 0;
|
|
|
|
u32 size = 0;
|
2009-09-13 16:03:18 -06:00
|
|
|
|
|
|
|
// Iterate through the 7 code segments
|
|
|
|
for (u8 i = 0; i < 7; i++)
|
2009-09-13 03:03:38 -06:00
|
|
|
{
|
2015-10-03 05:24:13 -06:00
|
|
|
if (!m_rVolume->ReadSwapped(dol_offset + 0x00 + i * 4, &offset, m_Wii) ||
|
|
|
|
!m_rVolume->ReadSwapped(dol_offset + 0x90 + i * 4, &size, m_Wii))
|
|
|
|
return 0;
|
2015-10-17 12:52:26 -06:00
|
|
|
dol_size = std::max(offset + size, dol_size);
|
2009-09-13 16:03:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Iterate through the 11 data segments
|
|
|
|
for (u8 i = 0; i < 11; i++)
|
|
|
|
{
|
2015-10-03 05:24:13 -06:00
|
|
|
if (!m_rVolume->ReadSwapped(dol_offset + 0x1c + i * 4, &offset, m_Wii) ||
|
|
|
|
!m_rVolume->ReadSwapped(dol_offset + 0xac + i * 4, &size, m_Wii))
|
|
|
|
return 0;
|
2015-10-17 12:52:26 -06:00
|
|
|
dol_size = std::max(offset + size, dol_size);
|
2009-09-13 03:03:38 -06:00
|
|
|
}
|
2015-10-17 12:52:26 -06:00
|
|
|
|
|
|
|
return dol_size;
|
2012-05-05 02:38:00 -06:00
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
bool CFileSystemGCWii::ExportDOL(const std::string& _rExportFolder) const
|
2012-05-05 02:38:00 -06:00
|
|
|
{
|
2015-10-03 05:24:13 -06:00
|
|
|
u64 DolOffset = GetBootDOLOffset();
|
|
|
|
u32 DolSize = GetBootDOLSize(DolOffset);
|
|
|
|
|
|
|
|
if (DolOffset == 0 || DolSize == 0)
|
|
|
|
return false;
|
2009-10-11 10:06:02 -06:00
|
|
|
|
2013-01-09 00:16:23 -07:00
|
|
|
std::vector<u8> buffer(DolSize);
|
2014-12-28 02:35:48 -07:00
|
|
|
if (m_rVolume->Read(DolOffset, DolSize, &buffer[0], m_Wii))
|
2009-09-12 03:09:47 -06:00
|
|
|
{
|
2014-10-28 11:41:34 -06:00
|
|
|
std::string exportName(_rExportFolder + "/boot.dol");
|
2013-01-09 00:16:23 -07:00
|
|
|
|
2011-03-11 03:21:46 -07:00
|
|
|
File::IOFile DolFile(exportName, "wb");
|
2009-10-11 10:06:02 -06:00
|
|
|
if (DolFile)
|
|
|
|
{
|
2013-01-09 00:16:23 -07:00
|
|
|
DolFile.WriteBytes(&buffer[0], DolSize);
|
2009-10-11 10:06:02 -06:00
|
|
|
return true;
|
|
|
|
}
|
2009-09-12 03:09:47 -06:00
|
|
|
}
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2009-10-11 10:06:02 -06:00
|
|
|
return false;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2013-03-03 15:51:26 -07:00
|
|
|
std::string CFileSystemGCWii::GetStringFromOffset(u64 _Offset) const
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2015-01-11 13:46:22 -07:00
|
|
|
std::string data(255, 0x00);
|
2014-12-28 02:35:48 -07:00
|
|
|
m_rVolume->Read(_Offset, data.size(), (u8*)&data[0], m_Wii);
|
2013-03-03 15:51:26 -07:00
|
|
|
data.erase(std::find(data.begin(), data.end(), 0x00), data.end());
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-03-03 15:51:26 -07:00
|
|
|
// TODO: Should we really always use SHIFT-JIS?
|
|
|
|
// It makes some filenames in Pikmin (NTSC-U) sane, but is it correct?
|
|
|
|
return SHIFTJISToUTF8(data);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2015-04-28 04:48:05 -06:00
|
|
|
const std::vector<SFileInfo>& CFileSystemGCWii::GetFileList()
|
2013-10-28 23:23:17 -06:00
|
|
|
{
|
2010-06-03 14:37:32 -06:00
|
|
|
if (!m_Initialized)
|
|
|
|
InitFileSystem();
|
|
|
|
|
2015-04-28 04:48:05 -06:00
|
|
|
return m_FileInfoVector;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
const SFileInfo* CFileSystemGCWii::FindFileInfo(const std::string& _rFullPath)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-06-03 14:37:32 -06:00
|
|
|
if (!m_Initialized)
|
|
|
|
InitFileSystem();
|
|
|
|
|
2013-10-28 23:09:01 -06:00
|
|
|
for (auto& fileInfo : m_FileInfoVector)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2014-03-14 21:38:14 -06:00
|
|
|
if (!strcasecmp(fileInfo.m_FullPath.c_str(), _rFullPath.c_str()))
|
2013-10-28 23:09:01 -06:00
|
|
|
return &fileInfo;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2014-03-09 14:14:26 -06:00
|
|
|
return nullptr;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2010-06-03 14:37:32 -06:00
|
|
|
bool CFileSystemGCWii::DetectFileSystem()
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2015-10-03 05:24:13 -06:00
|
|
|
u32 magic_bytes;
|
|
|
|
if (m_rVolume->ReadSwapped(0x18, &magic_bytes, false) && magic_bytes == 0x5D1C9EA3)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2014-12-28 02:35:48 -07:00
|
|
|
m_Wii = true;
|
2010-06-03 14:59:55 -06:00
|
|
|
return true;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2015-10-03 05:24:13 -06:00
|
|
|
else if (m_rVolume->ReadSwapped(0x1c, &magic_bytes, false) && magic_bytes == 0xC2339F3D)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2014-12-28 02:35:48 -07:00
|
|
|
m_Wii = false;
|
2010-06-03 14:59:55 -06:00
|
|
|
return true;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2010-06-03 14:59:55 -06:00
|
|
|
|
|
|
|
return false;
|
2010-06-03 14:37:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFileSystemGCWii::InitFileSystem()
|
|
|
|
{
|
|
|
|
m_Initialized = true;
|
2015-01-11 13:46:22 -07:00
|
|
|
u32 const shift = GetOffsetShift();
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
// read the whole FST
|
2015-10-03 05:24:13 -06:00
|
|
|
u32 fst_offset_unshifted;
|
|
|
|
if (!m_rVolume->ReadSwapped(0x424, &fst_offset_unshifted, m_Wii))
|
|
|
|
return;
|
|
|
|
u64 FSTOffset = static_cast<u64>(fst_offset_unshifted) << shift;
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
// read all fileinfos
|
2015-10-03 05:24:13 -06:00
|
|
|
u32 name_offset, offset, size;
|
|
|
|
if (!m_rVolume->ReadSwapped(FSTOffset + 0x0, &name_offset, m_Wii) ||
|
|
|
|
!m_rVolume->ReadSwapped(FSTOffset + 0x4, &offset, m_Wii) ||
|
|
|
|
!m_rVolume->ReadSwapped(FSTOffset + 0x8, &size, m_Wii))
|
|
|
|
return;
|
|
|
|
SFileInfo root = { name_offset, static_cast<u64>(offset) << shift, size };
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2015-10-03 05:24:13 -06:00
|
|
|
if (!root.IsDirectory())
|
2015-01-11 14:49:26 -07:00
|
|
|
return;
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2015-10-04 02:17:43 -06:00
|
|
|
// 12 bytes (the size of a file entry) times 10 * 1024 * 1024 is 120 MiB,
|
|
|
|
// more than total RAM in a Wii. No file system should use anywhere near that much.
|
|
|
|
static const u32 ARBITRARY_FILE_SYSTEM_SIZE_LIMIT = 10 * 1024 * 1024;
|
2015-10-03 05:24:13 -06:00
|
|
|
if (root.m_FileSize > ARBITRARY_FILE_SYSTEM_SIZE_LIMIT)
|
2015-10-04 02:17:43 -06:00
|
|
|
{
|
|
|
|
// Without this check, Dolphin can crash by trying to allocate too much
|
|
|
|
// memory when loading the file systems of certain malformed disc images.
|
|
|
|
|
|
|
|
ERROR_LOG(DISCIO, "File system is abnormally large! Aborting loading");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-11 13:46:22 -07:00
|
|
|
if (m_FileInfoVector.size())
|
|
|
|
PanicAlert("Wtf?");
|
|
|
|
u64 NameTableOffset = FSTOffset;
|
|
|
|
|
2015-10-03 05:24:13 -06:00
|
|
|
m_FileInfoVector.reserve((size_t)root.m_FileSize);
|
|
|
|
for (u32 i = 0; i < root.m_FileSize; i++)
|
2015-01-11 13:46:22 -07:00
|
|
|
{
|
2015-10-03 05:24:13 -06:00
|
|
|
const u64 read_offset = FSTOffset + (i * 0xC);
|
|
|
|
name_offset = 0;
|
|
|
|
m_rVolume->ReadSwapped(read_offset + 0x0, &name_offset, m_Wii);
|
|
|
|
offset = 0;
|
|
|
|
m_rVolume->ReadSwapped(read_offset + 0x4, &offset, m_Wii);
|
|
|
|
size = 0;
|
|
|
|
m_rVolume->ReadSwapped(read_offset + 0x8, &size, m_Wii);
|
|
|
|
m_FileInfoVector.emplace_back(name_offset, static_cast<u64>(offset) << shift, size);
|
2015-01-11 13:46:22 -07:00
|
|
|
NameTableOffset += 0xC;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2015-01-11 13:46:22 -07:00
|
|
|
|
|
|
|
BuildFilenames(1, m_FileInfoVector.size(), "", NameTableOffset);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2014-03-14 21:38:14 -06:00
|
|
|
size_t CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const std::string& _szDirectory, u64 _NameTableOffset)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
|
|
|
size_t CurrentIndex = _FirstIndex;
|
|
|
|
|
|
|
|
while (CurrentIndex < _LastIndex)
|
|
|
|
{
|
2014-06-29 13:22:06 -06:00
|
|
|
SFileInfo& rFileInfo = m_FileInfoVector[CurrentIndex];
|
|
|
|
u64 const uOffset = _NameTableOffset + (rFileInfo.m_NameOffset & 0xFFFFFF);
|
2015-01-11 13:46:22 -07:00
|
|
|
std::string const offset_str { GetStringFromOffset(uOffset) };
|
|
|
|
bool const is_dir = rFileInfo.IsDirectory();
|
|
|
|
rFileInfo.m_FullPath.reserve(_szDirectory.size() + offset_str.size());
|
2014-06-29 13:22:06 -06:00
|
|
|
|
2015-01-11 13:46:22 -07:00
|
|
|
rFileInfo.m_FullPath.append(_szDirectory.data(), _szDirectory.size())
|
|
|
|
.append(offset_str.data(), offset_str.size())
|
|
|
|
.append("/", size_t(is_dir));
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2015-01-11 13:46:22 -07:00
|
|
|
if (!is_dir)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2014-06-29 13:22:06 -06:00
|
|
|
++CurrentIndex;
|
2015-01-11 13:46:22 -07:00
|
|
|
continue;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2015-01-11 13:46:22 -07:00
|
|
|
|
|
|
|
// check next index
|
|
|
|
CurrentIndex = BuildFilenames(CurrentIndex + 1, (size_t) rFileInfo.m_FileSize, rFileInfo.m_FullPath, _NameTableOffset);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return CurrentIndex;
|
|
|
|
}
|
|
|
|
|
2014-12-28 02:35:48 -07:00
|
|
|
u32 CFileSystemGCWii::GetOffsetShift() const
|
|
|
|
{
|
|
|
|
return m_Wii ? 2 : 0;
|
|
|
|
}
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
} // namespace
|