diff --git a/.idea/.idea.DiscImageChef/.idea/contentModel.xml b/.idea/.idea.DiscImageChef/.idea/contentModel.xml index 5879d5010..6111907e0 100644 --- a/.idea/.idea.DiscImageChef/.idea/contentModel.xml +++ b/.idea/.idea.DiscImageChef/.idea/contentModel.xml @@ -780,6 +780,14 @@ + + + + + + + + diff --git a/DiscImageChef.DiscImages/CopyTape/Constants.cs b/DiscImageChef.DiscImages/CopyTape/Constants.cs new file mode 100644 index 000000000..6911d553c --- /dev/null +++ b/DiscImageChef.DiscImages/CopyTape/Constants.cs @@ -0,0 +1,41 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Constants.cs +// Author(s) : Natalia Portillo +// +// Component : Disk image plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains constants for CopyTape tape images. +// +// --[ 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-2019 Natalia Portillo +// ****************************************************************************/ + +namespace DiscImageChef.DiscImages.CopyTape +{ + public partial class CopyTape + { + const string BlockRegex = @"^CPTP:BLK (?\d{6})\n$"; + const string FilemarkRegex = @"^CPTP:MRK\n$"; + const string EndOfTapeRegex = @"^CPTP:EOT\n$"; + } +} \ No newline at end of file diff --git a/DiscImageChef.DiscImages/CopyTape/CopyTape.cs b/DiscImageChef.DiscImages/CopyTape/CopyTape.cs new file mode 100644 index 000000000..f2b17c662 --- /dev/null +++ b/DiscImageChef.DiscImages/CopyTape/CopyTape.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using DiscImageChef.CommonTypes.Enums; +using DiscImageChef.CommonTypes.Interfaces; +using DiscImageChef.CommonTypes.Structs; + +namespace DiscImageChef.DiscImages.CopyTape +{ + public partial class CopyTape : ITapeImage + { + public CopyTape() + { + Info = new ImageInfo + { + ReadableSectorTags = new List(), + ReadableMediaTags = new List(), + HasPartitions = true, + HasSessions = true, + Version = null, + ApplicationVersion = null, + MediaTitle = null, + Creator = null, + MediaManufacturer = null, + MediaModel = null, + MediaPartNumber = null, + MediaSequence = 0, + LastMediaSequence = 0, + DriveManufacturer = null, + DriveModel = null, + DriveSerialNumber = null, + DriveFirmwareRevision = null + }; + } + } +} \ No newline at end of file diff --git a/DiscImageChef.DiscImages/CopyTape/Identify.cs b/DiscImageChef.DiscImages/CopyTape/Identify.cs new file mode 100644 index 000000000..0e320db32 --- /dev/null +++ b/DiscImageChef.DiscImages/CopyTape/Identify.cs @@ -0,0 +1,74 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Identify.cs +// Author(s) : Natalia Portillo +// +// Component : Disk image plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies CopyTape images. +// +// --[ 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-2019 Natalia Portillo +// ****************************************************************************/ + +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using DiscImageChef.CommonTypes.Interfaces; + +namespace DiscImageChef.DiscImages.CopyTape +{ + public partial class CopyTape + { + public bool Identify(IFilter imageFilter) + { + if(imageFilter.GetDataForkLength() <= 16) return false; + + byte[] header = new byte[16]; + + Stream strm = imageFilter.GetDataForkStream(); + strm.Position = 0; + strm.Read(header, 0, 16); + + string mark = Encoding.ASCII.GetString(header); + + Regex blockRx = new Regex(BlockRegex); + Match blockMt = blockRx.Match(mark); + + if(!blockMt.Success) return false; + + string blkSize = blockMt.Groups["blockSize"].Value; + + if(string.IsNullOrWhiteSpace(blkSize)) return false; + + if(!uint.TryParse(blkSize, out uint blockSize)) return false; + + if(blockSize == 0 || blockSize + 17 >= imageFilter.GetDataForkLength()) return false; + + strm.Position += blockSize; + + int newLine = strm.ReadByte(); + + return newLine == 0x0A; + } + } +} \ No newline at end of file diff --git a/DiscImageChef.DiscImages/CopyTape/Properties.cs b/DiscImageChef.DiscImages/CopyTape/Properties.cs new file mode 100644 index 000000000..98a65b799 --- /dev/null +++ b/DiscImageChef.DiscImages/CopyTape/Properties.cs @@ -0,0 +1,53 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Properties.cs +// Author(s) : Natalia Portillo +// +// Component : Disk image plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains properties for CopyTape tape images. +// +// --[ 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-2019 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using DiscImageChef.CommonTypes.Structs; +using Schemas; + +namespace DiscImageChef.DiscImages.CopyTape +{ + public partial class CopyTape + { + public ImageInfo Info { get; } + public string Name => "CopyTape"; + public Guid Id => new Guid("C537D41E-D6A7-4922-9AA9-8E8442D0E340"); + public string Author => "Natalia Portillo"; + public string Format => "CopyTape"; + public List DumpHardware => null; + public CICMMetadataType CicmMetadata => null; + public List Files { get; } + public List TapePartitions { get; } + public bool IsTape => true; + } +} \ No newline at end of file diff --git a/DiscImageChef.DiscImages/CopyTape/Read.cs b/DiscImageChef.DiscImages/CopyTape/Read.cs new file mode 100644 index 000000000..5aa55b297 --- /dev/null +++ b/DiscImageChef.DiscImages/CopyTape/Read.cs @@ -0,0 +1,46 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Read.cs +// Author(s) : Natalia Portillo +// +// Component : Disk image plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Reads CopyTape tape images. +// +// --[ 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-2019 Natalia Portillo +// ****************************************************************************/ + +using System; +using DiscImageChef.CommonTypes.Interfaces; + +namespace DiscImageChef.DiscImages.CopyTape +{ + public partial class CopyTape + { + public bool Open(IFilter imageFilter) => throw new NotImplementedException(); + + public byte[] ReadSector(ulong sectorAddress) => throw new NotImplementedException(); + + public byte[] ReadSectors(ulong sectorAddress, uint length) => throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/DiscImageChef.DiscImages/CopyTape/Unsupported.cs b/DiscImageChef.DiscImages/CopyTape/Unsupported.cs new file mode 100644 index 000000000..00afb098c --- /dev/null +++ b/DiscImageChef.DiscImages/CopyTape/Unsupported.cs @@ -0,0 +1,55 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Unsupported.cs +// Author(s) : Natalia Portillo +// +// Component : Disk image plugins. +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains features unsupported by CopyTape tape images. +// +// --[ 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-2019 Natalia Portillo +// ****************************************************************************/ + +using DiscImageChef.CommonTypes.Enums; +using DiscImageChef.CommonTypes.Exceptions; + +namespace DiscImageChef.DiscImages.CopyTape +{ + public partial class CopyTape + { + public byte[] ReadDiskTag(MediaTagType tag) => + throw new FeatureUnsupportedImageException("Feature not supported by image format"); + + public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) => + throw new FeatureUnsupportedImageException("Feature not supported by image format"); + + public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) => + throw new FeatureUnsupportedImageException("Feature not supported by image format"); + + public byte[] ReadSectorLong(ulong sectorAddress) => + throw new FeatureUnsupportedImageException("Feature not supported by image format"); + + public byte[] ReadSectorsLong(ulong sectorAddress, uint length) => + throw new FeatureUnsupportedImageException("Feature not supported by image format"); + } +} \ No newline at end of file diff --git a/DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj b/DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj index 70f6f9a51..beb1f5d43 100644 --- a/DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj +++ b/DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj @@ -171,6 +171,12 @@ + + + + + +