mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
constification, code style, changed vector<FileInfo*> to vector<FileInfo> for less allocs and more speed in debug mode
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@611 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -135,20 +135,20 @@ bool AsciiToHex(const char* _szValue, u32& result)
|
|||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args)
|
bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args)
|
||||||
{
|
{
|
||||||
int writtenCount = vsnprintf(out, outsize, format, args);
|
int writtenCount = vsnprintf(out, outsize, format, args);
|
||||||
|
|
||||||
if (writtenCount > 0)
|
if (writtenCount > 0 && writtenCount < outsize)
|
||||||
{
|
{
|
||||||
out[writtenCount] = '\0';
|
out[writtenCount] = '\0';
|
||||||
return(true);
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out[outsize - 1] = '\0';
|
out[outsize - 1] = '\0';
|
||||||
return(false);
|
PanicAlert("DANGER WILL ROBINSON! CharArrayFromFormatV overflowed.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +165,8 @@ void StringFromFormatV(std::string* out, const char* format, va_list args)
|
|||||||
delete [] buf;
|
delete [] buf;
|
||||||
buf = new char[newSize + 1];
|
buf = new char[newSize + 1];
|
||||||
writtenCount = vsnprintf(buf, newSize, format, args);
|
writtenCount = vsnprintf(buf, newSize, format, args);
|
||||||
|
if (writtenCount > (int)newSize)
|
||||||
|
writtenCount = -1;
|
||||||
// ARGH! vsnprintf does no longer return -1 on truncation in newer libc!
|
// ARGH! vsnprintf does no longer return -1 on truncation in newer libc!
|
||||||
// WORKAROUND! let's fake the old behaviour (even though it's less efficient).
|
// WORKAROUND! let's fake the old behaviour (even though it's less efficient).
|
||||||
// TODO: figure out why the fix causes an invalid read in strlen called from vsnprintf :(
|
// TODO: figure out why the fix causes an invalid read in strlen called from vsnprintf :(
|
||||||
|
@ -36,97 +36,69 @@ CFileSystemGCWii::CFileSystemGCWii(const IVolume *_rVolume)
|
|||||||
|
|
||||||
CFileSystemGCWii::~CFileSystemGCWii()
|
CFileSystemGCWii::~CFileSystemGCWii()
|
||||||
{
|
{
|
||||||
while(m_FileInfoVector.size() > 0) {
|
|
||||||
SFileInfo *sfi = m_FileInfoVector.back();
|
|
||||||
m_FileInfoVector.pop_back();
|
|
||||||
delete sfi;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CFileSystemGCWii::IsInitialized() const
|
||||||
bool
|
|
||||||
CFileSystemGCWii::IsInitialized()
|
|
||||||
{
|
{
|
||||||
return(m_Initialized);
|
return m_Initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t CFileSystemGCWii::GetFileSize(const char* _rFullPath) const
|
||||||
size_t
|
|
||||||
CFileSystemGCWii::GetFileSize(const char* _rFullPath)
|
|
||||||
{
|
{
|
||||||
if (!m_Initialized)
|
if (!m_Initialized)
|
||||||
{
|
return 0;
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||||
|
|
||||||
if (pFileInfo != NULL)
|
if (pFileInfo != NULL)
|
||||||
{
|
return pFileInfo->m_FileSize;
|
||||||
return(pFileInfo->m_FileSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* CFileSystemGCWii::GetFileName(u64 _Address) const
|
||||||
const char*
|
|
||||||
CFileSystemGCWii::GetFileName(u64 _Address)
|
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
|
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
|
||||||
{
|
{
|
||||||
if ((m_FileInfoVector[i]->m_Offset <= _Address) &&
|
if ((m_FileInfoVector[i].m_Offset <= _Address) &&
|
||||||
((m_FileInfoVector[i]->m_Offset + m_FileInfoVector[i]->m_FileSize) > _Address))
|
((m_FileInfoVector[i].m_Offset + m_FileInfoVector[i].m_FileSize) > _Address))
|
||||||
{
|
{
|
||||||
return(m_FileInfoVector[i]->m_FullPath);
|
return m_FileInfoVector[i].m_FullPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t CFileSystemGCWii::ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const
|
||||||
size_t
|
|
||||||
CFileSystemGCWii::ReadFile(const char* _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 == NULL)
|
if (pFileInfo == NULL)
|
||||||
{
|
return 0;
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pFileInfo->m_FileSize > _MaxBufferSize)
|
if (pFileInfo->m_FileSize > _MaxBufferSize)
|
||||||
{
|
return 0;
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_rVolume->Read(pFileInfo->m_Offset, pFileInfo->m_FileSize, _pBuffer);
|
m_rVolume->Read(pFileInfo->m_Offset, pFileInfo->m_FileSize, _pBuffer);
|
||||||
return(pFileInfo->m_FileSize);
|
return pFileInfo->m_FileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFilename) const
|
||||||
bool
|
|
||||||
CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFilename)
|
|
||||||
{
|
{
|
||||||
size_t filesize = GetFileSize(_rFullPath);
|
size_t filesize = GetFileSize(_rFullPath);
|
||||||
|
|
||||||
if (filesize == 0)
|
if (filesize == 0)
|
||||||
{
|
return false;
|
||||||
return(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
u8* buffer = new u8[filesize];
|
u8* buffer = new u8[filesize];
|
||||||
|
|
||||||
if (!ReadFile(_rFullPath, buffer, filesize))
|
if (!ReadFile(_rFullPath, buffer, filesize))
|
||||||
{
|
{
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* f = fopen(_rExportFilename, "wb");
|
FILE* f = fopen(_rExportFilename, "wb");
|
||||||
@ -136,62 +108,52 @@ CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFilenam
|
|||||||
fwrite(buffer, filesize, 1, f);
|
fwrite(buffer, filesize, 1, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
return(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CFileSystemGCWii::ExportAllFiles(const char* _rFullPath) const
|
||||||
bool
|
|
||||||
CFileSystemGCWii::ExportAllFiles(const char* _rFullPath)
|
|
||||||
{
|
{
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 CFileSystemGCWii::Read32(u64 _Offset) const
|
||||||
u32
|
|
||||||
CFileSystemGCWii::Read32(u64 _Offset) const
|
|
||||||
{
|
{
|
||||||
u32 Temp = 0;
|
u32 Temp = 0;
|
||||||
m_rVolume->Read(_Offset, 4, (u8*)&Temp);
|
m_rVolume->Read(_Offset, 4, (u8*)&Temp);
|
||||||
return(Common::swap32(Temp));
|
return Common::swap32(Temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CFileSystemGCWii::GetStringFromOffset(u64 _Offset, char* Filename) const
|
void CFileSystemGCWii::GetStringFromOffset(u64 _Offset, char* Filename) const
|
||||||
{
|
{
|
||||||
m_rVolume->Read(_Offset, 255, (u8*)Filename);
|
m_rVolume->Read(_Offset, 255, (u8*)Filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CFileSystemGCWii::GetFileList(std::vector<SFileInfo *> &_rFilenames)
|
size_t CFileSystemGCWii::GetFileList(std::vector<const SFileInfo *> &_rFilenames) const
|
||||||
{
|
{
|
||||||
|
if (_rFilenames.size())
|
||||||
|
PanicAlert("GetFileList : input list has contents?");
|
||||||
_rFilenames.clear();
|
_rFilenames.clear();
|
||||||
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
|
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
|
||||||
{
|
_rFilenames.push_back(&m_FileInfoVector[i]);
|
||||||
_rFilenames.push_back(new SFileInfo(*m_FileInfoVector[i]));
|
|
||||||
}
|
|
||||||
return m_FileInfoVector.size();
|
return m_FileInfoVector.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
const SFileInfo*
|
const SFileInfo* CFileSystemGCWii::FindFileInfo(const char* _rFullPath) const
|
||||||
CFileSystemGCWii::FindFileInfo(const char* _rFullPath) const
|
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
|
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
|
||||||
{
|
{
|
||||||
if (!strcasecmp(m_FileInfoVector[i]->m_FullPath, _rFullPath))
|
if (!strcasecmp(m_FileInfoVector[i].m_FullPath, _rFullPath))
|
||||||
{
|
return &m_FileInfoVector[i];
|
||||||
return(m_FileInfoVector[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CFileSystemGCWii::InitFileSystem()
|
||||||
bool
|
|
||||||
CFileSystemGCWii::InitFileSystem()
|
|
||||||
{
|
{
|
||||||
if (Read32(0x18) == 0x5D1C9EA3)
|
if (Read32(0x18) == 0x5D1C9EA3)
|
||||||
{
|
{
|
||||||
@ -203,7 +165,7 @@ CFileSystemGCWii::InitFileSystem()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the whole FST
|
// read the whole FST
|
||||||
@ -225,11 +187,11 @@ CFileSystemGCWii::InitFileSystem()
|
|||||||
|
|
||||||
for (u32 i = 0; i < Root.m_FileSize; i++)
|
for (u32 i = 0; i < Root.m_FileSize; i++)
|
||||||
{
|
{
|
||||||
SFileInfo *sfi = new SFileInfo();
|
SFileInfo sfi;
|
||||||
u64 Offset = FSTOffset + (i * 0xC);
|
u64 Offset = FSTOffset + (i * 0xC);
|
||||||
sfi->m_NameOffset = Read32(Offset + 0x0);
|
sfi.m_NameOffset = Read32(Offset + 0x0);
|
||||||
sfi->m_Offset = (u64)Read32(Offset + 0x4) << m_OffsetShift;
|
sfi.m_Offset = (u64)Read32(Offset + 0x4) << m_OffsetShift;
|
||||||
sfi->m_FileSize = Read32(Offset + 0x8);
|
sfi.m_FileSize = Read32(Offset + 0x8);
|
||||||
|
|
||||||
m_FileInfoVector.push_back(sfi);
|
m_FileInfoVector.push_back(sfi);
|
||||||
|
|
||||||
@ -239,24 +201,23 @@ CFileSystemGCWii::InitFileSystem()
|
|||||||
BuildFilenames(1, m_FileInfoVector.size(), NULL, NameTableOffset);
|
BuildFilenames(1, m_FileInfoVector.size(), NULL, NameTableOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// __________________________________________________________________________________________________
|
// __________________________________________________________________________________________________
|
||||||
//
|
//
|
||||||
// Changed this stuff from C++ string to C strings for speed in debug mode. Doesn't matter in release, but
|
// Changed this stuff from C++ string to C strings for speed in debug mode. Doesn't matter in release, but
|
||||||
// std::string is SLOW in debug mode.
|
// std::string is SLOW in debug mode.
|
||||||
size_t
|
size_t CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, u64 _NameTableOffset)
|
||||||
CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, u64 _NameTableOffset)
|
|
||||||
{
|
{
|
||||||
size_t CurrentIndex = _FirstIndex;
|
size_t CurrentIndex = _FirstIndex;
|
||||||
|
|
||||||
while (CurrentIndex < _LastIndex)
|
while (CurrentIndex < _LastIndex)
|
||||||
{
|
{
|
||||||
SFileInfo *rFileInfo = m_FileInfoVector[CurrentIndex];
|
SFileInfo *rFileInfo = &m_FileInfoVector[CurrentIndex];
|
||||||
u64 uOffset = _NameTableOffset + (rFileInfo->m_NameOffset & 0xFFFFFF);
|
u64 uOffset = _NameTableOffset + (rFileInfo->m_NameOffset & 0xFFFFFF);
|
||||||
char filename[512];
|
char filename[512];
|
||||||
|
memset(filename, 0, sizeof(filename));
|
||||||
GetStringFromOffset(uOffset, filename);
|
GetStringFromOffset(uOffset, filename);
|
||||||
|
|
||||||
// check next index
|
// check next index
|
||||||
@ -264,13 +225,9 @@ CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastInd
|
|||||||
{
|
{
|
||||||
// this is a directory, build up the new szDirectory
|
// this is a directory, build up the new szDirectory
|
||||||
if (_szDirectory != NULL)
|
if (_szDirectory != NULL)
|
||||||
{
|
|
||||||
CharArrayFromFormat(rFileInfo->m_FullPath, "%s%s\\", _szDirectory, filename);
|
CharArrayFromFormat(rFileInfo->m_FullPath, "%s%s\\", _szDirectory, filename);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
CharArrayFromFormat(rFileInfo->m_FullPath, "%s\\", filename);
|
CharArrayFromFormat(rFileInfo->m_FullPath, "%s\\", filename);
|
||||||
}
|
|
||||||
|
|
||||||
CurrentIndex = BuildFilenames(CurrentIndex + 1, rFileInfo->m_FileSize, rFileInfo->m_FullPath, _NameTableOffset);
|
CurrentIndex = BuildFilenames(CurrentIndex + 1, rFileInfo->m_FileSize, rFileInfo->m_FullPath, _NameTableOffset);
|
||||||
}
|
}
|
||||||
@ -278,19 +235,16 @@ CFileSystemGCWii::BuildFilenames(const size_t _FirstIndex, const size_t _LastInd
|
|||||||
{
|
{
|
||||||
// this is a filename
|
// this is a filename
|
||||||
if (_szDirectory != NULL)
|
if (_szDirectory != NULL)
|
||||||
{
|
|
||||||
CharArrayFromFormat(rFileInfo->m_FullPath, "%s%s", _szDirectory, filename);
|
CharArrayFromFormat(rFileInfo->m_FullPath, "%s%s", _szDirectory, filename);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
CharArrayFromFormat(rFileInfo->m_FullPath, "%s", filename);
|
CharArrayFromFormat(rFileInfo->m_FullPath, "%s", filename);
|
||||||
}
|
|
||||||
|
|
||||||
CurrentIndex++;
|
CurrentIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(CurrentIndex);
|
return CurrentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -24,48 +24,33 @@
|
|||||||
|
|
||||||
namespace DiscIO
|
namespace DiscIO
|
||||||
{
|
{
|
||||||
class CFileSystemGCWii
|
|
||||||
: public IFileSystem
|
class CFileSystemGCWii : public IFileSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CFileSystemGCWii(const IVolume *_rVolume);
|
CFileSystemGCWii(const IVolume *_rVolume);
|
||||||
|
|
||||||
virtual ~CFileSystemGCWii();
|
virtual ~CFileSystemGCWii();
|
||||||
|
virtual bool IsInitialized() const;
|
||||||
virtual bool IsInitialized();
|
virtual size_t GetFileSize(const char* _rFullPath) const;
|
||||||
|
virtual const char* GetFileName(u64 _Address) const;
|
||||||
virtual size_t GetFileSize(const char* _rFullPath);
|
virtual size_t ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const;
|
||||||
|
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) const;
|
||||||
virtual const char* GetFileName(u64 _Address);
|
virtual bool ExportAllFiles(const char* _rFullPath) const;
|
||||||
|
|
||||||
virtual size_t ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize);
|
|
||||||
|
|
||||||
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename);
|
|
||||||
|
|
||||||
virtual bool ExportAllFiles(const char* _rFullPath);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::vector <SFileInfo> m_FileInfoVector;
|
||||||
std::vector<SFileInfo *> m_FileInfoVector;
|
|
||||||
|
|
||||||
bool m_Initialized;
|
bool m_Initialized;
|
||||||
|
|
||||||
u32 m_OffsetShift; // WII offsets are all shifted
|
u32 m_OffsetShift; // WII offsets are all shifted
|
||||||
|
|
||||||
u32 Read32(u64 _Offset) const;
|
u32 Read32(u64 _Offset) const;
|
||||||
|
virtual size_t GetFileList(std::vector<const SFileInfo *> &_rFilenames) const;
|
||||||
virtual size_t GetFileList(std::vector<SFileInfo *> &_rFilenames);
|
|
||||||
|
|
||||||
void GetStringFromOffset(u64 _Offset, char* Filename) const;
|
void GetStringFromOffset(u64 _Offset, char* Filename) const;
|
||||||
|
|
||||||
const SFileInfo* FindFileInfo(const char* _rFullPath) const;
|
const SFileInfo* FindFileInfo(const char* _rFullPath) const;
|
||||||
|
|
||||||
bool InitFileSystem();
|
bool 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 char* _szDirectory, u64 _NameTableOffset);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,15 +36,15 @@ IFileSystem* CreateFileSystem(const IVolume* _rVolume)
|
|||||||
{
|
{
|
||||||
IFileSystem* pFileSystem = new CFileSystemGCWii(_rVolume);
|
IFileSystem* pFileSystem = new CFileSystemGCWii(_rVolume);
|
||||||
|
|
||||||
if (pFileSystem)
|
if (!pFileSystem)
|
||||||
{
|
return 0;
|
||||||
|
|
||||||
if (!pFileSystem->IsInitialized())
|
if (!pFileSystem->IsInitialized())
|
||||||
{
|
{
|
||||||
delete pFileSystem;
|
delete pFileSystem;
|
||||||
pFileSystem = NULL;
|
pFileSystem = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return(pFileSystem);
|
return pFileSystem;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -31,10 +31,10 @@ struct SFileInfo
|
|||||||
u32 m_FileSize;
|
u32 m_FileSize;
|
||||||
char m_FullPath[512];
|
char m_FullPath[512];
|
||||||
|
|
||||||
bool IsDirectory() {return((m_NameOffset& 0xFF000000) != 0 ? true : false);}
|
bool IsDirectory() const { return (m_NameOffset & 0xFF000000) != 0 ? true : false; }
|
||||||
|
|
||||||
SFileInfo() : m_NameOffset(0), m_Offset(0), m_FileSize(0) {
|
SFileInfo() : m_NameOffset(0), m_Offset(0), m_FileSize(0) {
|
||||||
memset(m_FullPath, 0, 512);
|
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),
|
||||||
@ -42,39 +42,29 @@ struct SFileInfo
|
|||||||
strcpy(m_FullPath, rhs.m_FullPath);
|
strcpy(m_FullPath, rhs.m_FullPath);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class IFileSystem
|
class IFileSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
IFileSystem(const IVolume *_rVolume);
|
IFileSystem(const IVolume *_rVolume);
|
||||||
|
|
||||||
virtual ~IFileSystem();
|
virtual ~IFileSystem();
|
||||||
|
virtual bool IsInitialized() const = 0;
|
||||||
|
virtual size_t GetFileList(std::vector<const SFileInfo *> &_rFilenames) const = 0;
|
||||||
|
virtual size_t GetFileSize(const char* _rFullPath) const = 0;
|
||||||
|
|
||||||
virtual bool IsInitialized() = 0;
|
virtual size_t ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const = 0;
|
||||||
|
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) const = 0;
|
||||||
|
virtual bool ExportAllFiles(const char* _rFullPath) const = 0;
|
||||||
virtual size_t GetFileList(std::vector<SFileInfo *> &_rFilenames) = 0;
|
virtual const char* GetFileName(u64 _Address) const = 0;
|
||||||
|
|
||||||
virtual size_t GetFileSize(const char* _rFullPath) = 0;
|
|
||||||
|
|
||||||
virtual size_t ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) = 0;
|
|
||||||
|
|
||||||
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) = 0;
|
|
||||||
|
|
||||||
virtual bool ExportAllFiles(const char* _rFullPath) = 0;
|
|
||||||
|
|
||||||
virtual const char* GetFileName(u64 _Address) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
virtual const IVolume *GetVolume() {return(m_rVolume);}
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
|
virtual const IVolume *GetVolume() const { return m_rVolume; }
|
||||||
|
protected:
|
||||||
const IVolume *m_rVolume;
|
const IVolume *m_rVolume;
|
||||||
};
|
};
|
||||||
|
|
||||||
IFileSystem* CreateFileSystem(const IVolume *_rVolume);
|
IFileSystem* CreateFileSystem(const IVolume *_rVolume);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class CISOFile;
|
class GameListItem;
|
||||||
|
|
||||||
namespace BootManager
|
namespace BootManager
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ DiscIO::IFileSystem* pFileSystem = NULL;
|
|||||||
CFilesystemViewer::CFilesystemViewer(const std::string fileName, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
|
CFilesystemViewer::CFilesystemViewer(const std::string fileName, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
|
||||||
: wxDialog(parent, id, title, position, size, style)
|
: wxDialog(parent, id, title, position, size, style)
|
||||||
{
|
{
|
||||||
std::vector<DiscIO::SFileInfo *> Our_Files;
|
std::vector<const DiscIO::SFileInfo *> Our_Files;
|
||||||
|
|
||||||
OpenIso = DiscIO::CreateVolumeFromFilename(fileName);
|
OpenIso = DiscIO::CreateVolumeFromFilename(fileName);
|
||||||
pFileSystem = DiscIO::CreateFileSystem(OpenIso);
|
pFileSystem = DiscIO::CreateFileSystem(OpenIso);
|
||||||
|
@ -36,8 +36,9 @@
|
|||||||
#include "../resources/Flag_USA.xpm"
|
#include "../resources/Flag_USA.xpm"
|
||||||
#endif // USE_XPM_BITMAPS
|
#endif // USE_XPM_BITMAPS
|
||||||
|
|
||||||
int currentColumn ;
|
static int currentColumn = 0;
|
||||||
bool operator < (const CISOFile &one, const CISOFile &other)
|
|
||||||
|
bool operator < (const GameListItem &one, const GameListItem &other)
|
||||||
{
|
{
|
||||||
switch(currentColumn)
|
switch(currentColumn)
|
||||||
{
|
{
|
||||||
@ -189,7 +190,7 @@ wxString NiceSizeFormat(s64 _size)
|
|||||||
|
|
||||||
void CGameListCtrl::InsertItemInReportView(long _Index)
|
void CGameListCtrl::InsertItemInReportView(long _Index)
|
||||||
{
|
{
|
||||||
CISOFile& rISOFile = m_ISOFiles[_Index];
|
GameListItem& rISOFile = m_ISOFiles[_Index];
|
||||||
|
|
||||||
int ImageIndex = -1;
|
int ImageIndex = -1;
|
||||||
|
|
||||||
@ -284,7 +285,7 @@ bool CGameListCtrl::MSWDrawSubItem(wxPaintDC& rPaintDC, int item, int subitem)
|
|||||||
|
|
||||||
if (Index < m_ISOFiles.size())
|
if (Index < m_ISOFiles.size())
|
||||||
{
|
{
|
||||||
const CISOFile& rISO = m_ISOFiles[Index];
|
const GameListItem& rISO = m_ISOFiles[Index];
|
||||||
wxRect SubItemRect;
|
wxRect SubItemRect;
|
||||||
this->GetSubItemRect(item, subitem, SubItemRect);
|
this->GetSubItemRect(item, subitem, SubItemRect);
|
||||||
m_imageListSmall->Draw(m_FlagImageIndex[rISO.GetCountry()], rPaintDC, SubItemRect.GetLeft(), SubItemRect.GetTop());
|
m_imageListSmall->Draw(m_FlagImageIndex[rISO.GetCountry()], rPaintDC, SubItemRect.GetLeft(), SubItemRect.GetTop());
|
||||||
@ -364,7 +365,7 @@ void CGameListCtrl::ScanForISOs()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CISOFile ISOFile(rFilenames[i]);
|
GameListItem ISOFile(rFilenames[i]);
|
||||||
|
|
||||||
if (ISOFile.IsValid())
|
if (ISOFile.IsValid())
|
||||||
m_ISOFiles.push_back(ISOFile);
|
m_ISOFiles.push_back(ISOFile);
|
||||||
@ -382,7 +383,7 @@ void CGameListCtrl::OnColBeginDrag(wxListEvent& event)
|
|||||||
event.Veto();
|
event.Veto();
|
||||||
}
|
}
|
||||||
|
|
||||||
const CISOFile * CGameListCtrl::GetISO(int index) const
|
const GameListItem *CGameListCtrl::GetISO(int index) const
|
||||||
{
|
{
|
||||||
return &m_ISOFiles[index];
|
return &m_ISOFiles[index];
|
||||||
}
|
}
|
||||||
@ -393,14 +394,14 @@ int wxCALLBACK wxListCompare(long item1, long item2, long sortData)
|
|||||||
//return 1 if item1 > item2
|
//return 1 if item1 > item2
|
||||||
//return -1 if item1 < item2
|
//return -1 if item1 < item2
|
||||||
//0 for identity
|
//0 for identity
|
||||||
const CISOFile *iso1 = caller->GetISO(item1);
|
const GameListItem *iso1 = caller->GetISO(item1);
|
||||||
const CISOFile *iso2 = caller->GetISO(item2);
|
const GameListItem *iso2 = caller->GetISO(item2);
|
||||||
|
|
||||||
int t = 1;
|
int t = 1;
|
||||||
|
|
||||||
if(sortData<0)
|
if (sortData < 0)
|
||||||
{
|
{
|
||||||
t=-1;
|
t = -1;
|
||||||
sortData = -sortData;
|
sortData = -sortData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +464,7 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event)
|
|||||||
SetItemState(item, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
|
SetItemState(item, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
|
||||||
wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
|
wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
|
||||||
}
|
}
|
||||||
const CISOFile *selected_iso = GetSelectedISO();
|
const GameListItem *selected_iso = GetSelectedISO();
|
||||||
if (selected_iso)
|
if (selected_iso)
|
||||||
{
|
{
|
||||||
std::string unique_id = selected_iso->GetUniqueID();
|
std::string unique_id = selected_iso->GetUniqueID();
|
||||||
@ -496,13 +497,13 @@ void CGameListCtrl::OnActivated(wxListEvent& event)
|
|||||||
size_t Index = event.GetData();
|
size_t Index = event.GetData();
|
||||||
if (Index < m_ISOFiles.size())
|
if (Index < m_ISOFiles.size())
|
||||||
{
|
{
|
||||||
const CISOFile& rISOFile = m_ISOFiles[Index];
|
const GameListItem& rISOFile = m_ISOFiles[Index];
|
||||||
BootManager::BootCore(rISOFile.GetFileName());
|
BootManager::BootCore(rISOFile.GetFileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CISOFile * CGameListCtrl::GetSelectedISO() const
|
const GameListItem * CGameListCtrl::GetSelectedISO() const
|
||||||
{
|
{
|
||||||
int item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
int item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||||
if (item == -1)
|
if (item == -1)
|
||||||
@ -512,7 +513,7 @@ const CISOFile * CGameListCtrl::GetSelectedISO() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event)) {
|
void CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event)) {
|
||||||
const CISOFile *iso = GetSelectedISO();
|
const GameListItem *iso = GetSelectedISO();
|
||||||
if (!iso)
|
if (!iso)
|
||||||
return;
|
return;
|
||||||
std::string path;
|
std::string path;
|
||||||
@ -521,7 +522,7 @@ void CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
|
void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
|
||||||
const CISOFile *iso = GetSelectedISO();
|
const GameListItem *iso = GetSelectedISO();
|
||||||
if (!iso)
|
if (!iso)
|
||||||
return;
|
return;
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM = iso->GetFileName();
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM = iso->GetFileName();
|
||||||
@ -529,7 +530,7 @@ void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event)) {
|
void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event)) {
|
||||||
const CISOFile *iso = GetSelectedISO();
|
const GameListItem *iso = GetSelectedISO();
|
||||||
if (!iso)
|
if (!iso)
|
||||||
return;
|
return;
|
||||||
if (wxMessageBox("Are you sure you want to delete this file?", wxMessageBoxCaptionStr, wxYES_NO) == wxYES)
|
if (wxMessageBox("Are you sure you want to delete this file?", wxMessageBoxCaptionStr, wxYES_NO) == wxYES)
|
||||||
@ -539,7 +540,7 @@ void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CGameListCtrl::OnFilesystemViewer(wxCommandEvent& WXUNUSED (event)) {
|
void CGameListCtrl::OnFilesystemViewer(wxCommandEvent& WXUNUSED (event)) {
|
||||||
const CISOFile *iso = GetSelectedISO();
|
const GameListItem *iso = GetSelectedISO();
|
||||||
if (!iso)
|
if (!iso)
|
||||||
return;
|
return;
|
||||||
CFilesystemViewer FSViewer(iso->GetFileName(), this);
|
CFilesystemViewer FSViewer(iso->GetFileName(), this);
|
||||||
@ -553,7 +554,7 @@ void CGameListCtrl::CompressCB(const char* text, float percent, void* arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) {
|
void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) {
|
||||||
const CISOFile *iso = GetSelectedISO();
|
const GameListItem *iso = GetSelectedISO();
|
||||||
if (!iso)
|
if (!iso)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -624,7 +625,7 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) {
|
|||||||
|
|
||||||
void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
|
void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
const CISOFile *iso = GetSelectedISO();
|
const GameListItem *iso = GetSelectedISO();
|
||||||
if (!iso)
|
if (!iso)
|
||||||
return;
|
return;
|
||||||
std::string filename = "Patches/" + iso->GetUniqueID() + ".ini";
|
std::string filename = "Patches/" + iso->GetUniqueID() + ".ini";
|
||||||
@ -644,6 +645,7 @@ void CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
|
|||||||
|
|
||||||
void CGameListCtrl::OnSelected(wxListEvent& WXUNUSED (event))
|
void CGameListCtrl::OnSelected(wxListEvent& WXUNUSED (event))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameListCtrl::OnSize(wxSizeEvent& event)
|
void CGameListCtrl::OnSize(wxSizeEvent& event)
|
||||||
|
@ -33,8 +33,8 @@ class CGameListCtrl : public wxListCtrl
|
|||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
void BrowseForDirectory();
|
void BrowseForDirectory();
|
||||||
const CISOFile *GetSelectedISO() const;
|
const GameListItem *GetSelectedISO() const;
|
||||||
const CISOFile *GetISO(int index) const;
|
const GameListItem *GetISO(int index) const;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -50,8 +50,8 @@ class CGameListCtrl : public wxListCtrl
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::vector<int>m_FlagImageIndex;
|
std::vector<int> m_FlagImageIndex;
|
||||||
std::vector<CISOFile> m_ISOFiles;
|
std::vector<GameListItem> m_ISOFiles;
|
||||||
|
|
||||||
int last_column;
|
int last_column;
|
||||||
int last_sort;
|
int last_sort;
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
static u32 g_ImageTemp[DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT];
|
static u32 g_ImageTemp[DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT];
|
||||||
|
|
||||||
CISOFile::CISOFile(const std::string& _rFileName)
|
GameListItem::GameListItem(const std::string& _rFileName)
|
||||||
: m_FileName(_rFileName),
|
: m_FileName(_rFileName),
|
||||||
m_FileSize(0),
|
m_FileSize(0),
|
||||||
m_Valid(false),
|
m_Valid(false),
|
||||||
@ -65,7 +65,6 @@ CISOFile::CISOFile(const std::string& _rFileName)
|
|||||||
pBannerLoader->GetName(m_Name, 0); //m_Country == DiscIO::IVolume::COUNTRY_JAP ? 1 : 0);
|
pBannerLoader->GetName(m_Name, 0); //m_Country == DiscIO::IVolume::COUNTRY_JAP ? 1 : 0);
|
||||||
pBannerLoader->GetCompany(m_Company);
|
pBannerLoader->GetCompany(m_Company);
|
||||||
pBannerLoader->GetDescription(m_Description);
|
pBannerLoader->GetDescription(m_Description);
|
||||||
|
|
||||||
if (pBannerLoader->GetBanner(g_ImageTemp))
|
if (pBannerLoader->GetBanner(g_ImageTemp))
|
||||||
{
|
{
|
||||||
unsigned char* pImage = (unsigned char*)malloc(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT * 3);
|
unsigned char* pImage = (unsigned char*)malloc(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT * 3);
|
||||||
@ -83,6 +82,7 @@ CISOFile::CISOFile(const std::string& _rFileName)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// default banner
|
// default banner
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pBannerLoader;
|
delete pBannerLoader;
|
||||||
@ -98,7 +98,7 @@ CISOFile::CISOFile(const std::string& _rFileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CISOFile::~CISOFile()
|
GameListItem::~GameListItem()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
|
|
||||||
#include "Volume.h"
|
#include "Volume.h"
|
||||||
|
|
||||||
class CISOFile
|
class GameListItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CISOFile(const std::string& _rFileName);
|
GameListItem(const std::string& _rFileName);
|
||||||
~CISOFile();
|
~GameListItem();
|
||||||
|
|
||||||
bool IsValid() const {return m_Valid;}
|
bool IsValid() const {return m_Valid;}
|
||||||
const std::string& GetFileName() const {return m_FileName;}
|
const std::string& GetFileName() const {return m_FileName;}
|
||||||
|
@ -51,6 +51,11 @@ Display* GXdsp;
|
|||||||
bool KeyStatus[23];
|
bool KeyStatus[23];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void __Log(int, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
//DebugLog(fmt);
|
||||||
|
}
|
||||||
|
|
||||||
// controls
|
// controls
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user