// /*************************************************************************** // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // // Filename : Structs.cs // Author(s) : Natalia Portillo // // Component : Opera filesystem plugin. // // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 2.1 of the // License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, see . // // ---------------------------------------------------------------------------- // Copyright © 2011-2025 Natalia Portillo // ****************************************************************************/ using System.Runtime.InteropServices; using Aaru.CommonTypes.Attributes; using Aaru.CommonTypes.Interfaces; namespace Aaru.Filesystems; public sealed partial class OperaFS { #region Nested type: DirectoryEntry [StructLayout(LayoutKind.Sequential, Pack = 1)] [SwapEndian] partial struct DirectoryEntry { /// File flags, see public uint flags; /// Unique file identifier public uint id; /// Entry type public uint type; /// Block size public uint block_size; /// Size in bytes public uint byte_count; /// Block count public uint block_count; /// Unknown public uint burst; /// Unknown public uint gap; /// Filename [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)] public byte[] name; /// Last copy public uint last_copy; } #endregion #region Nested type: DirectoryEntryWithPointers sealed class DirectoryEntryWithPointers { public DirectoryEntry Entry; public uint[] Pointers; } #endregion #region Nested type: DirectoryHeader [StructLayout(LayoutKind.Sequential, Pack = 1)] [SwapEndian] partial struct DirectoryHeader { /// Next block from this directory, -1 if last public int next_block; /// Previous block from this directory, -1 if first public int prev_block; /// Directory flags public uint flags; /// Offset to first free unused byte in the directory public uint first_free; /// Offset to first directory entry public uint first_used; } #endregion #region Nested type: OperaDirNode sealed class OperaDirNode : IDirNode { internal string[] Contents; internal int Position; #region IDirNode Members /// public string Path { get; init; } #endregion } #endregion #region Nested type: OperaFileNode sealed class OperaFileNode : IFileNode { internal DirectoryEntryWithPointers Dentry; #region IFileNode Members /// public string Path { get; init; } /// public long Length { get; init; } /// public long Offset { get; set; } #endregion } #endregion #region Nested type: SuperBlock [StructLayout(LayoutKind.Sequential, Pack = 1)] [SwapEndian] partial struct SuperBlock { /// 0x000, Record type, must be 1 public byte record_type; /// 0x001, 5 bytes, "ZZZZZ" [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public byte[] sync_bytes; /// 0x006, Record version, must be 1 public byte record_version; /// 0x007, Volume flags public byte volume_flags; /// 0x008, 32 bytes, volume comment [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)] public byte[] volume_comment; /// 0x028, 32 bytes, volume label [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)] public byte[] volume_label; /// 0x048, Volume ID public uint volume_id; /// 0x04C, Block size in bytes public uint block_size; /// 0x050, Blocks in volume public uint block_count; /// 0x054, Root directory ID public uint root_dirid; /// 0x058, Root directory blocks public uint rootdir_blocks; /// 0x05C, Root directory block size public uint rootdir_bsize; /// 0x060, Last root directory copy public uint last_root_copy; } #endregion }