From c387aee8fe307203fc9394e26e763d70b7abb1b3 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Mon, 8 Sep 2025 01:14:58 +0100 Subject: [PATCH] [HA] Implement GetEntryNumber. --- Aaru.Archives/Ha/Files.cs | 26 ++++++++++++++++++++++++++ Aaru.Archives/Ha/Unimplemented.cs | 4 ---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Aaru.Archives/Ha/Files.cs b/Aaru.Archives/Ha/Files.cs index d517d0649..a0fb3fe53 100644 --- a/Aaru.Archives/Ha/Files.cs +++ b/Aaru.Archives/Ha/Files.cs @@ -1,3 +1,4 @@ +using System; using Aaru.CommonTypes.Enums; namespace Aaru.Archives; @@ -20,5 +21,30 @@ public sealed partial class Ha return ErrorNumber.NoError; } + /// + public ErrorNumber GetEntryNumber(string fileName, bool caseInsensitiveMatch, out int entryNumber) + { + entryNumber = -1; + + if(!Opened) return ErrorNumber.NotOpened; + + if(entryNumber < 0 || entryNumber >= _entries.Count) return ErrorNumber.OutOfRange; + + StringComparison comparison = caseInsensitiveMatch + ? StringComparison.CurrentCultureIgnoreCase + : StringComparison.CurrentCulture; + + for(int i = 0, count = _entries.Count; i < count; i++) + { + if(!_entries[i].Filename.Equals(fileName, comparison)) continue; + + entryNumber = i; + + return ErrorNumber.NoError; + } + + return ErrorNumber.NoSuchFile; + } + #endregion } \ No newline at end of file diff --git a/Aaru.Archives/Ha/Unimplemented.cs b/Aaru.Archives/Ha/Unimplemented.cs index 4ac88cfd5..02a207a19 100644 --- a/Aaru.Archives/Ha/Unimplemented.cs +++ b/Aaru.Archives/Ha/Unimplemented.cs @@ -11,10 +11,6 @@ public sealed partial class Ha { #region IArchive Members - /// - public ErrorNumber GetEntryNumber(string fileName, bool caseInsensitiveMatch, out int entryNumber) => - throw new NotImplementedException(); - /// public ErrorNumber GetCompressedSize(int entryNumber, out long length) => throw new NotImplementedException();