mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-27 06:35:39 +00:00
Filesystem: Make FindFileInfo public
This commit is contained in:
parent
07d3a39aeb
commit
3d5ef948d0
@ -42,12 +42,34 @@ FileSystemGCWii::~FileSystemGCWii()
|
||||
m_FileInfoVector.clear();
|
||||
}
|
||||
|
||||
const std::vector<FileInfoGCWii>& FileSystemGCWii::GetFileList()
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
return m_FileInfoVector;
|
||||
}
|
||||
|
||||
const FileInfo* FileSystemGCWii::FindFileInfo(const std::string& _rFullPath)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
for (size_t i = 0; i < m_FileInfoVector.size(); ++i)
|
||||
{
|
||||
if (!strcasecmp(GetPathFromFSTOffset(i).c_str(), _rFullPath.c_str()))
|
||||
return &m_FileInfoVector[i];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
u64 FileSystemGCWii::GetFileSize(const std::string& _rFullPath)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
const FileInfoGCWii* pFileInfo = FindFileInfo(_rFullPath);
|
||||
const FileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
|
||||
if (pFileInfo != nullptr && !pFileInfo->IsDirectory())
|
||||
return pFileInfo->GetSize();
|
||||
@ -119,7 +141,7 @@ u64 FileSystemGCWii::ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64 _
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
const FileInfoGCWii* pFileInfo = FindFileInfo(_rFullPath);
|
||||
const FileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
if (pFileInfo == nullptr)
|
||||
return 0;
|
||||
|
||||
@ -142,7 +164,7 @@ bool FileSystemGCWii::ExportFile(const std::string& _rFullPath, const std::strin
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
const FileInfoGCWii* pFileInfo = FindFileInfo(_rFullPath);
|
||||
const FileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
|
||||
if (!pFileInfo)
|
||||
return false;
|
||||
@ -276,28 +298,6 @@ std::string FileSystemGCWii::GetStringFromOffset(u64 _Offset) const
|
||||
return SHIFTJISToUTF8(data);
|
||||
}
|
||||
|
||||
const std::vector<FileInfoGCWii>& FileSystemGCWii::GetFileList()
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
return m_FileInfoVector;
|
||||
}
|
||||
|
||||
const FileInfoGCWii* FileSystemGCWii::FindFileInfo(const std::string& _rFullPath)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
for (size_t i = 0; i < m_FileInfoVector.size(); ++i)
|
||||
{
|
||||
if (!strcasecmp(GetPathFromFSTOffset(i).c_str(), _rFullPath.c_str()))
|
||||
return &m_FileInfoVector[i];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool FileSystemGCWii::DetectFileSystem()
|
||||
{
|
||||
if (m_rVolume->ReadSwapped<u32>(0x18, m_partition) == u32(0x5D1C9EA3))
|
||||
|
@ -42,8 +42,9 @@ public:
|
||||
FileSystemGCWii(const Volume* _rVolume, const Partition& partition);
|
||||
~FileSystemGCWii() override;
|
||||
bool IsValid() const override { return m_Valid; }
|
||||
u64 GetFileSize(const std::string& _rFullPath) override;
|
||||
const std::vector<FileInfoGCWii>& GetFileList() override;
|
||||
const FileInfo* FindFileInfo(const std::string& path) override;
|
||||
u64 GetFileSize(const std::string& _rFullPath) override;
|
||||
std::string GetPath(u64 _Address) override;
|
||||
std::string GetPathFromFSTOffset(size_t file_info_offset) override;
|
||||
u64 ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64 _MaxBufferSize,
|
||||
@ -61,7 +62,6 @@ private:
|
||||
std::vector<FileInfoGCWii> m_FileInfoVector;
|
||||
|
||||
std::string GetStringFromOffset(u64 _Offset) const;
|
||||
const FileInfoGCWii* FindFileInfo(const std::string& _rFullPath);
|
||||
bool DetectFileSystem();
|
||||
void InitFileSystem();
|
||||
};
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
// TODO: Should only return FileInfo, not FileInfoGCWii
|
||||
virtual const std::vector<FileInfoGCWii>& GetFileList() = 0;
|
||||
virtual u64 GetFileSize(const std::string& _rFullPath) = 0;
|
||||
virtual const FileInfo* FindFileInfo(const std::string& path) = 0;
|
||||
virtual u64 ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64 _MaxBufferSize,
|
||||
u64 _OffsetInFile = 0) = 0;
|
||||
virtual bool ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename) = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user