// /*************************************************************************** // 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-2023 Natalia Portillo // ****************************************************************************/ using System.Runtime.InteropServices; using Aaru.CommonTypes.Interfaces; namespace Aaru.Filesystems; public sealed partial class OperaFS { #region Nested type: DirectoryEntry [StructLayout(LayoutKind.Sequential, Pack = 1)] readonly struct DirectoryEntry { /// File flags, see public readonly uint flags; /// Unique file identifier public readonly uint id; /// Entry type public readonly uint type; /// Block size public readonly uint block_size; /// Size in bytes public readonly uint byte_count; /// Block count public readonly uint block_count; /// Unknown public readonly uint burst; /// Unknown public readonly uint gap; /// Filename [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)] public readonly byte[] name; /// Last copy public readonly 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)] readonly struct DirectoryHeader { /// Next block from this directory, -1 if last public readonly int next_block; /// Previous block from this directory, -1 if first public readonly int prev_block; /// Directory flags public readonly uint flags; /// Offset to first free unused byte in the directory public readonly uint first_free; /// Offset to first directory entry public readonly 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)] readonly struct SuperBlock { /// 0x000, Record type, must be 1 public readonly byte record_type; /// 0x001, 5 bytes, "ZZZZZ" [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public readonly byte[] sync_bytes; /// 0x006, Record version, must be 1 public readonly byte record_version; /// 0x007, Volume flags public readonly byte volume_flags; /// 0x008, 32 bytes, volume comment [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)] public readonly byte[] volume_comment; /// 0x028, 32 bytes, volume label [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)] public readonly byte[] volume_label; /// 0x048, Volume ID public readonly uint volume_id; /// 0x04C, Block size in bytes public readonly uint block_size; /// 0x050, Blocks in volume public readonly uint block_count; /// 0x054, Root directory ID public readonly uint root_dirid; /// 0x058, Root directory blocks public readonly uint rootdir_blocks; /// 0x05C, Root directory block size public readonly uint rootdir_bsize; /// 0x060, Last root directory copy public readonly uint last_root_copy; } #endregion }