From da7a5de9fd66db844c7bd70ea7c54b57a8c1671a Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sat, 23 Aug 2025 04:34:40 +0100 Subject: [PATCH] [ZOO] Add constants and structures. --- Aaru.Archives/Zoo/Consts.cs | 60 +++++++++++++++ Aaru.Archives/Zoo/Structs.cs | 138 +++++++++++++++++++++++++++++++++++ Aaru.Archives/Zoo/Zoo.cs | 14 +++- 3 files changed, 208 insertions(+), 4 deletions(-) create mode 100644 Aaru.Archives/Zoo/Consts.cs create mode 100644 Aaru.Archives/Zoo/Structs.cs diff --git a/Aaru.Archives/Zoo/Consts.cs b/Aaru.Archives/Zoo/Consts.cs new file mode 100644 index 000000000..4788a6276 --- /dev/null +++ b/Aaru.Archives/Zoo/Consts.cs @@ -0,0 +1,60 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Zoo 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 +// ****************************************************************************/ + +// Copied from zoo.h +/* +The contents of this file are hereby released to the public domain. + + -- Rahul Dhesi 1986/11/14 +*/ + +namespace Aaru.Archives; + +public sealed partial class Zoo +{ + const uint ZOO_TAG = 0xFDC4A7DC; + /// Size of header text + const int SIZ_TEXT = 20; + /// Max length of pathname + const int PATHSIZE = 256; + /// Size of DOS filename + const int FNAMESIZE = 13; + /// Size of long filename + const int LFNAMESIZE = 256; + /// Size of fname without extension + const int ROOTSIZE = 8; + /// Size of extension + const int EXTLEN = 3; + /// 4 chars plus null + const int SIZ_FLDR = 5; + /// max packing method we can handle + const int MAX_PACK = 2; + /// Allowing location of file data + readonly byte[] FILE_LEADER = "@)#("u8.ToArray(); + readonly byte[] HEADER_TEXT = "ZOO 2.10 Archive.\x1A"u8.ToArray(); +} \ No newline at end of file diff --git a/Aaru.Archives/Zoo/Structs.cs b/Aaru.Archives/Zoo/Structs.cs new file mode 100644 index 000000000..0ae8a2cff --- /dev/null +++ b/Aaru.Archives/Zoo/Structs.cs @@ -0,0 +1,138 @@ +// /*************************************************************************** +// Aaru Data Preservation Suite +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Zoo 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 +// ****************************************************************************/ + +// Copied from zoo.h +/* +The contents of this file are hereby released to the public domain. + + -- Rahul Dhesi 1986/11/14 +*/ + +using System.Runtime.InteropServices; + +namespace Aaru.Archives; + +public sealed partial class Zoo +{ +#region Nested type: Direntry + + record Direntry + { + /// length of comment, 0 if none + ushort cmt_size; + /// points to comment; zero if none + int comment; + /// DOS format date + ushort date; + /// will be 1 if deleted, 0 if not + byte deleted; + /// CRC of directory entry + ushort dir_crc; + /// length of directory name + byte dirlen; + /// directory name + [MarshalAs(UnmanagedType.ByValArray, SizeConst = PATHSIZE)] + byte[] dirname; + /// File attributes -- 24 bits + uint fattr; + /// CRC of this file + ushort file_crc; + /// filename + [MarshalAs(UnmanagedType.ByValArray, SizeConst = FNAMESIZE)] + byte[] fname; + /// long filename + [MarshalAs(UnmanagedType.ByValArray, SizeConst = LFNAMESIZE)] + char lfname; + byte major_ver; + /// minimum version needed to extract + byte minor_ver; + + /* fields for variable part of directory entry follow */ + + /// length of long filename + byte namlen; + /// pos'n of next directory entry + int next; + /// position of this file + int offset; + int org_size; + /// 0 = no packing, 1 = normal LZW + byte packing_method; + int size_now; + /// file structure if any + byte struc; + /// Filesystem ID + ushort system_id; + /// DOS format time + ushort time; + /// type of directory entry. always 1 for now + byte type; + /// timezone where file was archived + byte tz; + + /// length of variable part of dir entry + int var_dir_len; + /// file version number if any + ushort version_no; + /// version flag bits -- one byte in archive + ushort vflag; + /// tag -- redundancy check + uint zoo_tag; + } + +#endregion + +#region Nested type: ZooHeader + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] + record ZooHeader + { + /// length of archive comment + ushort acmt_len; + /// position of archive comment + int acmt_pos; + byte major_ver; + /// minimum version to extract all files + byte minor_ver; + /// archive header text + [MarshalAs(UnmanagedType.ByValArray, SizeConst = SIZ_TEXT)] + byte[] text; + /// type of archive header + byte type; + /// byte in archive; data about versions + ushort vdata; + /// for consistency checking of zoo_start + int zoo_minus; + /// where the archive's data starts + int zoo_start; + /// identifies archives + uint zoo_tag; + } + +#endregion +} \ No newline at end of file diff --git a/Aaru.Archives/Zoo/Zoo.cs b/Aaru.Archives/Zoo/Zoo.cs index 640ed672d..9161cbb61 100644 --- a/Aaru.Archives/Zoo/Zoo.cs +++ b/Aaru.Archives/Zoo/Zoo.cs @@ -33,18 +33,24 @@ namespace Aaru.Archives; public sealed partial class Zoo : IArchive { + const string MODULE_NAME = "zoo Archive Plugin"; + #region IArchive Members /// - public string Name { get; } + public string Name => "zoo"; /// - public Guid Id { get; } + public Guid Id => new("02CB37D8-1999-4B4A-9C8E-64FA87B9CDF1"); /// - public string Author { get; } + public string Author => Authors.NataliaPortillo; /// public bool Opened { get; } /// - public ArchiveSupportedFeature ArchiveFeatures { get; } + public ArchiveSupportedFeature ArchiveFeatures => ArchiveSupportedFeature.HasEntryTimestamp | + ArchiveSupportedFeature.SupportsCompression | + ArchiveSupportedFeature.SupportsFilenames | + ArchiveSupportedFeature.SupportsSubdirectories | + ArchiveSupportedFeature.SupportsXAttrs; /// public int NumberOfEntries { get; }