mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[AMG] Implement Stat.
This commit is contained in:
@@ -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,43 @@ public sealed partial class Amg
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber Stat(int entryNumber, out FileEntryInfo stat)
|
||||
{
|
||||
stat = null;
|
||||
|
||||
if(!Opened) return ErrorNumber.NotOpened;
|
||||
|
||||
if(entryNumber < 0 || entryNumber >= _files.Count) return ErrorNumber.OutOfRange;
|
||||
|
||||
FileEntry entry = _files[entryNumber];
|
||||
|
||||
stat = new FileEntryInfo
|
||||
{
|
||||
Attributes = CommonTypes.Structs.FileAttributes.File,
|
||||
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.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;
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -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 Amg
|
||||
{
|
||||
#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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user