Skip to content

Commit e069b88

Browse files
committed
Check if an AFS archive contains sizes in their attributes or not.
1 parent 2df6740 commit e069b88

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

AFSLib/AFS.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ public class AFS : IDisposable
4343
/// </summary>
4444
public bool ContainsAttributes => AttributesInfoType != AttributesInfoType.NoAttributes;
4545

46+
/// <summary>
47+
/// Returns true if all attributes contain the size of the entry.
48+
/// Some AFS archives contain each entry's size in their attributes, while others contain custom developer data.
49+
/// To access this data use the CustomData property of the Entry.
50+
/// </summary>
51+
public bool AllAttributesContainEntrySize => DoAllAttributesContainEntrySize();
52+
4653
/// <summary>
4754
/// Event that will be called each time some process wants to report something.
4855
/// </summary>
@@ -725,7 +732,23 @@ private bool IsAttributeInfoValid(uint attributesOffset, uint attributesSize, ui
725732
if (attributesOffset < dataBlockEndOffset) return false;
726733
if (attributesOffset > afsFileSize - attributesSize) return false;
727734

728-
// If the above conditions are not met, it looks like it's valid attribute data
735+
// If the above conditions are not met, it looks like it's valid attribute info
736+
return true;
737+
}
738+
739+
private bool DoAllAttributesContainEntrySize()
740+
{
741+
if (!ContainsAttributes) return false;
742+
743+
for (int e = 0; e < EntryCount; e++)
744+
{
745+
if (entries[e] is NullEntry) continue;
746+
747+
DataEntry dataEntry = entries[e] as DataEntry;
748+
749+
if (!dataEntry.CustomDataContainsSize) return false;
750+
}
751+
729752
return true;
730753
}
731754

0 commit comments

Comments
 (0)