2025-09-01 06:10:13 +01:00
|
|
|
using System;
|
2025-09-01 06:16:19 +01:00
|
|
|
using System.IO;
|
2025-09-01 06:07:31 +01:00
|
|
|
using Aaru.CommonTypes.Enums;
|
|
|
|
|
|
|
|
|
|
namespace Aaru.Archives;
|
|
|
|
|
|
|
|
|
|
public sealed partial class Arc
|
|
|
|
|
{
|
|
|
|
|
#region IArchive Members
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public ErrorNumber GetFilename(int entryNumber, out string fileName)
|
|
|
|
|
{
|
|
|
|
|
fileName = null;
|
|
|
|
|
|
|
|
|
|
if(!Opened) return ErrorNumber.NotOpened;
|
|
|
|
|
|
|
|
|
|
if(entryNumber < 0 || entryNumber >= _entries.Count) return ErrorNumber.OutOfRange;
|
|
|
|
|
|
|
|
|
|
fileName = _entries[entryNumber].Filename;
|
|
|
|
|
|
|
|
|
|
return ErrorNumber.NoError;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-01 06:10:13 +01:00
|
|
|
/// <inheritdoc />
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-01 06:11:36 +01:00
|
|
|
/// <inheritdoc />
|
|
|
|
|
public ErrorNumber GetCompressedSize(int entryNumber, out long length)
|
|
|
|
|
{
|
|
|
|
|
length = -1;
|
|
|
|
|
|
|
|
|
|
if(!Opened) return ErrorNumber.NotOpened;
|
|
|
|
|
|
|
|
|
|
if(entryNumber < 0 || entryNumber >= _entries.Count) return ErrorNumber.OutOfRange;
|
|
|
|
|
|
|
|
|
|
length = _entries[entryNumber].Compressed;
|
|
|
|
|
|
|
|
|
|
return ErrorNumber.NoError;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-01 06:14:11 +01:00
|
|
|
/// <inheritdoc />
|
|
|
|
|
public ErrorNumber GetUncompressedSize(int entryNumber, out long length)
|
|
|
|
|
{
|
|
|
|
|
length = -1;
|
|
|
|
|
|
|
|
|
|
if(!Opened) return ErrorNumber.NotOpened;
|
|
|
|
|
|
|
|
|
|
if(entryNumber < 0 || entryNumber >= _entries.Count) return ErrorNumber.OutOfRange;
|
|
|
|
|
|
|
|
|
|
length = _entries[entryNumber].Uncompressed;
|
|
|
|
|
|
|
|
|
|
return ErrorNumber.NoError;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-01 06:16:19 +01:00
|
|
|
/// <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;
|
|
|
|
|
|
|
|
|
|
if(entryNumber < 0 || entryNumber >= _entries.Count) return ErrorNumber.OutOfRange;
|
|
|
|
|
|
|
|
|
|
attributes = _entries[entryNumber].Attributes;
|
|
|
|
|
|
|
|
|
|
return ErrorNumber.NoError;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-01 06:07:31 +01:00
|
|
|
#endregion
|
|
|
|
|
}
|