Files
Aaru/Aaru.Filesystems/ISO9660/Structs/CDi.cs

207 lines
7.9 KiB
C#
Raw Normal View History

// /***************************************************************************
2020-02-27 12:31:25 +00:00
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : CDi.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : ISO9660 filesystem plugin.
//
// --[ Description ] ----------------------------------------------------------
//
2019-07-31 20:10:27 +01:00
// CD-i extensions structures.
//
// --[ 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
2024-12-19 10:45:18 +00:00
// Copyright © 2011-2025 Natalia Portillo
// In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24
// ****************************************************************************/
2017-12-19 19:33:46 +00:00
2017-12-21 14:30:38 +00:00
using System;
using System.Runtime.InteropServices;
using Aaru.CommonTypes.Attributes;
2020-07-20 15:43:52 +01:00
using Aaru.Helpers;
namespace Aaru.Filesystems;
2022-03-06 13:29:38 +00:00
public sealed partial class ISO9660
{
2022-03-06 13:29:38 +00:00
static DecodedVolumeDescriptor DecodeVolumeDescriptor(FileStructureVolumeDescriptor pvd)
{
2022-03-06 13:29:38 +00:00
var decodedVd = new DecodedVolumeDescriptor
{
2022-03-06 13:29:38 +00:00
SystemIdentifier = StringHandlers.CToString(pvd.system_id).TrimEnd(),
VolumeIdentifier = StringHandlers.CToString(pvd.volume_id).TrimEnd(),
VolumeSetIdentifier = StringHandlers.CToString(pvd.volume_set_id).TrimEnd(),
PublisherIdentifier = StringHandlers.CToString(pvd.publisher_id).TrimEnd(),
DataPreparerIdentifier = StringHandlers.CToString(pvd.preparer_id).TrimEnd(),
ApplicationIdentifier = StringHandlers.CToString(pvd.application_data).TrimEnd()
};
if(pvd.creation_date[0] == '0' || pvd.creation_date[0] == 0x00)
2022-03-06 13:29:38 +00:00
decodedVd.CreationTime = DateTime.MinValue;
else
decodedVd.CreationTime = DateHandlers.HighSierraToDateTime(pvd.creation_date);
if(pvd.modification_date[0] == '0' || pvd.modification_date[0] == 0x00)
2022-03-06 13:29:38 +00:00
decodedVd.HasModificationTime = false;
else
{
decodedVd.HasModificationTime = true;
decodedVd.ModificationTime = DateHandlers.HighSierraToDateTime(pvd.modification_date);
}
if(pvd.expiration_date[0] == '0' || pvd.expiration_date[0] == 0x00)
2022-03-06 13:29:38 +00:00
decodedVd.HasExpirationTime = false;
else
{
decodedVd.HasExpirationTime = true;
decodedVd.ExpirationTime = DateHandlers.HighSierraToDateTime(pvd.expiration_date);
}
if(pvd.effective_date[0] == '0' || pvd.effective_date[0] == 0x00)
2022-03-06 13:29:38 +00:00
decodedVd.HasEffectiveTime = false;
else
{
decodedVd.HasEffectiveTime = true;
decodedVd.EffectiveTime = DateHandlers.HighSierraToDateTime(pvd.effective_date);
}
2022-03-06 13:29:38 +00:00
decodedVd.Blocks = pvd.volume_space_size;
decodedVd.BlockSize = pvd.logical_block_size;
2022-03-06 13:29:38 +00:00
return decodedVd;
}
#region Nested type: CdiDirectoryRecord
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[SwapEndian]
partial struct CdiDirectoryRecord
{
public byte length;
public byte xattr_len;
public uint reserved1;
public uint start_lbn;
public uint reserved2;
public uint size;
public HighSierraTimestamp date;
public byte reserved3;
public CdiFileFlags flags;
public ushort file_unit_size;
public ushort reserved4;
public ushort volume_sequence_number;
public byte name_len;
// Followed by name[name_len] and then CdiSystemArea until length arrives
}
#endregion
#region Nested type: CdiSystemArea
// Follows filename on directory record
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[SwapEndian]
partial struct CdiSystemArea
{
public ushort group;
public ushort owner;
public CdiAttributes attributes;
public ushort reserved1;
public byte file_no;
public byte reserved2;
}
#endregion
#region Nested type: FileStructureVolumeDescriptor
2022-03-06 13:29:38 +00:00
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[SwapEndian]
partial struct FileStructureVolumeDescriptor
2022-03-06 13:29:38 +00:00
{
public byte type;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public byte[] id;
public byte version;
public CdiVolumeFlags flags;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] system_id;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] volume_id;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public byte[] reserved1;
public uint volume_space_size;
2022-03-06 13:29:38 +00:00
// Only used in SVDs
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] escape_sequences;
public ushort reserved2;
public ushort volume_set_size;
public ushort reserved3;
public ushort volume_sequence_number;
public ushort reserved4;
public ushort logical_block_size;
public uint reserved5;
public uint path_table_size;
public ulong reserved6;
public uint path_table_addr;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 38)]
public byte[] reserved7;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public byte[] volume_set_id;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public byte[] publisher_id;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public byte[] preparer_id;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public byte[] application_id;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] copyright_file_id;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public byte[] reserved8;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] abstract_file_id;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public byte[] reserved9;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] bibliographic_file_id;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public byte[] reserved10;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] creation_date;
public byte reserved11;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] modification_date;
public byte reserved12;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] expiration_date;
public byte reserved13;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] effective_date;
public byte reserved14;
public byte file_structure_version;
public byte reserved15;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
public byte[] application_data;
2022-03-06 13:29:38 +00:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 653)]
public byte[] reserved16;
2022-03-06 13:29:38 +00:00
}
#endregion
2017-12-19 20:33:03 +00:00
}