mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-16 23:43:13 +00:00
Clean up FileHandlerARC.cpp/.h
- Removed parentheses from the returns. - Put the function declaration headers back on a single line. - Make FindFileInfo's parameter a const string reference.
This commit is contained in:
parent
63a09b76f9
commit
f325fc9634
@ -69,70 +69,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 +137,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));
|
||||||
@ -186,12 +180,11 @@ CARCFile::ParseBuffer()
|
|||||||
BuildFilenames(1, m_FileInfoVector.size(), nullptr, szNameTable);
|
BuildFilenames(1, m_FileInfoVector.size(), nullptr, szNameTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t CARCFile::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _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;
|
||||||
|
|
||||||
@ -231,21 +224,20 @@ CARCFile::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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, _rFullPath.c_str()))
|
||||||
{
|
{
|
||||||
return(&fileInfo);
|
return &fileInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(nullptr);
|
return nullptr;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -49,6 +49,6 @@ class CARCFile
|
|||||||
|
|
||||||
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 char* _szDirectory, const char* _szNameTable);
|
||||||
|
|
||||||
const SFileInfo* FindFileInfo(std::string _rFullPath) const;
|
const SFileInfo* FindFileInfo(const std::string& _rFullPath) const;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Loading…
x
Reference in New Issue
Block a user