├── .gitignore
├── DiscUtilsGD
├── DiscUtils.Core
│ ├── ApplePartitionMap
│ │ ├── BlockZero.cs
│ │ ├── PartitionMap.cs
│ │ ├── PartitionMapEntry.cs
│ │ └── PartitionMapFactory.cs
│ ├── Archives
│ │ ├── FileRecord.cs
│ │ ├── TarFile.cs
│ │ ├── TarFileBuilder.cs
│ │ ├── TarHeader.cs
│ │ ├── TarHeaderExtent.cs
│ │ └── UnixBuildFileRecord.cs
│ ├── ChsAddress.cs
│ ├── ClusterMap.cs
│ ├── ClusterRoles.cs
│ ├── Compression
│ │ ├── Adler32.cs
│ │ ├── BZip2BlockDecoder.cs
│ │ ├── BZip2CombinedHuffmanTrees.cs
│ │ ├── BZip2DecoderStream.cs
│ │ ├── BZip2Randomizer.cs
│ │ ├── BZip2RleStream.cs
│ │ ├── BigEndianBitStream.cs
│ │ ├── BitStream.cs
│ │ ├── BlockCompressor.cs
│ │ ├── CompressionResult.cs
│ │ ├── DataBlockTransform.cs
│ │ ├── HuffmanTree.cs
│ │ ├── InverseBurrowsWheeler.cs
│ │ ├── MoveToFront.cs
│ │ ├── SizedDeflateStream.cs
│ │ ├── ZlibBuffer.cs
│ │ └── ZlibStream.cs
│ ├── CoreCompat
│ │ ├── EncodingHelper.cs
│ │ └── ReflectionHelper.cs
│ ├── DiscDirectoryInfo.cs
│ ├── DiscFileInfo.cs
│ ├── DiscFileLocator.cs
│ ├── DiscFileSystem.cs
│ ├── DiscFileSystemChecker.cs
│ ├── DiscFileSystemInfo.cs
│ ├── DiscFileSystemOptions.cs
│ ├── DiskImageBuilder.cs
│ ├── DiskImageFileSpecification.cs
│ ├── FileLocator.cs
│ ├── FileSystemInfo.cs
│ ├── FileSystemManager.cs
│ ├── FileSystemParameters.cs
│ ├── FileTransport.cs
│ ├── FloppyDiskType.cs
│ ├── GenericDiskAdapterType.cs
│ ├── Geometry.cs
│ ├── GeometryCalculation.cs
│ ├── GeometryTranslation.cs
│ ├── IClusterBasedFileSystem.cs
│ ├── IDiagnosticTraceable.cs
│ ├── IFileSystem.cs
│ ├── IUnixFileSystem.cs
│ ├── IWindowsFileSystem.cs
│ ├── Internal
│ │ ├── Crc32.cs
│ │ ├── Crc32Algorithm.cs
│ │ ├── Crc32BigEndian.cs
│ │ ├── Crc32LittleEndian.cs
│ │ ├── LocalFileLocator.cs
│ │ ├── LogicalVolumeFactory.cs
│ │ ├── LogicalVolumeFactoryAttribute.cs
│ │ ├── ObjectCache.cs
│ │ ├── Utilities.cs
│ │ ├── VirtualDiskFactory.cs
│ │ ├── VirtualDiskFactoryAttribute.cs
│ │ ├── VirtualDiskTransport.cs
│ │ └── VirtualDiskTransportAttribute.cs
│ ├── InvalidFileSystemException.cs
│ ├── LogicalDiskManager
│ │ ├── ComponentRecord.cs
│ │ ├── Database.cs
│ │ ├── DatabaseHeader.cs
│ │ ├── DatabaseRecord.cs
│ │ ├── DiskGroupRecord.cs
│ │ ├── DiskRecord.cs
│ │ ├── DynamicDisk.cs
│ │ ├── DynamicDiskGroup.cs
│ │ ├── DynamicDiskManager.cs
│ │ ├── DynamicDiskManagerFactory.cs
│ │ ├── DynamicVolume.cs
│ │ ├── ExtentMergeType.cs
│ │ ├── ExtentRecord.cs
│ │ ├── PrivateHeader.cs
│ │ ├── RecordType.cs
│ │ ├── TocBlock.cs
│ │ └── VolumeRecord.cs
│ ├── LogicalVolumeInfo.cs
│ ├── LogicalVolumeStatus.cs
│ ├── NativeFileSystem.cs
│ ├── Partitions
│ │ ├── BiosExtendedPartitionTable.cs
│ │ ├── BiosPartitionInfo.cs
│ │ ├── BiosPartitionRecord.cs
│ │ ├── BiosPartitionTable.cs
│ │ ├── BiosPartitionTypes.cs
│ │ ├── BiosPartitionedDiskBuilder.cs
│ │ ├── DefaultPartitionTableFactory.cs
│ │ ├── GptEntry.cs
│ │ ├── GptHeader.cs
│ │ ├── GuidPartitionInfo.cs
│ │ ├── GuidPartitionTable.cs
│ │ ├── GuidPartitionTypes.cs
│ │ ├── PartitionInfo.cs
│ │ ├── PartitionTable.cs
│ │ ├── PartitionTableFactory.cs
│ │ ├── PartitionTableFactoryAttribute.cs
│ │ └── WellKnownPartitionType.cs
│ ├── PhysicalVolumeInfo.cs
│ ├── PhysicalVolumeType.cs
│ ├── Plist.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Raw
│ │ ├── Disk.cs
│ │ ├── DiskFactory.cs
│ │ └── DiskImageFile.cs
│ ├── ReadOnlyDiscFileSystem.cs
│ ├── ReparsePoint.cs
│ ├── ReportLevels.cs
│ ├── Setup
│ │ ├── FileOpenEventArgs.cs
│ │ └── SetupHelper.cs
│ ├── System
│ │ └── DateTimeOffsetExtensions.cs
│ ├── TimeConverter.cs
│ ├── UnixFilePermissions.cs
│ ├── UnixFileSystemInfo.cs
│ ├── UnixFileType.cs
│ ├── Vfs
│ │ ├── IVfsDirectory.cs
│ │ ├── IVfsFile.cs
│ │ ├── IVfsFileWithStreams.cs
│ │ ├── IVfsSymlink.cs
│ │ ├── VfsContext.cs
│ │ ├── VfsDirEntry.cs
│ │ ├── VfsFileSystem.cs
│ │ ├── VfsFileSystemFacade.cs
│ │ ├── VfsFileSystemFactory.cs
│ │ ├── VfsFileSystemFactoryAttribute.cs
│ │ ├── VfsFileSystemInfo.cs
│ │ ├── VfsFileSystemOpener.cs
│ │ └── VfsReadOnlyFileSystem.cs
│ ├── VirtualDisk.cs
│ ├── VirtualDiskClass.cs
│ ├── VirtualDiskExtent.cs
│ ├── VirtualDiskLayer.cs
│ ├── VirtualDiskManager.cs
│ ├── VirtualDiskParameters.cs
│ ├── VirtualDiskTypeInfo.cs
│ ├── VolumeInfo.cs
│ ├── VolumeManager.cs
│ └── WindowsFileInformation.cs
├── DiscUtils.Iso9660
│ ├── BaseVolumeDescriptor.cs
│ ├── BootDeviceEmulation.cs
│ ├── BootInitialEntry.cs
│ ├── BootValidationEntry.cs
│ ├── BootVolumeDescriptor.cs
│ ├── BootVolumeDescriptorRegion.cs
│ ├── BuildDirectoryInfo.cs
│ ├── BuildDirectoryMember.cs
│ ├── BuildFileInfo.cs
│ ├── BuildParameters.cs
│ ├── CDBuilder.cs
│ ├── CDReader.cs
│ ├── CommonVolumeDescriptor.cs
│ ├── DirectoryExtent.cs
│ ├── DirectoryRecord.cs
│ ├── ECM.cs
│ ├── ExtentStream.cs
│ ├── File.cs
│ ├── FileExtent.cs
│ ├── FileFlags.cs
│ ├── GDROM
│ │ ├── GDReader.cs
│ │ └── GDromBuilder.cs
│ ├── Iso9660Variant.cs
│ ├── IsoContext.cs
│ ├── IsoUtilities.cs
│ ├── PathTable.cs
│ ├── PathTableRecord.cs
│ ├── PrimaryVolumeDescriptor.cs
│ ├── PrimaryVolumeDescriptorRegion.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ReaderDirEntry.cs
│ ├── ReaderDirectory.cs
│ ├── RockRidge
│ │ ├── ChildLinkSystemUseEntry.cs
│ │ ├── FileTimeSystemUseEntry.cs
│ │ ├── PosixFileInfoSystemUseEntry.cs
│ │ ├── PosixNameSystemUseEntry.cs
│ │ └── RockRidgeExtension.cs
│ ├── SupplementaryVolumeDescriptor.cs
│ ├── SupplementaryVolumeDescriptorRegion.cs
│ ├── Susp
│ │ ├── ContinuationSystemUseEntry.cs
│ │ ├── ExtensionSelectSystemUseEntry.cs
│ │ ├── ExtensionSystemUseEntry.cs
│ │ ├── GenericSuspExtension.cs
│ │ ├── GenericSystemUseEntry.cs
│ │ ├── PaddingSystemUseEntry.cs
│ │ ├── SharingProtocolSystemUseEntry.cs
│ │ ├── SuspExtension.cs
│ │ ├── SuspRecords.cs
│ │ └── SystemUseEntry.cs
│ ├── VfsCDReader.cs
│ ├── VolumeDescriptorDiskRegion.cs
│ ├── VolumeDescriptorSetTerminator.cs
│ ├── VolumeDescriptorSetTerminatorRegion.cs
│ └── VolumeDescriptorType.cs
├── DiscUtils.Streams
│ ├── AligningStream.cs
│ ├── Block
│ │ ├── Block.cs
│ │ ├── BlockCache.cs
│ │ ├── BlockCacheSettings.cs
│ │ ├── BlockCacheStatistics.cs
│ │ └── BlockCacheStream.cs
│ ├── Buffer
│ │ ├── Buffer.cs
│ │ ├── BufferStream.cs
│ │ ├── IBuffer.cs
│ │ ├── IMappedBuffer.cs
│ │ └── SubBuffer.cs
│ ├── Builder
│ │ ├── BuilderBufferExtent.cs
│ │ ├── BuilderBufferExtentSource.cs
│ │ ├── BuilderBytesExtent.cs
│ │ ├── BuilderExtent.cs
│ │ ├── BuilderExtentSource.cs
│ │ ├── BuilderSparseStreamExtent.cs
│ │ ├── BuilderStreamExtent.cs
│ │ ├── BuilderStreamExtentSource.cs
│ │ ├── PassthroughStreamBuilder.cs
│ │ └── StreamBuilder.cs
│ ├── BuiltStream.cs
│ ├── CircularStream.cs
│ ├── ConcatStream.cs
│ ├── IByteArraySerializable.cs
│ ├── LengthWrappingStream.cs
│ ├── MappedStream.cs
│ ├── MirrorStream.cs
│ ├── PositionWrappingStream.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── PumpProgressEventArgs.cs
│ ├── ReaderWriter
│ │ ├── BigEndianDataReader.cs
│ │ ├── BigEndianDataWriter.cs
│ │ ├── DataReader.cs
│ │ ├── DataWriter.cs
│ │ └── LittleEndianDataReader.cs
│ ├── SnapshotStream.cs
│ ├── SparseMemoryBuffer.cs
│ ├── SparseMemoryStream.cs
│ ├── SparseStream.cs
│ ├── SparseStreamOpenDelegate.cs
│ ├── StreamBuffer.cs
│ ├── StreamExtent.cs
│ ├── StreamPump.cs
│ ├── StripedStream.cs
│ ├── SubStream.cs
│ ├── ThreadSafeStream.cs
│ ├── Util
│ │ ├── BitCounter.cs
│ │ ├── EndianUtilities.cs
│ │ ├── MathUtilities.cs
│ │ ├── Numbers.cs
│ │ ├── Ownership.cs
│ │ ├── Range.cs
│ │ ├── Sizes.cs
│ │ └── StreamUtilities.cs
│ ├── WrappingMappedStream.cs
│ ├── WrappingStream.cs
│ └── ZeroStream.cs
├── DiscUtilsGD.csproj
└── LICENSE.txt
├── GDIBuilder.sln
├── GDIBuilderUI
├── GDIBuilder2.Gtk
│ ├── GDIBuilder2.Gtk.csproj
│ └── Program.cs
├── GDIBuilder2.Mac
│ ├── GDIBuilder2.Mac.csproj
│ ├── Icon.icns
│ ├── Info.plist
│ ├── Program.cs
│ └── dotnet.entitlements
├── GDIBuilder2.Wpf
│ ├── BlankMedia.ico
│ ├── GDIBuilder2.Wpf.csproj
│ └── Program.cs
└── GDIBuilder2
│ ├── BuildAdvancedDialog.cs
│ ├── BuildResultDialog.cs
│ ├── BuildView.cs
│ ├── ExtractProgressDialog.cs
│ ├── ExtractView.cs
│ ├── GDIBuilder2.csproj
│ ├── MainForm.cs
│ ├── RebuildView.cs
│ ├── file.png
│ └── folder.png
├── README.md
└── buildgdi
├── Program.cs
├── Properties
└── AssemblyInfo.cs
├── buildgdi.csproj
└── nuget.config
/DiscUtilsGD/DiscUtils.Core/ApplePartitionMap/BlockZero.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using DiscUtils.Streams;
25 |
26 | namespace DiscUtils.ApplePartitionMap
27 | {
28 | internal sealed class BlockZero : IByteArraySerializable
29 | {
30 | public uint BlockCount;
31 | public ushort BlockSize;
32 | public ushort DeviceId;
33 | public ushort DeviceType;
34 | public ushort DriverCount;
35 | public uint DriverData;
36 | public ushort Signature;
37 |
38 | public int Size
39 | {
40 | get { return 512; }
41 | }
42 |
43 | public int ReadFrom(byte[] buffer, int offset)
44 | {
45 | Signature = EndianUtilities.ToUInt16BigEndian(buffer, offset + 0);
46 | BlockSize = EndianUtilities.ToUInt16BigEndian(buffer, offset + 2);
47 | BlockCount = EndianUtilities.ToUInt32BigEndian(buffer, offset + 4);
48 | DeviceType = EndianUtilities.ToUInt16BigEndian(buffer, offset + 8);
49 | DeviceId = EndianUtilities.ToUInt16BigEndian(buffer, offset + 10);
50 | DriverData = EndianUtilities.ToUInt32BigEndian(buffer, offset + 12);
51 | DriverCount = EndianUtilities.ToUInt16LittleEndian(buffer, offset + 16);
52 |
53 | return 512;
54 | }
55 |
56 | public void WriteTo(byte[] buffer, int offset)
57 | {
58 | throw new NotImplementedException();
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/ApplePartitionMap/PartitionMapFactory.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.IO;
24 | using DiscUtils.Partitions;
25 | using DiscUtils.Streams;
26 |
27 | namespace DiscUtils.ApplePartitionMap
28 | {
29 | [PartitionTableFactory]
30 | internal sealed class PartitionMapFactory : PartitionTableFactory
31 | {
32 | public override bool DetectIsPartitioned(Stream s)
33 | {
34 | if (s.Length < 1024)
35 | {
36 | return false;
37 | }
38 |
39 | s.Position = 0;
40 |
41 | byte[] initialBytes = StreamUtilities.ReadExact(s, 1024);
42 |
43 | BlockZero b0 = new BlockZero();
44 | b0.ReadFrom(initialBytes, 0);
45 | if (b0.Signature != 0x4552)
46 | {
47 | return false;
48 | }
49 |
50 | PartitionMapEntry initialPart = new PartitionMapEntry(s);
51 | initialPart.ReadFrom(initialBytes, 512);
52 |
53 | return initialPart.Signature == 0x504d;
54 | }
55 |
56 | public override PartitionTable DetectPartitionTable(VirtualDisk disk)
57 | {
58 | if (!DetectIsPartitioned(disk.Content))
59 | {
60 | return null;
61 | }
62 |
63 | return new PartitionMap(disk.Content);
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Archives/FileRecord.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Archives
24 | {
25 | internal sealed class FileRecord
26 | {
27 | public long Length;
28 | public string Name;
29 | public long Start;
30 |
31 | public FileRecord(string name, long start, long length)
32 | {
33 | Name = name;
34 | Start = start;
35 | Length = length;
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/ClusterRoles.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DiscUtils
4 | {
5 | ///
6 | /// Enumeration of possible cluster roles.
7 | ///
8 | /// A cluster may be in more than one role.
9 | [Flags]
10 | public enum ClusterRoles
11 | {
12 | ///
13 | /// Unknown, or unspecified role.
14 | ///
15 | None = 0x00,
16 |
17 | ///
18 | /// Cluster is free.
19 | ///
20 | Free = 0x01,
21 |
22 | ///
23 | /// Cluster is in use by a normal file.
24 | ///
25 | DataFile = 0x02,
26 |
27 | ///
28 | /// Cluster is in use by a system file.
29 | ///
30 | /// This isn't a file marked with the 'system' attribute,
31 | /// rather files that form part of the file system namespace but also
32 | /// form part of the file system meta-data.
33 | SystemFile = 0x04,
34 |
35 | ///
36 | /// Cluster is in use for meta-data.
37 | ///
38 | Metadata = 0x08,
39 |
40 | ///
41 | /// Cluster contains the boot region.
42 | ///
43 | BootArea = 0x10,
44 |
45 | ///
46 | /// Cluster is marked bad.
47 | ///
48 | Bad = 0x20
49 | }
50 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Compression/BitStream.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Compression
24 | {
25 | ///
26 | /// Base class for bit streams.
27 | ///
28 | ///
29 | /// The rules for conversion of a byte stream to a bit stream vary
30 | /// between implementations.
31 | ///
32 | internal abstract class BitStream
33 | {
34 | ///
35 | /// Gets the maximum number of bits that can be peeked on the stream.
36 | ///
37 | public abstract int MaxReadAhead { get; }
38 |
39 | ///
40 | /// Reads bits from the stream.
41 | ///
42 | /// The number of bits to read.
43 | /// The bits as a UInt32.
44 | public abstract uint Read(int count);
45 |
46 | ///
47 | /// Queries data from the stream.
48 | ///
49 | /// The number of bits to query.
50 | /// The bits as a UInt32.
51 | /// This method does not consume the bits (i.e. move the file pointer).
52 | public abstract uint Peek(int count);
53 |
54 | ///
55 | /// Consumes bits from the stream without returning them.
56 | ///
57 | /// The number of bits to consume.
58 | public abstract void Consume(int count);
59 | }
60 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Compression/CompressionResult.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Compression
24 | {
25 | ///
26 | /// Possible results of attempting to compress data.
27 | ///
28 | ///
29 | /// A compression routine may return Compressed, even if the data
30 | /// was 'all zeros' or increased in size. The AllZeros and Incompressible
31 | /// values are for algorithms that include special detection for these cases.
32 | ///
33 | public enum CompressionResult
34 | {
35 | ///
36 | /// The data compressed succesfully.
37 | ///
38 | Compressed,
39 |
40 | ///
41 | /// The data was all-zero's.
42 | ///
43 | AllZeros,
44 |
45 | ///
46 | /// The data was incompressible (could not fit into destination buffer).
47 | ///
48 | Incompressible
49 | }
50 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Compression/MoveToFront.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Compression
24 | {
25 | internal class MoveToFront
26 | {
27 | private readonly byte[] _buffer;
28 |
29 | public MoveToFront()
30 | : this(256, false) {}
31 |
32 | public MoveToFront(int size, bool autoInit)
33 | {
34 | _buffer = new byte[size];
35 |
36 | if (autoInit)
37 | {
38 | for (byte i = 0; i < size; ++i)
39 | {
40 | _buffer[i] = i;
41 | }
42 | }
43 | }
44 |
45 | public byte Head
46 | {
47 | get { return _buffer[0]; }
48 | }
49 |
50 | public void Set(int pos, byte val)
51 | {
52 | _buffer[pos] = val;
53 | }
54 |
55 | public byte GetAndMove(int pos)
56 | {
57 | byte val = _buffer[pos];
58 |
59 | for (int i = pos; i > 0; --i)
60 | {
61 | _buffer[i] = _buffer[i - 1];
62 | }
63 |
64 | _buffer[0] = val;
65 | return val;
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Compression/SizedDeflateStream.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2014, Quamotion
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using System.IO;
25 | using System.IO.Compression;
26 |
27 | namespace DiscUtils.Compression
28 | {
29 | internal class SizedDeflateStream : DeflateStream
30 | {
31 | private readonly int _length;
32 | private int _position;
33 |
34 | public SizedDeflateStream(Stream stream, CompressionMode mode, bool leaveOpen, int length)
35 | : base(stream, mode, leaveOpen)
36 | {
37 | _length = length;
38 | }
39 |
40 | public override long Length
41 | {
42 | get { return _length; }
43 | }
44 |
45 | public override long Position
46 | {
47 | get { return _position; }
48 | set
49 | {
50 | if (value != Position)
51 | {
52 | throw new NotImplementedException();
53 | }
54 | }
55 | }
56 |
57 | public override int Read(byte[] array, int offset, int count)
58 | {
59 | int read = base.Read(array, offset, count);
60 | _position += read;
61 | return read;
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/CoreCompat/EncodingHelper.cs:
--------------------------------------------------------------------------------
1 | #if !NET40 && !NET45
2 | using System.Text;
3 | #endif
4 |
5 | namespace DiscUtils.CoreCompat
6 | {
7 | internal static class EncodingHelper
8 | {
9 | private static bool _registered;
10 |
11 | public static void RegisterEncodings()
12 | {
13 | if (_registered)
14 | return;
15 |
16 | _registered = true;
17 |
18 | #if !NET40 && !NET45
19 | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
20 | #endif
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/CoreCompat/ReflectionHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace DiscUtils.CoreCompat
7 | {
8 | internal static class ReflectionHelper
9 | {
10 | public static bool IsEnum(Type type)
11 | {
12 | return type.IsEnum;
13 | }
14 |
15 | public static Attribute GetCustomAttribute(PropertyInfo property, Type attributeType)
16 | {
17 | return Attribute.GetCustomAttribute(property, attributeType);
18 | }
19 |
20 | public static Attribute GetCustomAttribute(PropertyInfo property, Type attributeType, bool inherit)
21 | {
22 | return Attribute.GetCustomAttribute(property, attributeType, inherit);
23 | }
24 |
25 | public static Attribute GetCustomAttribute(FieldInfo field, Type attributeType)
26 | {
27 | return Attribute.GetCustomAttribute(field, attributeType);
28 | }
29 |
30 | public static Attribute GetCustomAttribute(Type type, Type attributeType)
31 | {
32 | return Attribute.GetCustomAttribute(type, attributeType);
33 | }
34 |
35 | public static Attribute GetCustomAttribute(Type type, Type attributeType, bool inherit)
36 | {
37 | return Attribute.GetCustomAttribute(type, attributeType);
38 | }
39 |
40 | public static IEnumerable GetCustomAttributes(Type type, Type attributeType, bool inherit)
41 | {
42 | return Attribute.GetCustomAttributes(type, attributeType);
43 | }
44 |
45 | public static Assembly GetAssembly(Type type)
46 | {
47 | return type.Assembly;
48 | }
49 |
50 | public static int SizeOf()
51 | {
52 | return Marshal.SizeOf(typeof(T));
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/DiscFileSystemChecker.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.IO;
24 |
25 | namespace DiscUtils
26 | {
27 | ///
28 | /// Base class for objects that validate file system integrity.
29 | ///
30 | /// Instances of this class do not offer the ability to fix/correct
31 | /// file system issues, just to perform a limited number of checks on
32 | /// integrity of the file system.
33 | public abstract class DiscFileSystemChecker
34 | {
35 | ///
36 | /// Checks the integrity of a file system held in a stream.
37 | ///
38 | /// A report on issues found.
39 | /// The amount of detail to report.
40 | /// true if the file system appears valid, else false.
41 | public abstract bool Check(TextWriter reportOutput, ReportLevels levels);
42 | }
43 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/DiscFileSystemOptions.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 |
25 | namespace DiscUtils
26 | {
27 | ///
28 | /// Common file system options.
29 | ///
30 | /// Not all options are honoured by all file systems.
31 | public class DiscFileSystemOptions
32 | {
33 | ///
34 | /// Gets or sets the random number generator the file system should use.
35 | ///
36 | /// This option is normally null, which is fine for most purposes.
37 | /// Use this option when you need to finely control the filesystem for
38 | /// reproducibility of behaviour (for example in a test harness).
39 | public Random RandomNumberGenerator { get; set; }
40 | }
41 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/DiskImageFileSpecification.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using DiscUtils.Streams;
24 |
25 | namespace DiscUtils
26 | {
27 | ///
28 | /// Describes a particular file that is a constituent part of a virtual disk.
29 | ///
30 | public sealed class DiskImageFileSpecification
31 | {
32 | private readonly StreamBuilder _builder;
33 |
34 | internal DiskImageFileSpecification(string name, StreamBuilder builder)
35 | {
36 | Name = name;
37 | _builder = builder;
38 | }
39 |
40 | ///
41 | /// Gets name of the file.
42 | ///
43 | public string Name { get; }
44 |
45 | ///
46 | /// Gets the object that provides access to the file's content.
47 | ///
48 | /// A stream object that contains the file's content.
49 | public SparseStream OpenStream()
50 | {
51 | return _builder.Build();
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/FileSystemParameters.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.Text;
24 |
25 | namespace DiscUtils
26 | {
27 | ///
28 | /// Class with generic file system parameters.
29 | ///
30 | /// Note - not all parameters apply to all types of file system.
31 | public sealed class FileSystemParameters
32 | {
33 | ///
34 | /// Gets or sets the character encoding for file names, or null for default.
35 | ///
36 | /// Some file systems, such as FAT, don't specify a particular character set for
37 | /// file names. This parameter determines the character set that will be used for such
38 | /// file systems.
39 | public Encoding FileNameEncoding { get; set; }
40 |
41 | ///
42 | /// Gets or sets the algorithm to convert file system time to UTC.
43 | ///
44 | /// Some file system, such as FAT, don't have a defined way to convert from file system
45 | /// time (local time where the file system is authored) to UTC time. This parameter determines
46 | /// the algorithm to use.
47 | public TimeConverter TimeConverter { get; set; }
48 | }
49 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/FileTransport.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using System.Globalization;
25 | using System.IO;
26 | using DiscUtils.Internal;
27 |
28 | namespace DiscUtils
29 | {
30 | [VirtualDiskTransport("file")]
31 | internal sealed class FileTransport : VirtualDiskTransport
32 | {
33 | private string _extraInfo;
34 | private string _path;
35 |
36 | public override bool IsRawDisk
37 | {
38 | get { return false; }
39 | }
40 |
41 | public override void Connect(Uri uri, string username, string password)
42 | {
43 | _path = uri.LocalPath;
44 | _extraInfo = uri.Fragment.TrimStart('#');
45 |
46 | if (!Directory.Exists(Path.GetDirectoryName(_path)))
47 | {
48 | throw new FileNotFoundException(
49 | string.Format(CultureInfo.InvariantCulture, "No such file '{0}'", uri.OriginalString), _path);
50 | }
51 | }
52 |
53 | public override VirtualDisk OpenDisk(FileAccess access)
54 | {
55 | throw new NotSupportedException();
56 | }
57 |
58 | public override FileLocator GetFileLocator()
59 | {
60 | return new LocalFileLocator(Path.GetDirectoryName(_path) + @"\");
61 | }
62 |
63 | public override string GetFileName()
64 | {
65 | return Path.GetFileName(_path);
66 | }
67 |
68 | public override string GetExtraInfo()
69 | {
70 | return _extraInfo;
71 | }
72 | }
73 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/FloppyDiskType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils
24 | {
25 | ///
26 | /// The supported Floppy Disk logical formats.
27 | ///
28 | public enum FloppyDiskType
29 | {
30 | ///
31 | /// 720KiB capacity disk.
32 | ///
33 | DoubleDensity = 0,
34 |
35 | ///
36 | /// 1440KiB capacity disk.
37 | ///
38 | HighDensity = 1,
39 |
40 | ///
41 | /// 2880KiB capacity disk.
42 | ///
43 | Extended = 2
44 | }
45 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/GenericDiskAdapterType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils
24 | {
25 | ///
26 | /// Well known hard disk adaptor types.
27 | ///
28 | public enum GenericDiskAdapterType
29 | {
30 | ///
31 | /// IDE adaptor.
32 | ///
33 | Ide = 0,
34 |
35 | ///
36 | /// SCSI adaptor.
37 | ///
38 | Scsi = 1
39 | }
40 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/GeometryCalculation.cs:
--------------------------------------------------------------------------------
1 | namespace DiscUtils
2 | {
3 | ///
4 | /// Delegate for calculating a disk geometry from a capacity.
5 | ///
6 | /// The disk capacity to convert.
7 | /// The appropriate geometry for the disk.
8 | public delegate Geometry GeometryCalculation(long capacity);
9 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/GeometryTranslation.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils
24 | {
25 | ///
26 | /// Enumeration of standard BIOS disk geometry translation methods.
27 | ///
28 | public enum GeometryTranslation
29 | {
30 | ///
31 | /// Apply no translation.
32 | ///
33 | None = 0,
34 |
35 | ///
36 | /// Automatic, based on the physical geometry select the most appropriate translation.
37 | ///
38 | Auto = 1,
39 |
40 | ///
41 | /// LBA assisted translation, based on just the disk capacity.
42 | ///
43 | Lba = 2,
44 |
45 | ///
46 | /// Bit-shifting translation, based on the physical geometry of the disk.
47 | ///
48 | Large = 3
49 | }
50 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/IDiagnosticTraceable.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.IO;
24 |
25 | namespace DiscUtils
26 | {
27 | ///
28 | /// Interface exposed by objects that can provide a structured trace of their content.
29 | ///
30 | public interface IDiagnosticTraceable
31 | {
32 | ///
33 | /// Writes a diagnostic report about the state of the object to a writer.
34 | ///
35 | /// The writer to send the report to.
36 | /// The prefix to place at the start of each line.
37 | void Dump(TextWriter writer, string linePrefix);
38 | }
39 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/IUnixFileSystem.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils
24 | {
25 | ///
26 | /// Provides the base class for all file systems that support Unix semantics.
27 | ///
28 | public interface IUnixFileSystem : IFileSystem
29 | {
30 | ///
31 | /// Retrieves Unix-specific information about a file or directory.
32 | ///
33 | /// Path to the file or directory.
34 | /// Information about the owner, group, permissions and type of the
35 | /// file or directory.
36 | UnixFileSystemInfo GetUnixFileInfo(string path);
37 | }
38 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Internal/Crc32.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Internal
24 | {
25 | internal abstract class Crc32
26 | {
27 | protected readonly uint[] Table;
28 | protected uint _value;
29 |
30 | protected Crc32(uint[] table)
31 | {
32 | Table = table;
33 | _value = 0xFFFFFFFF;
34 | }
35 |
36 | public uint Value
37 | {
38 | get { return _value ^ 0xFFFFFFFF; }
39 | }
40 |
41 | public abstract void Process(byte[] buffer, int offset, int count);
42 | }
43 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Internal/Crc32Algorithm.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Internal
24 | {
25 | internal enum Crc32Algorithm
26 | {
27 | ///
28 | /// Used in Ethernet, PKZIP, BZIP2, Gzip, PNG, etc. (aka CRC32).
29 | ///
30 | Common = 0,
31 |
32 | ///
33 | /// Used in iSCSI, SCTP, Btrfs, Vhdx. (aka CRC32C).
34 | ///
35 | Castagnoli = 1,
36 |
37 | ///
38 | /// Unknown usage. (aka CRC32K).
39 | ///
40 | Koopman = 2,
41 |
42 | ///
43 | /// Used in AIXM. (aka CRC32Q).
44 | ///
45 | Aeronautical = 3
46 | }
47 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Internal/LogicalVolumeFactory.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.Collections.Generic;
24 |
25 | namespace DiscUtils.Internal
26 | {
27 | internal abstract class LogicalVolumeFactory
28 | {
29 | public abstract bool HandlesPhysicalVolume(PhysicalVolumeInfo volume);
30 |
31 | public abstract void MapDisks(IEnumerable disks, Dictionary result);
32 | }
33 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Internal/LogicalVolumeFactoryAttribute.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 |
25 | namespace DiscUtils.Internal
26 | {
27 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
28 | internal sealed class LogicalVolumeFactoryAttribute : Attribute {}
29 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Internal/VirtualDiskFactory.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.Collections.Generic;
24 | using System.IO;
25 |
26 | namespace DiscUtils.Internal
27 | {
28 | public abstract class VirtualDiskFactory
29 | {
30 | public abstract string[] Variants { get; }
31 |
32 | public abstract VirtualDiskTypeInfo GetDiskTypeInformation(string variant);
33 |
34 | public abstract DiskImageBuilder GetImageBuilder(string variant);
35 |
36 | public abstract VirtualDisk CreateDisk(FileLocator locator, string variant, string path,
37 | VirtualDiskParameters diskParameters);
38 |
39 | public abstract VirtualDisk OpenDisk(string path, FileAccess access);
40 |
41 | public abstract VirtualDisk OpenDisk(FileLocator locator, string path, FileAccess access);
42 |
43 | public virtual VirtualDisk OpenDisk(FileLocator locator, string path, string extraInfo,
44 | Dictionary parameters, FileAccess access)
45 | {
46 | return OpenDisk(locator, path, access);
47 | }
48 |
49 | public VirtualDisk OpenDisk(DiscFileSystem fileSystem, string path, FileAccess access)
50 | {
51 | return OpenDisk(new DiscFileLocator(fileSystem, @"\"), path, access);
52 | }
53 |
54 | public abstract VirtualDiskLayer OpenDiskLayer(FileLocator locator, string path, FileAccess access);
55 | }
56 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Internal/VirtualDiskFactoryAttribute.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 |
25 | namespace DiscUtils.Internal
26 | {
27 | [AttributeUsage(AttributeTargets.Class)]
28 | public sealed class VirtualDiskFactoryAttribute : Attribute
29 | {
30 | public VirtualDiskFactoryAttribute(string type, string fileExtensions)
31 | {
32 | Type = type;
33 | FileExtensions = fileExtensions.Replace(".", string.Empty).Split(',');
34 | }
35 |
36 | public string[] FileExtensions { get; }
37 |
38 | public string Type { get; }
39 | }
40 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Internal/VirtualDiskTransport.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using System.IO;
25 |
26 | namespace DiscUtils.Internal
27 | {
28 | internal abstract class VirtualDiskTransport : IDisposable
29 | {
30 | public abstract bool IsRawDisk { get; }
31 |
32 | public void Dispose()
33 | {
34 | Dispose(true);
35 | GC.SuppressFinalize(this);
36 | }
37 |
38 | public abstract void Connect(Uri uri, string username, string password);
39 |
40 | public abstract VirtualDisk OpenDisk(FileAccess access);
41 |
42 | public abstract FileLocator GetFileLocator();
43 |
44 | public abstract string GetFileName();
45 |
46 | public abstract string GetExtraInfo();
47 |
48 | protected virtual void Dispose(bool disposing) {}
49 | }
50 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Internal/VirtualDiskTransportAttribute.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 |
25 | namespace DiscUtils.Internal
26 | {
27 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
28 | internal sealed class VirtualDiskTransportAttribute : Attribute
29 | {
30 | public VirtualDiskTransportAttribute(string scheme)
31 | {
32 | Scheme = scheme;
33 | }
34 |
35 | public string Scheme { get; }
36 | }
37 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/LogicalDiskManager/DiskGroupRecord.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.LogicalDiskManager
24 | {
25 | internal sealed class DiskGroupRecord : DatabaseRecord
26 | {
27 | public string GroupGuidString;
28 | public uint Unknown1;
29 |
30 | protected override void DoReadFrom(byte[] buffer, int offset)
31 | {
32 | base.DoReadFrom(buffer, offset);
33 |
34 | int pos = offset + 0x18;
35 |
36 | Id = ReadVarULong(buffer, ref pos);
37 | Name = ReadVarString(buffer, ref pos);
38 | if ((Flags & 0xF0) == 0x40)
39 | {
40 | GroupGuidString = ReadBinaryGuid(buffer, ref pos).ToString();
41 | }
42 | else
43 | {
44 | GroupGuidString = ReadVarString(buffer, ref pos);
45 | }
46 | Unknown1 = ReadUInt(buffer, ref pos);
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/LogicalDiskManager/DiskRecord.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.LogicalDiskManager
24 | {
25 | internal sealed class DiskRecord : DatabaseRecord
26 | {
27 | public string DiskGuidString;
28 |
29 | protected override void DoReadFrom(byte[] buffer, int offset)
30 | {
31 | base.DoReadFrom(buffer, offset);
32 |
33 | int pos = offset + 0x18;
34 |
35 | Id = ReadVarULong(buffer, ref pos);
36 | Name = ReadVarString(buffer, ref pos);
37 | if ((Flags & 0xF0) == 0x40)
38 | {
39 | DiskGuidString = ReadBinaryGuid(buffer, ref pos).ToString();
40 | }
41 | else
42 | {
43 | DiskGuidString = ReadVarString(buffer, ref pos);
44 | }
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/LogicalDiskManager/DynamicDiskManagerFactory.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.Collections.Generic;
24 | using DiscUtils.Internal;
25 |
26 | namespace DiscUtils.LogicalDiskManager
27 | {
28 | [LogicalVolumeFactory]
29 | internal class DynamicDiskManagerFactory : LogicalVolumeFactory
30 | {
31 | public override bool HandlesPhysicalVolume(PhysicalVolumeInfo volume)
32 | {
33 | return DynamicDiskManager.HandlesPhysicalVolume(volume);
34 | }
35 |
36 | public override void MapDisks(IEnumerable disks, Dictionary result)
37 | {
38 | DynamicDiskManager mgr = new DynamicDiskManager();
39 |
40 | foreach (VirtualDisk disk in disks)
41 | {
42 | if (DynamicDiskManager.IsDynamicDisk(disk))
43 | {
44 | mgr.Add(disk);
45 | }
46 | }
47 |
48 | foreach (LogicalVolumeInfo vol in mgr.GetLogicalVolumes())
49 | {
50 | result.Add(vol.Identity, vol);
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/LogicalDiskManager/DynamicVolume.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using System.IO;
25 | using DiscUtils.Streams;
26 |
27 | namespace DiscUtils.LogicalDiskManager
28 | {
29 | internal class DynamicVolume
30 | {
31 | private readonly DynamicDiskGroup _group;
32 |
33 | internal DynamicVolume(DynamicDiskGroup group, Guid volumeId)
34 | {
35 | _group = group;
36 | Identity = volumeId;
37 | }
38 |
39 | public byte BiosType
40 | {
41 | get { return Record.BiosType; }
42 | }
43 |
44 | public Guid Identity { get; }
45 |
46 | public long Length
47 | {
48 | get { return Record.Size * Sizes.Sector; }
49 | }
50 |
51 | private VolumeRecord Record
52 | {
53 | get { return _group.GetVolume(Identity); }
54 | }
55 |
56 | public LogicalVolumeStatus Status
57 | {
58 | get { return _group.GetVolumeStatus(Record.Id); }
59 | }
60 |
61 | public SparseStream Open()
62 | {
63 | if (Status == LogicalVolumeStatus.Failed)
64 | {
65 | throw new IOException("Attempt to open 'failed' volume");
66 | }
67 | return _group.OpenVolume(Record.Id);
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/LogicalDiskManager/ExtentMergeType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.LogicalDiskManager
24 | {
25 | internal enum ExtentMergeType : byte
26 | {
27 | None = 0,
28 | Interleaved = 1,
29 | Concatenated = 2
30 | }
31 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/LogicalDiskManager/ExtentRecord.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.LogicalDiskManager
24 | {
25 | internal sealed class ExtentRecord : DatabaseRecord
26 | {
27 | public ulong ComponentId;
28 | public ulong DiskId;
29 | public long DiskOffsetLba;
30 | public ulong InterleaveOrder;
31 | public long OffsetInVolumeLba;
32 | public uint PartitionComponentLink;
33 | public long SizeLba;
34 | public uint Unknown1;
35 | public uint Unknown2;
36 |
37 | protected override void DoReadFrom(byte[] buffer, int offset)
38 | {
39 | base.DoReadFrom(buffer, offset);
40 |
41 | int pos = offset + 0x18;
42 |
43 | Id = ReadVarULong(buffer, ref pos);
44 | Name = ReadVarString(buffer, ref pos);
45 | Unknown1 = ReadUInt(buffer, ref pos);
46 | Unknown2 = ReadUInt(buffer, ref pos);
47 | PartitionComponentLink = ReadUInt(buffer, ref pos);
48 | DiskOffsetLba = ReadLong(buffer, ref pos);
49 | OffsetInVolumeLba = ReadLong(buffer, ref pos);
50 | SizeLba = ReadVarLong(buffer, ref pos);
51 | ComponentId = ReadVarULong(buffer, ref pos);
52 | DiskId = ReadVarULong(buffer, ref pos);
53 |
54 | if ((Flags & 0x0800) != 0)
55 | {
56 | InterleaveOrder = ReadVarULong(buffer, ref pos);
57 | }
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/LogicalDiskManager/RecordType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.LogicalDiskManager
24 | {
25 | internal enum RecordType : byte
26 | {
27 | None = 0,
28 | Volume = 1,
29 | Component = 2,
30 | Extent = 3,
31 | Disk = 4,
32 | DiskGroup = 5
33 | }
34 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/LogicalVolumeStatus.cs:
--------------------------------------------------------------------------------
1 | namespace DiscUtils
2 | {
3 | ///
4 | /// Enumeration of the health status of a logical volume.
5 | ///
6 | public enum LogicalVolumeStatus
7 | {
8 | ///
9 | /// The volume is healthy and fully functional.
10 | ///
11 | Healthy = 0,
12 |
13 | ///
14 | /// The volume is completely accessible, but at degraded redundancy.
15 | ///
16 | FailedRedundancy = 1,
17 |
18 | ///
19 | /// The volume is wholey, or partly, inaccessible.
20 | ///
21 | Failed = 2
22 | }
23 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Partitions/BiosPartitionTypes.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sappharad/GDIbuilder/4a3fe4531288d81dad8eaabb9106d810c9ad69c7/DiscUtilsGD/DiscUtils.Core/Partitions/BiosPartitionTypes.cs
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Partitions/DefaultPartitionTableFactory.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.IO;
24 |
25 | namespace DiscUtils.Partitions
26 | {
27 | [PartitionTableFactory]
28 | internal sealed class DefaultPartitionTableFactory : PartitionTableFactory
29 | {
30 | public override bool DetectIsPartitioned(Stream s)
31 | {
32 | return BiosPartitionTable.IsValid(s);
33 | }
34 |
35 | public override PartitionTable DetectPartitionTable(VirtualDisk disk)
36 | {
37 | if (BiosPartitionTable.IsValid(disk.Content))
38 | {
39 | BiosPartitionTable table = new BiosPartitionTable(disk);
40 | if (table.Count == 1 && table[0].BiosType == BiosPartitionTypes.GptProtective)
41 | {
42 | return new GuidPartitionTable(disk);
43 | }
44 | return table;
45 | }
46 | return null;
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Partitions/PartitionTableFactory.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.IO;
24 |
25 | namespace DiscUtils.Partitions
26 | {
27 | internal abstract class PartitionTableFactory
28 | {
29 | public abstract bool DetectIsPartitioned(Stream s);
30 |
31 | public abstract PartitionTable DetectPartitionTable(VirtualDisk disk);
32 | }
33 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Partitions/PartitionTableFactoryAttribute.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 |
25 | namespace DiscUtils.Partitions
26 | {
27 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
28 | internal sealed class PartitionTableFactoryAttribute : Attribute {}
29 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Partitions/WellKnownPartitionType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Partitions
24 | {
25 | ///
26 | /// Enumeration of partition-table technology neutral partition types.
27 | ///
28 | public enum WellKnownPartitionType
29 | {
30 | ///
31 | /// Windows FAT-based partition.
32 | ///
33 | WindowsFat = 0,
34 |
35 | ///
36 | /// Windows NTFS-based partition.
37 | ///
38 | WindowsNtfs = 1,
39 |
40 | ///
41 | /// Linux native file system.
42 | ///
43 | Linux = 2,
44 |
45 | ///
46 | /// Linux swap.
47 | ///
48 | LinuxSwap = 3,
49 |
50 | ///
51 | /// Linux Logical Volume Manager (LVM).
52 | ///
53 | LinuxLvm = 4
54 | }
55 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/PhysicalVolumeType.cs:
--------------------------------------------------------------------------------
1 | namespace DiscUtils
2 | {
3 | ///
4 | /// Enumeration of possible types of physical volume.
5 | ///
6 | public enum PhysicalVolumeType
7 | {
8 | ///
9 | /// Unknown type.
10 | ///
11 | None,
12 |
13 | ///
14 | /// Physical volume encompasses the entire disk.
15 | ///
16 | EntireDisk,
17 |
18 | ///
19 | /// Physical volume is defined by a BIOS-style partition table.
20 | ///
21 | BiosPartition,
22 |
23 | ///
24 | /// Physical volume is defined by a GUID partition table.
25 | ///
26 | GptPartition,
27 |
28 | ///
29 | /// Physical volume is defined by an Apple partition map.
30 | ///
31 | ApplePartition
32 | }
33 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/ReparsePoint.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils
24 | {
25 | ///
26 | /// Represents a Reparse Point, which can be associated with a file or directory.
27 | ///
28 | public sealed class ReparsePoint
29 | {
30 | ///
31 | /// Initializes a new instance of the ReparsePoint class.
32 | ///
33 | /// The defined reparse point tag.
34 | /// The reparse point's content.
35 | public ReparsePoint(int tag, byte[] content)
36 | {
37 | Tag = tag;
38 | Content = content;
39 | }
40 |
41 | ///
42 | /// Gets or sets the reparse point's content.
43 | ///
44 | public byte[] Content { get; set; }
45 |
46 | ///
47 | /// Gets or sets the defined reparse point tag.
48 | ///
49 | public int Tag { get; set; }
50 | }
51 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/ReportLevels.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DiscUtils
4 | {
5 | ///
6 | /// Flags for the amount of detail to include in a report.
7 | ///
8 | [Flags]
9 | public enum ReportLevels
10 | {
11 | ///
12 | /// Report no information.
13 | ///
14 | None = 0x00,
15 |
16 | ///
17 | /// Report informational level items.
18 | ///
19 | Information = 0x01,
20 |
21 | ///
22 | /// Report warning level items.
23 | ///
24 | Warnings = 0x02,
25 |
26 | ///
27 | /// Report error level items.
28 | ///
29 | Errors = 0x04,
30 |
31 | ///
32 | /// Report all items.
33 | ///
34 | All = 0x07
35 | }
36 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Setup/SetupHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using DiscUtils.CoreCompat;
5 |
6 | namespace DiscUtils.Setup
7 | {
8 | ///
9 | /// Helps setup new DiscUtils dependencies, when loaded into target programs
10 | ///
11 | public static class SetupHelper
12 | {
13 | private static readonly HashSet _alreadyLoaded;
14 |
15 | static SetupHelper()
16 | {
17 | _alreadyLoaded = new HashSet();
18 |
19 | // Register the core DiscUtils lib
20 | RegisterAssembly(ReflectionHelper.GetAssembly(typeof(SetupHelper)));
21 | }
22 |
23 | ///
24 | /// Registers the types provided by an assembly to all relevant DiscUtils managers
25 | ///
26 | ///
27 | public static void RegisterAssembly(Assembly assembly)
28 | {
29 | lock (_alreadyLoaded)
30 | {
31 | if (!_alreadyLoaded.Add(assembly.FullName))
32 | return;
33 |
34 | FileSystemManager.RegisterFileSystems(assembly);
35 | VirtualDiskManager.RegisterVirtualDiskTypes(assembly);
36 | VolumeManager.RegisterLogicalVolumeFactory(assembly);
37 | }
38 | }
39 |
40 | ///
41 | /// Allows intercepting any file open operation
42 | ///
43 | ///
44 | /// Can be used to wrap the opened file for special use cases,
45 | /// modify the parameters for opening files, validate file names
46 | /// and many more.
47 | ///
48 | public static event EventHandler OpeningFile;
49 |
50 | internal static void OnOpeningFile(object sender, FileOpenEventArgs e)
51 | {
52 | OpeningFile?.Invoke(sender, e);
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/System/DateTimeOffsetExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace System
2 | {
3 | ///
4 | /// DateTimeOffset extension methods.
5 | ///
6 | public static class DateTimeOffsetExtensions
7 | {
8 | ///
9 | /// The Epoch common to most (all?) Unix systems.
10 | ///
11 | public static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
12 |
13 | ///
14 | /// Converts the current Unix time to a DateTimeOffset.
15 | ///
16 | /// Seconds since UnixEpoch.
17 | /// DateTimeOffset.
18 | public static DateTimeOffset FromUnixTimeSeconds(this long seconds)
19 | {
20 | #if NETSTANDARD
21 | return DateTimeOffset.FromUnixTimeSeconds(seconds);
22 | #else
23 | DateTimeOffset dateTimeOffset = new DateTimeOffset(DateTimeOffsetExtensions.UnixEpoch);
24 | dateTimeOffset = dateTimeOffset.AddSeconds(seconds);
25 | return dateTimeOffset;
26 | #endif
27 | }
28 |
29 | ///
30 | /// Converts the current DateTimeOffset to Unix time.
31 | ///
32 | /// DateTimeOffset.
33 | /// Seconds since UnixEpoch.
34 | public static long ToUnixTimeSeconds(this DateTimeOffset dateTimeOffset)
35 | {
36 | long unixTimeStampInTicks = (dateTimeOffset.ToUniversalTime() - DateTimeOffsetExtensions.UnixEpoch).Ticks;
37 | return unixTimeStampInTicks / TimeSpan.TicksPerSecond;
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/TimeConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DiscUtils
4 | {
5 | ///
6 | /// Converts a time to/from UTC.
7 | ///
8 | /// The time to convert.
9 | /// true to convert FAT time to UTC, false to convert UTC to FAT time.
10 | /// The converted time.
11 | public delegate DateTime TimeConverter(DateTime time, bool toUtc);
12 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/UnixFileSystemInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils
24 | {
25 | ///
26 | /// Information about a file or directory common to most Unix systems.
27 | ///
28 | public sealed class UnixFileSystemInfo
29 | {
30 | ///
31 | /// Gets or sets the device id of the referenced device (for character and block devices).
32 | ///
33 | public long DeviceId { get; set; }
34 |
35 | ///
36 | /// Gets or sets the file's type.
37 | ///
38 | public UnixFileType FileType { get; set; }
39 |
40 | ///
41 | /// Gets or sets the group that owns this file or directory.
42 | ///
43 | public int GroupId { get; set; }
44 |
45 | ///
46 | /// Gets or sets the file's serial number (unique within file system).
47 | ///
48 | public long Inode { get; set; }
49 |
50 | ///
51 | /// Gets or sets the number of hard links to this file.
52 | ///
53 | public int LinkCount { get; set; }
54 |
55 | ///
56 | /// Gets or sets the file permissions (aka flags) for this file or directory.
57 | ///
58 | public UnixFilePermissions Permissions { get; set; }
59 |
60 | ///
61 | /// Gets or sets the user that owns this file or directory.
62 | ///
63 | public int UserId { get; set; }
64 | }
65 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/UnixFileType.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils
24 | {
25 | ///
26 | /// Standard Unix-style file type.
27 | ///
28 | public enum UnixFileType
29 | {
30 | ///
31 | /// No type specified.
32 | ///
33 | None = 0,
34 |
35 | ///
36 | /// A FIFO / Named Pipe.
37 | ///
38 | Fifo = 0x1,
39 |
40 | ///
41 | /// A character device.
42 | ///
43 | Character = 0x2,
44 |
45 | ///
46 | /// A normal directory.
47 | ///
48 | Directory = 0x4,
49 |
50 | ///
51 | /// A block device.
52 | ///
53 | Block = 0x6,
54 |
55 | ///
56 | /// A regular file.
57 | ///
58 | Regular = 0x8,
59 |
60 | ///
61 | /// A soft link.
62 | ///
63 | Link = 0xA,
64 |
65 | ///
66 | /// A unix socket.
67 | ///
68 | Socket = 0xC
69 | }
70 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Vfs/IVfsDirectory.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.Collections.Generic;
24 |
25 | namespace DiscUtils.Vfs
26 | {
27 | ///
28 | /// Interface implemented by classes representing a directory.
29 | ///
30 | /// Concrete type representing directory entries.
31 | /// Concrete type representing files.
32 | public interface IVfsDirectory : IVfsFile
33 | where TDirEntry : VfsDirEntry
34 | where TFile : IVfsFile
35 | {
36 | ///
37 | /// Gets all of the directory entries.
38 | ///
39 | ICollection AllEntries { get; }
40 |
41 | ///
42 | /// Gets a self-reference, if available.
43 | ///
44 | TDirEntry Self { get; }
45 |
46 | ///
47 | /// Gets a specific directory entry, by name.
48 | ///
49 | /// The name of the directory entry.
50 | /// The directory entry, or null if not found.
51 | TDirEntry GetEntryByName(string name);
52 |
53 | ///
54 | /// Creates a new file.
55 | ///
56 | /// The name of the file (relative to this directory).
57 | /// The newly created file.
58 | TDirEntry CreateNewFile(string name);
59 | }
60 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Vfs/IVfsFile.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using System.IO;
25 | using DiscUtils.Streams;
26 |
27 | namespace DiscUtils.Vfs
28 | {
29 | ///
30 | /// Interface implemented by a class representing a file.
31 | ///
32 | ///
33 | /// File system implementations should have a class that implements this
34 | /// interface. If the file system implementation is read-only, it is
35 | /// acceptable to throw NotImplementedException from setters.
36 | ///
37 | public interface IVfsFile
38 | {
39 | ///
40 | /// Gets or sets the last creation time in UTC.
41 | ///
42 | DateTime CreationTimeUtc { get; set; }
43 |
44 | ///
45 | /// Gets or sets the file's attributes.
46 | ///
47 | FileAttributes FileAttributes { get; set; }
48 |
49 | ///
50 | /// Gets a buffer to access the file's contents.
51 | ///
52 | IBuffer FileContent { get; }
53 |
54 | ///
55 | /// Gets the length of the file.
56 | ///
57 | long FileLength { get; }
58 |
59 | ///
60 | /// Gets or sets the last access time in UTC.
61 | ///
62 | DateTime LastAccessTimeUtc { get; set; }
63 |
64 | ///
65 | /// Gets or sets the last write time in UTC.
66 | ///
67 | DateTime LastWriteTimeUtc { get; set; }
68 | }
69 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Vfs/IVfsFileWithStreams.cs:
--------------------------------------------------------------------------------
1 | using DiscUtils.Streams;
2 |
3 | namespace DiscUtils.Vfs
4 | {
5 | ///
6 | /// Interface implemented by classes representing files, in file systems that support multi-stream files.
7 | ///
8 | public interface IVfsFileWithStreams : IVfsFile
9 | {
10 | ///
11 | /// Creates a new stream.
12 | ///
13 | /// The name of the stream.
14 | /// An object representing the stream.
15 | SparseStream CreateStream(string name);
16 |
17 | ///
18 | /// Opens an existing stream.
19 | ///
20 | /// The name of the stream.
21 | /// An object representing the stream.
22 | /// The implementation must not implicitly create the stream if it doesn't already
23 | /// exist.
24 | SparseStream OpenExistingStream(string name);
25 | }
26 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Vfs/IVfsSymlink.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Vfs
24 | {
25 | ///
26 | /// Interface implemented by classes representing a directory.
27 | ///
28 | /// Concrete type representing directory entries.
29 | /// Concrete type representing files.
30 | public interface IVfsSymlink : IVfsFile
31 | where TDirEntry : VfsDirEntry
32 | where TFile : IVfsFile
33 | {
34 | ///
35 | /// Gets the target path for this symlink.
36 | ///
37 | string TargetPath { get; }
38 | }
39 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Vfs/VfsContext.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Vfs
24 | {
25 | ///
26 | /// Base class for a context object that holds global state for file system implementations.
27 | ///
28 | public abstract class VfsContext {}
29 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Vfs/VfsFileSystemFactoryAttribute.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 |
25 | namespace DiscUtils.Vfs
26 | {
27 | ///
28 | /// Attribute identifying file system factory classes.
29 | ///
30 | [AttributeUsage(AttributeTargets.Class)]
31 | public sealed class VfsFileSystemFactoryAttribute : Attribute {}
32 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/Vfs/VfsFileSystemOpener.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace DiscUtils.Vfs
4 | {
5 | ///
6 | /// Delegate for instantiating a file system.
7 | ///
8 | /// The stream containing the file system.
9 | /// Optional, information about the volume the file system is on.
10 | /// Parameters for the file system.
11 | /// A file system implementation.
12 | public delegate DiscFileSystem VfsFileSystemOpener(
13 | Stream stream, VolumeInfo volumeInfo, FileSystemParameters parameters);
14 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/VirtualDiskClass.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils
24 | {
25 | ///
26 | /// Enumeration of different classes of disk.
27 | ///
28 | public enum VirtualDiskClass
29 | {
30 | ///
31 | /// Unknown (or unspecified) type.
32 | ///
33 | None = 0,
34 |
35 | ///
36 | /// Hard disk.
37 | ///
38 | HardDisk = 1,
39 |
40 | ///
41 | /// Optical disk, such as CD or DVD.
42 | ///
43 | OpticalDisk = 2,
44 |
45 | ///
46 | /// Floppy disk.
47 | ///
48 | FloppyDisk = 3
49 | }
50 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/VirtualDiskTypeInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils
24 | {
25 | ///
26 | /// Information about a type of virtual disk.
27 | ///
28 | public sealed class VirtualDiskTypeInfo
29 | {
30 | ///
31 | /// Gets or sets the algorithm for determining the geometry for a given disk capacity.
32 | ///
33 | public GeometryCalculation CalcGeometry { get; set; }
34 |
35 | ///
36 | /// Gets or sets a value indicating whether this disk type can represent hard disks.
37 | ///
38 | public bool CanBeHardDisk { get; set; }
39 |
40 | ///
41 | /// Gets or sets a value indicating whether this disk type requires a specific geometry for any given disk capacity.
42 | ///
43 | public bool DeterministicGeometry { get; set; }
44 |
45 | ///
46 | /// Gets or sets the name of the virtual disk type.
47 | ///
48 | public string Name { get; set; }
49 |
50 | ///
51 | /// Gets or sets a value indicating whether this disk type persists the BIOS geometry.
52 | ///
53 | public bool PreservesBiosGeometry { get; set; }
54 |
55 | ///
56 | /// Gets or sets the variant of the virtual disk type.
57 | ///
58 | public string Variant { get; set; }
59 | }
60 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Core/WindowsFileInformation.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using System.IO;
25 |
26 | namespace DiscUtils
27 | {
28 | ///
29 | /// Common information for Windows files.
30 | ///
31 | public class WindowsFileInformation
32 | {
33 | ///
34 | /// Gets or sets the last time the file was changed.
35 | ///
36 | public DateTime ChangeTime { get; set; }
37 |
38 | ///
39 | /// Gets or sets the creation time of the file.
40 | ///
41 | public DateTime CreationTime { get; set; }
42 |
43 | ///
44 | /// Gets or sets the file attributes.
45 | ///
46 | public FileAttributes FileAttributes { get; set; }
47 |
48 | ///
49 | /// Gets or sets the last access time of the file.
50 | ///
51 | public DateTime LastAccessTime { get; set; }
52 |
53 | ///
54 | /// Gets or sets the modification time of the file.
55 | ///
56 | public DateTime LastWriteTime { get; set; }
57 | }
58 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/BaseVolumeDescriptor.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using System.Text;
25 |
26 | namespace DiscUtils.Iso9660
27 | {
28 | internal class BaseVolumeDescriptor
29 | {
30 | public const string Iso9660StandardIdentifier = "CD001";
31 |
32 | public readonly string StandardIdentifier;
33 | public readonly VolumeDescriptorType VolumeDescriptorType;
34 | public readonly byte VolumeDescriptorVersion;
35 |
36 | public BaseVolumeDescriptor(VolumeDescriptorType type, byte version)
37 | {
38 | VolumeDescriptorType = type;
39 | StandardIdentifier = "CD001";
40 | VolumeDescriptorVersion = version;
41 | }
42 |
43 | public BaseVolumeDescriptor(byte[] src, int offset)
44 | {
45 | VolumeDescriptorType = (VolumeDescriptorType)src[offset + 0];
46 | StandardIdentifier = Encoding.ASCII.GetString(src, offset + 1, 5);
47 | VolumeDescriptorVersion = src[offset + 6];
48 | }
49 |
50 | internal virtual void WriteTo(byte[] buffer, int offset)
51 | {
52 | Array.Clear(buffer, offset, IsoUtilities.SectorSize);
53 | buffer[offset] = (byte)VolumeDescriptorType;
54 | IsoUtilities.WriteAChars(buffer, offset + 1, 5, StandardIdentifier);
55 | buffer[offset + 6] = VolumeDescriptorVersion;
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/BootDeviceEmulation.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Iso9660
24 | {
25 | ///
26 | /// Enumeration of boot device emulation modes.
27 | ///
28 | public enum BootDeviceEmulation : byte
29 | {
30 | ///
31 | /// No emulation, the boot image is just loaded and executed.
32 | ///
33 | NoEmulation = 0x0,
34 |
35 | ///
36 | /// Emulates 1.2MB diskette image as drive A.
37 | ///
38 | Diskette1200KiB = 0x1,
39 |
40 | ///
41 | /// Emulates 1.44MB diskette image as drive A.
42 | ///
43 | Diskette1440KiB = 0x2,
44 |
45 | ///
46 | /// Emulates 2.88MB diskette image as drive A.
47 | ///
48 | Diskette2880KiB = 0x3,
49 |
50 | ///
51 | /// Emulates hard disk image as drive C.
52 | ///
53 | HardDisk = 0x4
54 | }
55 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/BootVolumeDescriptor.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using DiscUtils.Streams;
24 |
25 | namespace DiscUtils.Iso9660
26 | {
27 | internal class BootVolumeDescriptor : BaseVolumeDescriptor
28 | {
29 | public const string ElToritoSystemIdentifier = "EL TORITO SPECIFICATION";
30 |
31 | public BootVolumeDescriptor(uint catalogSector)
32 | : base(VolumeDescriptorType.Boot, 1)
33 | {
34 | CatalogSector = catalogSector;
35 | }
36 |
37 | public BootVolumeDescriptor(byte[] src, int offset)
38 | : base(src, offset)
39 | {
40 | SystemId = EndianUtilities.BytesToString(src, offset + 0x7, 0x20).TrimEnd('\0');
41 | CatalogSector = EndianUtilities.ToUInt32LittleEndian(src, offset + 0x47);
42 | }
43 |
44 | public uint CatalogSector { get; }
45 |
46 | public string SystemId { get; }
47 |
48 | internal override void WriteTo(byte[] buffer, int offset)
49 | {
50 | base.WriteTo(buffer, offset);
51 |
52 | EndianUtilities.StringToBytes(ElToritoSystemIdentifier, buffer, offset + 7, 0x20);
53 | EndianUtilities.WriteBytesLittleEndian(CatalogSector, buffer, offset + 0x47);
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/BootVolumeDescriptorRegion.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Iso9660
24 | {
25 | internal class BootVolumeDescriptorRegion : VolumeDescriptorDiskRegion
26 | {
27 | private readonly BootVolumeDescriptor _descriptor;
28 |
29 | public BootVolumeDescriptorRegion(BootVolumeDescriptor descriptor, long start)
30 | : base(start)
31 | {
32 | _descriptor = descriptor;
33 | }
34 |
35 | protected override byte[] GetBlockData()
36 | {
37 | byte[] buffer = new byte[IsoUtilities.SectorSize];
38 | _descriptor.WriteTo(buffer, 0);
39 | return buffer;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/BuildParameters.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 |
25 | namespace DiscUtils.Iso9660
26 | {
27 | internal class BuildParameters
28 | {
29 | public BuildParameters()
30 | {
31 | VolumeIdentifier = string.Empty;
32 | VolumeSetIdentifier = string.Empty;
33 | PublisherIdentifier = string.Empty;
34 | DataPreparerIdentifier = string.Empty;
35 | ApplicationIdentifier = string.Empty;
36 | UseJoliet = true;
37 | }
38 |
39 | public bool UseJoliet { get; set; }
40 |
41 | public string VolumeIdentifier { get; set; }
42 | public string SystemIdentifier { get; set; }
43 | public string VolumeSetIdentifier { get; set; }
44 | public string PublisherIdentifier { get; set; }
45 | public string DataPreparerIdentifier { get; set; }
46 | public string ApplicationIdentifier { get; set; }
47 | public uint LBAoffset { get; set; }
48 | public uint LastFileStartSector { get; set; }
49 | public uint? EndSector { get; set; }
50 | public DateTime? BuildDate { get; set; }
51 |
52 | }
53 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/FileFlags.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DiscUtils.Iso9660
4 | {
5 | [Flags]
6 | internal enum FileFlags : byte
7 | {
8 | None = 0x00,
9 | Hidden = 0x01,
10 | Directory = 0x02,
11 | AssociatedFile = 0x04,
12 | Record = 0x08,
13 | Protection = 0x10,
14 | MultiExtent = 0x80
15 | }
16 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/Iso9660Variant.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Iso9660
24 | {
25 | ///
26 | /// Enumeration of known file system variants.
27 | ///
28 | ///
29 | /// ISO9660 has a number of significant limitations, and over time
30 | /// multiple schemes have been devised for extending the standard
31 | /// to support the richer file system semantics typical of most modern
32 | /// operating systems. These variants differ functionally and (in the
33 | /// case of RockRidge) may represent a logically different directory
34 | /// hierarchy to that encoded in the vanilla iso9660 standard.
35 | /// Use this enum to control which variants to honour / prefer
36 | /// when accessing an ISO image.
37 | ///
38 | public enum Iso9660Variant
39 | {
40 | ///
41 | /// No known variant.
42 | ///
43 | None,
44 |
45 | ///
46 | /// Vanilla ISO9660.
47 | ///
48 | Iso9660,
49 |
50 | ///
51 | /// Joliet file system (Windows).
52 | ///
53 | Joliet,
54 |
55 | ///
56 | /// Rock Ridge (Unix).
57 | ///
58 | RockRidge
59 | }
60 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/IsoContext.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.Collections.Generic;
24 | using System.IO;
25 | using DiscUtils.Vfs;
26 |
27 | namespace DiscUtils.Iso9660
28 | {
29 | internal class IsoContext : VfsContext
30 | {
31 | public Stream DataStream { get; set; }
32 |
33 | public string RockRidgeIdentifier { get; set; }
34 |
35 | public bool SuspDetected { get; set; }
36 |
37 | public List SuspExtensions { get; set; }
38 |
39 | public int SuspSkipBytes { get; set; }
40 | public CommonVolumeDescriptor VolumeDescriptor { get; set; }
41 | }
42 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/PrimaryVolumeDescriptorRegion.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Iso9660
24 | {
25 | internal class PrimaryVolumeDescriptorRegion : VolumeDescriptorDiskRegion
26 | {
27 | private readonly PrimaryVolumeDescriptor _descriptor;
28 |
29 | public PrimaryVolumeDescriptorRegion(PrimaryVolumeDescriptor descriptor, long start)
30 | : base(start)
31 | {
32 | _descriptor = descriptor;
33 | }
34 |
35 | protected override byte[] GetBlockData()
36 | {
37 | byte[] buffer = new byte[IsoUtilities.SectorSize];
38 | _descriptor.WriteTo(buffer, 0);
39 | return buffer;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 | using System.Runtime.InteropServices;
3 |
4 | // Setting ComVisible to false makes the types in this assembly not visible
5 | // to COM components. If you need to access a type in this assembly from
6 | // COM, set the ComVisible attribute to true on that type.
7 |
8 | [assembly: ComVisible(false)]
9 |
10 | // The following GUID is for the ID of the typelib if this project is exposed to COM
11 |
12 | [assembly: Guid("1c0dd4d8-3db3-4630-8253-ea8566686225")]
13 | [assembly: InternalsVisibleTo("DiscUtils.Udf, PublicKey=002400000480000094000000060200000024000052534131000400000100010047ebec172a9831bb20fede77e17d784026ea7030d7055f2ae09576c71cebe77ebfab436d80580a4fcbba7242ff61bd52b686f5fe9d41fe7cd3e6c05b8a876eccf35b8ad7c5e3a6704295d7210b138d7280a6f72688419a65dd7a8612d66869f2e712c57c41fcc9196e4cb06d95d8e678f6967e65348c370405fb7eeb6aa1d3e8")]
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/RockRidge/ChildLinkSystemUseEntry.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Iso9660
24 | {
25 | internal sealed class ChildLinkSystemUseEntry : SystemUseEntry
26 | {
27 | public uint ChildDirLocation;
28 |
29 | public ChildLinkSystemUseEntry(string name, byte length, byte version, byte[] data, int offset)
30 | {
31 | CheckAndSetCommonProperties(name, length, version, 12, 1);
32 |
33 | ChildDirLocation = IsoUtilities.ToUInt32FromBoth(data, offset + 4);
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/RockRidge/PosixFileInfoSystemUseEntry.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Iso9660
24 | {
25 | internal sealed class PosixFileInfoSystemUseEntry : SystemUseEntry
26 | {
27 | public uint FileMode;
28 | public uint GroupId;
29 | public uint Inode;
30 | public uint NumLinks;
31 | public uint UserId;
32 |
33 | public PosixFileInfoSystemUseEntry(string name, byte length, byte version, byte[] data, int offset)
34 | {
35 | CheckAndSetCommonProperties(name, length, version, 36, 1);
36 |
37 | FileMode = IsoUtilities.ToUInt32FromBoth(data, offset + 4);
38 | NumLinks = IsoUtilities.ToUInt32FromBoth(data, offset + 12);
39 | UserId = IsoUtilities.ToUInt32FromBoth(data, offset + 20);
40 | GroupId = IsoUtilities.ToUInt32FromBoth(data, offset + 28);
41 | Inode = 0;
42 | if (length >= 44)
43 | {
44 | Inode = IsoUtilities.ToUInt32FromBoth(data, offset + 36);
45 | }
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/RockRidge/PosixNameSystemUseEntry.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using DiscUtils.Streams;
24 |
25 | namespace DiscUtils.Iso9660
26 | {
27 | internal sealed class PosixNameSystemUseEntry : SystemUseEntry
28 | {
29 | public byte Flags;
30 | public string NameData;
31 |
32 | public PosixNameSystemUseEntry(string name, byte length, byte version, byte[] data, int offset)
33 | {
34 | CheckAndSetCommonProperties(name, length, version, 5, 1);
35 |
36 | Flags = data[offset + 4];
37 | NameData = EndianUtilities.BytesToString(data, offset + 5, length - 5);
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/RockRidge/RockRidgeExtension.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.Text;
24 |
25 | namespace DiscUtils.Iso9660
26 | {
27 | internal sealed class RockRidgeExtension : SuspExtension
28 | {
29 | public RockRidgeExtension(string identifier)
30 | {
31 | Identifier = identifier;
32 | }
33 |
34 | public override string Identifier { get; }
35 |
36 | public override SystemUseEntry Parse(string name, byte length, byte version, byte[] data, int offset, Encoding encoding)
37 | {
38 | switch (name)
39 | {
40 | case "PX":
41 | return new PosixFileInfoSystemUseEntry(name, length, version, data, offset);
42 |
43 | case "NM":
44 | return new PosixNameSystemUseEntry(name, length, version, data, offset);
45 |
46 | case "CL":
47 | return new ChildLinkSystemUseEntry(name, length, version, data, offset);
48 |
49 | case "TF":
50 | return new FileTimeSystemUseEntry(name, length, version, data, offset);
51 |
52 | default:
53 | return new GenericSystemUseEntry(name, length, version, data, offset);
54 | }
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/SupplementaryVolumeDescriptorRegion.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Iso9660
24 | {
25 | internal class SupplementaryVolumeDescriptorRegion : VolumeDescriptorDiskRegion
26 | {
27 | private readonly SupplementaryVolumeDescriptor _descriptor;
28 |
29 | public SupplementaryVolumeDescriptorRegion(SupplementaryVolumeDescriptor descriptor, long start)
30 | : base(start)
31 | {
32 | _descriptor = descriptor;
33 | }
34 |
35 | protected override byte[] GetBlockData()
36 | {
37 | byte[] buffer = new byte[IsoUtilities.SectorSize];
38 | _descriptor.WriteTo(buffer, 0);
39 | return buffer;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/Susp/ContinuationSystemUseEntry.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Iso9660
24 | {
25 | internal sealed class ContinuationSystemUseEntry : SystemUseEntry
26 | {
27 | public uint Block;
28 | public uint BlockOffset;
29 | public uint Length;
30 |
31 | public ContinuationSystemUseEntry(string name, byte length, byte version, byte[] data, int offset)
32 | {
33 | CheckAndSetCommonProperties(name, length, version, 28, 1);
34 |
35 | Block = IsoUtilities.ToUInt32FromBoth(data, offset + 4);
36 | BlockOffset = IsoUtilities.ToUInt32FromBoth(data, offset + 12);
37 | Length = IsoUtilities.ToUInt32FromBoth(data, offset + 20);
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/Susp/ExtensionSelectSystemUseEntry.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Iso9660
24 | {
25 | internal sealed class ExtensionSelectSystemUseEntry : SystemUseEntry
26 | {
27 | public byte SelectedExtension;
28 |
29 | public ExtensionSelectSystemUseEntry(string name, byte length, byte version, byte[] data, int offset)
30 | {
31 | CheckAndSetCommonProperties(name, length, version, 5, 1);
32 |
33 | SelectedExtension = data[offset + 4];
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/Susp/ExtensionSystemUseEntry.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.IO;
24 | using System.Text;
25 |
26 | namespace DiscUtils.Iso9660
27 | {
28 | internal sealed class ExtensionSystemUseEntry : SystemUseEntry
29 | {
30 | public string ExtensionDescriptor;
31 | public string ExtensionIdentifier;
32 | public string ExtensionSource;
33 | public byte ExtensionVersion;
34 |
35 | public ExtensionSystemUseEntry(string name, byte length, byte version, byte[] data, int offset, Encoding encoding)
36 | {
37 | CheckAndSetCommonProperties(name, length, version, 8, 1);
38 |
39 | int lenId = data[offset + 4];
40 | int lenDescriptor = data[offset + 5];
41 | int lenSource = data[offset + 6];
42 |
43 | ExtensionVersion = data[offset + 7];
44 |
45 | if (length < 8 + lenId + lenDescriptor + lenSource)
46 | {
47 | throw new InvalidDataException("Invalid SUSP ER entry - too short, only " + length + " bytes - expected: " +
48 | (8 + lenId + lenDescriptor + lenSource));
49 | }
50 |
51 | ExtensionIdentifier = IsoUtilities.ReadChars(data, offset + 8, lenId, encoding);
52 | ExtensionDescriptor = IsoUtilities.ReadChars(data, offset + 8 + lenId, lenDescriptor, encoding);
53 | ExtensionSource = IsoUtilities.ReadChars(data, offset + 8 + lenId + lenDescriptor, lenSource, encoding);
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/Susp/GenericSuspExtension.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.Text;
24 |
25 | namespace DiscUtils.Iso9660
26 | {
27 | internal sealed class GenericSuspExtension : SuspExtension
28 | {
29 | public GenericSuspExtension(string identifier)
30 | {
31 | Identifier = identifier;
32 | }
33 |
34 | public override string Identifier { get; }
35 |
36 | public override SystemUseEntry Parse(string name, byte length, byte version, byte[] data, int offset, Encoding encoding)
37 | {
38 | return new GenericSystemUseEntry(name, length, version, data, offset);
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/Susp/GenericSystemUseEntry.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 |
25 | namespace DiscUtils.Iso9660
26 | {
27 | internal sealed class GenericSystemUseEntry : SystemUseEntry
28 | {
29 | public byte[] Data;
30 |
31 | public GenericSystemUseEntry(string name, byte length, byte version, byte[] data, int offset)
32 | {
33 | CheckAndSetCommonProperties(name, length, version, 4, 0xFF);
34 |
35 | Data = new byte[length - 4];
36 | Array.Copy(data, offset + 4, Data, 0, length - 4);
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/Susp/PaddingSystemUseEntry.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Iso9660
24 | {
25 | internal sealed class PaddingSystemUseEntry : SystemUseEntry
26 | {
27 | public PaddingSystemUseEntry(string name, byte length, byte version)
28 | {
29 | CheckAndSetCommonProperties(name, length, version, 4, 1);
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/Susp/SharingProtocolSystemUseEntry.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.IO;
24 |
25 | namespace DiscUtils.Iso9660
26 | {
27 | internal sealed class SharingProtocolSystemUseEntry : SystemUseEntry
28 | {
29 | public byte SystemAreaSkip;
30 |
31 | public SharingProtocolSystemUseEntry(string name, byte length, byte version, byte[] data, int offset)
32 | {
33 | CheckAndSetCommonProperties(name, length, version, 7, 1);
34 |
35 | if (data[offset + 4] != 0xBE || data[offset + 5] != 0xEF)
36 | {
37 | throw new InvalidDataException("Invalid SUSP SP entry - invalid checksum bytes");
38 | }
39 |
40 | SystemAreaSkip = data[offset + 6];
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/Susp/SuspExtension.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.Text;
24 |
25 | namespace DiscUtils.Iso9660
26 | {
27 | internal abstract class SuspExtension
28 | {
29 | public abstract string Identifier { get; }
30 |
31 | public abstract SystemUseEntry Parse(string name, byte length, byte version, byte[] data, int offset, Encoding encoding);
32 | }
33 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/VolumeDescriptorDiskRegion.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using DiscUtils.Streams;
25 |
26 | namespace DiscUtils.Iso9660
27 | {
28 | internal abstract class VolumeDescriptorDiskRegion : BuilderExtent
29 | {
30 | private byte[] _readCache;
31 |
32 | public VolumeDescriptorDiskRegion(long start)
33 | : base(start, IsoUtilities.SectorSize) {}
34 |
35 | public override void Dispose() {}
36 |
37 | public override void PrepareForRead()
38 | {
39 | _readCache = GetBlockData();
40 | }
41 |
42 | public override int Read(long diskOffset, byte[] buffer, int offset, int count)
43 | {
44 | long relPos = diskOffset - Start;
45 |
46 | int numRead = (int)Math.Min(count, _readCache.Length - relPos);
47 |
48 | Array.Copy(_readCache, (int)relPos, buffer, offset, numRead);
49 |
50 | return numRead;
51 | }
52 |
53 | public override void DisposeReadState()
54 | {
55 | _readCache = null;
56 | }
57 |
58 | protected abstract byte[] GetBlockData();
59 | }
60 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/VolumeDescriptorSetTerminator.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Iso9660
24 | {
25 | internal class VolumeDescriptorSetTerminator : BaseVolumeDescriptor
26 | {
27 | public VolumeDescriptorSetTerminator()
28 | : base(VolumeDescriptorType.SetTerminator, 1) {}
29 | }
30 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/VolumeDescriptorSetTerminatorRegion.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Iso9660
24 | {
25 | internal class VolumeDescriptorSetTerminatorRegion : VolumeDescriptorDiskRegion
26 | {
27 | private readonly VolumeDescriptorSetTerminator _descriptor;
28 |
29 | public VolumeDescriptorSetTerminatorRegion(VolumeDescriptorSetTerminator descriptor, long start)
30 | : base(start)
31 | {
32 | _descriptor = descriptor;
33 | }
34 |
35 | protected override byte[] GetBlockData()
36 | {
37 | byte[] buffer = new byte[IsoUtilities.SectorSize];
38 | _descriptor.WriteTo(buffer, 0);
39 | return buffer;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Iso9660/VolumeDescriptorType.cs:
--------------------------------------------------------------------------------
1 | namespace DiscUtils.Iso9660
2 | {
3 | internal enum VolumeDescriptorType : byte
4 | {
5 | Boot = 0,
6 | Primary = 1,
7 | Supplementary = 2,
8 | Partition = 3,
9 | SetTerminator = 255
10 | }
11 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Block/Block.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Streams
24 | {
25 | public class Block
26 | {
27 | public int Available { get; set; }
28 |
29 | public byte[] Data { get; set; }
30 |
31 | public long Position { get; set; }
32 |
33 | public bool Equals(Block other)
34 | {
35 | return Position == other.Position;
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Buffer/IMappedBuffer.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Streams
24 | {
25 | public interface IMappedBuffer : IBuffer
26 | {
27 | long MapPosition(long position);
28 | }
29 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Builder/BuilderBufferExtentSource.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Streams
24 | {
25 | public class BuilderBufferExtentSource : BuilderExtentSource
26 | {
27 | private readonly byte[] _buffer;
28 |
29 | public BuilderBufferExtentSource(byte[] buffer)
30 | {
31 | _buffer = buffer;
32 | }
33 |
34 | public override BuilderExtent Fix(long pos)
35 | {
36 | return new BuilderBufferExtent(pos, _buffer);
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Builder/BuilderBytesExtent.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 |
25 | namespace DiscUtils.Streams
26 | {
27 | public class BuilderBytesExtent : BuilderExtent
28 | {
29 | protected byte[] _data;
30 |
31 | public BuilderBytesExtent(long start, byte[] data)
32 | : base(start, data.Length)
33 | {
34 | _data = data;
35 | }
36 |
37 | protected BuilderBytesExtent(long start, long length)
38 | : base(start, length) {}
39 |
40 | public override void Dispose() {}
41 |
42 | public override void PrepareForRead() {}
43 |
44 | public override int Read(long diskOffset, byte[] block, int offset, int count)
45 | {
46 | int start = (int)Math.Min(diskOffset - Start, _data.Length);
47 | int numRead = Math.Min(count, _data.Length - start);
48 |
49 | Array.Copy(_data, start, block, offset, numRead);
50 |
51 | return numRead;
52 | }
53 |
54 | public override void DisposeReadState() {}
55 | }
56 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Builder/BuilderExtent.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using System.Collections.Generic;
25 |
26 | namespace DiscUtils.Streams
27 | {
28 | public abstract class BuilderExtent : IDisposable
29 | {
30 | public BuilderExtent(long start, long length)
31 | {
32 | Start = start;
33 | Length = length;
34 | }
35 |
36 | public long Length { get; }
37 |
38 | public long Start { get; set; }
39 |
40 | ///
41 | /// Gets the parts of the stream that are stored.
42 | ///
43 | /// This may be an empty enumeration if all bytes are zero.
44 | public virtual IEnumerable StreamExtents
45 | {
46 | get { return new[] { new StreamExtent(Start, Length) }; }
47 | }
48 |
49 | public abstract void Dispose();
50 |
51 | public abstract void PrepareForRead();
52 |
53 | public abstract int Read(long diskOffset, byte[] block, int offset, int count);
54 |
55 | public abstract void DisposeReadState();
56 | }
57 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Builder/BuilderExtentSource.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Streams
24 | {
25 | public abstract class BuilderExtentSource
26 | {
27 | public abstract BuilderExtent Fix(long pos);
28 | }
29 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Builder/BuilderSparseStreamExtent.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.Collections.Generic;
24 |
25 | namespace DiscUtils.Streams
26 | {
27 | public class BuilderSparseStreamExtent : BuilderExtent
28 | {
29 | private readonly Ownership _ownership;
30 | private SparseStream _stream;
31 |
32 | public BuilderSparseStreamExtent(long start, SparseStream stream)
33 | : this(start, stream, Ownership.None) {}
34 |
35 | public BuilderSparseStreamExtent(long start, SparseStream stream, Ownership ownership)
36 | : base(start, stream.Length)
37 | {
38 | _stream = stream;
39 | _ownership = ownership;
40 | }
41 |
42 | public override IEnumerable StreamExtents
43 | {
44 | get { return StreamExtent.Offset(_stream.Extents, Start); }
45 | }
46 |
47 | public override void Dispose()
48 | {
49 | if (_stream != null && _ownership == Ownership.Dispose)
50 | {
51 | _stream.Dispose();
52 | _stream = null;
53 | }
54 | }
55 |
56 | public override void PrepareForRead() {}
57 |
58 | public override int Read(long diskOffset, byte[] block, int offset, int count)
59 | {
60 | _stream.Position = diskOffset - Start;
61 | return _stream.Read(block, offset, count);
62 | }
63 |
64 | public override void DisposeReadState() {}
65 | }
66 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Builder/BuilderStreamExtent.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.IO;
24 |
25 | namespace DiscUtils.Streams
26 | {
27 | public class BuilderStreamExtent : BuilderExtent
28 | {
29 | private readonly Ownership _ownership;
30 | private Stream _source;
31 |
32 | public BuilderStreamExtent(long start, Stream source)
33 | : this(start, source, Ownership.None) {}
34 |
35 | public BuilderStreamExtent(long start, Stream source, Ownership ownership)
36 | : base(start, source.Length)
37 | {
38 | _source = source;
39 | _ownership = ownership;
40 | }
41 |
42 | public override void Dispose()
43 | {
44 | if (_source != null && _ownership == Ownership.Dispose)
45 | {
46 | _source.Dispose();
47 | _source = null;
48 | }
49 | }
50 |
51 | public override void PrepareForRead() {}
52 |
53 | public override int Read(long diskOffset, byte[] block, int offset, int count)
54 | {
55 | _source.Position = diskOffset - Start;
56 | return _source.Read(block, offset, count);
57 | }
58 |
59 | public override void DisposeReadState() {}
60 | }
61 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Builder/BuilderStreamExtentSource.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.IO;
24 |
25 | namespace DiscUtils.Streams
26 | {
27 | public class BuilderStreamExtentSource : BuilderExtentSource
28 | {
29 | private readonly Stream _stream;
30 |
31 | public BuilderStreamExtentSource(Stream stream)
32 | {
33 | _stream = stream;
34 | }
35 |
36 | public override BuilderExtent Fix(long pos)
37 | {
38 | return new BuilderStreamExtent(pos, _stream);
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Builder/PassthroughStreamBuilder.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.Collections.Generic;
24 | using System.IO;
25 |
26 | namespace DiscUtils.Streams
27 | {
28 | public class PassthroughStreamBuilder : StreamBuilder
29 | {
30 | private readonly Stream _stream;
31 |
32 | public PassthroughStreamBuilder(Stream stream)
33 | {
34 | _stream = stream;
35 | }
36 |
37 | protected override List FixExtents(out long totalLength)
38 | {
39 | _stream.Position = 0;
40 | List result = new List();
41 | result.Add(new BuilderStreamExtent(0, _stream));
42 | totalLength = _stream.Length;
43 | return result;
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/CircularStream.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2013, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 |
25 | namespace DiscUtils.Streams
26 | {
27 | ///
28 | /// Represents a stream that is circular, so reads and writes off the end of the stream wrap.
29 | ///
30 | public sealed class CircularStream : WrappingStream
31 | {
32 | public CircularStream(SparseStream toWrap, Ownership ownership)
33 | : base(toWrap, ownership) {}
34 |
35 | public override int Read(byte[] buffer, int offset, int count)
36 | {
37 | WrapPosition();
38 |
39 | int read = base.Read(buffer, offset, (int)Math.Min(Length - Position, count));
40 |
41 | WrapPosition();
42 |
43 | return read;
44 | }
45 |
46 | public override void Write(byte[] buffer, int offset, int count)
47 | {
48 | WrapPosition();
49 |
50 | int totalWritten = 0;
51 | while (totalWritten < count)
52 | {
53 | int toWrite = (int)Math.Min(count - totalWritten, Length - Position);
54 |
55 | base.Write(buffer, offset + totalWritten, toWrite);
56 |
57 | WrapPosition();
58 |
59 | totalWritten += toWrite;
60 | }
61 | }
62 |
63 | private void WrapPosition()
64 | {
65 | long pos = Position;
66 | long length = Length;
67 |
68 | if (pos >= length)
69 | {
70 | Position = pos % length;
71 | }
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/IByteArraySerializable.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Streams
24 | {
25 | ///
26 | /// Common interface for reading structures to/from byte arrays.
27 | ///
28 | public interface IByteArraySerializable
29 | {
30 | ///
31 | /// Gets the total number of bytes the structure occupies.
32 | ///
33 | int Size { get; }
34 |
35 | ///
36 | /// Reads the structure from a byte array.
37 | ///
38 | /// The buffer to read from.
39 | /// The buffer offset to start reading from.
40 | /// The number of bytes read.
41 | int ReadFrom(byte[] buffer, int offset);
42 |
43 | ///
44 | /// Writes a structure to a byte array.
45 | ///
46 | /// The buffer to write to.
47 | /// The buffer offset to start writing at.
48 | void WriteTo(byte[] buffer, int offset);
49 | }
50 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/LengthWrappingStream.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2017, Bianco Veigel
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Streams
24 | {
25 | ///
26 | /// Represents a stream with a specified length
27 | ///
28 | ///
29 | /// since the wrapped stream may not support
30 | /// there is no validation of the specified length
31 | ///
32 | public class LengthWrappingStream : WrappingStream
33 | {
34 | private readonly long _length;
35 |
36 | public LengthWrappingStream(SparseStream toWrap, long length, Ownership ownership)
37 | : base(toWrap, ownership)
38 | {
39 | _length = length;
40 | }
41 |
42 | public override long Length
43 | {
44 | get { return _length; }
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | // Setting ComVisible to false makes the types in this assembly not visible
4 | // to COM components. If you need to access a type in this assembly from
5 | // COM, set the ComVisible attribute to true on that type.
6 |
7 | [assembly: ComVisible(false)]
8 |
9 | // The following GUID is for the ID of the typelib if this project is exposed to COM
10 |
11 | [assembly: Guid("cf8c37c3-69f4-40ef-a3a1-4d1dcc332058")]
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/PumpProgressEventArgs.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 |
25 | namespace DiscUtils.Streams
26 | {
27 | ///
28 | /// Event arguments indicating progress on pumping a stream.
29 | ///
30 | public class PumpProgressEventArgs : EventArgs
31 | {
32 | ///
33 | /// Gets or sets the number of bytes read from InputStream.
34 | ///
35 | public long BytesRead { get; set; }
36 |
37 | ///
38 | /// Gets or sets the number of bytes written to OutputStream.
39 | ///
40 | public long BytesWritten { get; set; }
41 |
42 | ///
43 | /// Gets or sets the absolute position in OutputStream.
44 | ///
45 | public long DestinationPosition { get; set; }
46 |
47 | ///
48 | /// Gets or sets the absolute position in InputStream.
49 | ///
50 | public long SourcePosition { get; set; }
51 | }
52 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/ReaderWriter/BigEndianDataReader.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using System.IO;
25 |
26 | namespace DiscUtils.Streams
27 | {
28 | public class BigEndianDataReader : DataReader
29 | {
30 | public BigEndianDataReader(Stream stream)
31 | : base(stream) {}
32 |
33 | public override ushort ReadUInt16()
34 | {
35 | ReadToBuffer(sizeof(UInt16));
36 | return EndianUtilities.ToUInt16BigEndian(_buffer, 0);
37 | }
38 |
39 | public override int ReadInt32()
40 | {
41 | ReadToBuffer(sizeof(Int32));
42 | return EndianUtilities.ToInt32BigEndian(_buffer, 0);
43 | }
44 |
45 | public override uint ReadUInt32()
46 | {
47 | ReadToBuffer(sizeof(UInt32));
48 | return EndianUtilities.ToUInt32BigEndian(_buffer, 0);
49 | }
50 |
51 | public override long ReadInt64()
52 | {
53 | ReadToBuffer(sizeof(Int64));
54 | return EndianUtilities.ToInt64BigEndian(_buffer, 0);
55 | }
56 |
57 | public override ulong ReadUInt64()
58 | {
59 | ReadToBuffer(sizeof(UInt64));
60 | return EndianUtilities.ToUInt64BigEndian(_buffer, 0);
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/ReaderWriter/BigEndianDataWriter.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using System.IO;
25 |
26 | namespace DiscUtils.Streams
27 | {
28 | public class BigEndianDataWriter : DataWriter
29 | {
30 | public BigEndianDataWriter(Stream stream)
31 | : base(stream) {}
32 |
33 | public override void Write(ushort value)
34 | {
35 | EnsureBuffer();
36 | EndianUtilities.WriteBytesBigEndian(value, _buffer, 0);
37 | FlushBuffer(sizeof(UInt16));
38 | }
39 |
40 | public override void Write(int value)
41 | {
42 | EnsureBuffer();
43 | EndianUtilities.WriteBytesBigEndian(value, _buffer, 0);
44 | FlushBuffer(sizeof(Int32));
45 | }
46 |
47 | public override void Write(uint value)
48 | {
49 | EnsureBuffer();
50 | EndianUtilities.WriteBytesBigEndian(value, _buffer, 0);
51 | FlushBuffer(sizeof(UInt32));
52 | }
53 |
54 | public override void Write(long value)
55 | {
56 | EnsureBuffer();
57 | EndianUtilities.WriteBytesBigEndian(value, _buffer, 0);
58 | FlushBuffer(sizeof(Int64));
59 | }
60 |
61 | public override void Write(ulong value)
62 | {
63 | EnsureBuffer();
64 | EndianUtilities.WriteBytesBigEndian(value, _buffer, 0);
65 | FlushBuffer(sizeof(UInt64));
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/ReaderWriter/DataWriter.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using System.IO;
25 |
26 | namespace DiscUtils.Streams
27 | {
28 | public abstract class DataWriter
29 | {
30 | private const int _bufferSize = sizeof(UInt64);
31 |
32 | protected readonly Stream _stream;
33 |
34 | protected byte[] _buffer;
35 |
36 | public DataWriter(Stream stream)
37 | {
38 | _stream = stream;
39 | }
40 |
41 | public abstract void Write(ushort value);
42 |
43 | public abstract void Write(int value);
44 |
45 | public abstract void Write(uint value);
46 |
47 | public abstract void Write(long value);
48 |
49 | public abstract void Write(ulong value);
50 |
51 | public virtual void WriteBytes(byte[] value, int offset, int count)
52 | {
53 | _stream.Write(value, offset, count);
54 | }
55 |
56 | public virtual void WriteBytes(byte[] value)
57 | {
58 | _stream.Write(value, 0, value.Length);
59 | }
60 |
61 | public virtual void Flush()
62 | {
63 | _stream.Flush();
64 | }
65 |
66 | protected void EnsureBuffer()
67 | {
68 | if (_buffer == null)
69 | {
70 | _buffer = new byte[_bufferSize];
71 | }
72 | }
73 |
74 | protected void FlushBuffer(int count)
75 | {
76 | _stream.Write(_buffer, 0, count);
77 | }
78 | }
79 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/ReaderWriter/LittleEndianDataReader.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System;
24 | using System.IO;
25 |
26 | namespace DiscUtils.Streams
27 | {
28 | ///
29 | /// Class for reading little-endian data from a stream.
30 | ///
31 | public class LittleEndianDataReader : DataReader
32 | {
33 | public LittleEndianDataReader(Stream stream)
34 | : base(stream) {}
35 |
36 | public override ushort ReadUInt16()
37 | {
38 | ReadToBuffer(sizeof(UInt16));
39 | return EndianUtilities.ToUInt16LittleEndian(_buffer, 0);
40 | }
41 |
42 | public override int ReadInt32()
43 | {
44 | ReadToBuffer(sizeof(Int32));
45 | return EndianUtilities.ToInt32LittleEndian(_buffer, 0);
46 | }
47 |
48 | public override uint ReadUInt32()
49 | {
50 | ReadToBuffer(sizeof(UInt32));
51 | return EndianUtilities.ToUInt32LittleEndian(_buffer, 0);
52 | }
53 |
54 | public override long ReadInt64()
55 | {
56 | ReadToBuffer(sizeof(Int64));
57 | return EndianUtilities.ToInt64LittleEndian(_buffer, 0);
58 | }
59 |
60 | public override ulong ReadUInt64()
61 | {
62 | ReadToBuffer(sizeof(UInt64));
63 | return EndianUtilities.ToUInt64LittleEndian(_buffer, 0);
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/SparseMemoryStream.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | using System.IO;
24 |
25 | namespace DiscUtils.Streams
26 | {
27 | ///
28 | /// Provides a sparse equivalent to MemoryStream.
29 | ///
30 | public sealed class SparseMemoryStream : BufferStream
31 | {
32 | ///
33 | /// Initializes a new instance of the SparseMemoryStream class.
34 | ///
35 | /// The created instance permits read and write access.
36 | public SparseMemoryStream()
37 | : base(new SparseMemoryBuffer(16 * 1024), FileAccess.ReadWrite) {}
38 |
39 | ///
40 | /// Initializes a new instance of the SparseMemoryStream class.
41 | ///
42 | /// The buffer to use.
43 | /// The access permitted to clients.
44 | public SparseMemoryStream(SparseMemoryBuffer buffer, FileAccess access)
45 | : base(buffer, access) {}
46 | }
47 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/SparseStreamOpenDelegate.cs:
--------------------------------------------------------------------------------
1 | namespace DiscUtils.Streams
2 | {
3 | public delegate SparseStream SparseStreamOpenDelegate();
4 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Util/Ownership.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Streams
24 | {
25 | ///
26 | /// Enumeration used to indicate transfer of disposable objects.
27 | ///
28 | public enum Ownership
29 | {
30 | ///
31 | /// Indicates there is no transfer of ownership.
32 | ///
33 | None,
34 |
35 | ///
36 | /// Indicates ownership of the stream is transfered, the owner should dispose of the stream when appropriate.
37 | ///
38 | Dispose
39 | }
40 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/DiscUtils.Streams/Util/Sizes.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2008-2011, Kenneth Bell
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a
5 | // copy of this software and associated documentation files (the "Software"),
6 | // to deal in the Software without restriction, including without limitation
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | // and/or sell copies of the Software, and to permit persons to whom the
9 | // Software is furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | // DEALINGS IN THE SOFTWARE.
21 | //
22 |
23 | namespace DiscUtils.Streams
24 | {
25 | public static class Sizes
26 | {
27 | public const long OneKiB = 1024;
28 | public const long OneMiB = 1024 * OneKiB;
29 | public const long OneGiB = 1024 * OneMiB;
30 |
31 | public const int Sector = 512;
32 | }
33 | }
--------------------------------------------------------------------------------
/DiscUtilsGD/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Portions Copyright (c) 2008-2011, Kenneth Bell
2 | Portions Copyright (c) 2014, Quamotion
3 | Portions Copyright (c) 2014-2024, Paul Kratt
4 | Additional contributors may be missing from here because they never added
5 | themselves to this file; see upstream DiscUtils commit history for details.
6 |
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a
9 | copy of this software and associated documentation files (the "Software"),
10 | to deal in the Software without restriction, including without limitation
11 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 | and/or sell copies of the Software, and to permit persons to whom the
13 | Software is furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in
16 | all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 | DEALINGS IN THE SOFTWARE.
25 |
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2.Gtk/GDIBuilder2.Gtk.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net8.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2.Gtk/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Eto.Forms;
3 |
4 | namespace GDIBuilder2.Gtk
5 | {
6 | class Program
7 | {
8 | [STAThread]
9 | public static void Main(string[] args)
10 | {
11 | new Application(Eto.Platforms.Gtk).Run(new MainForm());
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2.Mac/GDIBuilder2.Mac.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 |
7 | osx-x64;osx-arm64
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2.Mac/Icon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sappharad/GDIbuilder/4a3fe4531288d81dad8eaabb9106d810c9ad69c7/GDIBuilderUI/GDIBuilder2.Mac/Icon.icns
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2.Mac/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleName
6 | GDIBuilder
7 | CFBundleIdentifier
8 | com.sappharad.GDIBuilder
9 | CFBundleShortVersionString
10 | 2.1.1
11 | LSMinimumSystemVersion
12 | 10.15
13 | CFBundleDevelopmentRegion
14 | en
15 | NSHumanReadableCopyright
16 |
17 | CFBundleIconFile
18 | Icon.icns
19 |
20 |
21 |
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2.Mac/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Eto.Forms;
3 |
4 | namespace GDIBuilder2.Mac
5 | {
6 | class Program
7 | {
8 | [STAThread]
9 | public static void Main(string[] args)
10 | {
11 | Eto.Style.Add(null, handler => handler.AllowClosingMainForm = true);
12 | new Application(Eto.Platforms.Mac64).Run(new MainForm());
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2.Mac/dotnet.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.cs.disable-library-validation
6 |
7 | com.apple.security.cs.disable-executable-page-protection
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2.Wpf/BlankMedia.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sappharad/GDIbuilder/4a3fe4531288d81dad8eaabb9106d810c9ad69c7/GDIBuilderUI/GDIBuilder2.Wpf/BlankMedia.ico
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2.Wpf/GDIBuilder2.Wpf.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net8.0-windows
6 | BlankMedia.ico
7 | GDIBuilder2.Wpf.Program
8 | True
9 | 2.1.1.0
10 | 2.1.1.0
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2.Wpf/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Eto.Forms;
3 |
4 | namespace GDIBuilder2.Wpf
5 | {
6 | class Program
7 | {
8 | [STAThread]
9 | public static void Main(string[] args)
10 | {
11 | new Application(Eto.Platforms.Wpf).Run(new MainForm());
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2/BuildResultDialog.cs:
--------------------------------------------------------------------------------
1 | using Eto.Drawing;
2 | using Eto.Forms;
3 |
4 | namespace GDIBuilder2
5 | {
6 | public class BuildResultDialog : Dialog
7 | {
8 | #region Controls
9 | private Label lblIntro = new Label { Text = "GD-ROM build complete. Here is the new track info for the GDI file:" };
10 | private TextBox txtResult = new TextBox();
11 | private Button btnOK = new Button { Text = "OK" };
12 | private Label lblOutro = new Label { Text = "If disc.gdi exists in the output folder, this was updated for you automatically." };
13 | #endregion
14 |
15 | public BuildResultDialog(string text)
16 | {
17 | txtResult.Text = text;
18 | InitializeComponent();
19 | }
20 |
21 | #region Component Init
22 | private void InitializeComponent()
23 | {
24 | DisplayMode = DialogDisplayMode.Attached;
25 | Title = "Finished";
26 | MinimumSize = new Size(430, 200);
27 | Padding = new Padding(4, 3, 4, 3);
28 | btnOK.Click += (sender, e) =>
29 | {
30 | Close();
31 | };
32 | DefaultButton = btnOK;
33 |
34 | DynamicLayout completeLayout = new DynamicLayout() { Padding = 6 };
35 | completeLayout.Add(lblIntro);
36 | completeLayout.Add(txtResult, true, true);
37 | completeLayout.Add(lblOutro);
38 | completeLayout.Add(new StackLayout(null, btnOK)
39 | { Orientation = Orientation.Horizontal, Spacing = 5, Padding = 6 });
40 | Content = completeLayout;
41 | }
42 | #endregion
43 | }
44 | }
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2/GDIBuilder2.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2/file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sappharad/GDIbuilder/4a3fe4531288d81dad8eaabb9106d810c9ad69c7/GDIBuilderUI/GDIBuilder2/file.png
--------------------------------------------------------------------------------
/GDIBuilderUI/GDIBuilder2/folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sappharad/GDIbuilder/4a3fe4531288d81dad8eaabb9106d810c9ad69c7/GDIBuilderUI/GDIBuilder2/folder.png
--------------------------------------------------------------------------------
/buildgdi/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // General Information about an assembly is controlled through the following
5 | // set of attributes. Change these attribute values to modify the information
6 | // associated with an assembly.
7 | [assembly: AssemblyTitle("buildgdi")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("buildgdi")]
12 | [assembly: AssemblyCopyright("Copyright © 2014-2024")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("1f403826-d284-4cfe-a90b-d84bc02b1daf")]
23 |
24 | // Version information for an assembly consists of the following four values:
25 | //
26 | // Major Version
27 | // Minor Version
28 | // Build Number
29 | // Revision
30 | //
31 | // You can specify all the values or you can default the Build and Revision Numbers
32 | // by using the '*' as shown below:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.9.94.0")]
35 | [assembly: AssemblyFileVersion("1.9.94.0")]
36 |
--------------------------------------------------------------------------------
/buildgdi/buildgdi.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | x86
5 | Exe
6 | false
7 | buildgdi.Program
8 |
9 |
10 | true
11 |
12 |
13 | true
14 | true
15 | false
16 |
17 |
18 | true
19 | true
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/buildgdi/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------