2017-10-13 21:50:10 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : CDi.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : ISO9660 filesystem plugin.
|
2017-10-13 21:50:10 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2019-07-31 20:10:27 +01:00
|
|
|
|
// CD-i extensions structures.
|
2017-10-13 21:50:10 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ 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
|
2019-07-31 20:19:22 +01:00
|
|
|
|
// In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24
|
2017-10-13 21:50:10 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 19:33:46 +00:00
|
|
|
|
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using System;
|
2017-10-13 21:50:10 +01:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Filesystems.ISO9660
|
|
|
|
|
|
{
|
2017-12-21 16:27:09 +00:00
|
|
|
|
public partial class ISO9660
|
2017-10-13 21:50:10 +01:00
|
|
|
|
{
|
2017-12-24 02:37:41 +00:00
|
|
|
|
static DecodedVolumeDescriptor DecodeVolumeDescriptor(FileStructureVolumeDescriptor pvd)
|
|
|
|
|
|
{
|
|
|
|
|
|
DecodedVolumeDescriptor decodedVD = new DecodedVolumeDescriptor
|
|
|
|
|
|
{
|
2018-06-22 08:08:38 +01: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(),
|
2018-01-29 17:36:58 +00:00
|
|
|
|
DataPreparerIdentifier = StringHandlers.CToString(pvd.preparer_id).TrimEnd(),
|
2018-06-22 08:08:38 +01:00
|
|
|
|
ApplicationIdentifier = StringHandlers.CToString(pvd.application_data).TrimEnd()
|
2017-12-24 02:37:41 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
|
|
|
|
|
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);
|
2017-12-24 02:37:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
2017-12-24 02:37:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
2017-12-24 02:37:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
decodedVD.Blocks = pvd.volume_space_size;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
decodedVD.BlockSize = pvd.logical_block_size;
|
|
|
|
|
|
|
|
|
|
|
|
return decodedVD;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-13 21:50:10 +01:00
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct FileStructureVolumeDescriptor
|
|
|
|
|
|
{
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte type;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] id;
|
|
|
|
|
|
public readonly byte version;
|
|
|
|
|
|
public readonly CdiVolumeFlags flags;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] system_id;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] volume_id;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] reserved1;
|
|
|
|
|
|
public readonly uint volume_space_size;
|
2017-10-13 21:50:10 +01:00
|
|
|
|
// Only used in SVDs
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] escape_sequences;
|
|
|
|
|
|
public readonly ushort reserved2;
|
|
|
|
|
|
public readonly ushort volume_set_size;
|
|
|
|
|
|
public readonly ushort reserved3;
|
|
|
|
|
|
public readonly ushort volume_sequence_number;
|
|
|
|
|
|
public readonly ushort reserved4;
|
|
|
|
|
|
public readonly ushort logical_block_size;
|
|
|
|
|
|
public readonly uint reserved5;
|
|
|
|
|
|
public readonly uint path_table_size;
|
|
|
|
|
|
public readonly ulong reserved6;
|
|
|
|
|
|
public readonly uint path_table_addr;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 38)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] reserved7;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] volume_set_id;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] publisher_id;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] preparer_id;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] application_id;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] copyright_file_id;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] reserved8;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] abstract_file_id;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] reserved9;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] bibliographic_file_id;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] reserved10;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] creation_date;
|
|
|
|
|
|
public readonly byte reserved11;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] modification_date;
|
|
|
|
|
|
public readonly byte reserved12;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] expiration_date;
|
|
|
|
|
|
public readonly byte reserved13;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] effective_date;
|
|
|
|
|
|
public readonly byte reserved14;
|
|
|
|
|
|
public readonly byte file_structure_version;
|
|
|
|
|
|
public readonly byte reserved15;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] application_data;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 653)]
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte[] reserved16;
|
2017-10-13 21:50:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct CdiDirectoryRecord
|
|
|
|
|
|
{
|
2019-07-31 05:19:18 +01:00
|
|
|
|
public readonly byte length;
|
|
|
|
|
|
public readonly byte xattr_len;
|
|
|
|
|
|
public readonly uint reserved1;
|
|
|
|
|
|
public readonly uint start_lbn;
|
|
|
|
|
|
public readonly uint reserved2;
|
|
|
|
|
|
public readonly uint size;
|
|
|
|
|
|
public readonly HighSierraTimestamp date;
|
|
|
|
|
|
public readonly byte reserved3;
|
|
|
|
|
|
public readonly CdiFileFlags flags;
|
|
|
|
|
|
public readonly ushort file_unit_size;
|
|
|
|
|
|
public readonly ushort reserved4;
|
|
|
|
|
|
public readonly ushort volume_sequence_number;
|
|
|
|
|
|
public readonly byte name_len;
|
2017-10-13 21:50:10 +01:00
|
|
|
|
// Followed by name[name_len] and then CdiSystemArea until length arrives
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Follows filename on directory record
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct CdiSystemArea
|
|
|
|
|
|
{
|
2019-07-31 23:02:43 +01:00
|
|
|
|
public readonly ushort group;
|
|
|
|
|
|
public readonly ushort owner;
|
|
|
|
|
|
public readonly ushort attributes;
|
|
|
|
|
|
public readonly ushort reserved1;
|
|
|
|
|
|
public readonly byte file_no;
|
|
|
|
|
|
public readonly byte reserved2;
|
2017-10-13 21:50:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|