From 9f91ae340c169e8701ac524663cab7191c9aaebf Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sat, 14 Dec 2013 23:02:04 +0000 Subject: [PATCH] Added CDRWin image plugin skeleton. git-svn-id: svn://claunia.com/FileSystemIDandChk@25 17725271-3d32-4980-a8cb-9ff532f270ba --- FileSystemIDandChk/FileSystemIDandChk.csproj | 1 + FileSystemIDandChk/ImagePlugins/CDRWin.cs | 279 ++++++++++++++++++ .../ImagePlugins/ImagePlugin.cs | 20 +- FileSystemIDandChk/Main.cs | 2 +- 4 files changed, 293 insertions(+), 9 deletions(-) create mode 100644 FileSystemIDandChk/ImagePlugins/CDRWin.cs diff --git a/FileSystemIDandChk/FileSystemIDandChk.csproj b/FileSystemIDandChk/FileSystemIDandChk.csproj index cbb6322b8..a7311deb0 100644 --- a/FileSystemIDandChk/FileSystemIDandChk.csproj +++ b/FileSystemIDandChk/FileSystemIDandChk.csproj @@ -68,6 +68,7 @@ + diff --git a/FileSystemIDandChk/ImagePlugins/CDRWin.cs b/FileSystemIDandChk/ImagePlugins/CDRWin.cs new file mode 100644 index 000000000..155e8b576 --- /dev/null +++ b/FileSystemIDandChk/ImagePlugins/CDRWin.cs @@ -0,0 +1,279 @@ +using System; +using System.IO; +using System.Text; +using System.Collections.Generic; +using FileSystemIDandChk; + +namespace FileSystemIDandChk.ImagePlugins +{ + class CDRWin : ImagePlugin + { +#region Internal structures + private struct TrackFile + { + public UInt32 sequence; // Track # + public string datafile; // Path of file containing track + public UInt64 offset; // Offset of track start in file + } +#endregion + +#region Internal variables + private string imagePath; + private FileStream imageStream; + private List sessions; + private List tracks; + private Dictionary trackFiles; // Dictionary, index is track #, value is TrackFile +#region + +#region Parsing regexs + private const string SessionRegEx = "REM\\s+SESSION\\s+(?\\d+)$"; + private const string CommentRegEx = "REM\\s+(?.+)$"; + private const string CDTextRegEx = "CDTEXMAIN\\s+(?.+)$"; + private const string MCNRegEx = "CATALOG\\s+(?\\d{13})$"; + private const string TitleRegEx = "TITLE\\s+(?.+)$"; + private const string PerformerRegEx = "PERFORMER\\s+(?<performer>.+)$"; + private const string SongWriterRegEx = "SONGWRITER\\s+(?<songwriter>.+)$"; + private const string FileRegEx = "FILE\\s+(?<filename>.+)\\s+(?<type>\\S+)$"; + private const string TrackRegEx = "TRACK\\s+(?<number>\\d+)\\s+(?<type>\\S+)$"; + private const string ISRCRegEx = "ISRC\\s+(?<isrc>\\w{12})$"; + private const string IndexRegEx = "INDEX\\s+(?<index>\\d+)\\s+(?<msf>[\\d]+:[\\d]+:[\\d]+)$"; + private const string PregapRegEx = "PREGAP\\s+(?<msf>[\\d]+:[\\d]+:[\\d]+)$"; + private const string PostgapRegex = "POSTGAP\\s+(?<msf>[\\d]+:[\\d]+:[\\d]+)$"; + private const string FlagsRegEx = "FLAGS\\+(((?<dcp>DCP)|(?<4ch>4CH)|(?<pre>PRE)|(?<scms>SCMS))\\s*)+$"; +#endregion + +#region Methods + public CDRWin (PluginBase Core) + { + base.Name = "CDRWin cuesheet handler"; + base.PluginUUID = new Guid("664568B2-15D4-4E64-8A7A-20BDA8B8386F"); + this.imagePath = ""; + } + + public CDRWin (PluginBase Core, string imagePath) + { + this.imagePath = imagePath; + } + + // Due to .cue format, this method must parse whole file, ignoring errors (those will be thrown by OpenImage()). + public override bool IdentifyImage() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + public override bool OpenImage() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + public override bool ImageHasPartitions() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override UInt64 GetImageSize() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + public override UInt64 GetSectors() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + public override UInt32 GetSectorSize() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadDiskTag(DiskTagType tag) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadSector(UInt64 SectorAddress) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadSectorTag(UInt64 SectorAddress, SectorTagType tag) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadSector(UInt64 SectorAddress, UInt32 track) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadSectorTag(UInt64 SectorAddress, UInt32 track, SectorTagType tag) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadSectors(UInt64 SectorAddress, UInt32 length) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadSectorsTag(UInt64 SectorAddress, UInt32 length, SectorTagType tag) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadSectors(UInt64 SectorAddress, UInt32 length, UInt32 track) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadSectorsTag(UInt64 SectorAddress, UInt32 length, UInt32 track, SectorTagType tag) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadSectorLong(UInt64 SectorAddress) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadSectorLong(UInt64 SectorAddress, UInt32 track) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadSectorsLong(UInt64 SectorAddress, UInt32 length) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override byte[] ReadSectorsLong(UInt64 SectorAddress, UInt32 length, UInt32 track) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override string GetImageFormat() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override string GetImageVersion() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override string GetImageApplication() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override string GetImageApplicationVersion() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override DateTime GetImageCreationTime() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override DateTime GetImageLastModificationTime() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override string GetImageComments() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override string GetDiskSerialNumber() + { + return this.GetDiskBarcode(); + } + + public override string GetDiskBarcode() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override DiskType GetDiskType() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override List<PartPlugins.Partition> GetPartitions() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override List<Track> GetTracks() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override List<Track> GetSessionTracks(Session Session) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override List<Track> GetSessionTracks(UInt16 Session) + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } + + public override List<Session> GetSessions() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); + } +#endregion + +#region Unsupported features + public override int GetDiskSequence() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format"); + } + + public override int GetLastDiskSequence() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format"); + } + + public override string GetDriveManufacturer() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format"); + } + + public override string GetDriveModel() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format"); + } + + public override string GetDriveSerialNumber() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format"); + } + + public override string GetDiskPartNumber() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format"); + } + + public override string GetDiskManufacturer() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format"); + } + + public override string GetDiskModel() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format"); + } + + public override string GetImageName() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format"); + } + + public override string GetImageCreator() + { + throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format"); + } +#endregion + } +} + diff --git a/FileSystemIDandChk/ImagePlugins/ImagePlugin.cs b/FileSystemIDandChk/ImagePlugins/ImagePlugin.cs index dbf86f16d..f6a3e2a12 100644 --- a/FileSystemIDandChk/ImagePlugins/ImagePlugin.cs +++ b/FileSystemIDandChk/ImagePlugins/ImagePlugin.cs @@ -9,6 +9,10 @@ namespace FileSystemIDandChk.ImagePlugins public string Name; public Guid PluginUUID; + protected ImagePlugin () + { + } + protected ImagePlugin (string ImagePath) { } @@ -50,14 +54,14 @@ namespace FileSystemIDandChk.ImagePlugins public abstract string GetImageComments(); // Gets image comments // Functions to get information from disk represented by image - public abstract string GetDiskManufacturer(); // Gets disk manufacturer - public abstract string GetDiskModel(); // Gets disk model - public abstract string GetDiskSerialNumber(); // Gets disk serial number - public abstract string GetDiskBarcode(); // Gets disk (or product) - public abstract string GetDiskPartNumber(); // Gets disk part no. as manufacturer set - public abstract string GetDiskType(); // Gets disk type - public abstract int GetDiskSequence(); // Gets disk sequence number, 1-starting - public abstract int GetLastDiskSequence(); // Gets last disk sequence number + public abstract string GetDiskManufacturer(); // Gets disk manufacturer + public abstract string GetDiskModel(); // Gets disk model + public abstract string GetDiskSerialNumber(); // Gets disk serial number + public abstract string GetDiskBarcode(); // Gets disk (or product) + public abstract string GetDiskPartNumber(); // Gets disk part no. as manufacturer set + public abstract DiskType GetDiskType(); // Gets disk type + public abstract int GetDiskSequence(); // Gets disk sequence number, 1-starting + public abstract int GetLastDiskSequence(); // Gets last disk sequence number // Functions to get information from drive used to create image public abstract string GetDriveManufacturer(); // Gets drive manufacturer diff --git a/FileSystemIDandChk/Main.cs b/FileSystemIDandChk/Main.cs index fbb7e896b..7f79957a0 100644 --- a/FileSystemIDandChk/Main.cs +++ b/FileSystemIDandChk/Main.cs @@ -199,7 +199,7 @@ namespace FileSystemIDandChk } finally { - stream.Close(); + stream = null; } }