mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-27 06:35:39 +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
|
||||
CARCFile::IsInitialized()
|
||||
bool CARCFile::IsInitialized()
|
||||
{
|
||||
return(m_Initialized);
|
||||
return m_Initialized;
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
CARCFile::GetFileSize(const std::string& _rFullPath)
|
||||
size_t CARCFile::GetFileSize(const std::string& _rFullPath)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
{
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
|
||||
if (pFileInfo != nullptr)
|
||||
{
|
||||
return((size_t) pFileInfo->m_FileSize);
|
||||
return (size_t) pFileInfo->m_FileSize;
|
||||
}
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
CARCFile::ReadFile(const std::string& _rFullPath, u8* _pBuffer, size_t _MaxBufferSize)
|
||||
size_t CARCFile::ReadFile(const std::string& _rFullPath, u8* _pBuffer, size_t _MaxBufferSize)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
{
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
|
||||
if (pFileInfo == nullptr)
|
||||
{
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pFileInfo->m_FileSize > _MaxBufferSize)
|
||||
{
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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
|
||||
CARCFile::ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename)
|
||||
bool CARCFile::ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
{
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
|
||||
if (pFileInfo == nullptr)
|
||||
{
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
File::IOFile pFile(_rExportFilename, "wb");
|
||||
@ -141,15 +137,13 @@ CARCFile::ExportFile(const std::string& _rFullPath, const std::string& _rExportF
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CARCFile::ExportAllFiles(const std::string& _rFullPath)
|
||||
bool CARCFile::ExportAllFiles(const std::string& _rFullPath)
|
||||
{
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CARCFile::ParseBuffer()
|
||||
bool CARCFile::ParseBuffer()
|
||||
{
|
||||
// check ID
|
||||
u32 ID = Common::swap32(*(u32*)(m_pBuffer));
|
||||
@ -186,12 +180,11 @@ CARCFile::ParseBuffer()
|
||||
BuildFilenames(1, m_FileInfoVector.size(), nullptr, szNameTable);
|
||||
}
|
||||
|
||||
return(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
CARCFile::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, const char* _szNameTable)
|
||||
size_t CARCFile::BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, const char* _szNameTable)
|
||||
{
|
||||
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*
|
||||
CARCFile::FindFileInfo(std::string _rFullPath) const
|
||||
const SFileInfo* CARCFile::FindFileInfo(const std::string& _rFullPath) const
|
||||
{
|
||||
for (auto& fileInfo : m_FileInfoVector)
|
||||
{
|
||||
if (!strcasecmp(fileInfo.m_FullPath, _rFullPath.c_str()))
|
||||
{
|
||||
return(&fileInfo);
|
||||
return &fileInfo;
|
||||
}
|
||||
}
|
||||
|
||||
return(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace
|
||||
|
@ -49,6 +49,6 @@ class CARCFile
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user