[STFS] Implement GetEntryNumber.

This commit is contained in:
2025-09-03 02:58:54 +01:00
parent e918ce9e3b
commit d858e5944b
3 changed files with 26 additions and 5 deletions

View File

@@ -86,7 +86,6 @@ public sealed partial class Arc
/// <inheritdoc />
public ErrorNumber GetAttributes(int entryNumber, out FileAttributes attributes)
{
// DOS version of ZOO ignores the attributes, so we just say it's a file
attributes = FileAttributes.None;
if(!Opened) return ErrorNumber.NotOpened;

View File

@@ -1,3 +1,4 @@
using System;
using Aaru.CommonTypes.Enums;
namespace Aaru.Archives;
@@ -20,5 +21,30 @@ public sealed partial class Stfs
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 >= _entries.Length) return ErrorNumber.OutOfRange;
StringComparison comparison = caseInsensitiveMatch
? StringComparison.CurrentCultureIgnoreCase
: StringComparison.CurrentCulture;
for(int i = 0, count = _entries.Length; i < count; i++)
{
if(!_entries[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 Stfs
{
#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();