mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Identify CopyTape images.
This commit is contained in:
8
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
8
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -780,6 +780,14 @@
|
||||
<e p="Structs.cs" t="Include" />
|
||||
<e p="Unsupported.cs" t="Include" />
|
||||
</e>
|
||||
<e p="CopyTape" t="Include">
|
||||
<e p="Constants.cs" t="Include" />
|
||||
<e p="CopyTape.cs" t="Include" />
|
||||
<e p="Identify.cs" t="Include" />
|
||||
<e p="Properties.cs" t="Include" />
|
||||
<e p="Read.cs" t="Include" />
|
||||
<e p="Unsupported.cs" t="Include" />
|
||||
</e>
|
||||
<e p="D88" t="Include">
|
||||
<e p="Constants.cs" t="Include" />
|
||||
<e p="D88.cs" t="Include" />
|
||||
|
||||
41
DiscImageChef.DiscImages/CopyTape/Constants.cs
Normal file
41
DiscImageChef.DiscImages/CopyTape/Constants.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Constants.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace DiscImageChef.DiscImages.CopyTape
|
||||
{
|
||||
public partial class CopyTape
|
||||
{
|
||||
const string BlockRegex = @"^CPTP:BLK (?<blockSize>\d{6})\n$";
|
||||
const string FilemarkRegex = @"^CPTP:MRK\n$";
|
||||
const string EndOfTapeRegex = @"^CPTP:EOT\n$";
|
||||
}
|
||||
}
|
||||
34
DiscImageChef.DiscImages/CopyTape/CopyTape.cs
Normal file
34
DiscImageChef.DiscImages/CopyTape/CopyTape.cs
Normal file
@@ -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<SectorTagType>(),
|
||||
ReadableMediaTags = new List<MediaTagType>(),
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
74
DiscImageChef.DiscImages/CopyTape/Identify.cs
Normal file
74
DiscImageChef.DiscImages/CopyTape/Identify.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Identify.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
53
DiscImageChef.DiscImages/CopyTape/Properties.cs
Normal file
53
DiscImageChef.DiscImages/CopyTape/Properties.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Properties.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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<DumpHardwareType> DumpHardware => null;
|
||||
public CICMMetadataType CicmMetadata => null;
|
||||
public List<TapeFile> Files { get; }
|
||||
public List<TapePartition> TapePartitions { get; }
|
||||
public bool IsTape => true;
|
||||
}
|
||||
}
|
||||
46
DiscImageChef.DiscImages/CopyTape/Read.cs
Normal file
46
DiscImageChef.DiscImages/CopyTape/Read.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Read.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
55
DiscImageChef.DiscImages/CopyTape/Unsupported.cs
Normal file
55
DiscImageChef.DiscImages/CopyTape/Unsupported.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Unsupported.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
@@ -171,6 +171,12 @@
|
||||
<Compile Include="CopyQM\Read.cs" />
|
||||
<Compile Include="CopyQM\Structs.cs" />
|
||||
<Compile Include="CopyQM\Unsupported.cs" />
|
||||
<Compile Include="CopyTape\Constants.cs" />
|
||||
<Compile Include="CopyTape\CopyTape.cs" />
|
||||
<Compile Include="CopyTape\Identify.cs" />
|
||||
<Compile Include="CopyTape\Properties.cs" />
|
||||
<Compile Include="CopyTape\Read.cs" />
|
||||
<Compile Include="CopyTape\Unsupported.cs" />
|
||||
<Compile Include="CPCDSK\Constants.cs" />
|
||||
<Compile Include="CPCDSK\Helpers.cs" />
|
||||
<Compile Include="CPCDSK\Identify.cs" />
|
||||
|
||||
Reference in New Issue
Block a user