diff --git a/Aaru.Archives/Ha/Files.cs b/Aaru.Archives/Ha/Files.cs
index 1255cfb0d..8509695f4 100644
--- a/Aaru.Archives/Ha/Files.cs
+++ b/Aaru.Archives/Ha/Files.cs
@@ -1,6 +1,7 @@
using System;
-using System.IO;
using Aaru.CommonTypes.Enums;
+using Aaru.CommonTypes.Structs;
+using FileAttributes = System.IO.FileAttributes;
namespace Aaru.Archives;
@@ -89,5 +90,52 @@ public sealed partial class Ha
return ErrorNumber.NoError;
}
+ ///
+ public ErrorNumber Stat(int entryNumber, out FileEntryInfo stat)
+ {
+ stat = null;
+
+ if(!Opened) return ErrorNumber.NotOpened;
+
+ if(entryNumber < 0 || entryNumber >= _entries.Count) return ErrorNumber.OutOfRange;
+
+ Entry entry = _entries[entryNumber];
+
+ stat = new FileEntryInfo
+ {
+ Attributes = CommonTypes.Structs.FileAttributes.None,
+ Blocks = entry.Uncompressed / 512,
+ BlockSize = 512,
+ Length = entry.Uncompressed,
+ LastWriteTime = entry.LastWrite,
+ LastWriteTimeUtc = entry.LastWrite
+ };
+
+ if(entry.Uncompressed % 512 != 0) stat.Blocks++;
+
+ if(entry.Attributes.HasFlag(FileAttributes.Directory))
+ stat.Attributes |= CommonTypes.Structs.FileAttributes.Directory;
+ else
+ stat.Attributes |= CommonTypes.Structs.FileAttributes.File;
+
+ if(entry.Attributes.HasFlag(FileAttributes.Archive))
+ stat.Attributes |= CommonTypes.Structs.FileAttributes.Archive;
+
+ if(entry.Attributes.HasFlag(FileAttributes.Hidden))
+ stat.Attributes |= CommonTypes.Structs.FileAttributes.Hidden;
+
+ if(entry.Attributes.HasFlag(FileAttributes.ReadOnly))
+ stat.Attributes |= CommonTypes.Structs.FileAttributes.ReadOnly;
+
+ if(entry.Attributes.HasFlag(FileAttributes.System))
+ stat.Attributes |= CommonTypes.Structs.FileAttributes.System;
+
+ stat.Mode = entry.Mode;
+ stat.UID = entry.Uid;
+ stat.GID = entry.Gid;
+
+ return ErrorNumber.NoError;
+ }
+
#endregion
}
\ No newline at end of file
diff --git a/Aaru.Archives/Ha/Structs.cs b/Aaru.Archives/Ha/Structs.cs
index d20532eaf..ce247eded 100644
--- a/Aaru.Archives/Ha/Structs.cs
+++ b/Aaru.Archives/Ha/Structs.cs
@@ -17,9 +17,9 @@ public sealed partial class Ha
public FileAttributes Attributes;
public long DataOffset;
public string Filename;
- public ushort Mode;
- public ushort Uid;
- public ushort Gid;
+ public ushort? Mode;
+ public ushort? Uid;
+ public ushort? Gid;
}
#endregion
diff --git a/Aaru.Archives/Ha/Unimplemented.cs b/Aaru.Archives/Ha/Unimplemented.cs
index 8926099ec..d8639a96d 100644
--- a/Aaru.Archives/Ha/Unimplemented.cs
+++ b/Aaru.Archives/Ha/Unimplemented.cs
@@ -1,7 +1,6 @@
using System;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
-using Aaru.CommonTypes.Structs;
namespace Aaru.Archives;
@@ -9,10 +8,6 @@ public sealed partial class Ha
{
#region IArchive Members
- ///
- ///
- public ErrorNumber Stat(int entryNumber, out FileEntryInfo stat) => throw new NotImplementedException();
-
///
public ErrorNumber GetEntry(int entryNumber, out IFilter filter) => throw new NotImplementedException();