Files
Aaru/DiscImageChef.Core/Sidecar/Sidecar.cs

112 lines
3.9 KiB
C#
Raw Normal View History

// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Sidecar.cs
// Version : 1.0
// Author(s) : Natalia Portillo
//
// Component : Component
//
// Revision : $Revision$
// Last change by : $Author$
// Date : $Date$
//
// --[ Description ] ----------------------------------------------------------
//
// Description
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright (C) 2011-2015 Claunia.com
// ****************************************************************************/
// //$Id$
2017-08-08 14:18:31 +01:00
using System.Collections.Generic;
using System.IO;
using DiscImageChef.ImagePlugins;
using Schemas;
namespace DiscImageChef.Core
{
2017-08-08 12:15:55 +01:00
public static partial class Sidecar
{
public static CICMMetadataType Create(ImagePlugin image, string imagePath, System.Guid filterId, System.Text.Encoding encoding)
{
CICMMetadataType sidecar = new CICMMetadataType();
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding);
FileInfo fi = new FileInfo(imagePath);
FileStream fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
Checksum imgChkWorker = new Checksum();
// For fast debugging, skip checksum
//goto skipImageChecksum;
byte[] data;
long position = 0;
InitProgress();
while(position < (fi.Length - 1048576))
{
data = new byte[1048576];
fs.Read(data, 0, 1048576);
UpdateProgress("Hashing image file byte {0} of {1}", position, fi.Length);
imgChkWorker.Update(data);
position += 1048576;
}
data = new byte[fi.Length - position];
fs.Read(data, 0, (int)(fi.Length - position));
UpdateProgress("Hashing image file byte {0} of {1}", position, fi.Length);
imgChkWorker.Update(data);
// For fast debugging, skip checksum
//skipImageChecksum:
EndProgress();
fs.Close();
List<ChecksumType> imgChecksums = imgChkWorker.End();
switch(image.ImageInfo.xmlMediaType)
{
case XmlMediaType.OpticalDisc:
2017-08-08 13:40:32 +01:00
OpticalDisc(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar);
break;
case XmlMediaType.BlockMedia:
2017-08-08 13:40:32 +01:00
BlockMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar);
break;
case XmlMediaType.LinearMedia:
2017-08-08 13:40:32 +01:00
LinearMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar);
break;
case XmlMediaType.AudioMedia:
2017-08-08 13:40:32 +01:00
AudioMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar);
break;
}
return sidecar;
}
}
}