initial commit
This commit is contained in:
commit
1b60743303
274 changed files with 25866 additions and 0 deletions
18
ImageReader/AssemblyGitBuildBranch.cs
Normal file
18
ImageReader/AssemblyGitBuildBranch.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.AssemblyGitBuildBranch
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace ImageReader
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Assembly)]
|
||||
public class AssemblyGitBuildBranch : Attribute
|
||||
{
|
||||
public string GitBuildBranch { get; private set; }
|
||||
|
||||
public AssemblyGitBuildBranch(string txt) => this.GitBuildBranch = txt;
|
||||
}
|
||||
}
|
18
ImageReader/AssemblyGitBuildSHA1.cs
Normal file
18
ImageReader/AssemblyGitBuildSHA1.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.AssemblyGitBuildSHA1
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace ImageReader
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Assembly)]
|
||||
public class AssemblyGitBuildSHA1 : Attribute
|
||||
{
|
||||
public string GitBuildSHA1 { get; private set; }
|
||||
|
||||
public AssemblyGitBuildSHA1(string txt) => this.GitBuildSHA1 = txt;
|
||||
}
|
||||
}
|
17
ImageReader/AssemblyInfo.cs
Normal file
17
ImageReader/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using ImageReader;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyGitBuildBranch("release_1.6.3")]
|
||||
[assembly: AssemblyFileVersion("1.5.2")]
|
||||
[assembly: AssemblyGitBuildSHA1("fd2eb45")]
|
||||
[assembly: AssemblyTitle("Image Reader")]
|
||||
[assembly: AssemblyDescription("ImageReader.dll")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Japanese Cake")]
|
||||
[assembly: AssemblyProduct("Image Reader")]
|
||||
[assembly: AssemblyCopyright("2012-2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: ComVisible(true)]
|
||||
[assembly: Guid("d23954c0-4b76-497a-bcac-66de624f695f")]
|
||||
[assembly: AssemblyVersion("1.5.2.0")]
|
12
ImageReader/AssemblyTest.cs
Normal file
12
ImageReader/AssemblyTest.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.AssemblyTest
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
namespace ImageReader
|
||||
{
|
||||
public class AssemblyTest
|
||||
{
|
||||
}
|
||||
}
|
14
ImageReader/DiscSectors/CDROMDataModeType.cs
Normal file
14
ImageReader/DiscSectors/CDROMDataModeType.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.DiscSectors.CDROMDataModeType
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
namespace ImageReader.DiscSectors
|
||||
{
|
||||
public enum CDROMDataModeType : byte
|
||||
{
|
||||
MODE1_RAW = 1,
|
||||
MODE2_RAW = 2,
|
||||
}
|
||||
}
|
58
ImageReader/DiscSectors/CDROMFrameHeaderConverter.cs
Normal file
58
ImageReader/DiscSectors/CDROMFrameHeaderConverter.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.DiscSectors.CDROMFrameHeaderConverter
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ImageReader.DiscSectors
|
||||
{
|
||||
public class CDROMFrameHeaderConverter
|
||||
{
|
||||
public static readonly ushort CDROM_FRAME_HEADER_SIZE = 16;
|
||||
private static readonly byte[] CDROM_FRAME_HEADER_SYNC = new byte[12]
|
||||
{
|
||||
(byte) 0,
|
||||
byte.MaxValue,
|
||||
byte.MaxValue,
|
||||
byte.MaxValue,
|
||||
byte.MaxValue,
|
||||
byte.MaxValue,
|
||||
byte.MaxValue,
|
||||
byte.MaxValue,
|
||||
byte.MaxValue,
|
||||
byte.MaxValue,
|
||||
byte.MaxValue,
|
||||
(byte) 0
|
||||
};
|
||||
|
||||
public static CDROMDataModeType ToCDROMFrameHeader(
|
||||
byte[] buffer,
|
||||
int startIndex)
|
||||
{
|
||||
if (buffer.Length < startIndex + (int) CDROMFrameHeaderConverter.CDROM_FRAME_HEADER_SIZE)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
GCHandle gcHandle = GCHandle.Alloc((object) buffer, GCHandleType.Pinned);
|
||||
CDROMFrameHeaderConverter.CDROMFrameHeader structure = (CDROMFrameHeaderConverter.CDROMFrameHeader) Marshal.PtrToStructure(gcHandle.AddrOfPinnedObject(), typeof (CDROMFrameHeaderConverter.CDROMFrameHeader));
|
||||
gcHandle.Free();
|
||||
if (((IEnumerable<byte>) CDROMFrameHeaderConverter.CDROM_FRAME_HEADER_SYNC).Where<byte>((Func<byte, int, bool>) ((t, i) => (int) t != (int) buffer[i])).Any<byte>())
|
||||
throw new FormatException();
|
||||
return Enum.IsDefined(typeof (CDROMDataModeType), (object) structure.Mode) ? structure.Mode : throw new FormatException();
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16)]
|
||||
private struct CDROMFrameHeader
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public byte Sync;
|
||||
[FieldOffset(12)]
|
||||
public byte Address;
|
||||
[FieldOffset(15)]
|
||||
public CDROMDataModeType Mode;
|
||||
}
|
||||
}
|
||||
}
|
17
ImageReader/DiscSectors/CDROMMode1RawSector.cs
Normal file
17
ImageReader/DiscSectors/CDROMMode1RawSector.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.DiscSectors.CDROMMode1RawSector
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
namespace ImageReader.DiscSectors
|
||||
{
|
||||
public class CDROMMode1RawSector : DiscSectorBase
|
||||
{
|
||||
public override int Size => 2352;
|
||||
|
||||
public override int DataOffset => 16;
|
||||
|
||||
public override int DataLength => 2048;
|
||||
}
|
||||
}
|
17
ImageReader/DiscSectors/CDROMXAMode2Form1RawSector.cs
Normal file
17
ImageReader/DiscSectors/CDROMXAMode2Form1RawSector.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.DiscSectors.CDROMXAMode2Form1RawSector
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
namespace ImageReader.DiscSectors
|
||||
{
|
||||
public class CDROMXAMode2Form1RawSector : DiscSectorBase
|
||||
{
|
||||
public override int Size => 2352;
|
||||
|
||||
public override int DataOffset => 24;
|
||||
|
||||
public override int DataLength => 2048;
|
||||
}
|
||||
}
|
17
ImageReader/DiscSectors/CDROMXAMode2Form1Sector.cs
Normal file
17
ImageReader/DiscSectors/CDROMXAMode2Form1Sector.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.DiscSectors.CDROMXAMode2Form1Sector
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
namespace ImageReader.DiscSectors
|
||||
{
|
||||
public class CDROMXAMode2Form1Sector : DiscSectorBase
|
||||
{
|
||||
public override int Size => 2336;
|
||||
|
||||
public override int DataOffset => 8;
|
||||
|
||||
public override int DataLength => 2048;
|
||||
}
|
||||
}
|
33
ImageReader/DiscSectors/DiscSectorBase.cs
Normal file
33
ImageReader/DiscSectors/DiscSectorBase.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.DiscSectors.DiscSectorBase
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace ImageReader.DiscSectors
|
||||
{
|
||||
public abstract class DiscSectorBase : IDiscSector
|
||||
{
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(obj is IDiscSector))
|
||||
return false;
|
||||
IDiscSector discSector = obj as IDiscSector;
|
||||
return this.Size == discSector.Size && this.DataOffset == discSector.DataOffset && this.DataLength == discSector.DataLength;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => ((17 * 23 + this.Size) * 23 + this.DataOffset) * 23 + this.DataLength;
|
||||
|
||||
public virtual int Size => throw new NotImplementedException();
|
||||
|
||||
public virtual int DataOffset => throw new NotImplementedException();
|
||||
|
||||
public virtual int DataLength => throw new NotImplementedException();
|
||||
}
|
||||
}
|
14
ImageReader/DiscSectors/DiscSectorCommon.cs
Normal file
14
ImageReader/DiscSectors/DiscSectorCommon.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.DiscSectors.DiscSectorCommon
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
namespace ImageReader.DiscSectors
|
||||
{
|
||||
public class DiscSectorCommon
|
||||
{
|
||||
public static readonly int RawSectorSize = 2352;
|
||||
public static readonly int LogicalSectorSize = 2048;
|
||||
}
|
||||
}
|
17
ImageReader/DiscSectors/IDiscSector.cs
Normal file
17
ImageReader/DiscSectors/IDiscSector.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.DiscSectors.IDiscSector
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
namespace ImageReader.DiscSectors
|
||||
{
|
||||
public interface IDiscSector
|
||||
{
|
||||
int Size { get; }
|
||||
|
||||
int DataOffset { get; }
|
||||
|
||||
int DataLength { get; }
|
||||
}
|
||||
}
|
17
ImageReader/DiscSectors/ISO9660Sector.cs
Normal file
17
ImageReader/DiscSectors/ISO9660Sector.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.DiscSectors.ISO9660Sector
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
namespace ImageReader.DiscSectors
|
||||
{
|
||||
public class ISO9660Sector : DiscSectorBase
|
||||
{
|
||||
public override int Size => 2048;
|
||||
|
||||
public override int DataOffset => 0;
|
||||
|
||||
public override int DataLength => 2048;
|
||||
}
|
||||
}
|
17
ImageReader/DiscSectors/RawSector.cs
Normal file
17
ImageReader/DiscSectors/RawSector.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.DiscSectors.RawSector
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
namespace ImageReader.DiscSectors
|
||||
{
|
||||
public class RawSector : DiscSectorBase
|
||||
{
|
||||
public override int Size => 2352;
|
||||
|
||||
public override int DataOffset => 0;
|
||||
|
||||
public override int DataLength => 2352;
|
||||
}
|
||||
}
|
199
ImageReader/ISO9660/DirectoryRecords/DirectoryRecord.cs
Normal file
199
ImageReader/ISO9660/DirectoryRecords/DirectoryRecord.cs
Normal file
|
@ -0,0 +1,199 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.ISO9660.DirectoryRecords.DirectoryRecord
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace ImageReader.ISO9660.DirectoryRecords
|
||||
{
|
||||
public class DirectoryRecord
|
||||
{
|
||||
public static readonly char DIRECTORY_SEPARATOR_CHAR = Path.DirectorySeparatorChar;
|
||||
public static readonly string DIRECTORY_SEPARATOR = DirectoryRecord.DIRECTORY_SEPARATOR_CHAR.ToString();
|
||||
public static readonly string ROOT_DIRECTORY_NAME = DirectoryRecord.DIRECTORY_SEPARATOR_CHAR.ToString();
|
||||
public static readonly string SELF_DIRECTORY_NAME = ".";
|
||||
public static readonly string PARENT_DIRECTORY_NAME = "..";
|
||||
internal static readonly byte ROOT_OR_SELF_DIRECTORY_FILE_IDENTIFIER = 0;
|
||||
internal static readonly byte PARENT_DIRECTORY_FILE_IDENTIFIER = 1;
|
||||
internal ushort extendAttributeLength;
|
||||
internal uint extentTypeL;
|
||||
internal uint extentTypeM;
|
||||
internal uint extentSizeTypeL;
|
||||
internal uint extentSizeTypeM;
|
||||
internal ushort fileUnitSize;
|
||||
internal ushort fileGapSize;
|
||||
internal ushort volumeSequenceNumberTypeL;
|
||||
internal ushort volumeSequenceNumberTypeM;
|
||||
internal DirectoryRecord parent;
|
||||
internal List<DirectoryRecord> children;
|
||||
|
||||
public static string FindCommonPathPrefix(List<DirectoryRecord> directoryRecords)
|
||||
{
|
||||
if (directoryRecords.Count < 1)
|
||||
return (string) null;
|
||||
Dictionary<DirectoryRecord, string> source = new Dictionary<DirectoryRecord, string>();
|
||||
foreach (DirectoryRecord directoryRecord in directoryRecords)
|
||||
source[directoryRecord] = directoryRecord.IsDirectory ? directoryRecord.FullPath : Path.GetDirectoryName(directoryRecord.FullPath);
|
||||
int minDepth = source.Min<KeyValuePair<DirectoryRecord, string>>((Func<KeyValuePair<DirectoryRecord, string>, int>) (pkv => pkv.Value.Split(new char[1]
|
||||
{
|
||||
DirectoryRecord.DIRECTORY_SEPARATOR_CHAR
|
||||
}, StringSplitOptions.RemoveEmptyEntries).Length));
|
||||
string pathPrefix = source.First<KeyValuePair<DirectoryRecord, string>>((Func<KeyValuePair<DirectoryRecord, string>, bool>) (pkv => pkv.Value.Split(new char[1]
|
||||
{
|
||||
DirectoryRecord.DIRECTORY_SEPARATOR_CHAR
|
||||
}, StringSplitOptions.RemoveEmptyEntries).Length == minDepth)).Value;
|
||||
for (int index = 0; index < minDepth && !directoryRecords.TrueForAll((Predicate<DirectoryRecord>) (dr => dr.FullPath.StartsWith(pathPrefix))); ++index)
|
||||
pathPrefix = Path.GetDirectoryName(pathPrefix);
|
||||
if (directoryRecords.Count == 1 && directoryRecords[0].IsDirectory && !directoryRecords[0].IsRoot)
|
||||
pathPrefix = Path.GetDirectoryName(pathPrefix);
|
||||
return pathPrefix;
|
||||
}
|
||||
|
||||
internal DirectoryRecord() => this.children = new List<DirectoryRecord>();
|
||||
|
||||
public byte RecordLength { get; internal set; }
|
||||
|
||||
public string Name { get; internal set; }
|
||||
|
||||
public uint Extent => !BitConverter.IsLittleEndian ? this.extentTypeM : this.extentTypeL;
|
||||
|
||||
public uint ExtentSize => !BitConverter.IsLittleEndian ? this.extentSizeTypeM : this.extentSizeTypeL;
|
||||
|
||||
public DateTime? RecordingDateTime { get; internal set; }
|
||||
|
||||
public DirectoryRecordFlags Flags { get; internal set; }
|
||||
|
||||
public bool HasValidFileIdentifier { get; internal set; }
|
||||
|
||||
public ushort VolumeSequenceNumber => !BitConverter.IsLittleEndian ? this.volumeSequenceNumberTypeM : this.volumeSequenceNumberTypeL;
|
||||
|
||||
public int Depth
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.IsRoot)
|
||||
return 0;
|
||||
return this.FullPath.Split(new char[1]
|
||||
{
|
||||
Path.DirectorySeparatorChar
|
||||
}, StringSplitOptions.RemoveEmptyEntries).Length;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsHidden => (this.Flags & DirectoryRecordFlags.HIDDEN_FILE) != DirectoryRecordFlags.NONE;
|
||||
|
||||
public bool IsDirectory => (this.Flags & DirectoryRecordFlags.DIRECTORY) != DirectoryRecordFlags.NONE;
|
||||
|
||||
public bool IsAssociated => (this.Flags & DirectoryRecordFlags.ASSOCIATED_FILE) != DirectoryRecordFlags.NONE;
|
||||
|
||||
public bool HasExtentedAttributeRecord => (this.Flags & DirectoryRecordFlags.EXTENDED_ATTRIBUTE_RECORD) != DirectoryRecordFlags.NONE;
|
||||
|
||||
public bool HasOwnerAndGroupPermissions => (this.Flags & DirectoryRecordFlags.OWNER_AND_GROUP_PERMISSIONS) != DirectoryRecordFlags.NONE;
|
||||
|
||||
public bool HasReservedFlags => (this.Flags & DirectoryRecordFlags.RESERVED_FLAGS) != DirectoryRecordFlags.NONE;
|
||||
|
||||
public bool IsNotFinalRecord => (this.Flags & DirectoryRecordFlags.NOT_FINAL_RECORD) != DirectoryRecordFlags.NONE;
|
||||
|
||||
public bool IsFlagSet(DirectoryRecordFlags flags) => (this.Flags & flags) != DirectoryRecordFlags.NONE;
|
||||
|
||||
public bool IsRoot => this.parent == null;
|
||||
|
||||
public DirectoryRecord RootDirectory => this.IsRoot ? this : this.parent.RootDirectory;
|
||||
|
||||
public DirectoryRecord ParentDirectory => this.parent;
|
||||
|
||||
public List<DirectoryRecord> SubDirectories => this.children;
|
||||
|
||||
public List<DirectoryRecord> GetAllSubFolder()
|
||||
{
|
||||
List<DirectoryRecord> list = new List<DirectoryRecord>();
|
||||
this.GetAllSubDirectoriesRec(list, true, false);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<DirectoryRecord> GetAllSubFiles()
|
||||
{
|
||||
List<DirectoryRecord> list = new List<DirectoryRecord>();
|
||||
this.GetAllSubDirectoriesRec(list, false, true);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<DirectoryRecord> GetAllSubDirectories()
|
||||
{
|
||||
List<DirectoryRecord> list = new List<DirectoryRecord>();
|
||||
this.GetAllSubDirectoriesRec(list, true, true);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void GetAllSubDirectoriesRec(
|
||||
List<DirectoryRecord> list,
|
||||
bool includeFolders,
|
||||
bool includeFiles)
|
||||
{
|
||||
foreach (DirectoryRecord child in this.children)
|
||||
{
|
||||
if (includeFolders && child.IsDirectory)
|
||||
list.Add(child);
|
||||
if (includeFiles && !child.IsDirectory)
|
||||
list.Add(child);
|
||||
child.GetAllSubDirectoriesRec(list, includeFolders, includeFiles);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Contains(string directoryRecordName) => this.children.Find((Predicate<DirectoryRecord>) (directoryRecord => directoryRecord.Name.Equals(directoryRecordName))) != null;
|
||||
|
||||
public DirectoryRecord Find(DirectoryRecord directoryRecord)
|
||||
{
|
||||
if (directoryRecord == this)
|
||||
return this;
|
||||
DirectoryRecord directoryRecord1 = (DirectoryRecord) null;
|
||||
if (directoryRecord.FullPath.StartsWith(this.FullPath))
|
||||
{
|
||||
foreach (DirectoryRecord child in this.children)
|
||||
{
|
||||
directoryRecord1 = child.Find(directoryRecord);
|
||||
if (directoryRecord1 != null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return directoryRecord1;
|
||||
}
|
||||
|
||||
public DirectoryRecord Find(string path)
|
||||
{
|
||||
if (this.FullPath.Equals(path))
|
||||
return this;
|
||||
DirectoryRecord directoryRecord = (DirectoryRecord) null;
|
||||
if (path.StartsWith(this.FullPath))
|
||||
{
|
||||
foreach (DirectoryRecord child in this.children)
|
||||
{
|
||||
directoryRecord = child.Find(path);
|
||||
if (directoryRecord != null)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return directoryRecord;
|
||||
}
|
||||
|
||||
public string FullPath => this.parent != null ? Path.Combine(this.parent.FullPath, this.Name) : this.Name;
|
||||
|
||||
public uint UsedSpace
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!this.IsDirectory)
|
||||
return this.ExtentSize;
|
||||
uint num = 0;
|
||||
foreach (DirectoryRecord child in this.children)
|
||||
num += child.UsedSpace;
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
114
ImageReader/ISO9660/DirectoryRecords/DirectoryRecordConverter.cs
Normal file
114
ImageReader/ISO9660/DirectoryRecords/DirectoryRecordConverter.cs
Normal file
|
@ -0,0 +1,114 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.ISO9660.DirectoryRecords.DirectoryRecordConverter
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ImageReader.ISO9660.DirectoryRecords
|
||||
{
|
||||
public class DirectoryRecordConverter
|
||||
{
|
||||
private static readonly Logger.ILog logger = Logger.CreateLog();
|
||||
private static readonly byte DIRECTORY_RECORD_MIN_SIZE = 34;
|
||||
private static readonly byte OFFSET_RECORD_LENGTH = 0;
|
||||
private static readonly byte OFFSET_EXTENDED_ATTRIBUTE_LENGTH = 1;
|
||||
private static readonly byte OFFSET_TYPE_L_EXTENT_LOCATION = 2;
|
||||
private static readonly byte OFFSET_TYPE_M_EXTENT_LOCATION = 6;
|
||||
private static readonly byte OFFSET_TYPE_L_EXTENT_SIZE = 10;
|
||||
private static readonly byte OFFSET_TYPE_M_EXTENT_SIZE = 14;
|
||||
private static readonly byte OFFSET_DATETIME = 18;
|
||||
private static readonly byte OFFSET_FLAGS = 25;
|
||||
private static readonly byte OFFSET_INTERLEAVED_FILE_UNIT_SIZE = 26;
|
||||
private static readonly byte OFFSET_INTERLEAVED_FILE_GAP_SIZE = 27;
|
||||
private static readonly byte OFFSET_TYPE_L_VOLUME_SEQUENCE_NUMBER = 28;
|
||||
private static readonly byte OFFSET_TYPE_M_VOLUME_SEQUENCE_NUMBER = 30;
|
||||
private static readonly byte OFFSET_FILE_IDENTIFIER_LENGTH = 32;
|
||||
private static readonly byte OFFSET_FILE_IDENTIFIER = 33;
|
||||
private static readonly Regex VALID_FILENAME = new Regex("[^A-Z0-9._]+", RegexOptions.IgnoreCase);
|
||||
|
||||
public static DirectoryRecord ToDirectoryRecord(byte[] buffer, int startIndex) => DirectoryRecordConverter.ToDirectoryRecord(buffer, startIndex, false);
|
||||
|
||||
public static DirectoryRecord ToRootDirectoryRecord(
|
||||
byte[] buffer,
|
||||
int startIndex)
|
||||
{
|
||||
return DirectoryRecordConverter.ToDirectoryRecord(buffer, startIndex, true);
|
||||
}
|
||||
|
||||
private static DirectoryRecord ToDirectoryRecord(
|
||||
byte[] buffer,
|
||||
int startIndex,
|
||||
bool isForRootDirectory)
|
||||
{
|
||||
byte num1 = buffer[startIndex + (int) DirectoryRecordConverter.OFFSET_RECORD_LENGTH];
|
||||
if (startIndex < 0 || buffer.Length - startIndex < (int) num1 || (int) num1 < (int) DirectoryRecordConverter.DIRECTORY_RECORD_MIN_SIZE)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
DirectoryRecord directoryRecord = new DirectoryRecord();
|
||||
directoryRecord.RecordLength = num1;
|
||||
directoryRecord.extendAttributeLength = (ushort) buffer[startIndex + (int) DirectoryRecordConverter.OFFSET_EXTENDED_ATTRIBUTE_LENGTH];
|
||||
directoryRecord.extentTypeL = BitConverter.ToUInt32(buffer, startIndex + (int) DirectoryRecordConverter.OFFSET_TYPE_L_EXTENT_LOCATION);
|
||||
directoryRecord.extentTypeM = BitConverter.ToUInt32(buffer, startIndex + (int) DirectoryRecordConverter.OFFSET_TYPE_M_EXTENT_LOCATION);
|
||||
directoryRecord.extentSizeTypeL = BitConverter.ToUInt32(buffer, startIndex + (int) DirectoryRecordConverter.OFFSET_TYPE_L_EXTENT_SIZE);
|
||||
directoryRecord.extentSizeTypeM = BitConverter.ToUInt32(buffer, startIndex + (int) DirectoryRecordConverter.OFFSET_TYPE_M_EXTENT_SIZE);
|
||||
directoryRecord.RecordingDateTime = DirectoryRecordConverter.DirectoryRecordDateTimeConverter.ToDateTime(buffer, startIndex + (int) DirectoryRecordConverter.OFFSET_DATETIME);
|
||||
directoryRecord.Flags = (DirectoryRecordFlags) buffer[startIndex + (int) DirectoryRecordConverter.OFFSET_FLAGS];
|
||||
directoryRecord.fileUnitSize = (ushort) buffer[startIndex + (int) DirectoryRecordConverter.OFFSET_INTERLEAVED_FILE_UNIT_SIZE];
|
||||
directoryRecord.fileGapSize = (ushort) buffer[startIndex + (int) DirectoryRecordConverter.OFFSET_INTERLEAVED_FILE_GAP_SIZE];
|
||||
directoryRecord.volumeSequenceNumberTypeL = BitConverter.ToUInt16(buffer, startIndex + (int) DirectoryRecordConverter.OFFSET_TYPE_L_VOLUME_SEQUENCE_NUMBER);
|
||||
directoryRecord.volumeSequenceNumberTypeM = BitConverter.ToUInt16(buffer, startIndex + (int) DirectoryRecordConverter.OFFSET_TYPE_M_VOLUME_SEQUENCE_NUMBER);
|
||||
byte num2 = buffer[startIndex + (int) DirectoryRecordConverter.OFFSET_FILE_IDENTIFIER_LENGTH];
|
||||
if ((int) buffer[startIndex + (int) DirectoryRecordConverter.OFFSET_FILE_IDENTIFIER] == (int) DirectoryRecord.ROOT_OR_SELF_DIRECTORY_FILE_IDENTIFIER)
|
||||
directoryRecord.Name = !isForRootDirectory ? DirectoryRecord.SELF_DIRECTORY_NAME : DirectoryRecord.ROOT_DIRECTORY_NAME;
|
||||
else if ((int) buffer[startIndex + (int) DirectoryRecordConverter.OFFSET_FILE_IDENTIFIER] == (int) DirectoryRecord.PARENT_DIRECTORY_FILE_IDENTIFIER)
|
||||
{
|
||||
directoryRecord.Name = DirectoryRecord.PARENT_DIRECTORY_NAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!directoryRecord.IsDirectory)
|
||||
num2 -= (byte) 2;
|
||||
string input = Encoding.Default.GetString(buffer, startIndex + (int) DirectoryRecordConverter.OFFSET_FILE_IDENTIFIER, (int) num2);
|
||||
directoryRecord.Name = DirectoryRecordConverter.VALID_FILENAME.Replace(input, "_invalid_");
|
||||
directoryRecord.HasValidFileIdentifier = directoryRecord.Name.Equals(input);
|
||||
}
|
||||
return directoryRecord;
|
||||
}
|
||||
|
||||
private sealed class DirectoryRecordDateTimeConverter
|
||||
{
|
||||
private static readonly byte DATETIME_SIZE = 7;
|
||||
private static readonly byte OFFSET_YEAR = 0;
|
||||
private static readonly byte OFFSET_MONTH = 1;
|
||||
private static readonly byte OFFSET_DAY = 2;
|
||||
private static readonly byte OFFSET_HOUR = 3;
|
||||
private static readonly byte OFFSET_MINUTE = 4;
|
||||
private static readonly byte OFFSET_SECOND = 5;
|
||||
private static readonly byte OFFSET_TIME_ZONE = 6;
|
||||
|
||||
internal static DateTime? ToDateTime(byte[] buffer, int startIndex)
|
||||
{
|
||||
if (startIndex < 0 || buffer.Length - startIndex < (int) DirectoryRecordConverter.DirectoryRecordDateTimeConverter.DATETIME_SIZE)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
byte num1 = buffer[startIndex + (int) DirectoryRecordConverter.DirectoryRecordDateTimeConverter.OFFSET_YEAR];
|
||||
byte num2 = buffer[startIndex + (int) DirectoryRecordConverter.DirectoryRecordDateTimeConverter.OFFSET_MONTH];
|
||||
byte num3 = buffer[startIndex + (int) DirectoryRecordConverter.DirectoryRecordDateTimeConverter.OFFSET_DAY];
|
||||
byte num4 = buffer[startIndex + (int) DirectoryRecordConverter.DirectoryRecordDateTimeConverter.OFFSET_HOUR];
|
||||
byte num5 = buffer[startIndex + (int) DirectoryRecordConverter.DirectoryRecordDateTimeConverter.OFFSET_MINUTE];
|
||||
byte num6 = buffer[startIndex + (int) DirectoryRecordConverter.DirectoryRecordDateTimeConverter.OFFSET_SECOND];
|
||||
try
|
||||
{
|
||||
return new DateTime?(new DateTime(1900 + (int) num1, (int) num2, (int) num3, (int) num4, (int) num5, (int) num6, DateTimeKind.Local));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex);
|
||||
return new DateTime?();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
24
ImageReader/ISO9660/DirectoryRecords/DirectoryRecordFlags.cs
Normal file
24
ImageReader/ISO9660/DirectoryRecords/DirectoryRecordFlags.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.ISO9660.DirectoryRecords.DirectoryRecordFlags
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace ImageReader.ISO9660.DirectoryRecords
|
||||
{
|
||||
[Flags]
|
||||
public enum DirectoryRecordFlags : byte
|
||||
{
|
||||
NONE = 0,
|
||||
HIDDEN_FILE = 1,
|
||||
DIRECTORY = 2,
|
||||
ASSOCIATED_FILE = 4,
|
||||
EXTENDED_ATTRIBUTE_RECORD = 8,
|
||||
OWNER_AND_GROUP_PERMISSIONS = EXTENDED_ATTRIBUTE_RECORD | ASSOCIATED_FILE | DIRECTORY | HIDDEN_FILE, // 0x0F
|
||||
RESERVED_FLAGS = 48, // 0x30
|
||||
NOT_FINAL_RECORD = 64, // 0x40
|
||||
ANY = 255, // 0xFF
|
||||
}
|
||||
}
|
40
ImageReader/ISO9660/PathTable/PathTableEntry.cs
Normal file
40
ImageReader/ISO9660/PathTable/PathTableEntry.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.ISO9660.PathTable.PathTableEntry
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
namespace ImageReader.ISO9660.PathTable
|
||||
{
|
||||
public class PathTableEntry
|
||||
{
|
||||
private byte extentAttributeRecordLength;
|
||||
private uint extent;
|
||||
private ushort parentDirectoryIndex;
|
||||
private string directoryIdentifier;
|
||||
|
||||
public byte ExtentAttributeRecordLength
|
||||
{
|
||||
get => this.extentAttributeRecordLength;
|
||||
internal set => this.extentAttributeRecordLength = value;
|
||||
}
|
||||
|
||||
public uint Extent
|
||||
{
|
||||
get => this.extent;
|
||||
internal set => this.extent = value;
|
||||
}
|
||||
|
||||
public ushort ParentDirectoryIndex
|
||||
{
|
||||
get => this.parentDirectoryIndex;
|
||||
internal set => this.parentDirectoryIndex = value;
|
||||
}
|
||||
|
||||
public string DirectoryIdentifier
|
||||
{
|
||||
get => this.directoryIdentifier;
|
||||
internal set => this.directoryIdentifier = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.ISO9660.VolumeDescriptors.PrimaryVolumeDescriptor
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using ImageReader.ISO9660.DirectoryRecords;
|
||||
using System;
|
||||
|
||||
namespace ImageReader.ISO9660.VolumeDescriptors
|
||||
{
|
||||
public class PrimaryVolumeDescriptor
|
||||
{
|
||||
internal uint volumeSpaceSizeTypeL;
|
||||
internal uint volumeSpaceSizeTypeM;
|
||||
internal ushort volumeSetSizeTypeL;
|
||||
internal ushort VolumeSetSizeTypeM;
|
||||
internal ushort volumeSequenceNumberTypeL;
|
||||
internal ushort volumeSequenceNumberTypeM;
|
||||
internal ushort logicalBlockSizeTypeL;
|
||||
internal ushort logicalBlockSizeTypeM;
|
||||
internal uint pathTableSizeTypeL;
|
||||
internal uint pathTableSizeTypeM;
|
||||
internal uint pathTableLocationTypeL;
|
||||
internal uint optionalPathTableLocationTypeL;
|
||||
internal uint pathTableLocationTypeM;
|
||||
internal uint optionalPathTableLocationTypeM;
|
||||
internal DirectoryRecord rootDirectoryRecord;
|
||||
|
||||
public VolumeDescriptorType Type { get; internal set; }
|
||||
|
||||
public string StandardIdentifier { get; internal set; }
|
||||
|
||||
public sbyte Version { get; internal set; }
|
||||
|
||||
public string SystemIdentifier { get; internal set; }
|
||||
|
||||
public string Identifier { get; internal set; }
|
||||
|
||||
public uint SpaceSize => !BitConverter.IsLittleEndian ? this.volumeSpaceSizeTypeM : this.volumeSpaceSizeTypeL;
|
||||
|
||||
public ushort SetSize => !BitConverter.IsLittleEndian ? this.VolumeSetSizeTypeM : this.volumeSetSizeTypeL;
|
||||
|
||||
public ushort SequenceNumber => !BitConverter.IsLittleEndian ? this.volumeSequenceNumberTypeM : this.volumeSequenceNumberTypeL;
|
||||
|
||||
public ushort LogicalBlockSize => !BitConverter.IsLittleEndian ? this.logicalBlockSizeTypeM : this.logicalBlockSizeTypeL;
|
||||
|
||||
public uint PathTableSize => !BitConverter.IsLittleEndian ? this.pathTableSizeTypeM : this.pathTableSizeTypeL;
|
||||
|
||||
public uint PathTableLocation => !BitConverter.IsLittleEndian ? this.pathTableLocationTypeM : this.pathTableLocationTypeL;
|
||||
|
||||
public bool HasOptionalPathTable => (BitConverter.IsLittleEndian ? (int) this.optionalPathTableLocationTypeL : (int) this.optionalPathTableLocationTypeM) != 0;
|
||||
|
||||
public uint OptionalPathTableLocation => !BitConverter.IsLittleEndian ? this.optionalPathTableLocationTypeM : this.optionalPathTableLocationTypeL;
|
||||
|
||||
public DirectoryRecord RootDirectoryRecord => this.rootDirectoryRecord;
|
||||
|
||||
public string SetIdentifier { get; internal set; }
|
||||
|
||||
public string PublisherIdentifier { get; internal set; }
|
||||
|
||||
public string PreparerIdentifier { get; internal set; }
|
||||
|
||||
public string ApplicationIdentifier { get; internal set; }
|
||||
|
||||
public string CopyrightFileIdentifier { get; internal set; }
|
||||
|
||||
public string AbstractFileIdentifier { get; internal set; }
|
||||
|
||||
public string BibliographicFileIdentifier { get; internal set; }
|
||||
|
||||
public DateTime? CreationDateTime { get; internal set; }
|
||||
|
||||
public DateTime? ModificationDateTime { get; internal set; }
|
||||
|
||||
public DateTime? ExpirationDateTime { get; internal set; }
|
||||
|
||||
public DateTime? EffectiveDateTime { get; internal set; }
|
||||
|
||||
public sbyte FileStructureVersion { get; internal set; }
|
||||
}
|
||||
}
|
23
ImageReader/ISO9660/VolumeDescriptors/VolumeDescriptor.cs
Normal file
23
ImageReader/ISO9660/VolumeDescriptors/VolumeDescriptor.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.ISO9660.VolumeDescriptors.VolumeDescriptor
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ImageReader.ISO9660.VolumeDescriptors
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct VolumeDescriptor
|
||||
{
|
||||
public const string VolumeDescriptorIdentifier = "CD001";
|
||||
public static readonly ushort VolumeDescriptorStartLba = 16;
|
||||
public static readonly ushort VolumeDescriptorSize = 2048;
|
||||
public static readonly byte VolumeDescriptorVersion = 1;
|
||||
public VolumeDescriptorType Type;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
|
||||
public byte[] StandardIdentifier;
|
||||
public byte Version;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.ISO9660.VolumeDescriptors.VolumeDescriptorConverter
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using ImageReader.ISO9660.DirectoryRecords;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace ImageReader.ISO9660.VolumeDescriptors
|
||||
{
|
||||
public class VolumeDescriptorConverter
|
||||
{
|
||||
private static readonly string STANDARD_IDENTIFIER = "CD001";
|
||||
private static readonly byte VOLUME_DESCRIPTOR_VERSION = 1;
|
||||
private static readonly byte FILE_STRUCTURE_VERSION = 1;
|
||||
private static readonly ushort OFFSET_VOLUME_DESCRIPTOR_TYPE = 0;
|
||||
private static readonly ushort OFFSET_STANDARD_IDENTIFIER = 1;
|
||||
private static readonly ushort OFFSET_VOLUME_DESCRIPTOR_VERSION = 6;
|
||||
private static readonly ushort OFFSET_SYSTEM_IDENTIFIER = 8;
|
||||
private static readonly ushort OFFSET_VOLUME_IDENTIFIER = 40;
|
||||
private static readonly ushort OFFSET_TYPE_L_VOLUME_SPACE_SIZE = 80;
|
||||
private static readonly ushort OFFSET_TYPE_M_VOLUME_SPACE_SIZE = 84;
|
||||
private static readonly ushort OFFSET_TYPE_L_VOLUME_SET_SIZE = 120;
|
||||
private static readonly ushort OFFSET_TYPE_M_VOLUME_SET_SIZE = 122;
|
||||
private static readonly ushort OFFSET_TYPE_L_VOLUME_SEQUENCE_NUMBER = 124;
|
||||
private static readonly ushort OFFSET_TYPE_M_VOLUME_SEQUENCE_NUMBER = 126;
|
||||
private static readonly ushort OFFSET_TYPE_L_LOGICAL_BLOCK_SIZE = 128;
|
||||
private static readonly ushort OFFSET_TYPE_M_LOGICAL_BLOCK_SIZE = 130;
|
||||
private static readonly ushort OFFSET_TYPE_L_PATH_TABLE_SIZE = 132;
|
||||
private static readonly ushort OFFSET_TYPE_M_PATH_TABLE_SIZE = 136;
|
||||
private static readonly ushort OFFSET_TYPE_L_PATH_TABLE = 140;
|
||||
private static readonly ushort OFFSET_TYPE_L_OPTIONAL_PATH_TABLE = 144;
|
||||
private static readonly ushort OFFSET_TYPE_M_PATH_TABLE = 148;
|
||||
private static readonly ushort OFFSET_TYPE_M_OPTIONAL_PATH_TABLE = 152;
|
||||
private static readonly ushort OFFSET_ROOT_DIRECTORY_RECORD = 156;
|
||||
private static readonly ushort OFFSET_VOLUME_SET_IDENTIFIER = 190;
|
||||
private static readonly ushort OFFSET_PUBLISHER_IDENTIFIER = 318;
|
||||
private static readonly ushort OFFSET_PREPARER_IDENTIFIER = 446;
|
||||
private static readonly ushort OFFSET_APPLICATION_IDENTIFIER = 574;
|
||||
private static readonly ushort OFFSET_COPYRIGHT_FILE_IDENTIFIER = 702;
|
||||
private static readonly ushort OFFSET_ABSTRACT_FILE_IDENTIFIER = 739;
|
||||
private static readonly ushort OFFSET_BIBLIOGRAPHIC_FILE_IDENTIFIER = 776;
|
||||
private static readonly ushort OFFSET_VOLUME_CREATION_DATE = 813;
|
||||
private static readonly ushort OFFSET_VOLUME_MODIFICATION_DATE = 830;
|
||||
private static readonly ushort OFFSET_VOLUME_EXPIRATION_DATE = 847;
|
||||
private static readonly ushort OFFSET_VOLUME_EFFECTIVE_DATE = 864;
|
||||
private static readonly ushort OFFSET_FILE_STRUCTURE_VERSION = 881;
|
||||
|
||||
public static PrimaryVolumeDescriptor ToPrimaryVolumeDescriptor(
|
||||
byte[] buffer,
|
||||
int startIndex)
|
||||
{
|
||||
if (startIndex < 0 || buffer.Length - startIndex < (int) VolumeDescriptor.VolumeDescriptorSize)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
PrimaryVolumeDescriptor volumeDescriptor = new PrimaryVolumeDescriptor()
|
||||
{
|
||||
Type = (VolumeDescriptorType) buffer[startIndex + (int) VolumeDescriptorConverter.OFFSET_VOLUME_DESCRIPTOR_TYPE],
|
||||
StandardIdentifier = Encoding.Default.GetString(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_STANDARD_IDENTIFIER, 5),
|
||||
Version = (sbyte) buffer[startIndex + (int) VolumeDescriptorConverter.OFFSET_VOLUME_DESCRIPTOR_VERSION],
|
||||
SystemIdentifier = Encoding.Default.GetString(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_SYSTEM_IDENTIFIER, 32).Trim(),
|
||||
Identifier = Encoding.Default.GetString(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_VOLUME_IDENTIFIER, 32).Trim(),
|
||||
volumeSpaceSizeTypeL = BitConverter.ToUInt32(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_L_VOLUME_SPACE_SIZE),
|
||||
volumeSpaceSizeTypeM = BitConverter.ToUInt32(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_M_VOLUME_SPACE_SIZE),
|
||||
volumeSetSizeTypeL = BitConverter.ToUInt16(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_L_VOLUME_SET_SIZE),
|
||||
VolumeSetSizeTypeM = BitConverter.ToUInt16(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_M_VOLUME_SET_SIZE),
|
||||
volumeSequenceNumberTypeL = BitConverter.ToUInt16(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_L_VOLUME_SEQUENCE_NUMBER),
|
||||
volumeSequenceNumberTypeM = BitConverter.ToUInt16(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_M_VOLUME_SEQUENCE_NUMBER),
|
||||
logicalBlockSizeTypeL = BitConverter.ToUInt16(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_L_LOGICAL_BLOCK_SIZE),
|
||||
logicalBlockSizeTypeM = BitConverter.ToUInt16(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_M_LOGICAL_BLOCK_SIZE),
|
||||
pathTableSizeTypeL = BitConverter.ToUInt32(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_L_PATH_TABLE_SIZE),
|
||||
pathTableSizeTypeM = BitConverter.ToUInt32(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_M_PATH_TABLE_SIZE),
|
||||
pathTableLocationTypeL = BitConverter.ToUInt32(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_L_PATH_TABLE),
|
||||
optionalPathTableLocationTypeL = BitConverter.ToUInt32(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_L_OPTIONAL_PATH_TABLE),
|
||||
pathTableLocationTypeM = BitConverter.ToUInt32(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_M_PATH_TABLE),
|
||||
optionalPathTableLocationTypeM = BitConverter.ToUInt32(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_TYPE_M_OPTIONAL_PATH_TABLE),
|
||||
SetIdentifier = Encoding.Default.GetString(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_VOLUME_SET_IDENTIFIER, 128).Trim(),
|
||||
PublisherIdentifier = Encoding.Default.GetString(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_PUBLISHER_IDENTIFIER, 128).Trim(),
|
||||
PreparerIdentifier = Encoding.Default.GetString(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_PREPARER_IDENTIFIER, 128).Trim(),
|
||||
ApplicationIdentifier = Encoding.Default.GetString(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_APPLICATION_IDENTIFIER, 128).Trim(),
|
||||
CopyrightFileIdentifier = Encoding.Default.GetString(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_COPYRIGHT_FILE_IDENTIFIER, 37).Trim(),
|
||||
AbstractFileIdentifier = Encoding.Default.GetString(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_ABSTRACT_FILE_IDENTIFIER, 37).Trim(),
|
||||
BibliographicFileIdentifier = Encoding.Default.GetString(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_BIBLIOGRAPHIC_FILE_IDENTIFIER, 37).Trim(),
|
||||
CreationDateTime = VolumeDescriptorConverter.VolumeDescriptorDateTimeConverter.ToDateTime(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_VOLUME_CREATION_DATE),
|
||||
ModificationDateTime = VolumeDescriptorConverter.VolumeDescriptorDateTimeConverter.ToDateTime(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_VOLUME_MODIFICATION_DATE),
|
||||
ExpirationDateTime = VolumeDescriptorConverter.VolumeDescriptorDateTimeConverter.ToDateTime(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_VOLUME_EXPIRATION_DATE),
|
||||
EffectiveDateTime = VolumeDescriptorConverter.VolumeDescriptorDateTimeConverter.ToDateTime(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_VOLUME_EFFECTIVE_DATE),
|
||||
FileStructureVersion = (sbyte) buffer[startIndex + (int) VolumeDescriptorConverter.OFFSET_FILE_STRUCTURE_VERSION]
|
||||
};
|
||||
volumeDescriptor.rootDirectoryRecord = DirectoryRecordConverter.ToRootDirectoryRecord(buffer, startIndex + (int) VolumeDescriptorConverter.OFFSET_ROOT_DIRECTORY_RECORD);
|
||||
if (!VolumeDescriptorConverter.STANDARD_IDENTIFIER.Equals(volumeDescriptor.StandardIdentifier) || volumeDescriptor.Type != VolumeDescriptorType.PRIMARY_VOLUME_DESCRIPTOR || (int) volumeDescriptor.Version != (int) VolumeDescriptorConverter.VOLUME_DESCRIPTOR_VERSION)
|
||||
throw new FormatException();
|
||||
return volumeDescriptor;
|
||||
}
|
||||
|
||||
private sealed class VolumeDescriptorDateTimeConverter
|
||||
{
|
||||
private static readonly Logger.ILog logger = Logger.CreateLog();
|
||||
|
||||
private const int DATETIME_SIZE = 17;
|
||||
private const int OFFSET_YEAR = 0;
|
||||
private const int OFFSET_MONTH = 4;
|
||||
private const int OFFSET_DAY = 6;
|
||||
private const int OFFSET_HOUR = 8;
|
||||
private const int OFFSET_MINUTE = 10;
|
||||
private const int OFFSET_SECOND = 12;
|
||||
private const int OFFSET_HUNDREDTHS_OF_SECOND = 14;
|
||||
private const int OFFSET_TIME_ZONE = 16;
|
||||
|
||||
internal static DateTime? ToDateTime(byte[] buffer, int startIndex)
|
||||
{
|
||||
if (startIndex < 0 || buffer.Length - startIndex < 17)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
string str = Encoding.Default.GetString(buffer, startIndex, 16);
|
||||
ushort result1;
|
||||
ushort.TryParse(str.Substring(0, 4), out result1);
|
||||
byte result2;
|
||||
byte.TryParse(str.Substring(4, 2), out result2);
|
||||
byte result3;
|
||||
byte.TryParse(str.Substring(6, 2), out result3);
|
||||
byte result4;
|
||||
byte.TryParse(str.Substring(8, 2), out result4);
|
||||
byte result5;
|
||||
byte.TryParse(str.Substring(10, 2), out result5);
|
||||
byte result6;
|
||||
byte.TryParse(str.Substring(12, 2), out result6);
|
||||
byte result7;
|
||||
byte.TryParse(str.Substring(14, 2), out result7);
|
||||
try
|
||||
{
|
||||
return new DateTime?(new DateTime((int) result1, (int) result2, (int) result3, (int) result4, (int) result5, (int) result6, (int) result7 * 100, DateTimeKind.Local));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warn(ex);
|
||||
return new DateTime?();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.ISO9660.VolumeDescriptors.VolumeDescriptorType
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
namespace ImageReader.ISO9660.VolumeDescriptors
|
||||
{
|
||||
public enum VolumeDescriptorType : byte
|
||||
{
|
||||
BOOT_RECORD = 0,
|
||||
PRIMARY_VOLUME_DESCRIPTOR = 1,
|
||||
SUPPLEMENTARY_VOLUME_DESCRIPTOR = 2,
|
||||
VOLUME_PARTITION_DESCRIPTOR = 3,
|
||||
VOLUME_DESCRIPTION_SET_TERMINATOR = 255, // 0xFF
|
||||
}
|
||||
}
|
85
ImageReader/ImageReader.csproj
Normal file
85
ImageReader/ImageReader.csproj
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<!--Project was exported from assembly: C:\Games\gdrom\ImageReader.dll-->
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{2185F55E-A4DA-486F-ACC8-3EE955205CE4}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AssemblyName>ImageReader</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<ApplicationVersion>1.5.2.0</ApplicationVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<RootNamespace>ImageReader</RootNamespace>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\GD-ROM Explorer\packages\log4net.2.0.12\lib\net35\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Web" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyGitBuildSHA1.cs" />
|
||||
<Compile Include="AssemblyGitBuildBranch.cs" />
|
||||
<Compile Include="AssemblyTest.cs" />
|
||||
<Compile Include="Logger.cs" />
|
||||
<Compile Include="DiscSectors\CDROMDataModeType.cs" />
|
||||
<Compile Include="DiscSectors\CDROMFrameHeaderConverter.cs" />
|
||||
<Compile Include="DiscSectors\IDiscSector.cs" />
|
||||
<Compile Include="DiscSectors\DiscSectorBase.cs" />
|
||||
<Compile Include="DiscSectors\CDROMXAMode2Form1RawSector.cs" />
|
||||
<Compile Include="DiscSectors\CDROMMode1RawSector.cs" />
|
||||
<Compile Include="DiscSectors\CDROMXAMode2Form1Sector.cs" />
|
||||
<Compile Include="DiscSectors\RawSector.cs" />
|
||||
<Compile Include="DiscSectors\ISO9660Sector.cs" />
|
||||
<Compile Include="DiscSectors\DiscSectorCommon.cs" />
|
||||
<Compile Include="ISO9660\DirectoryRecords\DirectoryRecordConverter.cs" />
|
||||
<Compile Include="ISO9660\DirectoryRecords\DirectoryRecord.cs" />
|
||||
<Compile Include="ISO9660\DirectoryRecords\DirectoryRecordFlags.cs" />
|
||||
<Compile Include="ISO9660\PathTable\PathTableEntry.cs" />
|
||||
<Compile Include="ISO9660\VolumeDescriptors\PrimaryVolumeDescriptor.cs" />
|
||||
<Compile Include="ISO9660\VolumeDescriptors\VolumeDescriptorType.cs" />
|
||||
<Compile Include="ISO9660\VolumeDescriptors\VolumeDescriptor.cs" />
|
||||
<Compile Include="ISO9660\VolumeDescriptors\VolumeDescriptorConverter.cs" />
|
||||
<Compile Include="ImageReader\DiscImageReaderStatus.cs" />
|
||||
<Compile Include="ImageReader\DiscImageReaderException.cs" />
|
||||
<Compile Include="ImageReader\DiscImageReader.cs" />
|
||||
<Compile Include="Stream\DiscSectorStream.cs" />
|
||||
<Compile Include="Properties\Resources.cs" />
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
342
ImageReader/ImageReader/DiscImageReader.cs
Normal file
342
ImageReader/ImageReader/DiscImageReader.cs
Normal file
|
@ -0,0 +1,342 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.ImageReader.DiscImageReader
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using ImageReader.DiscSectors;
|
||||
using ImageReader.ISO9660.DirectoryRecords;
|
||||
using ImageReader.ISO9660.VolumeDescriptors;
|
||||
using ImageReader.Stream;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace ImageReader.ImageReader
|
||||
{
|
||||
public class DiscImageReader : IDisposable
|
||||
{
|
||||
private static readonly Logger.ILog logger = Logger.CreateLog();
|
||||
private bool disposed;
|
||||
private IDiscSector discSector;
|
||||
private System.IO.Stream image;
|
||||
private uint numberOfFiles;
|
||||
private Dictionary<string, DirectoryRecord> pathTable;
|
||||
private uint preGap;
|
||||
private PrimaryVolumeDescriptor primaryVolumeDescriptor;
|
||||
private DiscImageReaderStatus status;
|
||||
private uint totalFileSize;
|
||||
|
||||
public uint NumberOfFiles
|
||||
{
|
||||
get
|
||||
{
|
||||
this.ValidateStatus(DiscImageReaderStatus.OPENED);
|
||||
return this.numberOfFiles;
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> Paths
|
||||
{
|
||||
get
|
||||
{
|
||||
this.ValidateStatus(DiscImageReaderStatus.OPENED);
|
||||
return new List<string>((IEnumerable<string>) this.pathTable.Keys);
|
||||
}
|
||||
}
|
||||
|
||||
public uint TotalFileSize
|
||||
{
|
||||
get
|
||||
{
|
||||
this.ValidateStatus(DiscImageReaderStatus.OPENED);
|
||||
return this.totalFileSize;
|
||||
}
|
||||
}
|
||||
|
||||
public DiscImageReaderStatus Status => this.status;
|
||||
|
||||
public PrimaryVolumeDescriptor PrimaryVolumeDescriptor
|
||||
{
|
||||
get
|
||||
{
|
||||
this.ValidateStatus(DiscImageReaderStatus.OPENED);
|
||||
return this.primaryVolumeDescriptor;
|
||||
}
|
||||
}
|
||||
|
||||
public DirectoryRecord RootDirectoryRecord
|
||||
{
|
||||
get
|
||||
{
|
||||
this.ValidateStatus(DiscImageReaderStatus.OPENED);
|
||||
return this.primaryVolumeDescriptor.RootDirectoryRecord;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ParsePathTable { get; set; }
|
||||
|
||||
public DiscImageReader()
|
||||
{
|
||||
this.disposed = false;
|
||||
this.ParsePathTable = false;
|
||||
this.status = DiscImageReaderStatus.CLOSED;
|
||||
}
|
||||
|
||||
public void Open(System.IO.Stream imageStream, uint imagePreGap, IDiscSector discSector)
|
||||
{
|
||||
this.ValidateStatus(DiscImageReaderStatus.CLOSED);
|
||||
this.discSector = discSector;
|
||||
this.image = this.ValidateImage(imageStream);
|
||||
this.preGap = this.ValidatePreGap(imagePreGap);
|
||||
this.ReadImageContent();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (this.image != null)
|
||||
{
|
||||
this.image.Dispose();
|
||||
this.image = (System.IO.Stream) null;
|
||||
}
|
||||
this.discSector = (IDiscSector) null;
|
||||
this.pathTable = (Dictionary<string, DirectoryRecord>) null;
|
||||
this.primaryVolumeDescriptor = (PrimaryVolumeDescriptor) null;
|
||||
this.numberOfFiles = 0U;
|
||||
this.totalFileSize = 0U;
|
||||
this.status = DiscImageReaderStatus.CLOSED;
|
||||
}
|
||||
|
||||
public bool PathExist(string Path)
|
||||
{
|
||||
this.ValidateStatus(DiscImageReaderStatus.OPENED);
|
||||
return this.GetDirectoryRecord(Path) != null;
|
||||
}
|
||||
|
||||
public DirectoryRecord GetDirectoryRecord(string path)
|
||||
{
|
||||
this.ValidateStatus(DiscImageReaderStatus.OPENED);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return (DirectoryRecord) null;
|
||||
if (!Path.IsPathRooted(path))
|
||||
throw new NotSupportedException("relative path are not supported");
|
||||
if (DirectoryRecord.ROOT_DIRECTORY_NAME.Equals(path))
|
||||
return this.primaryVolumeDescriptor.RootDirectoryRecord;
|
||||
if (this.pathTable.ContainsKey(path))
|
||||
return this.pathTable[path];
|
||||
string directoryName = Path.GetDirectoryName(path);
|
||||
if (!this.pathTable.ContainsKey(directoryName))
|
||||
return (DirectoryRecord) null;
|
||||
string FileName = Path.GetFileName(path);
|
||||
return this.pathTable[directoryName].children.Find((Predicate<DirectoryRecord>) (directoryRecord => directoryRecord.Name.Equals(FileName)));
|
||||
}
|
||||
|
||||
private System.IO.Stream ValidateImage(System.IO.Stream imageStream)
|
||||
{
|
||||
if (imageStream == null || !imageStream.CanRead || !imageStream.CanSeek)
|
||||
throw new DiscImageReaderException(string.Format("invalid image stream: {0}", (object) imageStream));
|
||||
if (imageStream.Length < (long) ((int) VolumeDescriptor.VolumeDescriptorStartLba * this.discSector.Size + (int) VolumeDescriptor.VolumeDescriptorSize))
|
||||
throw new DiscImageReaderException(string.Format("image stream too small: {0}", (object) imageStream));
|
||||
return imageStream;
|
||||
}
|
||||
|
||||
private uint ValidatePreGap(uint preGap) => preGap >= 0U ? preGap : throw new ArgumentOutOfRangeException(nameof (preGap), "must be positive");
|
||||
|
||||
private void ValidateStatus(DiscImageReaderStatus expectedStatus)
|
||||
{
|
||||
if (this.status != expectedStatus)
|
||||
throw new ObjectDisposedException(this.GetType().FullName);
|
||||
}
|
||||
|
||||
private void ReadImageContent()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.primaryVolumeDescriptor = this.ReadPrimaryVolumeDescriptor();
|
||||
this.numberOfFiles = 0U;
|
||||
this.totalFileSize = 0U;
|
||||
Dictionary<string, List<DirectoryRecord>> directories = this.ReadDirectories(this.primaryVolumeDescriptor, this.pathTable);
|
||||
DiscImageReader.logger.DebugFormat("{0} {1} found in the file table", (object) this.numberOfFiles, this.numberOfFiles > 1U ? (object) "files" : (object) "file");
|
||||
this.pathTable = !this.ParsePathTable ? this.ComputePathTable(directories) : this.ReadPathTable(this.primaryVolumeDescriptor);
|
||||
DiscImageReader.logger.DebugFormat("{0} {1} found in the path table", (object) this.pathTable.Count, this.pathTable.Count > 1 ? (object) "paths" : (object) "path");
|
||||
this.status = DiscImageReaderStatus.OPENED;
|
||||
DiscImageReader.logger.Debug((object) "Image content successfully read");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DiscImageReader.logger.DebugFormat("Unable to read the image content: {0}", (object) ex);
|
||||
this.Close();
|
||||
throw new DiscImageReaderException("the image content is not valid", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private PrimaryVolumeDescriptor ReadPrimaryVolumeDescriptor()
|
||||
{
|
||||
byte[] buffer = new byte[(int) VolumeDescriptor.VolumeDescriptorSize];
|
||||
using (DiscSectorStream discSectorStream = new DiscSectorStream(this.image, this.discSector, (uint) VolumeDescriptor.VolumeDescriptorStartLba, (uint) VolumeDescriptor.VolumeDescriptorSize, false))
|
||||
{
|
||||
discSectorStream.Read(buffer, 0, buffer.Length);
|
||||
GCHandle gcHandle = GCHandle.Alloc((object) buffer, GCHandleType.Pinned);
|
||||
VolumeDescriptor structure = (VolumeDescriptor) Marshal.PtrToStructure(gcHandle.AddrOfPinnedObject(), typeof (VolumeDescriptor));
|
||||
gcHandle.Free();
|
||||
string str;
|
||||
try
|
||||
{
|
||||
str = Encoding.ASCII.GetString(structure.StandardIdentifier);
|
||||
}
|
||||
catch (DecoderFallbackException ex)
|
||||
{
|
||||
logger.Error("wrong standard identifer");
|
||||
logger.Error(ex);
|
||||
throw new DiscImageReaderException("wrong standard identifer");
|
||||
}
|
||||
if ("CD001".Equals(str) && (int) VolumeDescriptor.VolumeDescriptorVersion == (int) structure.Version)
|
||||
{
|
||||
if (structure.Type == VolumeDescriptorType.PRIMARY_VOLUME_DESCRIPTOR)
|
||||
goto label_10;
|
||||
}
|
||||
throw new DiscImageReaderException("primary volume descriptor not found");
|
||||
}
|
||||
label_10:
|
||||
PrimaryVolumeDescriptor volumeDescriptor = VolumeDescriptorConverter.ToPrimaryVolumeDescriptor(buffer, 0);
|
||||
if (volumeDescriptor.RootDirectoryRecord.Extent < this.preGap)
|
||||
throw new DiscImageReaderException("the root directory record extent must be positive");
|
||||
return volumeDescriptor;
|
||||
}
|
||||
|
||||
private Dictionary<string, DirectoryRecord> ReadPathTable(
|
||||
PrimaryVolumeDescriptor PrimVolDesc)
|
||||
{
|
||||
int index = 0;
|
||||
string empty = string.Empty;
|
||||
Dictionary<string, DirectoryRecord> dictionary = new Dictionary<string, DirectoryRecord>();
|
||||
List<string> stringList = new List<string>();
|
||||
int pathTableLocation = (int) PrimVolDesc.PathTableLocation;
|
||||
int logicalBlockSize = (int) PrimVolDesc.LogicalBlockSize;
|
||||
byte[] numArray = new byte[(int) PrimVolDesc.PathTableSize];
|
||||
new DiscSectorStream(this.image, this.discSector, PrimVolDesc.PathTableLocation - this.preGap, PrimVolDesc.PathTableSize, false).Read(numArray, 0, numArray.Length);
|
||||
while ((long) index < (long) PrimVolDesc.PathTableSize)
|
||||
{
|
||||
int count = (int) numArray[index];
|
||||
ushort num = 0;
|
||||
if (count > 0)
|
||||
{
|
||||
uint uint32 = BitConverter.ToUInt32(numArray, index + 2);
|
||||
num = BitConverter.ToUInt16(numArray, index + 6);
|
||||
string rootDirectoryName = Encoding.Default.GetString(numArray, index + 8, count);
|
||||
if (!string.IsNullOrEmpty(rootDirectoryName))
|
||||
{
|
||||
if ((int) DirectoryRecord.ROOT_OR_SELF_DIRECTORY_FILE_IDENTIFIER == (int) (byte) rootDirectoryName[0])
|
||||
rootDirectoryName = DirectoryRecord.ROOT_DIRECTORY_NAME;
|
||||
string key = Path.Combine(num <= (ushort) 1 ? DirectoryRecord.ROOT_DIRECTORY_NAME : stringList[(int) num - 1], rootDirectoryName);
|
||||
dictionary.Add(key, (DirectoryRecord) null);
|
||||
stringList.Add(key);
|
||||
DiscImageReader.logger.DebugFormat("Path {0} located at LBA {1}", (object) key, (object) uint32);
|
||||
}
|
||||
}
|
||||
index += count + 8;
|
||||
if (count % 2 > 0)
|
||||
++index;
|
||||
if (count == 0)
|
||||
++index;
|
||||
if (num == (ushort) 0)
|
||||
++index;
|
||||
}
|
||||
if (dictionary.Count == 0)
|
||||
dictionary.Add(DirectoryRecord.ROOT_DIRECTORY_NAME, (DirectoryRecord) null);
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
private Dictionary<string, List<DirectoryRecord>> ReadDirectories(
|
||||
PrimaryVolumeDescriptor pvd,
|
||||
Dictionary<string, DirectoryRecord> pathTable)
|
||||
{
|
||||
Dictionary<string, List<DirectoryRecord>> directories = new Dictionary<string, List<DirectoryRecord>>();
|
||||
this.ReadDirectoriesRec(this.primaryVolumeDescriptor, this.primaryVolumeDescriptor.RootDirectoryRecord.Name, pvd.RootDirectoryRecord, directories);
|
||||
return directories;
|
||||
}
|
||||
|
||||
private void ReadDirectoriesRec(
|
||||
PrimaryVolumeDescriptor Pvd,
|
||||
string parentPath,
|
||||
DirectoryRecord directoryRecord,
|
||||
Dictionary<string, List<DirectoryRecord>> directories)
|
||||
{
|
||||
byte[] buffer = new byte[(int) directoryRecord.ExtentSize];
|
||||
List<DirectoryRecord> directoryRecordList = new List<DirectoryRecord>();
|
||||
new DiscSectorStream(this.image, this.discSector, directoryRecord.Extent - this.preGap, directoryRecord.ExtentSize, false).Read(buffer, 0, (int) directoryRecord.ExtentSize);
|
||||
int startIndex = 0;
|
||||
while ((long) startIndex < (long) directoryRecord.ExtentSize)
|
||||
{
|
||||
ushort num = (ushort) buffer[startIndex];
|
||||
if (num > (ushort) 0)
|
||||
{
|
||||
DirectoryRecord directoryRecord1 = DirectoryRecordConverter.ToDirectoryRecord(buffer, startIndex);
|
||||
if (!DirectoryRecord.SELF_DIRECTORY_NAME.Equals(directoryRecord1.Name) && !DirectoryRecord.PARENT_DIRECTORY_NAME.Equals(directoryRecord1.Name))
|
||||
{
|
||||
if (directoryRecord1.IsDirectory)
|
||||
{
|
||||
string key = Path.Combine(parentPath, directoryRecord1.Name);
|
||||
directoryRecordList.Add(directoryRecord1);
|
||||
if (!directories.ContainsKey(key))
|
||||
directories.Add(key, new List<DirectoryRecord>());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.totalFileSize += directoryRecord1.ExtentSize;
|
||||
++this.numberOfFiles;
|
||||
}
|
||||
if (!directories.ContainsKey(parentPath))
|
||||
directories.Add(parentPath, new List<DirectoryRecord>());
|
||||
directories[parentPath].Add(directoryRecord1);
|
||||
directoryRecord1.parent = directoryRecord;
|
||||
directoryRecord.children.Add(directoryRecord1);
|
||||
}
|
||||
startIndex += (int) num;
|
||||
}
|
||||
else
|
||||
++startIndex;
|
||||
}
|
||||
foreach (DirectoryRecord directoryRecord1 in directoryRecordList)
|
||||
{
|
||||
string parentPath1 = Path.Combine(parentPath, directoryRecord1.Name);
|
||||
this.ReadDirectoriesRec(Pvd, parentPath1, directoryRecord1, directories);
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, DirectoryRecord> ComputePathTable(
|
||||
Dictionary<string, List<DirectoryRecord>> directories)
|
||||
{
|
||||
Dictionary<string, DirectoryRecord> dictionary = new Dictionary<string, DirectoryRecord>();
|
||||
foreach (KeyValuePair<string, List<DirectoryRecord>> directory in directories)
|
||||
{
|
||||
foreach (DirectoryRecord directoryRecord in directory.Value.FindAll((Predicate<DirectoryRecord>) (dr => dr.IsDirectory)))
|
||||
{
|
||||
if (!dictionary.Keys.Contains<string>(directoryRecord.ParentDirectory.FullPath))
|
||||
dictionary.Add(directoryRecord.ParentDirectory.FullPath, directoryRecord.ParentDirectory);
|
||||
if (!dictionary.Keys.Contains<string>(directoryRecord.FullPath))
|
||||
dictionary.Add(directoryRecord.FullPath, directoryRecord);
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize((object) this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (this.disposed)
|
||||
return;
|
||||
if (disposing)
|
||||
this.Close();
|
||||
this.disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
23
ImageReader/ImageReader/DiscImageReaderException.cs
Normal file
23
ImageReader/ImageReader/DiscImageReaderException.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.ImageReader.DiscImageReaderException
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace ImageReader.ImageReader
|
||||
{
|
||||
public class DiscImageReaderException : Exception
|
||||
{
|
||||
public DiscImageReaderException(string message)
|
||||
: base(string.Format("ISOReader Error: {0}", (object) message))
|
||||
{
|
||||
}
|
||||
|
||||
public DiscImageReaderException(string message, Exception innerException)
|
||||
: base(string.Format("ISOReader Error: {0}", (object) message), innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
14
ImageReader/ImageReader/DiscImageReaderStatus.cs
Normal file
14
ImageReader/ImageReader/DiscImageReaderStatus.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.ImageReader.DiscImageReaderStatus
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
namespace ImageReader.ImageReader
|
||||
{
|
||||
public enum DiscImageReaderStatus
|
||||
{
|
||||
CLOSED,
|
||||
OPENED,
|
||||
}
|
||||
}
|
475
ImageReader/Logger.cs
Normal file
475
ImageReader/Logger.cs
Normal file
|
@ -0,0 +1,475 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.Logger
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using log4net;
|
||||
using log4net.Core;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ImageReader
|
||||
{
|
||||
internal static class Logger
|
||||
{
|
||||
private static readonly bool loggingIsOff = true;
|
||||
|
||||
static Logger()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Assembly.Load("log4net").GetType("log4net.Config.XmlConfigurator").GetMethod("Configure", new Type[0]).Invoke((object) null, (object[]) null);
|
||||
Assembly.Load("log4net");
|
||||
//log4net.Config.XmlConfigurator.Configure();
|
||||
Logger.loggingIsOff = false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static Logger.ILog CreateLog()
|
||||
{
|
||||
Type declaringType = new StackFrame(1, false).GetMethod().DeclaringType;
|
||||
return !Logger.loggingIsOff ? (Logger.ILog) new Logger.Log4NetLogger(declaringType) : (Logger.ILog) new Logger.NoLog();
|
||||
}
|
||||
|
||||
internal interface ILog
|
||||
{
|
||||
bool IsDebugEnabled { get; }
|
||||
|
||||
bool IsInfoEnabled { get; }
|
||||
|
||||
bool IsWarnEnabled { get; }
|
||||
|
||||
bool IsErrorEnabled { get; }
|
||||
|
||||
bool IsFatalEnabled { get; }
|
||||
|
||||
void Debug(object message);
|
||||
|
||||
void Debug(object message, Exception exception);
|
||||
|
||||
void DebugFormat(string format, params object[] args);
|
||||
|
||||
void DebugFormat(string format, object arg0);
|
||||
|
||||
void DebugFormat(string format, object arg0, object arg1);
|
||||
|
||||
void DebugFormat(string format, object arg0, object arg1, object arg2);
|
||||
|
||||
void DebugFormat(IFormatProvider provider, string format, params object[] args);
|
||||
|
||||
void Info(object message);
|
||||
|
||||
void Info(object message, Exception exception);
|
||||
|
||||
void InfoFormat(string format, params object[] args);
|
||||
|
||||
void InfoFormat(string format, object arg0);
|
||||
|
||||
void InfoFormat(string format, object arg0, object arg1);
|
||||
|
||||
void InfoFormat(string format, object arg0, object arg1, object arg2);
|
||||
|
||||
void InfoFormat(IFormatProvider provider, string format, params object[] args);
|
||||
|
||||
void Warn(object message);
|
||||
|
||||
void Warn(object message, Exception exception);
|
||||
|
||||
void WarnFormat(string format, params object[] args);
|
||||
|
||||
void WarnFormat(string format, object arg0);
|
||||
|
||||
void WarnFormat(string format, object arg0, object arg1);
|
||||
|
||||
void WarnFormat(string format, object arg0, object arg1, object arg2);
|
||||
|
||||
void WarnFormat(IFormatProvider provider, string format, params object[] args);
|
||||
|
||||
void Error(object message);
|
||||
|
||||
void Error(object message, Exception exception);
|
||||
|
||||
void ErrorFormat(string format, params object[] args);
|
||||
|
||||
void ErrorFormat(string format, object arg0);
|
||||
|
||||
void ErrorFormat(string format, object arg0, object arg1);
|
||||
|
||||
void ErrorFormat(string format, object arg0, object arg1, object arg2);
|
||||
|
||||
void ErrorFormat(IFormatProvider provider, string format, params object[] args);
|
||||
|
||||
void Fatal(object message);
|
||||
|
||||
void Fatal(object message, Exception exception);
|
||||
|
||||
void FatalFormat(string format, params object[] args);
|
||||
|
||||
void FatalFormat(string format, object arg0);
|
||||
|
||||
void FatalFormat(string format, object arg0, object arg1);
|
||||
|
||||
void FatalFormat(string format, object arg0, object arg1, object arg2);
|
||||
|
||||
void FatalFormat(IFormatProvider provider, string format, params object[] args);
|
||||
}
|
||||
|
||||
private class NoLog : Logger.ILog
|
||||
{
|
||||
public bool IsDebugEnabled => false;
|
||||
|
||||
public bool IsInfoEnabled => false;
|
||||
|
||||
public bool IsWarnEnabled => false;
|
||||
|
||||
public bool IsErrorEnabled => false;
|
||||
|
||||
public bool IsFatalEnabled => false;
|
||||
|
||||
public void Debug(object message)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug(object message, Exception exception)
|
||||
{
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, object arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
}
|
||||
|
||||
public void DebugFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void Info(object message)
|
||||
{
|
||||
}
|
||||
|
||||
public void Info(object message, Exception exception)
|
||||
{
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, object arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
}
|
||||
|
||||
public void InfoFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warn(object message)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warn(object message, Exception exception)
|
||||
{
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, object arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
}
|
||||
|
||||
public void WarnFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error(object message)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error(object message, Exception exception)
|
||||
{
|
||||
}
|
||||
|
||||
public void ErrorFormat(string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void ErrorFormat(string format, object arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void ErrorFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
}
|
||||
|
||||
public void ErrorFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
}
|
||||
|
||||
public void ErrorFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal(object message)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal(object message, Exception exception)
|
||||
{
|
||||
}
|
||||
|
||||
public void FatalFormat(string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public void FatalFormat(string format, object arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void FatalFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
}
|
||||
|
||||
public void FatalFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
}
|
||||
|
||||
public void FatalFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class Log4NetLogger : Logger.ILog
|
||||
{
|
||||
private readonly log4net.ILog rootLogger;
|
||||
private readonly Type loggingType;
|
||||
private readonly ILogger logger;
|
||||
|
||||
public Log4NetLogger(Type type)
|
||||
{
|
||||
this.loggingType = type;
|
||||
this.rootLogger = LogManager.GetLogger(this.loggingType);
|
||||
this.logger = ((ILoggerWrapper) this.rootLogger).Logger;
|
||||
}
|
||||
|
||||
public bool IsDebugEnabled => this.rootLogger.IsDebugEnabled;
|
||||
|
||||
public bool IsInfoEnabled => this.rootLogger.IsInfoEnabled;
|
||||
|
||||
public bool IsWarnEnabled => this.rootLogger.IsWarnEnabled;
|
||||
|
||||
public bool IsErrorEnabled => this.rootLogger.IsErrorEnabled;
|
||||
|
||||
public bool IsFatalEnabled => this.rootLogger.IsFatalEnabled;
|
||||
|
||||
public void Debug(object message)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, message, (Exception) null);
|
||||
}
|
||||
|
||||
public void Debug(object message, Exception exception)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, message, exception);
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, params object[] args)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, args), (Exception) null);
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, object arg0)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0), (Exception) null);
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1), (Exception) null);
|
||||
}
|
||||
|
||||
public void DebugFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1, arg2), (Exception) null);
|
||||
}
|
||||
|
||||
public void DebugFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
if (!this.IsDebugEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Debug, (object) string.Format(provider, format, args), (Exception) null);
|
||||
}
|
||||
|
||||
public void Info(object message)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, message, (Exception) null);
|
||||
}
|
||||
|
||||
public void Info(object message, Exception exception)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, message, exception);
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, params object[] args)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, args), (Exception) null);
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, object arg0)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0), (Exception) null);
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1), (Exception) null);
|
||||
}
|
||||
|
||||
public void InfoFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1, arg2), (Exception) null);
|
||||
}
|
||||
|
||||
public void InfoFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
if (!this.IsInfoEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Info, (object) string.Format(provider, format, args), (Exception) null);
|
||||
}
|
||||
|
||||
public void Warn(object message)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, message, (Exception) null);
|
||||
}
|
||||
|
||||
public void Warn(object message, Exception exception)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, message, exception);
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, params object[] args)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, args), (Exception) null);
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, object arg0)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0), (Exception) null);
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, object arg0, object arg1)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1), (Exception) null);
|
||||
}
|
||||
|
||||
public void WarnFormat(string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1, arg2), (Exception) null);
|
||||
}
|
||||
|
||||
public void WarnFormat(IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
if (!this.IsWarnEnabled)
|
||||
return;
|
||||
this.logger.Log(this.loggingType, (Level) Level.Warn, (object) string.Format(provider, format, args), (Exception) null);
|
||||
}
|
||||
|
||||
public void Error(object message) => this.logger.Log(this.loggingType, (Level) Level.Error, message, (Exception) null);
|
||||
|
||||
public void Error(object message, Exception exception) => this.logger.Log(this.loggingType, (Level) Level.Error, message, exception);
|
||||
|
||||
public void ErrorFormat(string format, params object[] args) => this.logger.Log(this.loggingType, (Level) Level.Error, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, args), (Exception) null);
|
||||
|
||||
public void ErrorFormat(string format, object arg0) => this.logger.Log(this.loggingType, (Level) Level.Error, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0), (Exception) null);
|
||||
|
||||
public void ErrorFormat(string format, object arg0, object arg1) => this.logger.Log(this.loggingType, (Level) Level.Error, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1), (Exception) null);
|
||||
|
||||
public void ErrorFormat(string format, object arg0, object arg1, object arg2) => this.logger.Log(this.loggingType, (Level) Level.Error, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1, arg2), (Exception) null);
|
||||
|
||||
public void ErrorFormat(IFormatProvider provider, string format, params object[] args) => this.logger.Log(this.loggingType, (Level) Level.Error, (object) string.Format(provider, format, args), (Exception) null);
|
||||
|
||||
public void Fatal(object message) => this.logger.Log(this.loggingType, (Level) Level.Fatal, message, (Exception) null);
|
||||
|
||||
public void Fatal(object message, Exception exception) => this.logger.Log(this.loggingType, (Level) Level.Fatal, message, exception);
|
||||
|
||||
public void FatalFormat(string format, params object[] args) => this.logger.Log(this.loggingType, (Level) Level.Fatal, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, args), (Exception) null);
|
||||
|
||||
public void FatalFormat(string format, object arg0) => this.logger.Log(this.loggingType, (Level) Level.Fatal, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0), (Exception) null);
|
||||
|
||||
public void FatalFormat(string format, object arg0, object arg1) => this.logger.Log(this.loggingType, (Level) Level.Fatal, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1), (Exception) null);
|
||||
|
||||
public void FatalFormat(string format, object arg0, object arg1, object arg2) => this.logger.Log(this.loggingType, (Level) Level.Fatal, (object) string.Format((IFormatProvider) CultureInfo.InvariantCulture, format, arg0, arg1, arg2), (Exception) null);
|
||||
|
||||
public void FatalFormat(IFormatProvider provider, string format, params object[] args) => this.logger.Log(this.loggingType, (Level) Level.Fatal, (object) string.Format(provider, format, args), (Exception) null);
|
||||
}
|
||||
}
|
||||
}
|
46
ImageReader/Properties/Resources.cs
Normal file
46
ImageReader/Properties/Resources.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.Properties.Resources
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using System.CodeDom.Compiler;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ImageReader.Properties
|
||||
{
|
||||
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[DebuggerNonUserCode]
|
||||
[CompilerGenerated]
|
||||
internal class Resources
|
||||
{
|
||||
private static ResourceManager resourceMan;
|
||||
private static CultureInfo resourceCulture;
|
||||
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
internal static ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (object.ReferenceEquals((object) Properties.Resources.resourceMan, (object) null))
|
||||
Properties.Resources.resourceMan = new ResourceManager("Properties.Resources", typeof (Properties.Resources).Assembly);
|
||||
return Properties.Resources.resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
internal static CultureInfo Culture
|
||||
{
|
||||
get => Properties.Resources.resourceCulture;
|
||||
set => Properties.Resources.resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
120
ImageReader/Properties/Resources.resx
Normal file
120
ImageReader/Properties/Resources.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
211
ImageReader/Stream/DiscSectorStream.cs
Normal file
211
ImageReader/Stream/DiscSectorStream.cs
Normal file
|
@ -0,0 +1,211 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: ImageReader.Stream.DiscSectorStream
|
||||
// Assembly: ImageReader, Version=1.5.2.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: E0717604-B50B-4CB4-B85C-C17F43D5C04B
|
||||
// Assembly location: ImageReader.dll
|
||||
|
||||
using ImageReader.DiscSectors;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ImageReader.Stream
|
||||
{
|
||||
public class DiscSectorStream : System.IO.Stream
|
||||
{
|
||||
private System.IO.Stream sourceStream;
|
||||
private IDiscSector sector;
|
||||
private long absStartAddress;
|
||||
private long absEndAddress;
|
||||
private bool disposed;
|
||||
private bool disposeSourceStream;
|
||||
|
||||
public DiscSectorStream(
|
||||
System.IO.Stream source,
|
||||
IDiscSector sector,
|
||||
uint extent,
|
||||
uint size,
|
||||
bool autoReleaseSource)
|
||||
{
|
||||
this.disposed = false;
|
||||
if (size > (uint) int.MaxValue)
|
||||
throw new ArgumentException(string.Format("invalid size: files larger than {0} in size are not supported", (object) int.MaxValue), nameof (size));
|
||||
if (size > uint.MaxValue)
|
||||
throw new ArgumentException(string.Format("invalid size: a file on an ISO 9660 formatted disc cannot be larger than {0} in size", (object) uint.MaxValue), nameof (size));
|
||||
if (!source.CanSeek)
|
||||
throw new ArgumentException(string.Format("invalid base stream: only seekable streams are supported"), "baseStream");
|
||||
this.sector = sector;
|
||||
this.sourceStream = source;
|
||||
this.absStartAddress = (long) extent * (long) sector.Size;
|
||||
this.absEndAddress = this.absStartAddress + this.LogicalToPhysical((long) size);
|
||||
this.disposeSourceStream = autoReleaseSource;
|
||||
this.Seek(0L, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
public DiscSectorStream(string isoFile, IDiscSector sector, uint extent, uint size)
|
||||
: this((System.IO.Stream) new FileStream(isoFile, FileMode.Open, FileAccess.Read, FileShare.Read), sector, extent, size, true)
|
||||
{
|
||||
}
|
||||
|
||||
public DiscSectorStream(System.IO.Stream source, IDiscSector sector)
|
||||
: this(source, sector, 0U, 0U, true)
|
||||
=> this.absEndAddress = this.absStartAddress + source.Length;
|
||||
|
||||
public override bool CanRead => !this.disposed && this.sourceStream.CanRead;
|
||||
|
||||
public override bool CanTimeout => this.disposed || this.sourceStream.CanTimeout;
|
||||
|
||||
public override bool CanSeek => !this.disposed && this.sourceStream.CanSeek;
|
||||
|
||||
public override bool CanWrite => !this.disposed && this.sourceStream.CanWrite;
|
||||
|
||||
public override long Length => this.PhysicalToLogical(this.absEndAddress - this.absStartAddress);
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get => this.PhysicalToLogical(this.sourceStream.Position - this.absStartAddress);
|
||||
set => this.Seek(value, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
long logical = this.PhysicalToLogical(this.sourceStream.Position - this.absStartAddress);
|
||||
long num1 = Math.Min((long) count, this.Length - logical);
|
||||
long sectors = num1 / (long) this.sector.DataLength;
|
||||
long num2 = num1 % (long) this.sector.DataLength;
|
||||
int num3 = 0;
|
||||
if ((long) (buffer.Length - offset) < sectors * (long) this.sector.DataLength + num2)
|
||||
throw new ArgumentOutOfRangeException("buffer is too small");
|
||||
if (sectors > 0L)
|
||||
num3 += this.ReadSector(buffer, offset, sectors);
|
||||
if (num2 > 0L)
|
||||
{
|
||||
if (this.sourceStream.Position % (long) this.sector.Size == 0L)
|
||||
this.sourceStream.Seek((long) this.sector.DataOffset, SeekOrigin.Current);
|
||||
num3 += this.sourceStream.Read(buffer, Convert.ToInt32(sectors * (long) this.sector.DataLength), (int) num2);
|
||||
}
|
||||
return num3;
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer.Length - offset < count)
|
||||
throw new ArgumentOutOfRangeException("buffer is too small");
|
||||
long logical = this.PhysicalToLogical(this.sourceStream.Position - this.absStartAddress);
|
||||
long num1 = Math.Min((long) count, this.Length - logical);
|
||||
long sectors = num1 / (long) this.sector.DataLength;
|
||||
long num2 = num1 % (long) this.sector.DataLength;
|
||||
long num3 = 0;
|
||||
if (sectors > 0L)
|
||||
num3 += (long) this.WriteSector(buffer, offset, sectors);
|
||||
if (num2 <= 0L)
|
||||
return;
|
||||
if (sectors > 0L || this.sourceStream.Position == this.absStartAddress)
|
||||
this.sourceStream.Seek((long) this.sector.DataOffset, SeekOrigin.Current);
|
||||
this.sourceStream.Write(buffer, Convert.ToInt32(sectors * (long) this.sector.DataLength), (int) num2);
|
||||
long num4 = num3 + num2;
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
long offset1;
|
||||
switch (origin)
|
||||
{
|
||||
case SeekOrigin.Begin:
|
||||
if (offset < 0L || offset > this.Length)
|
||||
throw new ArgumentException(string.Format("must be in range of (0, {0}) when seeking from {1}", (object) this.Length, (object) SeekOrigin.Begin), nameof (offset));
|
||||
offset1 = this.absStartAddress + this.LogicalToPhysical(offset);
|
||||
break;
|
||||
case SeekOrigin.Current:
|
||||
long logical = this.PhysicalToLogical(this.sourceStream.Position - this.absStartAddress);
|
||||
if ((offset > 0L || logical + offset < 0L) && (offset < 0L || logical + offset > this.Length))
|
||||
throw new ArgumentException(string.Format("must be in range of (0, {0}) or (-{0}, 0) when seeking from {1}", (object) this.Length, (object) SeekOrigin.Current), nameof (offset));
|
||||
offset1 = this.LogicalToPhysical(logical + offset) - (this.sourceStream.Position - this.absStartAddress);
|
||||
break;
|
||||
case SeekOrigin.End:
|
||||
if (offset > 0L || this.Length + offset < 0L)
|
||||
throw new ArgumentException(string.Format("must be in range of (-{0}, 0) when seeking from {1}", (object) this.Length, (object) SeekOrigin.End), nameof (offset));
|
||||
offset1 = this.absStartAddress + this.LogicalToPhysical(this.Length + offset);
|
||||
origin = SeekOrigin.Begin;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException();
|
||||
}
|
||||
return this.PhysicalToLogical(this.sourceStream.Seek(offset1, origin) - this.absStartAddress);
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
if (this.sourceStream == null || !this.disposeSourceStream)
|
||||
return;
|
||||
this.sourceStream.Close();
|
||||
}
|
||||
|
||||
public override void SetLength(long value) => throw new NotSupportedException();
|
||||
|
||||
public override void WriteByte(byte value) => throw new NotSupportedException();
|
||||
|
||||
public override void Flush() => throw new NotSupportedException();
|
||||
|
||||
private long LogicalToPhysical(long logicalAddress)
|
||||
{
|
||||
long num1 = logicalAddress / (long) this.sector.DataLength;
|
||||
long num2 = logicalAddress % (long) this.sector.DataLength;
|
||||
if (num2 != 0L)
|
||||
num2 += (long) this.sector.DataOffset;
|
||||
return num1 * (long) this.sector.Size + num2;
|
||||
}
|
||||
|
||||
private long PhysicalToLogical(long physicalAddress)
|
||||
{
|
||||
long num1 = physicalAddress % (long) this.sector.Size;
|
||||
long num2 = physicalAddress / (long) this.sector.Size;
|
||||
if (num1 != 0L)
|
||||
{
|
||||
string.Format("the specified absolute address {0} is out of the stream's logical range", (object) physicalAddress);
|
||||
num1 -= (long) this.sector.DataOffset;
|
||||
}
|
||||
return num2 * (long) this.sector.DataLength + num1;
|
||||
}
|
||||
|
||||
private int ReadSector(byte[] buffer, int offset, long sectors)
|
||||
{
|
||||
int num = 0;
|
||||
byte[] buffer1 = new byte[this.sector.Size];
|
||||
for (int index = 0; (long) index < sectors; ++index)
|
||||
{
|
||||
this.sourceStream.Read(buffer1, 0, buffer1.Length);
|
||||
Buffer.BlockCopy((Array) buffer1, this.sector.DataOffset, (Array) buffer, offset + index * this.sector.DataLength, this.sector.DataLength);
|
||||
num += this.sector.DataLength;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
private int WriteSector(byte[] buffer, int offset, long sectors)
|
||||
{
|
||||
int num = 0;
|
||||
for (int index = 0; (long) index < sectors; ++index)
|
||||
{
|
||||
this.sourceStream.Seek((long) this.sector.DataOffset, SeekOrigin.Current);
|
||||
this.sourceStream.Write(buffer, offset + index * this.sector.DataLength, this.sector.DataLength);
|
||||
this.sourceStream.Seek((long) (this.sector.Size - this.sector.DataOffset), SeekOrigin.Current);
|
||||
num += this.sector.DataLength;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public new virtual void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize((object) this);
|
||||
}
|
||||
|
||||
protected new virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (this.disposed)
|
||||
return;
|
||||
if (disposing)
|
||||
this.Close();
|
||||
this.disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
4
ImageReader/packages.config
Normal file
4
ImageReader/packages.config
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="log4net" version="2.0.12" targetFramework="net35" />
|
||||
</packages>
|
Loading…
Add table
Add a link
Reference in a new issue