mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[AaruFormat] Fill image information from library.
This commit is contained in:
@@ -9,9 +9,8 @@ namespace Aaru.Images;
|
||||
public sealed partial class AaruFormat : IWritableOpticalImage, IVerifiableImage, IWritableTapeImage, IDisposable
|
||||
{
|
||||
const string MODULE_NAME = "Aaru Format plugin";
|
||||
|
||||
readonly ImageInfo _imageInfo;
|
||||
IntPtr _context;
|
||||
IntPtr _context;
|
||||
ImageInfo _imageInfo;
|
||||
|
||||
public AaruFormat() => _imageInfo = new ImageInfo
|
||||
{
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Helpers;
|
||||
using Aaru.Logging;
|
||||
using Marshal = System.Runtime.InteropServices.Marshal;
|
||||
|
||||
namespace Aaru.Images;
|
||||
|
||||
@@ -18,16 +21,43 @@ public sealed partial class AaruFormat
|
||||
|
||||
_context = aaruf_open(imagePath);
|
||||
|
||||
if(_context != IntPtr.Zero) return ErrorNumber.NoError;
|
||||
if(_context == IntPtr.Zero)
|
||||
{
|
||||
int errno = Marshal.GetLastWin32Error();
|
||||
|
||||
int errno = Marshal.GetLastWin32Error();
|
||||
AaruLogging.Debug(MODULE_NAME,
|
||||
"Failed to open AaruFormat image {0}, libaaruformat returned error number {1}",
|
||||
imagePath,
|
||||
errno);
|
||||
|
||||
AaruLogging.Debug(MODULE_NAME,
|
||||
"Failed to open AaruFormat image {0}, libaaruformat returned error number {1}",
|
||||
imagePath,
|
||||
errno);
|
||||
return (ErrorNumber)errno;
|
||||
}
|
||||
|
||||
return (ErrorNumber)errno;
|
||||
AaruFormatImageInfo imageInfo = new();
|
||||
|
||||
Status ret = aaruf_get_image_info(_context, ref imageInfo);
|
||||
|
||||
// TODO: Convert between error codes
|
||||
if(ret != Status.Ok) return (ErrorNumber)ret;
|
||||
|
||||
_imageInfo.Application = StringHandlers.CToString(imageInfo.Application, Encoding.UTF8);
|
||||
_imageInfo.Version = StringHandlers.CToString(imageInfo.Version, Encoding.UTF8);
|
||||
_imageInfo.ApplicationVersion = StringHandlers.CToString(imageInfo.ApplicationVersion, Encoding.UTF8);
|
||||
_imageInfo.CreationTime = DateTime.FromFileTimeUtc(imageInfo.CreationTime);
|
||||
_imageInfo.HasPartitions = imageInfo.HasPartitions;
|
||||
_imageInfo.HasSessions = imageInfo.HasSessions;
|
||||
_imageInfo.ImageSize = imageInfo.ImageSize;
|
||||
_imageInfo.MediaType = imageInfo.MediaType;
|
||||
_imageInfo.LastModificationTime = DateTime.FromFileTimeUtc(imageInfo.LastModificationTime);
|
||||
_imageInfo.SectorSize = imageInfo.SectorSize;
|
||||
_imageInfo.Sectors = imageInfo.Sectors;
|
||||
_imageInfo.MetadataMediaType = imageInfo.MetadataMediaType;
|
||||
|
||||
// TODO: rest of metadata
|
||||
// TODO: geometry
|
||||
// TODO: metadata from media tags
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user