Move all interfaces, extents, interop and metadata to DiscImageChef.CommonTypes.

This commit is contained in:
2018-06-25 19:08:16 +01:00
parent 7187ce2e36
commit 2af10e0a0b
34 changed files with 9254 additions and 0 deletions

321
Structs/Filesystems.cs Normal file
View File

@@ -0,0 +1,321 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Structs.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : DiscImageChef filesystem plugins.
//
// --[ Description ] ----------------------------------------------------------
//
// Contains enumerations and structures of common usage by filesystem
// plugins.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System;
using System.Runtime.InteropServices;
namespace DiscImageChef.CommonTypes.Structs
{
/// <summary>
/// File attributes.
/// </summary>
[Flags]
public enum FileAttributes : ulong
{
/// <summary>File is an alias (Mac OS)</summary>
Alias = 0x01,
/// <summary>Indicates that the file can only be writable appended</summary>
AppendOnly = 0x02,
/// <summary>File is candidate for archival/backup</summary>
Archive = 0x04,
/// <summary>File is a block device</summary>
BlockDevice = 0x08,
/// <summary>File is stored on filesystem block units instead of device sectors</summary>
BlockUnits = 0x10,
/// <summary>Directory is a bundle or file contains a BNDL resource</summary>
Bundle = 0x20,
/// <summary>File is a char device</summary>
CharDevice = 0x40,
/// <summary>File is compressed</summary>
Compressed = 0x80,
/// <summary>File is compressed and should not be uncompressed on read</summary>
CompressedRaw = 0x100,
/// <summary>File has compression errors</summary>
CompressionError = 0x200,
/// <summary>Compressed file is dirty</summary>
CompressionDirty = 0x400,
/// <summary>File is a device</summary>
Device = 0x800,
/// <summary>File is a directory</summary>
Directory = 0x1000,
/// <summary>File is encrypted</summary>
Encrypted = 0x2000,
/// <summary>File is stored on disk using extents</summary>
Extents = 0x4000,
/// <summary>File is a FIFO</summary>
FIFO = 0x8000,
/// <summary>File is a normal file</summary>
File = 0x10000,
/// <summary>File is a Mac OS file containing desktop databases that has already been added to the desktop database</summary>
HasBeenInited = 0x20000,
/// <summary>File contains an icon resource / EA</summary>
HasCustomIcon = 0x40000,
/// <summary>File is a Mac OS extension or control panel lacking INIT resources</summary>
HasNoINITs = 0x80000,
/// <summary>File is hidden/invisible</summary>
Hidden = 0x100000,
/// <summary>File cannot be written, deleted, modified or linked to</summary>
Immutable = 0x200000,
/// <summary>Directory is indexed using hashed trees</summary>
IndexedDirectory = 0x400000,
/// <summary>File contents are stored alongside its inode (or equivalent)</summary>
Inline = 0x800000,
/// <summary>File contains integrity checks</summary>
IntegrityStream = 0x1000000,
/// <summary>File is on desktop</summary>
IsOnDesk = 0x2000000,
/// <summary>File changes are written to filesystem journal before being written to file itself</summary>
Journaled = 0x4000000,
/// <summary>Access time will not be modified</summary>
NoAccessTime = 0x8000000,
/// <summary>File will not be subject to copy-on-write</summary>
NoCopyOnWrite = 0x10000000,
/// <summary>File will not be backed up</summary>
NoDump = 0x20000000,
/// <summary>File contents should not be scrubbed</summary>
NoScrub = 0x40000000,
/// <summary>File contents should not be indexed</summary>
NotIndexed = 0x80000000,
/// <summary>File is offline</summary>
Offline = 0x100000000,
/// <summary>File is password protected, but contents are not encrypted on disk</summary>
Password = 0x200000000,
/// <summary>File is read-only</summary>
ReadOnly = 0x400000000,
/// <summary>File is a reparse point</summary>
ReparsePoint = 0x800000000,
/// <summary>When file is removed its content will be overwritten with zeroes</summary>
Secured = 0x1000000000,
/// <summary>File contents are sparse</summary>
Sparse = 0x2000000000,
/// <summary>File is a shadow (OS/2)</summary>
Shadow = 0x4000000000,
/// <summary>File is shared</summary>
Shared = 0x8000000000,
/// <summary>File is a stationery</summary>
Stationery = 0x10000000000,
/// <summary>File is a symbolic link</summary>
Symlink = 0x20000000000,
/// <summary>File writes are synchronously written to disk</summary>
Sync = 0x40000000000,
/// <summary>File belongs to the operating system</summary>
System = 0x80000000000,
/// <summary>If file end is a partial block its content will be merged with other files</summary>
TailMerged = 0x100000000000,
/// <summary>File is temporary</summary>
Temporary = 0x200000000000,
/// <summary>Subdirectories inside of this directory are not related and should be allocated elsewhere</summary>
TopDirectory = 0x400000000000,
/// <summary>If file is deleted, contents should be stored, for a possible future undeletion</summary>
Undeletable = 0x800000000000,
/// <summary>File is a pipe</summary>
Pipe = 0x1000000000000
}
/// <summary>
/// Information about a file entry
/// </summary>
public class FileEntryInfo
{
/// <summary>File attributes</summary>
public FileAttributes Attributes;
/// <summary>File length in blocks</summary>
public long Blocks;
/// <summary>File block size in bytes</summary>
public long BlockSize;
/// <summary>If file points to a device, device number</summary>
public ulong DeviceNo;
/// <summary>POSIX group ID</summary>
public ulong GID;
/// <summary>inode number for this file</summary>
public ulong Inode;
/// <summary>File length in bytes</summary>
public long Length;
/// <summary>Number of hard links pointing to this file</summary>
public ulong Links;
/// <summary>POSIX permissions/mode for this file</summary>
public uint Mode;
/// <summary>POSIX owner ID</summary>
public ulong UID;
/// <summary>File creation date in UTC</summary>
public DateTime CreationTimeUtc { get; set; }
/// <summary>File last access date in UTC</summary>
public DateTime AccessTimeUtc { get; set; }
/// <summary>File attributes change date in UTC</summary>
public DateTime StatusChangeTimeUtc { get; set; }
/// <summary>File last backup date in UTC</summary>
public DateTime BackupTimeUtc { get; set; }
/// <summary>File last modification date in UTC</summary>
public DateTime LastWriteTimeUtc { get; set; }
/// <summary>File creation date</summary>
public DateTime CreationTime
{
get => CreationTimeUtc.ToLocalTime();
set => CreationTimeUtc = value.ToUniversalTime();
}
/// <summary>File last access date</summary>
public DateTime AccessTime
{
get => AccessTimeUtc.ToLocalTime();
set => AccessTimeUtc = value.ToUniversalTime();
}
/// <summary>File attributes change date</summary>
public DateTime StatusChangeTime
{
get => StatusChangeTimeUtc.ToLocalTime();
set => StatusChangeTimeUtc = value.ToUniversalTime();
}
/// <summary>File last backup date</summary>
public DateTime BackupTime
{
get => BackupTimeUtc.ToLocalTime();
set => BackupTimeUtc = value.ToUniversalTime();
}
/// <summary>File last modification date</summary>
public DateTime LastWriteTime
{
get => LastWriteTimeUtc.ToLocalTime();
set => LastWriteTimeUtc = value.ToUniversalTime();
}
}
public class FileSystemInfo
{
/// <summary>Blocks for this filesystem</summary>
public long Blocks;
/// <summary>Maximum length of filenames on this filesystem</summary>
public ushort FilenameLength;
/// <summary>Files on this filesystem</summary>
public ulong Files;
/// <summary>Blocks free on this filesystem</summary>
public long FreeBlocks;
/// <summary>Free inodes on this filesystem</summary>
public ulong FreeFiles;
/// <summary>Filesystem ID</summary>
public FileSystemId Id;
/// <summary>ID of plugin for this file</summary>
public Guid PluginId;
/// <summary>Filesystem type</summary>
public string Type;
public FileSystemInfo()
{
Id = new FileSystemId();
}
}
[StructLayout(LayoutKind.Explicit)]
public struct FileSystemId
{
[FieldOffset(0)] public bool IsInt;
[FieldOffset(1)] public bool IsLong;
[FieldOffset(2)] public bool IsGuid;
[FieldOffset(3)] public uint Serial32;
[FieldOffset(3)] public ulong Serial64;
[FieldOffset(3)] public Guid uuid;
}
/// <summary>
/// Errors
/// </summary>
public enum Errno
{
/// <summary>No error happened</summary>
NoError = 0,
/// <summary>Access denied</summary>
AccessDenied = -13,
/// <summary>Busy, cannot complete</summary>
Busy = -16,
/// <summary>File is too large</summary>
FileTooLarge = -27,
/// <summary>Invalid argument</summary>
InvalidArgument = -22,
/// <summary>I/O error</summary>
InOutError = -5,
/// <summary>Is a directory (e.g.: trying to Read() a dir)</summary>
IsDirectory = -21,
/// <summary>Name is too long</summary>
NameTooLong = -36,
/// <summary>There is no data available</summary>
NoData = 61,
/// <summary>There is no such attribute</summary>
NoSuchExtendedAttribute = NoData,
/// <summary>No such device</summary>
NoSuchDevice = -19,
/// <summary>No such file or directory</summary>
NoSuchFile = -2,
/// <summary>Is not a directory (e.g.: trying to ReadDir() a file)</summary>
NotDirectory = -20,
/// <summary>Not implemented</summary>
NotImplemented = -38,
/// <summary>Not supported</summary>
NotSupported = -252,
/// <summary>Link is severed</summary>
SeveredLink = -67,
/// <summary>Access denied</summary>
EACCES = AccessDenied,
/// <summary>Busy, cannot complete</summary>
EBUSY = Busy,
/// <summary>File is too large</summary>
EFBIG = FileTooLarge,
/// <summary>Invalid argument</summary>
EINVAL = InvalidArgument,
/// <summary>I/O error</summary>
EIO = InOutError,
/// <summary>Is a directory (e.g.: trying to Read() a dir)</summary>
EISDIR = IsDirectory,
/// <summary>Name is too long</summary>
ENAMETOOLONG = NameTooLong,
/// <summary>There is no such attribute</summary>
ENOATTR = NoSuchExtendedAttribute,
/// <summary>There is no data available</summary>
ENODATA = NoData,
/// <summary>No such device</summary>
ENODEV = NoSuchDevice,
/// <summary>No such file or directory</summary>
ENOENT = NoSuchFile,
/// <summary>Link is severed</summary>
ENOLINK = SeveredLink,
/// <summary>Not implemented</summary>
ENOSYS = NotImplemented,
/// <summary>Is not a directory (e.g.: trying to ReadDir() a file)</summary>
ENOTDIR = NotDirectory,
/// <summary>Not supported</summary>
ENOTSUP = NotSupported
}
}

188
Structs/Images.cs Normal file
View File

@@ -0,0 +1,188 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : IMediaImage.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Disc image plugins.
//
// --[ Description ] ----------------------------------------------------------
//
// Defines structures to be used by disc image plugins.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using DiscImageChef.CommonTypes.Enums;
using DiscImageChef.CommonTypes.Interfaces;
namespace DiscImageChef.CommonTypes.Structs
{
/// <summary>
/// Contains information about a dump image and its contents
/// </summary>
public struct ImageInfo
{
/// <summary>Image contains partitions (or tracks for optical media)</summary>
public bool HasPartitions;
/// <summary>Image contains sessions (optical media only)</summary>
public bool HasSessions;
/// <summary>Size of the image without headers</summary>
public ulong ImageSize;
/// <summary>Sectors contained in the image</summary>
public ulong Sectors;
/// <summary>Size of sectors contained in the image</summary>
public uint SectorSize;
/// <summary>Media tags contained by the image</summary>
public List<MediaTagType> ReadableMediaTags;
/// <summary>Sector tags contained by the image</summary>
public List<SectorTagType> ReadableSectorTags;
/// <summary>Image version</summary>
public string Version;
/// <summary>Application that created the image</summary>
public string Application;
/// <summary>Version of the application that created the image</summary>
public string ApplicationVersion;
/// <summary>Who (person) created the image?</summary>
public string Creator;
/// <summary>Image creation time</summary>
public DateTime CreationTime;
/// <summary>Image last modification time</summary>
public DateTime LastModificationTime;
/// <summary>Title of the media represented by the image</summary>
public string MediaTitle;
/// <summary>Image comments</summary>
public string Comments;
/// <summary>Manufacturer of the media represented by the image</summary>
public string MediaManufacturer;
/// <summary>Model of the media represented by the image</summary>
public string MediaModel;
/// <summary>Serial number of the media represented by the image</summary>
public string MediaSerialNumber;
/// <summary>Barcode of the media represented by the image</summary>
public string MediaBarcode;
/// <summary>Part number of the media represented by the image</summary>
public string MediaPartNumber;
/// <summary>Media type represented by the image</summary>
public MediaType MediaType;
/// <summary>Number in sequence for the media represented by the image</summary>
public int MediaSequence;
/// <summary>Last media of the sequence the media represented by the image corresponds to</summary>
public int LastMediaSequence;
/// <summary>Manufacturer of the drive used to read the media represented by the image</summary>
public string DriveManufacturer;
/// <summary>Model of the drive used to read the media represented by the image</summary>
public string DriveModel;
/// <summary>Serial number of the drive used to read the media represented by the image</summary>
public string DriveSerialNumber;
/// <summary>Firmware revision of the drive used to read the media represented by the image</summary>
public string DriveFirmwareRevision;
/// <summary>Type of the media represented by the image to use in XML sidecars</summary>
public XmlMediaType XmlMediaType;
// CHS geometry...
/// <summary>Cylinders of the media represented by the image</summary>
public uint Cylinders;
/// <summary>Heads of the media represented by the image</summary>
public uint Heads;
/// <summary>Sectors per track of the media represented by the image (for variable image, the smallest)</summary>
public uint SectorsPerTrack;
}
/// <summary>
/// Session defining structure.
/// </summary>
public struct Session
{
/// <summary>Session number, 1-started</summary>
public ushort SessionSequence;
/// <summary>First track present on this session</summary>
public uint StartTrack;
/// <summary>Last track present on this session</summary>
public uint EndTrack;
/// <summary>First sector present on this session</summary>
public ulong StartSector;
/// <summary>Last sector present on this session</summary>
public ulong EndSector;
}
/// <summary>
/// Track defining structure.
/// </summary>
public struct Track
{
/// <summary>Track number, 1-started</summary>
public uint TrackSequence;
/// <summary>Partition type</summary>
public TrackType TrackType;
/// <summary>Track starting sector</summary>
public ulong TrackStartSector;
/// <summary>Track ending sector</summary>
public ulong TrackEndSector;
/// <summary>Track pre-gap</summary>
public ulong TrackPregap;
/// <summary>Session this track belongs to</summary>
public ushort TrackSession;
/// <summary>Information that does not find space in this struct</summary>
public string TrackDescription;
/// <summary>Indexes, 00 to 99 and sector offset</summary>
public Dictionary<int, ulong> Indexes;
/// <summary>Which filter stores this track</summary>
public IFilter TrackFilter;
/// <summary>Which file stores this track</summary>
public string TrackFile;
/// <summary>Starting at which byte is this track stored</summary>
public ulong TrackFileOffset;
/// <summary>What kind of file is storing this track</summary>
public string TrackFileType;
/// <summary>How many main channel / user data bytes are per sector in this track</summary>
public int TrackBytesPerSector;
/// <summary>How many main channel bytes per sector are in the file with this track</summary>
public int TrackRawBytesPerSector;
/// <summary>Which filter stores this track's subchannel</summary>
public IFilter TrackSubchannelFilter;
/// <summary>Which file stores this track's subchannel</summary>
public string TrackSubchannelFile;
/// <summary>Starting at which byte are this track's subchannel stored</summary>
public ulong TrackSubchannelOffset;
/// <summary>Type of subchannel stored for this track</summary>
public TrackSubchannelType TrackSubchannelType;
}
/// <summary>
/// Floppy physical characteristics structure.
/// </summary>
public struct FloppyInfo
{
/// <summary>Physical floppy type.</summary>
public FloppyTypes Type;
/// <summary>Bitrate in bits per second used to write the floppy, 0 if unknown or track-variable.</summary>
public uint Bitrate;
/// <summary>Physical magnetic density (coercitivity) of floppy medium.</summary>
public FloppyDensities Coercitivity;
/// <summary>How many physical tracks are actually written in the floppy image.</summary>
public ushort Tracks;
/// <summary>How many physical heads are actually written in the floppy image.</summary>
public byte Heads;
/// <summary>How many tracks per inch are actually written in the floppy image.</summary>
public ushort TrackDensity;
}
}