Files
Aaru/Aaru.Images/ZZZRawImage/Properties.cs

204 lines
8.0 KiB
C#
Raw Normal View History

// /***************************************************************************
2020-02-27 12:31:25 +00:00
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Properties.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Disk image plugins.
//
// --[ Description ] ----------------------------------------------------------
//
// Contains properties for raw image, that is, user data sector by sector copy.
//
// --[ 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/>.
//
// ----------------------------------------------------------------------------
2020-12-31 23:08:23 +00:00
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
2020-02-27 00:33:26 +00:00
using Aaru.CommonTypes;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Exceptions;
using Aaru.CommonTypes.Structs;
using Schemas;
2020-02-27 00:33:26 +00:00
using TrackType = Aaru.CommonTypes.Enums.TrackType;
2020-02-27 00:33:26 +00:00
namespace Aaru.DiscImages
{
2020-07-22 13:20:25 +01:00
public sealed partial class ZZZRawImage
{
2020-10-23 03:33:22 +01:00
public OpticalImageCapabilities OpticalCapabilities => OpticalImageCapabilities.CanStoreDataTracks |
OpticalImageCapabilities.CanStoreCookedData;
public string Name => "Raw Disk Image";
2020-02-29 18:03:35 +00:00
// Non-random UUID to recognize this specific plugin
2018-08-29 22:15:43 +01:00
public Guid Id => new Guid("12345678-AAAA-BBBB-CCCC-123456789000");
2020-07-20 21:11:32 +01:00
public ImageInfo Info => _imageInfo;
2018-08-29 22:15:43 +01:00
public string Author => "Natalia Portillo";
public string Format => "Raw disk image (sector by sector copy)";
public List<Track> Tracks
{
get
{
2020-07-20 21:11:32 +01:00
if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc)
2020-02-29 18:03:35 +00:00
return null;
2020-02-29 18:03:35 +00:00
var trk = new Track
{
2020-07-20 21:11:32 +01:00
TrackBytesPerSector = _rawCompactDisc ? _mode2
? 2336
: 2048 : (int)_imageInfo.SectorSize,
TrackEndSector = _imageInfo.Sectors - 1,
TrackFile = _rawImageFilter?.GetFilename() ?? _basePath,
2020-07-20 21:11:32 +01:00
TrackFileOffset = 0,
TrackFileType = "BINARY",
TrackRawBytesPerSector = _rawCompactDisc ? 2352 : (int)_imageInfo.SectorSize,
TrackSequence = 1,
TrackStartSector = 0,
TrackSubchannelType =
_hasSubchannel ? TrackSubchannelType.RawInterleaved : TrackSubchannelType.None,
TrackType = _rawCompactDisc ? _mode2
? TrackType.CdMode2Formless
: TrackType.CdMode1 : TrackType.Data,
TrackSession = 1
};
2020-02-29 18:03:35 +00:00
List<Track> lst = new List<Track>
{
trk
};
return lst;
}
}
public List<Session> Sessions
{
get
{
2020-07-20 21:11:32 +01:00
if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc)
throw new FeatureUnsupportedImageException("Feature not supported by image format");
2020-02-29 18:03:35 +00:00
var sess = new Session
{
2020-07-20 21:11:32 +01:00
EndSector = _imageInfo.Sectors - 1,
2020-07-20 04:34:16 +01:00
EndTrack = 1,
SessionSequence = 1,
StartSector = 0,
StartTrack = 1
};
2020-02-29 18:03:35 +00:00
List<Session> lst = new List<Session>
{
sess
};
return lst;
}
}
public List<Partition> Partitions
{
get
{
2020-07-20 21:11:32 +01:00
if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc)
2020-02-29 18:03:35 +00:00
return null;
List<Partition> parts = new List<Partition>();
2020-02-29 18:03:35 +00:00
var part = new Partition
{
2020-07-20 04:34:16 +01:00
Start = 0,
2020-07-20 21:11:32 +01:00
Length = _imageInfo.Sectors,
2020-07-20 04:34:16 +01:00
Offset = 0,
Sequence = 0,
2020-07-20 21:11:32 +01:00
Type = _rawCompactDisc
? _mode2
? "MODE2/2352"
: "MODE1/2352"
2020-07-20 21:11:32 +01:00
: _imageInfo.MediaType == MediaType.PD650 || _imageInfo.MediaType == MediaType.PD650_WORM
2019-05-16 23:29:54 +01:00
? "DATA/512"
: "MODE1/2048",
2020-07-20 21:11:32 +01:00
Size = _imageInfo.Sectors * _imageInfo.SectorSize
};
2020-02-29 18:03:35 +00:00
parts.Add(part);
2020-02-29 18:03:35 +00:00
return parts;
}
}
2020-02-29 18:03:35 +00:00
public List<DumpHardwareType> DumpHardware => null;
public CICMMetadataType CicmMetadata { get; private set; }
2020-10-23 03:33:22 +01:00
public IEnumerable<MediaTagType> SupportedMediaTags => _readWriteSidecars.Concat(_writeOnlySidecars).
OrderBy(t => t.tag).Select(t => t.tag).ToArray();
2020-02-29 18:03:35 +00:00
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[]
{};
public IEnumerable<MediaType> SupportedMediaTypes
{
get
{
List<MediaType> types = new List<MediaType>();
2020-02-29 18:03:35 +00:00
foreach(MediaType type in Enum.GetValues(typeof(MediaType)))
switch(type)
{
// TODO: Implement support for writing formats with different track 0 bytes per sector
case MediaType.IBM33FD_256:
case MediaType.IBM33FD_512:
case MediaType.IBM43FD_128:
case MediaType.IBM43FD_256:
case MediaType.IBM53FD_256:
case MediaType.IBM53FD_512:
case MediaType.IBM53FD_1024:
case MediaType.ECMA_99_8:
case MediaType.ECMA_99_15:
case MediaType.ECMA_99_26:
case MediaType.ECMA_66:
case MediaType.ECMA_69_8:
case MediaType.ECMA_69_15:
case MediaType.ECMA_69_26:
case MediaType.ECMA_70:
case MediaType.ECMA_78: continue;
default:
types.Add(type);
2020-02-29 18:03:35 +00:00
break;
}
return types;
}
}
public IEnumerable<(string name, Type type, string description, object @default)> SupportedOptions =>
2020-02-29 18:03:35 +00:00
new (string name, Type type, string description, object @default)[]
{};
public IEnumerable<string> KnownExtensions => new[]
{
".adf", ".adl", ".d81", ".dsk", ".hdf", ".ima", ".img", ".iso", ".ssd", ".st", ".1kn", ".2kn", ".4kn",
".8kn", ".16kn", ".32kn", ".64kn", ".512e", ".512", ".128", ".256"
2020-02-29 18:03:35 +00:00
};
public bool IsWriting { get; private set; }
public string ErrorMessage { get; private set; }
}
}