[STFS] Implement Stat.

This commit is contained in:
2025-09-03 03:11:10 +01:00
parent 61919c5282
commit 6f0ddc711c
2 changed files with 35 additions and 5 deletions

View File

@@ -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;
@@ -91,5 +92,38 @@ public sealed partial class Stfs
return ErrorNumber.NoError;
}
/// <inheritdoc />
public ErrorNumber Stat(int entryNumber, out FileEntryInfo stat)
{
stat = null;
if(!Opened) return ErrorNumber.NotOpened;
if(entryNumber < 0 || entryNumber >= _entries.Length) return ErrorNumber.OutOfRange;
FileEntry entry = _entries[entryNumber];
stat = new FileEntryInfo
{
Attributes = CommonTypes.Structs.FileAttributes.None,
Blocks = entry.FileSize / 4096,
BlockSize = 4096,
Length = entry.FileSize,
LastWriteTime = entry.LastWrite,
LastWriteTimeUtc = entry.LastWrite,
AccessTime = entry.LastAccess,
AccessTimeUtc = entry.LastAccess
};
if(entry.FileSize % 4096 != 0) stat.Blocks++;
if(entry.IsDirectory)
stat.Attributes |= CommonTypes.Structs.FileAttributes.Directory;
else
stat.Attributes |= CommonTypes.Structs.FileAttributes.File;
return ErrorNumber.NoError;
}
#endregion
}

View File

@@ -1,7 +1,6 @@
using System;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
namespace Aaru.Archives;
@@ -9,9 +8,6 @@ public sealed partial class Stfs
{
#region IArchive Members
/// <inheritdoc />
public ErrorNumber Stat(int entryNumber, out FileEntryInfo stat) => throw new NotImplementedException();
/// <inheritdoc />
public ErrorNumber GetEntry(int entryNumber, out IFilter filter) => throw new NotImplementedException();