summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/FileHandlerARC.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2014-03-14 23:38:14 -0400
committerLioncash <mathew1800@gmail.com>2014-03-16 16:54:00 -0400
commitbd1ce18f9092f2929929513729e8abee8f60e4a5 (patch)
tree17e710b3672d4a971202dd7d4069eb880ecc1f23 /Source/Core/DiscIO/FileHandlerARC.cpp
parentf325fc9634350f63faa7b04893805ada8d3f8816 (diff)
Simplify file tree building for the filesystem view.
Technically this also simplifies on disc filename building in general.
Diffstat (limited to 'Source/Core/DiscIO/FileHandlerARC.cpp')
-rw-r--r--Source/Core/DiscIO/FileHandlerARC.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/Source/Core/DiscIO/FileHandlerARC.cpp b/Source/Core/DiscIO/FileHandlerARC.cpp
index 960ecaf07d..6215b0a100 100644
--- a/Source/Core/DiscIO/FileHandlerARC.cpp
+++ b/Source/Core/DiscIO/FileHandlerARC.cpp
@@ -9,6 +9,7 @@
#include "Common/Common.h"
#include "Common/FileUtil.h"
+#include "Common/StringUtil.h"
#include "DiscIO/Blob.h"
#include "DiscIO/FileHandlerARC.h"
#include "DiscIO/Filesystem.h"
@@ -86,7 +87,7 @@ size_t CARCFile::GetFileSize(const std::string& _rFullPath)
if (pFileInfo != nullptr)
{
- return (size_t) pFileInfo->m_FileSize;
+ return (size_t)pFileInfo->m_FileSize;
}
return 0;
@@ -177,14 +178,14 @@ bool CARCFile::ParseBuffer()
szNameTable += 0xC;
}
- BuildFilenames(1, m_FileInfoVector.size(), nullptr, szNameTable);
+ BuildFilenames(1, m_FileInfoVector.size(), "", szNameTable);
}
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 std::string& _szDirectory, const char* _szNameTable)
{
size_t CurrentIndex = _FirstIndex;
@@ -196,29 +197,19 @@ size_t CARCFile::BuildFilenames(const size_t _FirstIndex, const size_t _LastInde
// check next index
if (rFileInfo.IsDirectory())
{
- // this is a directory, build up the new szDirectory
- if (_szDirectory != nullptr)
- {
- sprintf(rFileInfo.m_FullPath, "%s%s/", _szDirectory, &_szNameTable[uOffset]);
- }
+ if (_szDirectory.empty())
+ rFileInfo.m_FullPath += StringFromFormat("%s/", &_szNameTable[uOffset]);
else
- {
- sprintf(rFileInfo.m_FullPath, "%s/", &_szNameTable[uOffset]);
- }
+ rFileInfo.m_FullPath += StringFromFormat("%s%s/", _szDirectory.c_str(), &_szNameTable[uOffset]);
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 != nullptr)
- {
- sprintf(rFileInfo.m_FullPath, "%s%s", _szDirectory, &_szNameTable[uOffset]);
- }
+ if (_szDirectory.empty())
+ rFileInfo.m_FullPath += StringFromFormat("%s", &_szNameTable[uOffset]);
else
- {
- sprintf(rFileInfo.m_FullPath, "%s", &_szNameTable[uOffset]);
- }
+ rFileInfo.m_FullPath += StringFromFormat("%s%s", _szDirectory.c_str(), &_szNameTable[uOffset]);
CurrentIndex++;
}
@@ -232,7 +223,7 @@ const SFileInfo* CARCFile::FindFileInfo(const std::string& _rFullPath) const
{
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;
}