Move C4Group::PrintInternals out of C4Group

C4Group::PrintInternals is only used in the c4group command line tool.
Move the code there.
issue1247
Nicolas Hake 2015-02-13 18:25:21 +01:00
parent c1e113f1f9
commit 413e66ff97
3 changed files with 28 additions and 26 deletions

View File

@ -2231,30 +2231,6 @@ bool C4Group::OpenMother()
return true;
}
void C4Group::PrintInternals(const char *szIndent)
{
if (!szIndent) szIndent = "";
printf("%sHead.id: '%s'\n", szIndent, Head.id);
printf("%sHead.Ver1: %d\n", szIndent, Head.Ver1);
printf("%sHead.Ver2: %d\n", szIndent, Head.Ver2);
printf("%sHead.Entries: %d\n", szIndent, Head.Entries);
for (C4GroupEntry * p = FirstEntry; p; p = p->Next)
{
printf("%sEntry '%s':\n", szIndent, p->FileName);
printf("%s Packed: %d\n", szIndent, p->Packed);
printf("%s ChildGroup: %d\n", szIndent, p->ChildGroup);
printf("%s Size: %d\n", szIndent, p->Size);
printf("%s Offset: %d\n", szIndent, p->Offset);
printf("%s Executable: %d\n", szIndent, p->Executable);
if (p->ChildGroup)
{
C4Group hChildGroup;
if (hChildGroup.OpenAsChild(this, p->FileName))
hChildGroup.PrintInternals(FormatString("%s%s", szIndent, " ").getData());
}
}
}
int C4Group::PreCacheEntries(const char *szSearchPattern)
{
assert(szSearchPattern);

View File

@ -253,7 +253,6 @@ public:
inline bool IsPacked() { return Status == GRPF_File; }
inline bool HasPackedMother() { if (!Mother) return false; return Mother->IsPacked(); }
inline bool SetNoSort(bool fNoSort) { NoSort = fNoSort; return true; }
void PrintInternals(const char *szIndent=NULL);
int PreCacheEntries(const char *szSearchPattern); // pre-load entries to memory. return number of loaded entries.
const C4GroupHeader &GetHeader() const { return Head; }

View File

@ -88,6 +88,33 @@ void DisplayGroup(const C4Group &grp, const char *filter = NULL)
printf("%d Entries, %d Bytes\n", file_count, byte_count);
}
void PrintGroupInternals(C4Group &grp, int indent_level = 0)
{
const C4GroupHeader &head = grp.GetHeader();
int indent = indent_level * 4;
printf("%*sHead.id: '%s'\n", indent, "", head.id);
printf("%*sHead.Ver1: %d\n", indent, "", head.Ver1);
printf("%*sHead.Ver2: %d\n", indent, "", head.Ver2);
printf("%*sHead.Entries: %d\n", indent, "", head.Entries);
for (const C4GroupEntry * p = grp.GetFirstEntry(); p; p = p->Next)
{
printf("%*sEntry '%s':\n", indent, "", p->FileName);
printf("%*s Packed: %d\n", indent, "", p->Packed);
printf("%*s ChildGroup: %d\n", indent, "", p->ChildGroup);
printf("%*s Size: %d\n", indent, "", p->Size);
printf("%*s Offset: %d\n", indent, "", p->Offset);
printf("%*s Executable: %d\n", indent, "", p->Executable);
if (p->ChildGroup != 0)
{
C4Group hChildGroup;
if (hChildGroup.OpenAsChild(&grp, p->FileName))
PrintGroupInternals(hChildGroup, indent_level + 1);
}
}
}
bool ProcessGroup(const char *FilenamePar)
{
C4Group hGroup;
@ -297,7 +324,7 @@ bool ProcessGroup(const char *FilenamePar)
}
break;
case 'z':
hGroup.PrintInternals();
PrintGroupInternals(hGroup);
break;
// Undefined
default: