mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[AMG] Implement ListXAttr and GetXAttr.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
@@ -10,13 +9,6 @@ public sealed partial class Amg
|
||||
{
|
||||
#region IArchive Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ListXAttr(int entryNumber, out List<string> xattrs) => throw new NotImplementedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber GetXattr(int entryNumber, string xattr, ref byte[] buffer) =>
|
||||
throw new NotImplementedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber Stat(int entryNumber, out FileEntryInfo stat) => throw new NotImplementedException();
|
||||
|
||||
|
||||
44
Aaru.Archives/Amg/Xattrs.cs
Normal file
44
Aaru.Archives/Amg/Xattrs.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
|
||||
namespace Aaru.Archives;
|
||||
|
||||
public sealed partial class Amg
|
||||
{
|
||||
#region IArchive Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ListXAttr(int entryNumber, out List<string> xattrs)
|
||||
{
|
||||
xattrs = null;
|
||||
|
||||
if(!Opened) return ErrorNumber.NotOpened;
|
||||
|
||||
if(entryNumber < 0 || entryNumber >= _files.Count) return ErrorNumber.OutOfRange;
|
||||
|
||||
xattrs = [];
|
||||
|
||||
if(_files[entryNumber].Comment is not null) xattrs.Add("comment");
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber GetXattr(int entryNumber, string xattr, ref byte[] buffer)
|
||||
{
|
||||
buffer = null;
|
||||
|
||||
if(!Opened) return ErrorNumber.NotOpened;
|
||||
|
||||
if(entryNumber < 0 || entryNumber >= _files.Count) return ErrorNumber.OutOfRange;
|
||||
|
||||
if(xattr != "comment" || _files[entryNumber].Comment is null) return ErrorNumber.NoSuchExtendedAttribute;
|
||||
|
||||
buffer = Encoding.UTF8.GetBytes(_files[entryNumber].Comment);
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user