Merge pull request #171 from lioncash/rarc-cleanup
File tree building cleanup
This commit is contained in:
commit
a3e18cd498
|
@ -201,19 +201,17 @@ u32 CWII_IPC_HLE_Device_di::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32
|
||||||
// Don't do anything if the log is unselected
|
// Don't do anything if the log is unselected
|
||||||
if (LogManager::GetInstance()->IsEnabled(LogTypes::FILEMON))
|
if (LogManager::GetInstance()->IsEnabled(LogTypes::FILEMON))
|
||||||
{
|
{
|
||||||
const char *pFilename = nullptr;
|
|
||||||
if (m_pFileSystem)
|
if (m_pFileSystem)
|
||||||
pFilename = m_pFileSystem->GetFileName(DVDAddress);
|
|
||||||
if (pFilename != nullptr)
|
|
||||||
{
|
{
|
||||||
|
const std::string filename = m_pFileSystem->GetFileName(DVDAddress);
|
||||||
|
|
||||||
INFO_LOG(WII_IPC_DVD, "DVDLowRead: %s (0x%" PRIx64 ") - (DVDAddr: 0x%" PRIx64 ", Size: 0x%x)",
|
INFO_LOG(WII_IPC_DVD, "DVDLowRead: %s (0x%" PRIx64 ") - (DVDAddr: 0x%" PRIx64 ", Size: 0x%x)",
|
||||||
pFilename, m_pFileSystem->GetFileSize(pFilename), DVDAddress, Size);
|
filename.c_str(), m_pFileSystem->GetFileSize(filename), DVDAddress, Size);
|
||||||
FileMon::CheckFile(std::string(pFilename), (int)m_pFileSystem->GetFileSize(pFilename));
|
FileMon::CheckFile(filename, (int)m_pFileSystem->GetFileSize(filename));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
INFO_LOG(WII_IPC_DVD, "DVDLowRead: file unknown - (DVDAddr: 0x%" PRIx64 ", Size: 0x%x)",
|
ERROR_LOG(WII_IPC_DVD, "Filesystem is invalid.");
|
||||||
DVDAddress, Size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,18 +336,17 @@ u32 CWII_IPC_HLE_Device_di::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32
|
||||||
case DVDLowSeek:
|
case DVDLowSeek:
|
||||||
{
|
{
|
||||||
u64 DVDAddress = Memory::Read_U32(_BufferIn + 0x4) << 2;
|
u64 DVDAddress = Memory::Read_U32(_BufferIn + 0x4) << 2;
|
||||||
const char *pFilename = nullptr;
|
|
||||||
if (m_pFileSystem)
|
if (m_pFileSystem)
|
||||||
pFilename = m_pFileSystem->GetFileName(DVDAddress);
|
|
||||||
if (pFilename != nullptr)
|
|
||||||
{
|
{
|
||||||
|
const std::string filename = m_pFileSystem->GetFileName(DVDAddress);
|
||||||
|
|
||||||
INFO_LOG(WII_IPC_DVD, "DVDLowSeek: %s (0x%" PRIx64 ") - (DVDAddr: 0x%" PRIx64 ")",
|
INFO_LOG(WII_IPC_DVD, "DVDLowSeek: %s (0x%" PRIx64 ") - (DVDAddr: 0x%" PRIx64 ")",
|
||||||
pFilename, m_pFileSystem->GetFileSize(pFilename), DVDAddress);
|
filename.c_str(), m_pFileSystem->GetFileSize(filename), DVDAddress);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
INFO_LOG(WII_IPC_DVD, "DVDLowSeek: file unknown - (DVDAddr: 0x%" PRIx64 ")",
|
ERROR_LOG(WII_IPC_DVD, "Filesystem is invalid.");
|
||||||
DVDAddress);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -317,7 +317,7 @@ bool ParsePartitionData(SPartition& _rPartition)
|
||||||
// Go through the filesystem and mark entries as used
|
// Go through the filesystem and mark entries as used
|
||||||
for (size_t currentFile = 0; currentFile < numFiles; currentFile++)
|
for (size_t currentFile = 0; currentFile < numFiles; currentFile++)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(DISCIO, "%s", currentFile ? (*Files.at(currentFile)).m_FullPath : "/");
|
DEBUG_LOG(DISCIO, "%s", currentFile ? (*Files.at(currentFile)).m_FullPath.c_str() : "/");
|
||||||
// Just 1byte for directory? - it will end up reserving a cluster this way
|
// Just 1byte for directory? - it will end up reserving a cluster this way
|
||||||
if ((*Files.at(currentFile)).m_NameOffset & 0x1000000)
|
if ((*Files.at(currentFile)).m_NameOffset & 0x1000000)
|
||||||
MarkAsUsedE(_rPartition.Offset
|
MarkAsUsedE(_rPartition.Offset
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
|
#include "Common/StringUtil.h"
|
||||||
#include "DiscIO/Blob.h"
|
#include "DiscIO/Blob.h"
|
||||||
#include "DiscIO/FileHandlerARC.h"
|
#include "DiscIO/FileHandlerARC.h"
|
||||||
#include "DiscIO/Filesystem.h"
|
#include "DiscIO/Filesystem.h"
|
||||||
|
@ -69,70 +70,66 @@ CARCFile::~CARCFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool CARCFile::IsInitialized()
|
||||||
CARCFile::IsInitialized()
|
|
||||||
{
|
{
|
||||||
return(m_Initialized);
|
return m_Initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t CARCFile::GetFileSize(const std::string& _rFullPath)
|
||||||
CARCFile::GetFileSize(const std::string& _rFullPath)
|
|
||||||
{
|
{
|
||||||
if (!m_Initialized)
|
if (!m_Initialized)
|
||||||
{
|
{
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||||
|
|
||||||
if (pFileInfo != nullptr)
|
if (pFileInfo != nullptr)
|
||||||
{
|
{
|
||||||
return((size_t) pFileInfo->m_FileSize);
|
return (size_t)pFileInfo->m_FileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t CARCFile::ReadFile(const std::string& _rFullPath, u8* _pBuffer, size_t _MaxBufferSize)
|
||||||
CARCFile::ReadFile(const std::string& _rFullPath, u8* _pBuffer, size_t _MaxBufferSize)
|
|
||||||
{
|
{
|
||||||
if (!m_Initialized)
|
if (!m_Initialized)
|
||||||
{
|
{
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||||
|
|
||||||
if (pFileInfo == nullptr)
|
if (pFileInfo == nullptr)
|
||||||
{
|
{
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pFileInfo->m_FileSize > _MaxBufferSize)
|
if (pFileInfo->m_FileSize > _MaxBufferSize)
|
||||||
{
|
{
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(_pBuffer, &m_pBuffer[pFileInfo->m_Offset], (size_t)pFileInfo->m_FileSize);
|
memcpy(_pBuffer, &m_pBuffer[pFileInfo->m_Offset], (size_t)pFileInfo->m_FileSize);
|
||||||
return((size_t) pFileInfo->m_FileSize);
|
return (size_t) pFileInfo->m_FileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool CARCFile::ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename)
|
||||||
CARCFile::ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename)
|
|
||||||
{
|
{
|
||||||
if (!m_Initialized)
|
if (!m_Initialized)
|
||||||
{
|
{
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||||
|
|
||||||
if (pFileInfo == nullptr)
|
if (pFileInfo == nullptr)
|
||||||
{
|
{
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
File::IOFile pFile(_rExportFilename, "wb");
|
File::IOFile pFile(_rExportFilename, "wb");
|
||||||
|
@ -141,15 +138,13 @@ CARCFile::ExportFile(const std::string& _rFullPath, const std::string& _rExportF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool CARCFile::ExportAllFiles(const std::string& _rFullPath)
|
||||||
CARCFile::ExportAllFiles(const std::string& _rFullPath)
|
|
||||||
{
|
{
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool CARCFile::ParseBuffer()
|
||||||
CARCFile::ParseBuffer()
|
|
||||||
{
|
{
|
||||||
// check ID
|
// check ID
|
||||||
u32 ID = Common::swap32(*(u32*)(m_pBuffer));
|
u32 ID = Common::swap32(*(u32*)(m_pBuffer));
|
||||||
|
@ -183,15 +178,14 @@ CARCFile::ParseBuffer()
|
||||||
szNameTable += 0xC;
|
szNameTable += 0xC;
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildFilenames(1, m_FileInfoVector.size(), nullptr, szNameTable);
|
BuildFilenames(1, m_FileInfoVector.size(), "", szNameTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t CARCFile::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const std::string& _szDirectory, const char* _szNameTable)
|
||||||
CARCFile::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, const char* _szNameTable)
|
|
||||||
{
|
{
|
||||||
size_t CurrentIndex = _FirstIndex;
|
size_t CurrentIndex = _FirstIndex;
|
||||||
|
|
||||||
|
@ -203,49 +197,38 @@ CARCFile::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, cons
|
||||||
// check next index
|
// check next index
|
||||||
if (rFileInfo.IsDirectory())
|
if (rFileInfo.IsDirectory())
|
||||||
{
|
{
|
||||||
// this is a directory, build up the new szDirectory
|
if (_szDirectory.empty())
|
||||||
if (_szDirectory != nullptr)
|
rFileInfo.m_FullPath += StringFromFormat("%s/", &_szNameTable[uOffset]);
|
||||||
{
|
|
||||||
sprintf(rFileInfo.m_FullPath, "%s%s/", _szDirectory, &_szNameTable[uOffset]);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
rFileInfo.m_FullPath += StringFromFormat("%s%s/", _szDirectory.c_str(), &_szNameTable[uOffset]);
|
||||||
sprintf(rFileInfo.m_FullPath, "%s/", &_szNameTable[uOffset]);
|
|
||||||
}
|
|
||||||
|
|
||||||
CurrentIndex = BuildFilenames(CurrentIndex + 1, (size_t) rFileInfo.m_FileSize, rFileInfo.m_FullPath, _szNameTable);
|
CurrentIndex = BuildFilenames(CurrentIndex + 1, (size_t) rFileInfo.m_FileSize, rFileInfo.m_FullPath, _szNameTable);
|
||||||
}
|
}
|
||||||
else
|
else // This is a filename
|
||||||
{
|
{
|
||||||
// this is a filename
|
if (_szDirectory.empty())
|
||||||
if (_szDirectory != nullptr)
|
rFileInfo.m_FullPath += StringFromFormat("%s", &_szNameTable[uOffset]);
|
||||||
{
|
|
||||||
sprintf(rFileInfo.m_FullPath, "%s%s", _szDirectory, &_szNameTable[uOffset]);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
rFileInfo.m_FullPath += StringFromFormat("%s%s", _szDirectory.c_str(), &_szNameTable[uOffset]);
|
||||||
sprintf(rFileInfo.m_FullPath, "%s", &_szNameTable[uOffset]);
|
|
||||||
}
|
|
||||||
|
|
||||||
CurrentIndex++;
|
CurrentIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(CurrentIndex);
|
return CurrentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const SFileInfo*
|
const SFileInfo* CARCFile::FindFileInfo(const std::string& _rFullPath) const
|
||||||
CARCFile::FindFileInfo(std::string _rFullPath) const
|
|
||||||
{
|
{
|
||||||
for (auto& fileInfo : m_FileInfoVector)
|
for (auto& fileInfo : m_FileInfoVector)
|
||||||
{
|
{
|
||||||
if (!strcasecmp(fileInfo.m_FullPath, _rFullPath.c_str()))
|
if (!strcasecmp(fileInfo.m_FullPath.c_str(), _rFullPath.c_str()))
|
||||||
{
|
{
|
||||||
return(&fileInfo);
|
return &fileInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(nullptr);
|
return nullptr;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -47,8 +47,8 @@ class CARCFile
|
||||||
|
|
||||||
bool ParseBuffer();
|
bool ParseBuffer();
|
||||||
|
|
||||||
size_t BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, const char* _szNameTable);
|
size_t BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const std::string& _szDirectory, const char* _szNameTable);
|
||||||
|
|
||||||
const SFileInfo* FindFileInfo(std::string _rFullPath) const;
|
const SFileInfo* FindFileInfo(const std::string& _rFullPath) const;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -142,13 +142,9 @@ void FindFilename(u64 offset)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *fname = pFileSystem->GetFileName(offset);
|
const std::string filename = pFileSystem->GetFileName(offset);
|
||||||
|
|
||||||
// There's something wrong with the paths
|
CheckFile(filename, pFileSystem->GetFileSize(filename));
|
||||||
if (!fname || (strlen(fname) == 512))
|
|
||||||
return;
|
|
||||||
|
|
||||||
CheckFile(fname, pFileSystem->GetFileSize(fname));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Close()
|
void Close()
|
||||||
|
|
|
@ -46,7 +46,7 @@ u64 CFileSystemGCWii::GetFileSize(const std::string& _rFullPath)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CFileSystemGCWii::GetFileName(u64 _Address)
|
const std::string CFileSystemGCWii::GetFileName(u64 _Address)
|
||||||
{
|
{
|
||||||
if (!m_Initialized)
|
if (!m_Initialized)
|
||||||
InitFileSystem();
|
InitFileSystem();
|
||||||
|
@ -239,7 +239,7 @@ const SFileInfo* CFileSystemGCWii::FindFileInfo(const std::string& _rFullPath)
|
||||||
|
|
||||||
for (auto& fileInfo : m_FileInfoVector)
|
for (auto& fileInfo : m_FileInfoVector)
|
||||||
{
|
{
|
||||||
if (!strcasecmp(fileInfo.m_FullPath, _rFullPath.c_str()))
|
if (!strcasecmp(fileInfo.m_FullPath.c_str(), _rFullPath.c_str()))
|
||||||
return &fileInfo;
|
return &fileInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,13 +297,11 @@ void CFileSystemGCWii::InitFileSystem()
|
||||||
NameTableOffset += 0xC;
|
NameTableOffset += 0xC;
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildFilenames(1, m_FileInfoVector.size(), nullptr, NameTableOffset);
|
BuildFilenames(1, m_FileInfoVector.size(), "", NameTableOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changed this stuff from C++ string to C strings for speed in debug mode. Doesn't matter in release, but
|
size_t CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const std::string& _szDirectory, u64 _NameTableOffset)
|
||||||
// std::string is SLOW in debug mode.
|
|
||||||
size_t CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, u64 _NameTableOffset)
|
|
||||||
{
|
{
|
||||||
size_t CurrentIndex = _FirstIndex;
|
size_t CurrentIndex = _FirstIndex;
|
||||||
|
|
||||||
|
@ -316,21 +314,19 @@ size_t CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _
|
||||||
// check next index
|
// check next index
|
||||||
if (rFileInfo->IsDirectory())
|
if (rFileInfo->IsDirectory())
|
||||||
{
|
{
|
||||||
// this is a directory, build up the new szDirectory
|
if (_szDirectory.empty())
|
||||||
if (_szDirectory != nullptr)
|
rFileInfo->m_FullPath += StringFromFormat("%s/", filename.c_str());
|
||||||
CharArrayFromFormat(rFileInfo->m_FullPath, "%s%s/", _szDirectory, filename.c_str());
|
|
||||||
else
|
else
|
||||||
CharArrayFromFormat(rFileInfo->m_FullPath, "%s/", filename.c_str());
|
rFileInfo->m_FullPath += StringFromFormat("%s%s/", _szDirectory.c_str(), filename.c_str());
|
||||||
|
|
||||||
CurrentIndex = BuildFilenames(CurrentIndex + 1, (size_t) rFileInfo->m_FileSize, rFileInfo->m_FullPath, _NameTableOffset);
|
CurrentIndex = BuildFilenames(CurrentIndex + 1, (size_t) rFileInfo->m_FileSize, rFileInfo->m_FullPath, _NameTableOffset);
|
||||||
}
|
}
|
||||||
else
|
else // This is a filename
|
||||||
{
|
{
|
||||||
// this is a filename
|
if (_szDirectory.empty())
|
||||||
if (_szDirectory != nullptr)
|
rFileInfo->m_FullPath += filename;
|
||||||
CharArrayFromFormat(rFileInfo->m_FullPath, "%s%s", _szDirectory, filename.c_str());
|
|
||||||
else
|
else
|
||||||
CharArrayFromFormat(rFileInfo->m_FullPath, "%s", filename.c_str());
|
rFileInfo->m_FullPath += StringFromFormat("%s%s", _szDirectory.c_str(), filename.c_str());
|
||||||
|
|
||||||
CurrentIndex++;
|
CurrentIndex++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
virtual bool IsValid() const override { return m_Valid; }
|
virtual bool IsValid() const override { return m_Valid; }
|
||||||
virtual u64 GetFileSize(const std::string& _rFullPath) override;
|
virtual u64 GetFileSize(const std::string& _rFullPath) override;
|
||||||
virtual size_t GetFileList(std::vector<const SFileInfo *> &_rFilenames) override;
|
virtual size_t GetFileList(std::vector<const SFileInfo *> &_rFilenames) override;
|
||||||
virtual const char* GetFileName(u64 _Address) override;
|
virtual const std::string GetFileName(u64 _Address) override;
|
||||||
virtual u64 ReadFile(const std::string& _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) override;
|
virtual u64 ReadFile(const std::string& _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) override;
|
||||||
virtual bool ExportFile(const std::string& _rFullPath, const std::string&_rExportFilename) override;
|
virtual bool ExportFile(const std::string& _rFullPath, const std::string&_rExportFilename) override;
|
||||||
virtual bool ExportApploader(const std::string& _rExportFolder) const override;
|
virtual bool ExportApploader(const std::string& _rExportFolder) const override;
|
||||||
|
@ -43,7 +43,7 @@ private:
|
||||||
const SFileInfo* FindFileInfo(const std::string& _rFullPath);
|
const SFileInfo* FindFileInfo(const std::string& _rFullPath);
|
||||||
bool DetectFileSystem();
|
bool DetectFileSystem();
|
||||||
void InitFileSystem();
|
void InitFileSystem();
|
||||||
size_t BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, u64 _NameTableOffset);
|
size_t BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const std::string& _szDirectory, u64 _NameTableOffset);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -22,17 +22,17 @@ struct SFileInfo
|
||||||
u64 m_NameOffset;
|
u64 m_NameOffset;
|
||||||
u64 m_Offset;
|
u64 m_Offset;
|
||||||
u64 m_FileSize;
|
u64 m_FileSize;
|
||||||
char m_FullPath[512];
|
std::string m_FullPath;
|
||||||
|
|
||||||
bool IsDirectory() const { return (m_NameOffset & 0xFF000000) != 0 ? true : false; }
|
bool IsDirectory() const { return (m_NameOffset & 0xFF000000) != 0; }
|
||||||
|
|
||||||
SFileInfo() : m_NameOffset(0), m_Offset(0), m_FileSize(0) {
|
SFileInfo() : m_NameOffset(0), m_Offset(0), m_FileSize(0)
|
||||||
memset(m_FullPath, 0, sizeof(m_FullPath));
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SFileInfo(const SFileInfo &rhs) : m_NameOffset(rhs.m_NameOffset),
|
SFileInfo(const SFileInfo& rhs) : m_NameOffset(rhs.m_NameOffset),
|
||||||
m_Offset(rhs.m_Offset), m_FileSize(rhs.m_FileSize) {
|
m_Offset(rhs.m_Offset), m_FileSize(rhs.m_FileSize), m_FullPath(rhs.m_FullPath)
|
||||||
memcpy(m_FullPath, rhs.m_FullPath, strlen(rhs.m_FullPath) + 1);
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public:
|
||||||
virtual bool ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename) = 0;
|
virtual bool ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename) = 0;
|
||||||
virtual bool ExportApploader(const std::string& _rExportFolder) const = 0;
|
virtual bool ExportApploader(const std::string& _rExportFolder) const = 0;
|
||||||
virtual bool ExportDOL(const std::string& _rExportFolder) const = 0;
|
virtual bool ExportDOL(const std::string& _rExportFolder) const = 0;
|
||||||
virtual const char* GetFileName(u64 _Address) = 0;
|
virtual const std::string GetFileName(u64 _Address) = 0;
|
||||||
virtual bool GetBootDOL(u8* &buffer, u32 DolSize) const = 0;
|
virtual bool GetBootDOL(u8* &buffer, u32 DolSize) const = 0;
|
||||||
virtual u32 GetBootDOLSize() const = 0;
|
virtual u32 GetBootDOLSize() const = 0;
|
||||||
|
|
||||||
|
|
|
@ -320,30 +320,32 @@ size_t CISOProperties::CreateDirectoryTree(wxTreeItemId& parent,
|
||||||
|
|
||||||
while (CurrentIndex < _LastIndex)
|
while (CurrentIndex < _LastIndex)
|
||||||
{
|
{
|
||||||
const DiscIO::SFileInfo *rFileInfo = fileInfos[CurrentIndex];
|
const DiscIO::SFileInfo* rFileInfo = fileInfos[CurrentIndex];
|
||||||
char *name = (char*)rFileInfo->m_FullPath;
|
std::string filePath = rFileInfo->m_FullPath;
|
||||||
|
|
||||||
if (rFileInfo->IsDirectory())
|
// Trim the trailing '/' if it exists.
|
||||||
|
if (filePath[filePath.length() - 1] == DIR_SEP_CHR)
|
||||||
{
|
{
|
||||||
name[strlen(name) - 1] = '\0';
|
filePath.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
char *itemName = strrchr(name, DIR_SEP_CHR);
|
// Cut off the path up to the actual filename or folder.
|
||||||
|
// Say we have "/music/stream/stream1.strm", the result will be "stream1.strm".
|
||||||
if (!itemName)
|
size_t dirSepIndex = filePath.find_last_of(DIR_SEP_CHR);
|
||||||
itemName = name;
|
if (dirSepIndex != std::string::npos)
|
||||||
else
|
{
|
||||||
itemName++;
|
filePath = filePath.substr(dirSepIndex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
// check next index
|
// check next index
|
||||||
if (rFileInfo->IsDirectory())
|
if (rFileInfo->IsDirectory())
|
||||||
{
|
{
|
||||||
wxTreeItemId item = m_Treectrl->AppendItem(parent, StrToWxStr(itemName), 1, 1);
|
wxTreeItemId item = m_Treectrl->AppendItem(parent, StrToWxStr(filePath), 1, 1);
|
||||||
CurrentIndex = CreateDirectoryTree(item, fileInfos, CurrentIndex + 1, (size_t)rFileInfo->m_FileSize);
|
CurrentIndex = CreateDirectoryTree(item, fileInfos, CurrentIndex + 1, (size_t)rFileInfo->m_FileSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Treectrl->AppendItem(parent, StrToWxStr(itemName), 2, 2);
|
m_Treectrl->AppendItem(parent, StrToWxStr(filePath), 2, 2);
|
||||||
CurrentIndex++;
|
CurrentIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -740,7 +742,7 @@ void CISOProperties::OnExtractFile(wxCommandEvent& WXUNUSED (event))
|
||||||
if (DiscIO::IsVolumeWiiDisc(OpenISO))
|
if (DiscIO::IsVolumeWiiDisc(OpenISO))
|
||||||
{
|
{
|
||||||
int partitionNum = wxAtoi(File.Mid(File.find_first_of("/") - 1, 1));
|
int partitionNum = wxAtoi(File.Mid(File.find_first_of("/") - 1, 1));
|
||||||
File.Remove(0, File.find_first_of("/") +1); // Remove "Partition x/"
|
File.Remove(0, File.find_first_of("/") + 1); // Remove "Partition x/"
|
||||||
WiiDisc.at(partitionNum).FileSystem->ExportFile(WxStrToStr(File), WxStrToStr(Path));
|
WiiDisc.at(partitionNum).FileSystem->ExportFile(WxStrToStr(File), WxStrToStr(Path));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -751,7 +753,7 @@ void CISOProperties::OnExtractFile(wxCommandEvent& WXUNUSED (event))
|
||||||
|
|
||||||
void CISOProperties::ExportDir(const char* _rFullPath, const char* _rExportFolder, const int partitionNum)
|
void CISOProperties::ExportDir(const char* _rFullPath, const char* _rExportFolder, const int partitionNum)
|
||||||
{
|
{
|
||||||
char exportName[512];
|
std::string exportName;
|
||||||
u32 index[2] = {0, 0};
|
u32 index[2] = {0, 0};
|
||||||
std::vector<const DiscIO::SFileInfo *> fst;
|
std::vector<const DiscIO::SFileInfo *> fst;
|
||||||
DiscIO::IFileSystem *FS = nullptr;
|
DiscIO::IFileSystem *FS = nullptr;
|
||||||
|
@ -780,7 +782,7 @@ void CISOProperties::ExportDir(const char* _rFullPath, const char* _rExportFolde
|
||||||
{
|
{
|
||||||
for (index[0] = 0; index[0] < fst.size(); index[0]++)
|
for (index[0] = 0; index[0] < fst.size(); index[0]++)
|
||||||
{
|
{
|
||||||
if (!strcmp(fst.at(index[0])->m_FullPath, _rFullPath))
|
if (fst.at(index[0])->m_FullPath == _rFullPath)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(DISCIO, "Found the directory at %u", index[0]);
|
DEBUG_LOG(DISCIO, "Found the directory at %u", index[0]);
|
||||||
index[1] = (u32)fst.at(index[0])->m_FileSize;
|
index[1] = (u32)fst.at(index[0])->m_FileSize;
|
||||||
|
@ -808,41 +810,40 @@ void CISOProperties::ExportDir(const char* _rFullPath, const char* _rExportFolde
|
||||||
dialog.SetTitle(wxString::Format(wxT("%s : %d%%"), dialogTitle.c_str(),
|
dialog.SetTitle(wxString::Format(wxT("%s : %d%%"), dialogTitle.c_str(),
|
||||||
(u32)(((float)(i - index[0]) / (float)(index[1] - index[0])) * 100)));
|
(u32)(((float)(i - index[0]) / (float)(index[1] - index[0])) * 100)));
|
||||||
|
|
||||||
dialog.Update(i, wxString::Format(_("Extracting %s"),
|
dialog.Update(i, wxString::Format(_("Extracting %s"), StrToWxStr(fst[i]->m_FullPath)));
|
||||||
StrToWxStr(fst[i]->m_FullPath)));
|
|
||||||
|
|
||||||
if (dialog.WasCancelled())
|
if (dialog.WasCancelled())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (fst[i]->IsDirectory())
|
if (fst[i]->IsDirectory())
|
||||||
{
|
{
|
||||||
snprintf(exportName, sizeof(exportName), "%s/%s/", _rExportFolder, fst[i]->m_FullPath);
|
exportName = StringFromFormat("%s/%s/", _rExportFolder, fst[i]->m_FullPath.c_str());
|
||||||
DEBUG_LOG(DISCIO, "%s", exportName);
|
DEBUG_LOG(DISCIO, "%s", exportName.c_str());
|
||||||
|
|
||||||
if (!File::Exists(exportName) && !File::CreateFullPath(exportName))
|
if (!File::Exists(exportName) && !File::CreateFullPath(exportName))
|
||||||
{
|
{
|
||||||
ERROR_LOG(DISCIO, "Could not create the path %s", exportName);
|
ERROR_LOG(DISCIO, "Could not create the path %s", exportName.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!File::IsDirectory(exportName))
|
if (!File::IsDirectory(exportName))
|
||||||
ERROR_LOG(DISCIO, "%s already exists and is not a directory", exportName);
|
ERROR_LOG(DISCIO, "%s already exists and is not a directory", exportName.c_str());
|
||||||
|
|
||||||
DEBUG_LOG(DISCIO, "Folder %s already exists", exportName);
|
DEBUG_LOG(DISCIO, "Folder %s already exists", exportName.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf(exportName, sizeof(exportName), "%s/%s", _rExportFolder, fst[i]->m_FullPath);
|
exportName = StringFromFormat("%s/%s", _rExportFolder, fst[i]->m_FullPath.c_str());
|
||||||
DEBUG_LOG(DISCIO, "%s", exportName);
|
DEBUG_LOG(DISCIO, "%s", exportName.c_str());
|
||||||
|
|
||||||
if (!File::Exists(exportName) && !FS->ExportFile(fst[i]->m_FullPath, exportName))
|
if (!File::Exists(exportName) && !FS->ExportFile(fst[i]->m_FullPath, exportName))
|
||||||
{
|
{
|
||||||
ERROR_LOG(DISCIO, "Could not export %s", exportName);
|
ERROR_LOG(DISCIO, "Could not export %s", exportName.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUG_LOG(DISCIO, "%s already exists", exportName);
|
DEBUG_LOG(DISCIO, "%s already exists", exportName.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -869,8 +870,7 @@ void CISOProperties::OnExtractDir(wxCommandEvent& event)
|
||||||
|
|
||||||
while (m_Treectrl->GetItemParent(m_Treectrl->GetSelection()) != m_Treectrl->GetRootItem())
|
while (m_Treectrl->GetItemParent(m_Treectrl->GetSelection()) != m_Treectrl->GetRootItem())
|
||||||
{
|
{
|
||||||
wxString temp;
|
wxString temp = m_Treectrl->GetItemText(m_Treectrl->GetItemParent(m_Treectrl->GetSelection()));
|
||||||
temp = m_Treectrl->GetItemText(m_Treectrl->GetItemParent(m_Treectrl->GetSelection()));
|
|
||||||
Directory = temp + wxT(DIR_SEP_CHR) + Directory;
|
Directory = temp + wxT(DIR_SEP_CHR) + Directory;
|
||||||
|
|
||||||
m_Treectrl->SelectItem(m_Treectrl->GetItemParent(m_Treectrl->GetSelection()));
|
m_Treectrl->SelectItem(m_Treectrl->GetItemParent(m_Treectrl->GetSelection()));
|
||||||
|
@ -879,7 +879,7 @@ void CISOProperties::OnExtractDir(wxCommandEvent& event)
|
||||||
if (DiscIO::IsVolumeWiiDisc(OpenISO))
|
if (DiscIO::IsVolumeWiiDisc(OpenISO))
|
||||||
{
|
{
|
||||||
int partitionNum = wxAtoi(Directory.Mid(Directory.find_first_of("/") - 1, 1));
|
int partitionNum = wxAtoi(Directory.Mid(Directory.find_first_of("/") - 1, 1));
|
||||||
Directory.Remove(0, Directory.find_first_of("/") +1); // Remove "Partition x/"
|
Directory.Remove(0, Directory.find_first_of("/") + 1); // Remove "Partition x/"
|
||||||
ExportDir(WxStrToStr(Directory).c_str(), WxStrToStr(Path).c_str(), partitionNum);
|
ExportDir(WxStrToStr(Directory).c_str(), WxStrToStr(Path).c_str(), partitionNum);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -899,7 +899,7 @@ void CISOProperties::OnExtractDataFromHeader(wxCommandEvent& event)
|
||||||
if (DiscIO::IsVolumeWiiDisc(OpenISO))
|
if (DiscIO::IsVolumeWiiDisc(OpenISO))
|
||||||
{
|
{
|
||||||
wxString Directory = m_Treectrl->GetItemText(m_Treectrl->GetSelection());
|
wxString Directory = m_Treectrl->GetItemText(m_Treectrl->GetSelection());
|
||||||
std::size_t partitionNum = (std::size_t)wxAtoi(Directory.Mid(Directory.find_first_of("0123456789"), 2));
|
int partitionNum = wxAtoi(Directory.Mid(Directory.find_first_of("0123456789"), 2));
|
||||||
|
|
||||||
if (WiiDisc.size() > partitionNum)
|
if (WiiDisc.size() > partitionNum)
|
||||||
{
|
{
|
||||||
|
@ -908,7 +908,7 @@ void CISOProperties::OnExtractDataFromHeader(wxCommandEvent& event)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PanicAlertT("Partition doesn't exist: %u", (unsigned) partitionNum);
|
PanicAlertT("Partition doesn't exist: %d", partitionNum);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue