Files
Aaru/DiscImageChef.Filesystems/ISO9660/Structs/HighSierra.cs

194 lines
9.3 KiB
C#
Raw Normal View History

// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : HighSierra.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : ISO9660 filesystem plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// High Sierra Format 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/>.
//
// ----------------------------------------------------------------------------
2018-12-29 17:34:38 +00:00
// Copyright © 2011-2019 Natalia Portillo
// ****************************************************************************/
2017-12-19 19:33:46 +00:00
2017-12-21 14:30:38 +00:00
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace DiscImageChef.Filesystems.ISO9660
{
public partial class ISO9660
{
static DecodedVolumeDescriptor DecodeVolumeDescriptor(HighSierraPrimaryVolumeDescriptor pvd)
{
DecodedVolumeDescriptor decodedVD = new DecodedVolumeDescriptor
{
2018-06-22 08:08:38 +01:00
SystemIdentifier = Encoding.ASCII.GetString(pvd.system_id).TrimEnd().Trim('\0'),
VolumeIdentifier = Encoding.ASCII.GetString(pvd.volume_id).TrimEnd().Trim('\0'),
VolumeSetIdentifier = Encoding.ASCII.GetString(pvd.volume_set_id).TrimEnd().Trim('\0'),
PublisherIdentifier = Encoding.ASCII.GetString(pvd.publisher_id).TrimEnd().Trim('\0'),
DataPreparerIdentifier = Encoding.ASCII.GetString(pvd.preparer_id).TrimEnd().Trim('\0'),
2018-06-22 08:08:38 +01:00
ApplicationIdentifier = Encoding.ASCII.GetString(pvd.application_data).TrimEnd().Trim('\0')
};
if(pvd.creation_date[0] == '0' || pvd.creation_date[0] == 0x00) decodedVD.CreationTime = DateTime.MinValue;
2018-06-22 08:08:38 +01:00
else
decodedVD.CreationTime =
DateHandlers.HighSierraToDateTime(pvd.creation_date);
if(pvd.modification_date[0] == '0' || pvd.modification_date[0] == 0x00)
decodedVD.HasModificationTime = false;
else
{
decodedVD.HasModificationTime = true;
2018-06-22 08:08:38 +01:00
decodedVD.ModificationTime = DateHandlers.HighSierraToDateTime(pvd.modification_date);
}
if(pvd.expiration_date[0] == '0' || pvd.expiration_date[0] == 0x00) decodedVD.HasExpirationTime = false;
else
{
decodedVD.HasExpirationTime = true;
2018-06-22 08:08:38 +01:00
decodedVD.ExpirationTime = DateHandlers.HighSierraToDateTime(pvd.expiration_date);
}
if(pvd.effective_date[0] == '0' || pvd.effective_date[0] == 0x00) decodedVD.HasEffectiveTime = false;
else
{
decodedVD.HasEffectiveTime = true;
2018-06-22 08:08:38 +01:00
decodedVD.EffectiveTime = DateHandlers.HighSierraToDateTime(pvd.effective_date);
}
2018-06-22 08:08:38 +01:00
decodedVD.Blocks = pvd.volume_space_size;
decodedVD.BlockSize = pvd.logical_block_size;
return decodedVD;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct HighSierraPrimaryVolumeDescriptor
{
public readonly uint volume_lbn;
public readonly uint volume_lbn_be;
public readonly byte type;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public readonly byte[] id;
public readonly byte version;
// Only used in SVDs
public readonly byte flags;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] system_id;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] volume_id;
public readonly ulong reserved1;
public readonly uint volume_space_size;
public readonly uint volume_space_size_be;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] escape_sequences;
public readonly ushort volume_set_size;
public readonly ushort volume_set_size_be;
public readonly ushort volume_sequence_number;
public readonly ushort volume_sequence_number_be;
public readonly ushort logical_block_size;
public readonly ushort logical_block_size_be;
public readonly uint path_table_size;
public readonly uint path_table_size_be;
public readonly uint manditory_path_table_lsb;
public readonly uint opt_path_table_lsb_1;
public readonly uint opt_path_table_lsb_2;
public readonly uint opt_path_table_lsb_3;
public readonly uint manditory_path_table_msb;
public readonly uint opt_path_table_msb_1;
public readonly uint opt_path_table_msb_2;
public readonly uint opt_path_table_msb_3;
public readonly HighSierraDirectoryRecord root_directory_record;
public readonly byte root_directory_name;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public readonly byte[] volume_set_id;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public readonly byte[] publisher_id;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public readonly byte[] preparer_id;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public readonly byte[] application_id;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] copyright_file_id;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] abstract_file_id;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] creation_date;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] modification_date;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] expiration_date;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public readonly byte[] effective_date;
public readonly byte file_structure_version;
public readonly byte reserved2;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
public readonly byte[] application_data;
2018-06-22 08:08:38 +01:00
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 680)]
public readonly byte[] reserved3;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct HighSierraDirectoryRecord
{
public readonly byte length;
public readonly byte xattr_len;
public readonly uint extent;
public readonly uint extent_be;
public readonly uint size;
public readonly uint size_be;
public readonly HighSierraTimestamp date;
public readonly FileFlags flags;
public readonly byte reserved;
public readonly byte interleave_size;
public readonly byte interleave;
public readonly ushort volume_sequence_number;
public readonly ushort volume_sequence_number_be;
public readonly byte name_len;
// Followed by name[name_len] and then system area until length arrives
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct HighSierraTimestamp
{
public readonly byte Years;
public readonly byte Month;
public readonly byte Day;
public readonly byte Hour;
public readonly byte Minute;
public readonly byte Second;
}
2019-07-23 06:19:40 +01:00
// There are two tables one in little endian one in big endian
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct HighSierraPathTableEntry
{
public readonly uint start_lbn;
public readonly byte xattr_len;
public readonly byte name_len;
public readonly ushort parent_dirno;
// Followed by name[name_len]
}
}
2017-12-19 20:33:03 +00:00
}