[AMG] Implement GetEntryNumber.

This commit is contained in:
2025-09-05 03:10:52 +01:00
parent 8c5c73f714
commit 3fd9066ac0
2 changed files with 26 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
using System;
using Aaru.CommonTypes.Enums;
namespace Aaru.Archives;
@@ -20,5 +21,30 @@ public sealed partial class Amg
return ErrorNumber.NoError;
}
/// <inheritdoc />
public ErrorNumber GetEntryNumber(string fileName, bool caseInsensitiveMatch, out int entryNumber)
{
entryNumber = -1;
if(!Opened) return ErrorNumber.NotOpened;
if(entryNumber < 0 || entryNumber >= _files.Count) return ErrorNumber.OutOfRange;
StringComparison comparison = caseInsensitiveMatch
? StringComparison.CurrentCultureIgnoreCase
: StringComparison.CurrentCulture;
for(int i = 0, count = _files.Count; i < count; i++)
{
if(!_files[i].Filename.Equals(fileName, comparison)) continue;
entryNumber = i;
return ErrorNumber.NoError;
}
return ErrorNumber.NoSuchFile;
}
#endregion
}

View File

@@ -11,10 +11,6 @@ public sealed partial class Amg
{
#region IArchive Members
/// <inheritdoc />
public ErrorNumber GetEntryNumber(string fileName, bool caseInsensitiveMatch, out int entryNumber) =>
throw new NotImplementedException();
/// <inheritdoc />
public ErrorNumber GetCompressedSize(int entryNumber, out long length) => throw new NotImplementedException();