diff --git a/ChangeLog b/ChangeLog index 83018df2..5f08310f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016-07-28 Natalia Portillo + + * DiscImageChef.sln: Refactor and code cleanup. + 2016-02-05 Natalia Portillo * commandline: diff --git a/DiscImageChef.Checksums/Adler32Context.cs b/DiscImageChef.Checksums/Adler32Context.cs index 4d969c54..09128e03 100644 --- a/DiscImageChef.Checksums/Adler32Context.cs +++ b/DiscImageChef.Checksums/Adler32Context.cs @@ -38,8 +38,8 @@ namespace DiscImageChef.Checksums { public class Adler32Context { - UInt16 sum1, sum2; - const UInt16 AdlerModule = 65521; + ushort sum1, sum2; + const ushort AdlerModule = 65521; /// /// Initializes the Adler-32 sums @@ -78,7 +78,7 @@ namespace DiscImageChef.Checksums /// public byte[] Final() { - UInt32 finalSum = (uint)((sum2 << 16) | sum1); + uint finalSum = (uint)((sum2 << 16) | sum1); return BigEndianBitConverter.GetBytes(finalSum); } @@ -87,7 +87,7 @@ namespace DiscImageChef.Checksums /// public string End() { - UInt32 finalSum = (uint)((sum2 << 16) | sum1); + uint finalSum = (uint)((sum2 << 16) | sum1); StringBuilder adlerOutput = new StringBuilder(); for(int i = 0; i < BigEndianBitConverter.GetBytes(finalSum).Length; i++) @@ -117,8 +117,8 @@ namespace DiscImageChef.Checksums public static string File(string filename, out byte[] hash) { FileStream fileStream = new FileStream(filename, FileMode.Open); - UInt16 localSum1, localSum2; - UInt32 finalSum; + ushort localSum1, localSum2; + uint finalSum; localSum1 = 1; localSum2 = 0; @@ -148,8 +148,8 @@ namespace DiscImageChef.Checksums /// Byte array of the hash value. public static string Data(byte[] data, uint len, out byte[] hash) { - UInt16 localSum1, localSum2; - UInt32 finalSum; + ushort localSum1, localSum2; + uint finalSum; localSum1 = 1; localSum2 = 0; diff --git a/DiscImageChef.Checksums/CDChecksums.cs b/DiscImageChef.Checksums/CDChecksums.cs index 73e499c0..4ad090c3 100644 --- a/DiscImageChef.Checksums/CDChecksums.cs +++ b/DiscImageChef.Checksums/CDChecksums.cs @@ -40,8 +40,8 @@ namespace DiscImageChef.Checksums { static byte[] ECC_F_Table; static byte[] ECC_B_Table; - const UInt32 CDCRC32Poly = 0xD8018001; - const UInt32 CDCRC32Seed = 0x00000000; + const uint CDCRC32Poly = 0xD8018001; + const uint CDCRC32Seed = 0x00000000; public static bool? CheckCDSector(byte[] buffer) { @@ -84,9 +84,9 @@ namespace DiscImageChef.Checksums ECC_F_Table = new byte[256]; ECC_B_Table = new byte[256]; - for(UInt32 i = 0; i < 256; i++) + for(uint i = 0; i < 256; i++) { - UInt32 j = (uint)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0)); + uint j = (uint)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0)); ECC_F_Table[i] = (byte)j; ECC_B_Table[i ^ j] = (byte)i; } @@ -95,21 +95,21 @@ namespace DiscImageChef.Checksums static bool CheckECC( byte[] address, byte[] data, - UInt32 major_count, - UInt32 minor_count, - UInt32 major_mult, - UInt32 minor_inc, + uint major_count, + uint minor_count, + uint major_mult, + uint minor_inc, byte[] ecc ) { - UInt32 size = major_count * minor_count; - UInt32 major; + uint size = major_count * minor_count; + uint major; for(major = 0; major < major_count; major++) { - UInt32 index = (major >> 1) * major_mult + (major & 1); + uint index = (major >> 1) * major_mult + (major & 1); byte ecc_a = 0; byte ecc_b = 0; - UInt32 minor; + uint minor; for(minor = 0; minor < minor_count; minor++) { byte temp; @@ -215,11 +215,11 @@ namespace DiscImageChef.Checksums return false; byte[] SectorForCheck = new byte[0x810]; - UInt32 StoredEDC = BitConverter.ToUInt32(channel, 0x810); + uint StoredEDC = BitConverter.ToUInt32(channel, 0x810); byte[] CalculatedEDCBytes; Array.Copy(channel, 0, SectorForCheck, 0, 0x810); CRC32Context.Data(SectorForCheck, 0x810, out CalculatedEDCBytes, CDCRC32Poly, CDCRC32Seed); - UInt32 CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0); + uint CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0); if(CalculatedEDC != StoredEDC) { @@ -241,11 +241,11 @@ namespace DiscImageChef.Checksums } byte[] SectorForCheck = new byte[0x91C]; - UInt32 StoredEDC = BitConverter.ToUInt32(channel, 0x92C); + uint StoredEDC = BitConverter.ToUInt32(channel, 0x92C); byte[] CalculatedEDCBytes; Array.Copy(channel, 0x10, SectorForCheck, 0, 0x91C); CRC32Context.Data(SectorForCheck, 0x91C, out CalculatedEDCBytes, CDCRC32Poly, CDCRC32Seed); - UInt32 CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0); + uint CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0); if(CalculatedEDC != StoredEDC && StoredEDC != 0x00000000) { @@ -287,11 +287,11 @@ namespace DiscImageChef.Checksums return false; byte[] SectorForCheck = new byte[0x808]; - UInt32 StoredEDC = BitConverter.ToUInt32(channel, 0x818); + uint StoredEDC = BitConverter.ToUInt32(channel, 0x818); byte[] CalculatedEDCBytes; Array.Copy(channel, 0x10, SectorForCheck, 0, 0x808); CRC32Context.Data(SectorForCheck, 0x808, out CalculatedEDCBytes, CDCRC32Poly, CDCRC32Seed); - UInt32 CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0); + uint CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0); if(CalculatedEDC != StoredEDC) { @@ -464,10 +464,10 @@ namespace DiscImageChef.Checksums BigEndianBitConverter.IsLittleEndian = true; - UInt16 QSubChannelCRC = BigEndianBitConverter.ToUInt16(QSubChannel, 10); + ushort QSubChannelCRC = BigEndianBitConverter.ToUInt16(QSubChannel, 10); byte[] QSubChannelForCRC = new byte[10]; Array.Copy(QSubChannel, 0, QSubChannelForCRC, 0, 10); - UInt16 CalculatedQCRC = CalculateCCITT_CRC16(QSubChannelForCRC); + ushort CalculatedQCRC = CalculateCCITT_CRC16(QSubChannelForCRC); if(QSubChannelCRC != CalculatedQCRC) { @@ -477,10 +477,10 @@ namespace DiscImageChef.Checksums if((CDTextPack1[0] & 0x80) == 0x80) { - UInt16 CDTextPack1CRC = BigEndianBitConverter.ToUInt16(CDTextPack1, 16); + ushort CDTextPack1CRC = BigEndianBitConverter.ToUInt16(CDTextPack1, 16); byte[] CDTextPack1ForCRC = new byte[16]; Array.Copy(CDTextPack1, 0, CDTextPack1ForCRC, 0, 16); - UInt16 CalculatedCDTP1CRC = CalculateCCITT_CRC16(CDTextPack1ForCRC); + ushort CalculatedCDTP1CRC = CalculateCCITT_CRC16(CDTextPack1ForCRC); if(CDTextPack1CRC != CalculatedCDTP1CRC && CDTextPack1CRC != 0) { @@ -491,10 +491,10 @@ namespace DiscImageChef.Checksums if((CDTextPack2[0] & 0x80) == 0x80) { - UInt16 CDTextPack2CRC = BigEndianBitConverter.ToUInt16(CDTextPack2, 16); + ushort CDTextPack2CRC = BigEndianBitConverter.ToUInt16(CDTextPack2, 16); byte[] CDTextPack2ForCRC = new byte[16]; Array.Copy(CDTextPack2, 0, CDTextPack2ForCRC, 0, 16); - UInt16 CalculatedCDTP2CRC = CalculateCCITT_CRC16(CDTextPack2ForCRC); + ushort CalculatedCDTP2CRC = CalculateCCITT_CRC16(CDTextPack2ForCRC); DicConsole.DebugWriteLine("CD checksums", "Cyclic CDTP2 0x{0:X4}, Calc CDTP2 0x{1:X4}", CDTextPack2CRC, CalculatedCDTP2CRC); if(CDTextPack2CRC != CalculatedCDTP2CRC && CDTextPack2CRC != 0) @@ -506,10 +506,10 @@ namespace DiscImageChef.Checksums if((CDTextPack3[0] & 0x80) == 0x80) { - UInt16 CDTextPack3CRC = BigEndianBitConverter.ToUInt16(CDTextPack3, 16); + ushort CDTextPack3CRC = BigEndianBitConverter.ToUInt16(CDTextPack3, 16); byte[] CDTextPack3ForCRC = new byte[16]; Array.Copy(CDTextPack3, 0, CDTextPack3ForCRC, 0, 16); - UInt16 CalculatedCDTP3CRC = CalculateCCITT_CRC16(CDTextPack3ForCRC); + ushort CalculatedCDTP3CRC = CalculateCCITT_CRC16(CDTextPack3ForCRC); DicConsole.DebugWriteLine("CD checksums", "Cyclic CDTP3 0x{0:X4}, Calc CDTP3 0x{1:X4}", CDTextPack3CRC, CalculatedCDTP3CRC); if(CDTextPack3CRC != CalculatedCDTP3CRC && CDTextPack3CRC != 0) @@ -521,10 +521,10 @@ namespace DiscImageChef.Checksums if((CDTextPack4[0] & 0x80) == 0x80) { - UInt16 CDTextPack4CRC = BigEndianBitConverter.ToUInt16(CDTextPack4, 16); + ushort CDTextPack4CRC = BigEndianBitConverter.ToUInt16(CDTextPack4, 16); byte[] CDTextPack4ForCRC = new byte[16]; Array.Copy(CDTextPack4, 0, CDTextPack4ForCRC, 0, 16); - UInt16 CalculatedCDTP4CRC = CalculateCCITT_CRC16(CDTextPack4ForCRC); + ushort CalculatedCDTP4CRC = CalculateCCITT_CRC16(CDTextPack4ForCRC); DicConsole.DebugWriteLine("CD checksums", "Cyclic CDTP4 0x{0:X4}, Calc CDTP4 0x{1:X4}", CDTextPack4CRC, CalculatedCDTP4CRC); if(CDTextPack4CRC != CalculatedCDTP4CRC && CDTextPack4CRC != 0) @@ -570,12 +570,12 @@ namespace DiscImageChef.Checksums 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, - 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0, + 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 }; static ushort CalculateCCITT_CRC16(byte[] buffer) { - UInt16 CRC16 = 0; + ushort CRC16 = 0; for(int i = 0; i < buffer.Length; i++) { CRC16 = (ushort)(CCITT_CRC16Table[(CRC16 >> 8) ^ buffer[i]] ^ (CRC16 << 8)); diff --git a/DiscImageChef.Checksums/CRC16Context.cs b/DiscImageChef.Checksums/CRC16Context.cs index 1a8c4950..777d3614 100644 --- a/DiscImageChef.Checksums/CRC16Context.cs +++ b/DiscImageChef.Checksums/CRC16Context.cs @@ -41,11 +41,11 @@ namespace DiscImageChef.Checksums /// public class CRC16Context { - const UInt16 crc16Poly = 0xA001; - const UInt16 crc16Seed = 0x0000; + const ushort crc16Poly = 0xA001; + const ushort crc16Seed = 0x0000; - UInt16[] table; - UInt16 hashInt; + ushort[] table; + ushort hashInt; /// /// Initializes the CRC16 table and seed @@ -54,10 +54,10 @@ namespace DiscImageChef.Checksums { hashInt = crc16Seed; - table = new UInt16[256]; + table = new ushort[256]; for(int i = 0; i < 256; i++) { - UInt16 entry = (UInt16)i; + ushort entry = (ushort)i; for(int j = 0; j < 8; j++) if((entry & 1) == 1) entry = (ushort)((entry >> 1) ^ crc16Poly); @@ -133,15 +133,15 @@ namespace DiscImageChef.Checksums public static string File(string filename, out byte[] hash) { FileStream fileStream = new FileStream(filename, FileMode.Open); - UInt16[] localTable; - UInt16 localhashInt; + ushort[] localTable; + ushort localhashInt; localhashInt = crc16Seed; - localTable = new UInt16[256]; + localTable = new ushort[256]; for(int i = 0; i < 256; i++) { - UInt16 entry = (UInt16)i; + ushort entry = (ushort)i; for(int j = 0; j < 8; j++) if((entry & 1) == 1) entry = (ushort)((entry >> 1) ^ crc16Poly); @@ -185,17 +185,17 @@ namespace DiscImageChef.Checksums /// Byte array of the hash value. /// CRC polynomial /// CRC seed - public static string Data(byte[] data, uint len, out byte[] hash, UInt16 polynomial, UInt16 seed) + public static string Data(byte[] data, uint len, out byte[] hash, ushort polynomial, ushort seed) { - UInt16[] localTable; - UInt16 localhashInt; + ushort[] localTable; + ushort localhashInt; localhashInt = seed; - localTable = new UInt16[256]; + localTable = new ushort[256]; for(int i = 0; i < 256; i++) { - UInt16 entry = (UInt16)i; + ushort entry = (ushort)i; for(int j = 0; j < 8; j++) if((entry & 1) == 1) entry = (ushort)((entry >> 1) ^ polynomial); diff --git a/DiscImageChef.Checksums/CRC32Context.cs b/DiscImageChef.Checksums/CRC32Context.cs index f0dbacac..774c3357 100644 --- a/DiscImageChef.Checksums/CRC32Context.cs +++ b/DiscImageChef.Checksums/CRC32Context.cs @@ -41,11 +41,11 @@ namespace DiscImageChef.Checksums /// public class CRC32Context { - const UInt32 crc32Poly = 0xEDB88320; - const UInt32 crc32Seed = 0xFFFFFFFF; + const uint crc32Poly = 0xEDB88320; + const uint crc32Seed = 0xFFFFFFFF; - UInt32[] table; - UInt32 hashInt; + uint[] table; + uint hashInt; /// /// Initializes the CRC32 table and seed @@ -54,10 +54,10 @@ namespace DiscImageChef.Checksums { hashInt = crc32Seed; - table = new UInt32[256]; + table = new uint[256]; for(int i = 0; i < 256; i++) { - UInt32 entry = (UInt32)i; + uint entry = (uint)i; for(int j = 0; j < 8; j++) if((entry & 1) == 1) entry = (entry >> 1) ^ crc32Poly; @@ -133,15 +133,15 @@ namespace DiscImageChef.Checksums public static string File(string filename, out byte[] hash) { FileStream fileStream = new FileStream(filename, FileMode.Open); - UInt32[] localTable; - UInt32 localhashInt; + uint[] localTable; + uint localhashInt; localhashInt = crc32Seed; - localTable = new UInt32[256]; + localTable = new uint[256]; for(int i = 0; i < 256; i++) { - UInt32 entry = (UInt32)i; + uint entry = (uint)i; for(int j = 0; j < 8; j++) if((entry & 1) == 1) entry = (entry >> 1) ^ crc32Poly; @@ -185,17 +185,17 @@ namespace DiscImageChef.Checksums /// Byte array of the hash value. /// CRC polynomial /// CRC seed - public static string Data(byte[] data, uint len, out byte[] hash, UInt32 polynomial, UInt32 seed) + public static string Data(byte[] data, uint len, out byte[] hash, uint polynomial, uint seed) { - UInt32[] localTable; - UInt32 localhashInt; + uint[] localTable; + uint localhashInt; localhashInt = seed; - localTable = new UInt32[256]; + localTable = new uint[256]; for(int i = 0; i < 256; i++) { - UInt32 entry = (UInt32)i; + uint entry = (uint)i; for(int j = 0; j < 8; j++) if((entry & 1) == 1) entry = (entry >> 1) ^ polynomial; diff --git a/DiscImageChef.Checksums/CRC64Context.cs b/DiscImageChef.Checksums/CRC64Context.cs index f11c6f42..84827ba3 100644 --- a/DiscImageChef.Checksums/CRC64Context.cs +++ b/DiscImageChef.Checksums/CRC64Context.cs @@ -41,11 +41,11 @@ namespace DiscImageChef.Checksums /// public class CRC64Context { - const UInt64 crc64Poly = 0xC96C5795D7870F42; - const UInt64 crc64Seed = 0xFFFFFFFFFFFFFFFF; + const ulong crc64Poly = 0xC96C5795D7870F42; + const ulong crc64Seed = 0xFFFFFFFFFFFFFFFF; - UInt64[] table; - UInt64 hashInt; + ulong[] table; + ulong hashInt; /// /// Initializes the CRC64 table and seed @@ -54,10 +54,10 @@ namespace DiscImageChef.Checksums { hashInt = crc64Seed; - table = new UInt64[256]; + table = new ulong[256]; for(int i = 0; i < 256; i++) { - UInt64 entry = (UInt64)i; + ulong entry = (ulong)i; for(int j = 0; j < 8; j++) if((entry & 1) == 1) entry = (entry >> 1) ^ crc64Poly; @@ -133,15 +133,15 @@ namespace DiscImageChef.Checksums public static string File(string filename, out byte[] hash) { FileStream fileStream = new FileStream(filename, FileMode.Open); - UInt64[] localTable; - UInt64 localhashInt; + ulong[] localTable; + ulong localhashInt; localhashInt = crc64Seed; - localTable = new UInt64[256]; + localTable = new ulong[256]; for(int i = 0; i < 256; i++) { - UInt64 entry = (UInt64)i; + ulong entry = (ulong)i; for(int j = 0; j < 8; j++) if((entry & 1) == 1) entry = (entry >> 1) ^ crc64Poly; @@ -151,7 +151,7 @@ namespace DiscImageChef.Checksums } for(int i = 0; i < fileStream.Length; i++) - localhashInt = (localhashInt >> 8) ^ localTable[(ulong)fileStream.ReadByte() ^ localhashInt & (ulong)0xff]; + localhashInt = (localhashInt >> 8) ^ localTable[(ulong)fileStream.ReadByte() ^ localhashInt & 0xffL]; BigEndianBitConverter.IsLittleEndian = BigEndianBitConverter.IsLittleEndian; hash = BitConverter.GetBytes(localhashInt); @@ -185,17 +185,17 @@ namespace DiscImageChef.Checksums /// Byte array of the hash value. /// CRC polynomial /// CRC seed - public static string Data(byte[] data, uint len, out byte[] hash, UInt64 polynomial, UInt64 seed) + public static string Data(byte[] data, uint len, out byte[] hash, ulong polynomial, ulong seed) { - UInt64[] localTable; - UInt64 localhashInt; + ulong[] localTable; + ulong localhashInt; localhashInt = seed; - localTable = new UInt64[256]; + localTable = new ulong[256]; for(int i = 0; i < 256; i++) { - UInt64 entry = (UInt64)i; + ulong entry = (ulong)i; for(int j = 0; j < 8; j++) if((entry & 1) == 1) entry = (entry >> 1) ^ polynomial; diff --git a/DiscImageChef.Checksums/ChangeLog b/DiscImageChef.Checksums/ChangeLog index bfac7eeb..d824fff6 100644 --- a/DiscImageChef.Checksums/ChangeLog +++ b/DiscImageChef.Checksums/ChangeLog @@ -1,3 +1,13 @@ +2016-07-28 Natalia Portillo + + * CDChecksums.cs: + * ReedSolomon.cs: + * CRC16Context.cs: + * CRC32Context.cs: + * CRC64Context.cs: + * Adler32Context.cs: + * SpamSumContext.cs: Refactor and code cleanup. + 2015-11-30 Natalia Portillo * FletcherContext.cs: diff --git a/DiscImageChef.Checksums/ReedSolomon.cs b/DiscImageChef.Checksums/ReedSolomon.cs index 104a7321..8fa73026 100644 --- a/DiscImageChef.Checksums/ReedSolomon.cs +++ b/DiscImageChef.Checksums/ReedSolomon.cs @@ -139,7 +139,7 @@ namespace DiscImageChef.Checksums Pp = new[] { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 }; break; default: - throw new ArgumentOutOfRangeException("m", "m must be between 2 and 16 inclusive"); + throw new ArgumentOutOfRangeException(nameof(m), "m must be between 2 and 16 inclusive"); } MM = m; diff --git a/DiscImageChef.Checksums/SpamSumContext.cs b/DiscImageChef.Checksums/SpamSumContext.cs index f6bf5055..facda0ce 100644 --- a/DiscImageChef.Checksums/SpamSumContext.cs +++ b/DiscImageChef.Checksums/SpamSumContext.cs @@ -49,13 +49,13 @@ namespace DiscImageChef.Checksums /// public class SpamSumContext { - const UInt32 ROLLING_WINDOW = 7; - const UInt32 MIN_BLOCKSIZE = 3; - const UInt32 HASH_PRIME = 0x01000193; - const UInt32 HASH_INIT = 0x28021967; - const UInt32 NUM_BLOCKHASHES = 31; - const UInt32 SPAMSUM_LENGTH = 64; - const UInt32 FUZZY_MAX_RESULT = (2 * SPAMSUM_LENGTH + 20); + const uint ROLLING_WINDOW = 7; + const uint MIN_BLOCKSIZE = 3; + const uint HASH_PRIME = 0x01000193; + const uint HASH_INIT = 0x28021967; + const uint NUM_BLOCKHASHES = 31; + const uint SPAMSUM_LENGTH = 64; + const uint FUZZY_MAX_RESULT = (2 * SPAMSUM_LENGTH + 20); //"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; readonly byte[] b64 = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, @@ -72,10 +72,10 @@ namespace DiscImageChef.Checksums { public byte[] window; // ROLLING_WINDOW - public UInt32 h1; - public UInt32 h2; - public UInt32 h3; - public UInt32 n; + public uint h1; + public uint h2; + public uint h3; + public uint n; } /* A blockhash contains a signature state for a specific (implicit) blocksize. @@ -85,21 +85,21 @@ namespace DiscImageChef.Checksums * output hash to stay compatible with ssdeep output. */ struct blockhash_context { - public UInt32 h; - public UInt32 halfh; + public uint h; + public uint halfh; public byte[] digest; // SPAMSUM_LENGTH public byte halfdigest; - public UInt32 dlen; + public uint dlen; } struct fuzzy_state { - public UInt32 bhstart; - public UInt32 bhend; + public uint bhstart; + public uint bhend; public blockhash_context[] bh; //NUM_BLOCKHASHES - public UInt64 total_size; + public ulong total_size; public roll_state roll; } @@ -145,10 +145,10 @@ namespace DiscImageChef.Checksums void roll_hash(byte c) { self.roll.h2 -= self.roll.h1; - self.roll.h2 += ROLLING_WINDOW * (UInt32)c; + self.roll.h2 += ROLLING_WINDOW * c; - self.roll.h1 += (UInt32)c; - self.roll.h1 -= (UInt32)self.roll.window[self.roll.n % ROLLING_WINDOW]; + self.roll.h1 += c; + self.roll.h1 -= self.roll.window[self.roll.n % ROLLING_WINDOW]; self.roll.window[self.roll.n % ROLLING_WINDOW] = c; self.roll.n++; @@ -160,18 +160,18 @@ namespace DiscImageChef.Checksums self.roll.h3 ^= c; } - UInt32 roll_sum() + uint roll_sum() { return self.roll.h1 + self.roll.h2 + self.roll.h3; } /* A simple non-rolling hash, based on the FNV hash. */ - static UInt32 sum_hash(byte c, UInt32 h) + static uint sum_hash(byte c, uint h) { return (h * HASH_PRIME) ^ c; } - static UInt32 SSDEEP_BS(UInt32 index) + static uint SSDEEP_BS(uint index) { return (MIN_BLOCKSIZE << (int)index); } @@ -204,7 +204,7 @@ namespace DiscImageChef.Checksums if(self.bhend - self.bhstart < 2) /* Need at least two working hashes. */ return; - if((UInt64)SSDEEP_BS(self.bhstart) * SPAMSUM_LENGTH >= + if((ulong)SSDEEP_BS(self.bhstart) * SPAMSUM_LENGTH >= self.total_size) /* Initial blocksize estimate would select this or a smaller * blocksize. */ @@ -219,8 +219,8 @@ namespace DiscImageChef.Checksums void fuzzy_engine_step(byte c) { - UInt64 h; - UInt32 i; + ulong h; + uint i; /* At each character we update the rolling hash and the normal hashes. * When the rolling hash hits a reset value then we emit a normal hash * as a element of the signature and reset the normal hash. */ @@ -295,22 +295,22 @@ namespace DiscImageChef.Checksums } // CLAUNIA: Flags seems to never be used in ssdeep, so I just removed it for code simplicity - UInt32 fuzzy_digest(out byte[] result) + uint fuzzy_digest(out byte[] result) { StringBuilder sb = new StringBuilder(); - UInt32 bi = self.bhstart; - UInt32 h = roll_sum(); + uint bi = self.bhstart; + uint h = roll_sum(); int i, result_off; int remain = (int)(FUZZY_MAX_RESULT - 1); /* Exclude terminating '\0'. */ result = new byte[FUZZY_MAX_RESULT]; /* Verify that our elimination was not overeager. */ - if(!(bi == 0 || (UInt64)SSDEEP_BS(bi) / 2 * SPAMSUM_LENGTH < self.total_size)) + if(!(bi == 0 || (ulong)SSDEEP_BS(bi) / 2 * SPAMSUM_LENGTH < self.total_size)) throw new Exception("Assertion failed"); result_off = 0; /* Initial blocksize guess. */ - while((UInt64)SSDEEP_BS(bi) * SPAMSUM_LENGTH < self.total_size) + while((ulong)SSDEEP_BS(bi) * SPAMSUM_LENGTH < self.total_size) { ++bi; if(bi >= NUM_BLOCKHASHES) diff --git a/DiscImageChef.CommonTypes/ChangeLog b/DiscImageChef.CommonTypes/ChangeLog index 3998f9dc..ec4e6970 100644 --- a/DiscImageChef.CommonTypes/ChangeLog +++ b/DiscImageChef.CommonTypes/ChangeLog @@ -1,3 +1,8 @@ +2016-07-28 Natalia Portillo + + * MediaType.cs: + * Partition.cs: Refactor and code cleanup. + 2016-02-04 Natalia Portillo * MediaType.cs: diff --git a/DiscImageChef.CommonTypes/MediaType.cs b/DiscImageChef.CommonTypes/MediaType.cs index 4f24a551..ffccbfb5 100644 --- a/DiscImageChef.CommonTypes/MediaType.cs +++ b/DiscImageChef.CommonTypes/MediaType.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.CommonTypes { // Media (disk, cartridge, tape, cassette, etc) types diff --git a/DiscImageChef.CommonTypes/Partition.cs b/DiscImageChef.CommonTypes/Partition.cs index c8825538..88c5e608 100644 --- a/DiscImageChef.CommonTypes/Partition.cs +++ b/DiscImageChef.CommonTypes/Partition.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.CommonTypes { /// diff --git a/DiscImageChef.Console/ChangeLog b/DiscImageChef.Console/ChangeLog index 57cc989c..f7f032fc 100644 --- a/DiscImageChef.Console/ChangeLog +++ b/DiscImageChef.Console/ChangeLog @@ -1,3 +1,7 @@ +2016-07-28 Natalia Portillo + + * DicConsole.cs: Refactor and code cleanup. + 2015-10-31 Natalia Portillo * DicConsole.cs: diff --git a/DiscImageChef.Console/DicConsole.cs b/DiscImageChef.Console/DicConsole.cs index 73a826a2..748cb4f0 100644 --- a/DiscImageChef.Console/DicConsole.cs +++ b/DiscImageChef.Console/DicConsole.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Console { public delegate void WriteLineHandler(string format, params object[] arg); diff --git a/DiscImageChef.Decoders/ATA/Errors.cs b/DiscImageChef.Decoders/ATA/Errors.cs index a0904194..4e357054 100644 --- a/DiscImageChef.Decoders/ATA/Errors.cs +++ b/DiscImageChef.Decoders/ATA/Errors.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.ATA { public struct AtaRegistersCHS diff --git a/DiscImageChef.Decoders/ATA/Identify.cs b/DiscImageChef.Decoders/ATA/Identify.cs index d2477025..c300aef9 100644 --- a/DiscImageChef.Decoders/ATA/Identify.cs +++ b/DiscImageChef.Decoders/ATA/Identify.cs @@ -49,7 +49,7 @@ namespace DiscImageChef.Decoders.ATA /// T13-1699D rev. 4a (ATA8-ACS) /// T13-2015D rev. 2 (ACS-2) /// T13-2161D rev. 5 (ACS-3) - /// CF+ & CF Specification rev. 1.4 (CFA) + /// CF+ & CF Specification rev. 1.4 (CFA) /// public static class Identify { @@ -2436,7 +2436,9 @@ namespace DiscImageChef.Decoders.ATA if((ATAID.PhysLogSectorSize & 0x2000) == 0x2000) { +#pragma warning disable IDE0004 // Remove Unnecessary Cast physicalsectorsize = logicalsectorsize * (uint)Math.Pow(2, (double)(ATAID.PhysLogSectorSize & 0xF)); +#pragma warning restore IDE0004 // Remove Unnecessary Cast } else physicalsectorsize = logicalsectorsize; @@ -2505,38 +2507,38 @@ namespace DiscImageChef.Decoders.ATA { if(ATAID.CommandSet5.HasFlag(CommandSetBit5.ExtSectors)) { - if((((ulong)ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024) > 1000000) + if(((ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024) > 1000000) { - sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", (ulong)ATAID.ExtendedUserSectors * logicalsectorsize, - ((ulong)ATAID.ExtendedUserSectors * logicalsectorsize) / 1000 / 1000 / 1000 / 1000, ((ulong)ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024).AppendLine(); + sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", ATAID.ExtendedUserSectors * logicalsectorsize, + (ATAID.ExtendedUserSectors * logicalsectorsize) / 1000 / 1000 / 1000 / 1000, (ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024).AppendLine(); } - else if((((ulong)ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024) > 1000) + else if(((ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024) > 1000) { - sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", (ulong)ATAID.ExtendedUserSectors * logicalsectorsize, - ((ulong)ATAID.ExtendedUserSectors * logicalsectorsize) / 1000 / 1000 / 1000, ((ulong)ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024 / 1024).AppendLine(); + sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", ATAID.ExtendedUserSectors * logicalsectorsize, + (ATAID.ExtendedUserSectors * logicalsectorsize) / 1000 / 1000 / 1000, (ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024 / 1024).AppendLine(); } else { - sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", (ulong)ATAID.ExtendedUserSectors * logicalsectorsize, - ((ulong)ATAID.ExtendedUserSectors * logicalsectorsize) / 1000 / 1000, ((ulong)ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024).AppendLine(); + sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", ATAID.ExtendedUserSectors * logicalsectorsize, + (ATAID.ExtendedUserSectors * logicalsectorsize) / 1000 / 1000, (ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024).AppendLine(); } } else { - if((((ulong)ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024) > 1000000) + if(((ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024) > 1000000) { - sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", (ulong)ATAID.LBA48Sectors * logicalsectorsize, - ((ulong)ATAID.LBA48Sectors * logicalsectorsize) / 1000 / 1000 / 1000 / 1000, ((ulong)ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024).AppendLine(); + sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", ATAID.LBA48Sectors * logicalsectorsize, + (ATAID.LBA48Sectors * logicalsectorsize) / 1000 / 1000 / 1000 / 1000, (ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024).AppendLine(); } - else if((((ulong)ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024) > 1000) + else if(((ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024) > 1000) { - sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", (ulong)ATAID.LBA48Sectors * logicalsectorsize, - ((ulong)ATAID.LBA48Sectors * logicalsectorsize) / 1000 / 1000 / 1000, ((ulong)ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024).AppendLine(); + sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", ATAID.LBA48Sectors * logicalsectorsize, + (ATAID.LBA48Sectors * logicalsectorsize) / 1000 / 1000 / 1000, (ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024).AppendLine(); } else { - sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", (ulong)ATAID.LBA48Sectors * logicalsectorsize, - ((ulong)ATAID.LBA48Sectors * logicalsectorsize) / 1000 / 1000, ((ulong)ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024).AppendLine(); + sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", ATAID.LBA48Sectors * logicalsectorsize, + (ATAID.LBA48Sectors * logicalsectorsize) / 1000 / 1000, (ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024).AppendLine(); } } } diff --git a/DiscImageChef.Decoders/Blu-ray/BCA.cs b/DiscImageChef.Decoders/Blu-ray/BCA.cs index 00e21952..b5090cc2 100644 --- a/DiscImageChef.Decoders/Blu-ray/BCA.cs +++ b/DiscImageChef.Decoders/Blu-ray/BCA.cs @@ -113,7 +113,7 @@ namespace DiscImageChef.Decoders.Bluray /// Bytes 0 to 1 /// Always 66 /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/Blu-ray/Cartridge.cs b/DiscImageChef.Decoders/Blu-ray/Cartridge.cs index 016676a1..65e30150 100644 --- a/DiscImageChef.Decoders/Blu-ray/Cartridge.cs +++ b/DiscImageChef.Decoders/Blu-ray/Cartridge.cs @@ -145,7 +145,7 @@ namespace DiscImageChef.Decoders.Bluray /// Bytes 0 to 1 /// Always 6 /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/Blu-ray/DDS.cs b/DiscImageChef.Decoders/Blu-ray/DDS.cs index fef71bd5..36e7e008 100644 --- a/DiscImageChef.Decoders/Blu-ray/DDS.cs +++ b/DiscImageChef.Decoders/Blu-ray/DDS.cs @@ -57,7 +57,7 @@ namespace DiscImageChef.Decoders.Bluray /// /// Disc Definition Structure Identifier "DS" /// - const UInt16 DDSIdentifier = 0x4453; + const ushort DDSIdentifier = 0x4453; #endregion Private constants #region Public methods @@ -170,7 +170,7 @@ namespace DiscImageChef.Decoders.Bluray /// Bytes 0 to 1 /// Data Length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -185,7 +185,7 @@ namespace DiscImageChef.Decoders.Bluray /// Bytes 4 to 5 /// "DS" /// - public UInt16 Signature; + public ushort Signature; /// /// Byte 6 /// DDS format @@ -200,57 +200,57 @@ namespace DiscImageChef.Decoders.Bluray /// Bytes 8 to 11 /// DDS update count /// - public UInt32 UpdateCount; + public uint UpdateCount; /// /// Bytes 12 to 19 /// Reserved /// - public UInt64 Reserved4; + public ulong Reserved4; /// /// Bytes 20 to 23 /// First PSN of Drive Area /// - public UInt32 DriveAreaPSN; + public uint DriveAreaPSN; /// /// Bytes 24 to 27 /// Reserved /// - public UInt32 Reserved5; + public uint Reserved5; /// /// Bytes 28 to 31 /// First PSN of Defect List /// - public UInt32 DefectListPSN; + public uint DefectListPSN; /// /// Bytes 32 to 35 /// Reserved /// - public UInt32 Reserved6; + public uint Reserved6; /// /// Bytes 36 to 39 /// PSN of LSN 0 of user data area /// - public UInt32 PSNofLSNZero; + public uint PSNofLSNZero; /// /// Bytes 40 to 43 /// Last LSN of user data area /// - public UInt32 LastUserAreaLSN; + public uint LastUserAreaLSN; /// /// Bytes 44 to 47 /// ISA0 size /// - public UInt32 ISA0; + public uint ISA0; /// /// Bytes 48 to 51 /// OSA size /// - public UInt32 OSA; + public uint OSA; /// /// Bytes 52 to 55 /// ISA1 size /// - public UInt32 ISA1; + public uint ISA1; /// /// Byte 56 /// Spare Area full flags @@ -275,12 +275,12 @@ namespace DiscImageChef.Decoders.Bluray /// Byte 60 to 63 /// Disc type specific field /// - public UInt32 DiscTypeSpecificField2; + public uint DiscTypeSpecificField2; /// /// Byte 64 to 67 /// Reserved /// - public UInt32 Reserved9; + public uint Reserved9; /// /// Bytes 68 to 99 /// Status bits of INFO1/2 and PAC1/2 on L0 and L1 diff --git a/DiscImageChef.Decoders/Blu-ray/DI.cs b/DiscImageChef.Decoders/Blu-ray/DI.cs index 9bced68d..cb7b524c 100644 --- a/DiscImageChef.Decoders/Blu-ray/DI.cs +++ b/DiscImageChef.Decoders/Blu-ray/DI.cs @@ -62,7 +62,7 @@ namespace DiscImageChef.Decoders.Bluray /// /// Disc Information Unit Identifier "DI" /// - const UInt16 DIUIdentifier = 0x4449; + const ushort DIUIdentifier = 0x4449; #endregion Private constants #region Public methods @@ -199,7 +199,7 @@ namespace DiscImageChef.Decoders.Bluray /// Bytes 0 to 1 /// Always 4098 /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -223,7 +223,7 @@ namespace DiscImageChef.Decoders.Bluray /// Byte 0 /// "DI" /// - public UInt16 Signature; + public ushort Signature; /// /// Byte 2 /// Disc information format @@ -283,7 +283,7 @@ namespace DiscImageChef.Decoders.Bluray /// Bytes 109 to 110, BD-R/-RE only /// Timestamp /// - public UInt16 TimeStamp; + public ushort TimeStamp; /// /// Byte 111 /// Product revision number diff --git a/DiscImageChef.Decoders/Blu-ray/Spare.cs b/DiscImageChef.Decoders/Blu-ray/Spare.cs index e707ad6f..a5580392 100644 --- a/DiscImageChef.Decoders/Blu-ray/Spare.cs +++ b/DiscImageChef.Decoders/Blu-ray/Spare.cs @@ -115,7 +115,7 @@ namespace DiscImageChef.Decoders.Bluray /// Bytes 0 to 1 /// Always 14 /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -130,17 +130,17 @@ namespace DiscImageChef.Decoders.Bluray /// Bytes 4 to 7 /// Reserved /// - public UInt32 Reserved3; + public uint Reserved3; /// /// Bytes 8 to 11 /// Free spare blocks /// - public UInt32 FreeSpareBlocks; + public uint FreeSpareBlocks; /// /// Bytes 12 to 15 /// Allocated spare blocks /// - public UInt32 AllocatedSpareBlocks; + public uint AllocatedSpareBlocks; } #endregion Public structures } diff --git a/DiscImageChef.Decoders/CD/ATIP.cs b/DiscImageChef.Decoders/CD/ATIP.cs index 62061028..01cdbf12 100644 --- a/DiscImageChef.Decoders/CD/ATIP.cs +++ b/DiscImageChef.Decoders/CD/ATIP.cs @@ -59,7 +59,7 @@ namespace DiscImageChef.Decoders.CD /// Bytes 1 to 0 /// Total size of returned session information minus this field /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs b/DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs index e634cd28..2e0ceb9f 100644 --- a/DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs +++ b/DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs @@ -33,7 +33,6 @@ using System; using DiscImageChef.Console; using System.Text; -using System.Collections.Generic; namespace DiscImageChef.Decoders.CD { @@ -127,7 +126,7 @@ namespace DiscImageChef.Decoders.CD /// /// Total size of returned CD-Text information minus this field /// - public UInt16 DataLength; + public ushort DataLength; /// /// Reserved /// @@ -183,7 +182,7 @@ namespace DiscImageChef.Decoders.CD /// Bytes 16 to 17 /// CRC16 /// - public UInt16 CRC; + public ushort CRC; } public static CDText? Decode(byte[] CDTextResponse) diff --git a/DiscImageChef.Decoders/CD/Enums.cs b/DiscImageChef.Decoders/CD/Enums.cs index fd1c8c99..c2d8d5c3 100644 --- a/DiscImageChef.Decoders/CD/Enums.cs +++ b/DiscImageChef.Decoders/CD/Enums.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.CD { public enum TOC_ADR : byte diff --git a/DiscImageChef.Decoders/CD/FullTOC.cs b/DiscImageChef.Decoders/CD/FullTOC.cs index d1012942..48bfb3ac 100644 --- a/DiscImageChef.Decoders/CD/FullTOC.cs +++ b/DiscImageChef.Decoders/CD/FullTOC.cs @@ -67,7 +67,7 @@ namespace DiscImageChef.Decoders.CD /// /// Total size of returned session information minus this field /// - public UInt16 DataLength; + public ushort DataLength; /// /// First complete session number in hex /// diff --git a/DiscImageChef.Decoders/CD/PMA.cs b/DiscImageChef.Decoders/CD/PMA.cs index 1b99547b..72db4710 100644 --- a/DiscImageChef.Decoders/CD/PMA.cs +++ b/DiscImageChef.Decoders/CD/PMA.cs @@ -58,7 +58,7 @@ namespace DiscImageChef.Decoders.CD /// /// Total size of returned session information minus this field /// - public UInt16 DataLength; + public ushort DataLength; /// /// Reserved /// diff --git a/DiscImageChef.Decoders/CD/Session.cs b/DiscImageChef.Decoders/CD/Session.cs index d4a39f50..03764651 100644 --- a/DiscImageChef.Decoders/CD/Session.cs +++ b/DiscImageChef.Decoders/CD/Session.cs @@ -58,7 +58,7 @@ namespace DiscImageChef.Decoders.CD /// /// Total size of returned session information minus this field /// - public UInt16 DataLength; + public ushort DataLength; /// /// First track number in hex /// @@ -104,7 +104,7 @@ namespace DiscImageChef.Decoders.CD /// Bytes 4 to 7 /// First track number in last complete session start address in LBA or in MSF /// - public UInt32 TrackStartAddress; + public uint TrackStartAddress; } public static CDSessionInfo? Decode(byte[] CDSessionInfoResponse) diff --git a/DiscImageChef.Decoders/CD/TOC.cs b/DiscImageChef.Decoders/CD/TOC.cs index f314bae7..791ed160 100644 --- a/DiscImageChef.Decoders/CD/TOC.cs +++ b/DiscImageChef.Decoders/CD/TOC.cs @@ -60,7 +60,7 @@ namespace DiscImageChef.Decoders.CD /// /// Total size of returned TOC minus this field /// - public UInt16 DataLength; + public ushort DataLength; /// /// First track number in hex /// @@ -106,7 +106,7 @@ namespace DiscImageChef.Decoders.CD /// Bytes 4 to 7 /// The track start address in LBA or in MSF /// - public UInt32 TrackStartAddress; + public uint TrackStartAddress; } public static CDTOC? Decode(byte[] CDTOCResponse) diff --git a/DiscImageChef.Decoders/ChangeLog b/DiscImageChef.Decoders/ChangeLog index 1b53dba5..4bb3b6e5 100644 --- a/DiscImageChef.Decoders/ChangeLog +++ b/DiscImageChef.Decoders/ChangeLog @@ -1,3 +1,62 @@ +2016-07-28 Natalia Portillo + + * PMA.cs: + * TOC.cs: + * PFI.cs: + * DMI.cs: + * ATIP.cs: + * DDS.cs: + * PRI.cs: + * RMD.cs: + * BCA.cs: + * UDI.cs: + * ADIP.cs: + * AACS.cs: + * DMI.cs: + * Enums.cs: + * CPRM.cs: + * Spare.cs: + * EVPD.cs: + * Enums.cs: + * ISO.cs: + * Errors.cs: + * Enums.cs: + * Modes.cs: + * Sense.cs: + * Types.cs: + * DI.cs: + * Session.cs: + * FullTOC.cs: + * Layers.cs: + * BCA.cs: + * DDS.cs: + * CSS&CPRM.cs: + * Inquiry.cs: + * Identify.cs: + * Enums.cs: + * Amiga.cs: + * Apple2.cs: + * CPRM.cs: + * AACS.cs: + * Spare.cs: + * Cartridge.cs: + * Enums.cs: + * System34.cs: + * Hybrid.cs: + * AppleSony.cs: + * Commodore.cs: + * CDTextOnLeadIn.cs: + * Cartridge.cs: + * System3740.cs: + * Features.cs: + * VendorString.cs: + * Perpendicular.cs: + * BlockLimits.cs: + * WriteProtect.cs: + * DensitySupport.cs: + * DiscInformation.cs: + * DiscStructureCapabilities.cs: Refactor and code cleanup. + 2016-02-05 Natalia Portillo * SCSI/Sense.cs: diff --git a/DiscImageChef.Decoders/DVD/AACS.cs b/DiscImageChef.Decoders/DVD/AACS.cs index 2d448b85..f2f54414 100644 --- a/DiscImageChef.Decoders/DVD/AACS.cs +++ b/DiscImageChef.Decoders/DVD/AACS.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.DVD { /// @@ -58,7 +56,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/DVD/ADIP.cs b/DiscImageChef.Decoders/DVD/ADIP.cs index 1669e4a2..74eb9020 100644 --- a/DiscImageChef.Decoders/DVD/ADIP.cs +++ b/DiscImageChef.Decoders/DVD/ADIP.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.DVD { /// @@ -58,7 +56,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/DVD/BCA.cs b/DiscImageChef.Decoders/DVD/BCA.cs index de8bfb07..a8c107ac 100644 --- a/DiscImageChef.Decoders/DVD/BCA.cs +++ b/DiscImageChef.Decoders/DVD/BCA.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.DVD { /// @@ -58,7 +56,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/DVD/CPRM.cs b/DiscImageChef.Decoders/DVD/CPRM.cs index 8ea2ae7b..6ef24013 100644 --- a/DiscImageChef.Decoders/DVD/CPRM.cs +++ b/DiscImageChef.Decoders/DVD/CPRM.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.DVD { /// @@ -58,7 +56,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -82,7 +80,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/DVD/CSS&CPRM.cs b/DiscImageChef.Decoders/DVD/CSS&CPRM.cs index 28bcb5fd..5df818c8 100644 --- a/DiscImageChef.Decoders/DVD/CSS&CPRM.cs +++ b/DiscImageChef.Decoders/DVD/CSS&CPRM.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Text; namespace DiscImageChef.Decoders.DVD @@ -59,7 +58,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -98,7 +97,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/DVD/Cartridge.cs b/DiscImageChef.Decoders/DVD/Cartridge.cs index 7198716a..05e0633a 100644 --- a/DiscImageChef.Decoders/DVD/Cartridge.cs +++ b/DiscImageChef.Decoders/DVD/Cartridge.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Text; namespace DiscImageChef.Decoders.DVD @@ -58,7 +57,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/DVD/DDS.cs b/DiscImageChef.Decoders/DVD/DDS.cs index 5949d751..dd943879 100644 --- a/DiscImageChef.Decoders/DVD/DDS.cs +++ b/DiscImageChef.Decoders/DVD/DDS.cs @@ -60,7 +60,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/DVD/DMI.cs b/DiscImageChef.Decoders/DVD/DMI.cs index 27368a44..b71a35c8 100644 --- a/DiscImageChef.Decoders/DVD/DMI.cs +++ b/DiscImageChef.Decoders/DVD/DMI.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.DVD { /// @@ -58,7 +56,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/DVD/Enums.cs b/DiscImageChef.Decoders/DVD/Enums.cs index 5c9c9600..8a1dd9f3 100644 --- a/DiscImageChef.Decoders/DVD/Enums.cs +++ b/DiscImageChef.Decoders/DVD/Enums.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.DVD { #region Public enumerations diff --git a/DiscImageChef.Decoders/DVD/Layers.cs b/DiscImageChef.Decoders/DVD/Layers.cs index 30656821..fcdfbfd1 100644 --- a/DiscImageChef.Decoders/DVD/Layers.cs +++ b/DiscImageChef.Decoders/DVD/Layers.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.DVD { /// @@ -58,7 +56,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -98,7 +96,7 @@ namespace DiscImageChef.Decoders.DVD /// Byte 8 to 11 /// L0 Data Area Capacity /// - public UInt32 Capacity; + public uint Capacity; } public struct MiddleZoneStartAddress @@ -107,7 +105,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length = 10 /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -147,7 +145,7 @@ namespace DiscImageChef.Decoders.DVD /// Byte 8 to 11 /// Start LBA of Shifted Middle Area on L0 /// - public UInt32 ShiftedMiddleAreaStartAddress; + public uint ShiftedMiddleAreaStartAddress; } public struct JumpIntervalSize @@ -156,7 +154,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length = 10 /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -191,7 +189,7 @@ namespace DiscImageChef.Decoders.DVD /// Byte 8 to 11 /// Jump Interval size for the Regular Interval Layer Jump /// - public UInt32 Size; + public uint Size; } public struct ManualLayerJumpAddress @@ -200,7 +198,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length = 10 /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -235,7 +233,7 @@ namespace DiscImageChef.Decoders.DVD /// Byte 8 to 11 /// LBA for the manual layer jump /// - public UInt32 LBA; + public uint LBA; } } } diff --git a/DiscImageChef.Decoders/DVD/PFI.cs b/DiscImageChef.Decoders/DVD/PFI.cs index 9f399872..8b5f336c 100644 --- a/DiscImageChef.Decoders/DVD/PFI.cs +++ b/DiscImageChef.Decoders/DVD/PFI.cs @@ -74,7 +74,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -141,17 +141,17 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 8 to 11 /// PSN where Data Area starts /// - public UInt32 DataAreaStartPSN; + public uint DataAreaStartPSN; /// /// Bytes 12 to 15 /// PSN where Data Area ends /// - public UInt32 DataAreaEndPSN; + public uint DataAreaEndPSN; /// /// Bytes 16 to 19 /// PSN where Data Area ends in Layer 0 /// - public UInt32 Layer0EndPSN; + public uint Layer0EndPSN; /// /// Byte 20, bit 7 /// True if BCA exists. GC/Wii discs do not have this bit set, but there is a BCA, making it unreadable in normal DVD drives @@ -169,7 +169,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 21 to 22 /// UMD only, media attribute, application-defined, part of media specific in rest of discs /// - public UInt16 MediaAttribute; + public ushort MediaAttribute; #endregion UMD PFI #region DVD-RAM PFI @@ -285,12 +285,12 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 36 to 39 /// Sector number of the first sector of the current Border Out /// - public UInt32 CurrentBorderOutSector; + public uint CurrentBorderOutSector; /// /// Bytes 40 to 43 /// Sector number of the first sector of the next Border In /// - public UInt32 NextBorderInSector; + public uint NextBorderInSector; #endregion DVD-R PFI, DVD-RW PFI #region DVD+RW PFI @@ -1013,12 +1013,12 @@ namespace DiscImageChef.Decoders.DVD /// Byte 36 /// Start sector number of current RMD in Extra Border Zone /// - public UInt32 CurrentRMDExtraBorderPSN; + public uint CurrentRMDExtraBorderPSN; /// /// Byte 40 /// Start sector number of Physical Format Information blocks in Extra Border Zone /// - public UInt32 PFIExtraBorderPSN; + public uint PFIExtraBorderPSN; /// /// Byte 44, bit 0 /// If NOT set, Control Data Zone is pre-recorded @@ -1351,7 +1351,7 @@ namespace DiscImageChef.Decoders.DVD sizeString = "120mm"; break; default: - sizeString = String.Format("unknown size identifier {0}", decoded.DiscSize); + sizeString = string.Format("unknown size identifier {0}", decoded.DiscSize); break; } diff --git a/DiscImageChef.Decoders/DVD/PRI.cs b/DiscImageChef.Decoders/DVD/PRI.cs index c1e02a89..08532040 100644 --- a/DiscImageChef.Decoders/DVD/PRI.cs +++ b/DiscImageChef.Decoders/DVD/PRI.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.DVD { /// @@ -58,7 +56,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/DVD/RMD.cs b/DiscImageChef.Decoders/DVD/RMD.cs index 7ed84eea..a0cd8087 100644 --- a/DiscImageChef.Decoders/DVD/RMD.cs +++ b/DiscImageChef.Decoders/DVD/RMD.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.DVD { /// @@ -58,7 +56,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -82,7 +80,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -112,7 +110,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 6 to 7 /// Number of remaining RMDs in current RMZ /// - public UInt16 CurrentRemainingRMDs; + public ushort CurrentRemainingRMDs; } } } diff --git a/DiscImageChef.Decoders/DVD/Spare.cs b/DiscImageChef.Decoders/DVD/Spare.cs index d24ca05a..d62af3ef 100644 --- a/DiscImageChef.Decoders/DVD/Spare.cs +++ b/DiscImageChef.Decoders/DVD/Spare.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Text; namespace DiscImageChef.Decoders.DVD @@ -58,7 +57,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -73,17 +72,17 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 4 to 7 /// Data length /// - public UInt32 UnusedPrimaryBlocks; + public uint UnusedPrimaryBlocks; /// /// Bytes 8 to 11 /// Data length /// - public UInt32 UnusedSupplementaryBlocks; + public uint UnusedSupplementaryBlocks; /// /// Bytes 12 to 15 /// Data length /// - public UInt32 AllocatedSupplementaryBlocks; + public uint AllocatedSupplementaryBlocks; } public static SpareAreaInformation? Decode(byte[] response) diff --git a/DiscImageChef.Decoders/DVD/UDI.cs b/DiscImageChef.Decoders/DVD/UDI.cs index 507994d0..1dd3fe0e 100644 --- a/DiscImageChef.Decoders/DVD/UDI.cs +++ b/DiscImageChef.Decoders/DVD/UDI.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.DVD { /// @@ -58,7 +56,7 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -83,37 +81,37 @@ namespace DiscImageChef.Decoders.DVD /// Bytes 6 to 7 /// Random number /// - public UInt16 RandomNumber; + public ushort RandomNumber; /// /// Byte 8 to 11 /// Year /// - public UInt32 Year; + public uint Year; /// /// Byte 12 to 13 /// Month /// - public UInt16 Month; + public ushort Month; /// /// Byte 14 to 15 /// Day /// - public UInt16 Day; + public ushort Day; /// /// Byte 16 to 17 /// Hour /// - public UInt16 Hour; + public ushort Hour; /// /// Byte 18 to 19 /// Minute /// - public UInt16 Minute; + public ushort Minute; /// /// Byte 20 to 21 /// Second /// - public UInt16 Second; + public ushort Second; } } } diff --git a/DiscImageChef.Decoders/Floppy/Amiga.cs b/DiscImageChef.Decoders/Floppy/Amiga.cs index 6fb36438..4cf36959 100644 --- a/DiscImageChef.Decoders/Floppy/Amiga.cs +++ b/DiscImageChef.Decoders/Floppy/Amiga.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Runtime.InteropServices; namespace DiscImageChef.Decoders.Floppy @@ -76,11 +75,11 @@ namespace DiscImageChef.Decoders.Floppy /// /// Checksum from to /// - public UInt32 headerChecksum; + public uint headerChecksum; /// /// Checksum from /// - public UInt32 dataChecksum; + public uint dataChecksum; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] public byte[] data; } diff --git a/DiscImageChef.Decoders/Floppy/Apple2.cs b/DiscImageChef.Decoders/Floppy/Apple2.cs index a1f8351f..7b656195 100644 --- a/DiscImageChef.Decoders/Floppy/Apple2.cs +++ b/DiscImageChef.Decoders/Floppy/Apple2.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Runtime.InteropServices; namespace DiscImageChef.Decoders.Floppy diff --git a/DiscImageChef.Decoders/Floppy/AppleSony.cs b/DiscImageChef.Decoders/Floppy/AppleSony.cs index 764ed5ce..254239cd 100644 --- a/DiscImageChef.Decoders/Floppy/AppleSony.cs +++ b/DiscImageChef.Decoders/Floppy/AppleSony.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Runtime.InteropServices; namespace DiscImageChef.Decoders.Floppy @@ -89,7 +88,7 @@ namespace DiscImageChef.Decoders.Floppy [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] prologue; /// - /// Encoded (decodedTrack & 0x3F) + /// Encoded (decodedTrack & 0x3F) /// public byte track; /// diff --git a/DiscImageChef.Decoders/Floppy/Commodore.cs b/DiscImageChef.Decoders/Floppy/Commodore.cs index 2d61ac30..8d9d9af8 100644 --- a/DiscImageChef.Decoders/Floppy/Commodore.cs +++ b/DiscImageChef.Decoders/Floppy/Commodore.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Runtime.InteropServices; namespace DiscImageChef.Decoders.Floppy @@ -64,11 +63,11 @@ namespace DiscImageChef.Decoders.Floppy /// /// Format ID, unknown meaning /// - public UInt16 format; + public ushort format; /// /// Filled with 0x0F /// - public UInt16 fill; + public ushort fill; } /// @@ -92,7 +91,7 @@ namespace DiscImageChef.Decoders.Floppy /// /// Filled with 0x0F /// - public UInt16 fill; + public ushort fill; } } } diff --git a/DiscImageChef.Decoders/Floppy/Enums.cs b/DiscImageChef.Decoders/Floppy/Enums.cs index 10f92302..97df797d 100644 --- a/DiscImageChef.Decoders/Floppy/Enums.cs +++ b/DiscImageChef.Decoders/Floppy/Enums.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.Floppy { /// diff --git a/DiscImageChef.Decoders/Floppy/ISO.cs b/DiscImageChef.Decoders/Floppy/ISO.cs index 1fb6b282..6edc6d80 100644 --- a/DiscImageChef.Decoders/Floppy/ISO.cs +++ b/DiscImageChef.Decoders/Floppy/ISO.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Runtime.InteropServices; namespace DiscImageChef.Decoders.Floppy @@ -130,9 +129,9 @@ namespace DiscImageChef.Decoders.Floppy /// public IBMSectorSizeCode sectorSize; /// - /// CRC16 from to end of + /// CRC16 from to end of /// - public UInt16 crc; + public ushort crc; } /// @@ -161,7 +160,7 @@ namespace DiscImageChef.Decoders.Floppy /// /// CRC16 from to end of /// - public UInt16 crc; + public ushort crc; } } } diff --git a/DiscImageChef.Decoders/Floppy/Perpendicular.cs b/DiscImageChef.Decoders/Floppy/Perpendicular.cs index 2f4c3f04..7bc69a53 100644 --- a/DiscImageChef.Decoders/Floppy/Perpendicular.cs +++ b/DiscImageChef.Decoders/Floppy/Perpendicular.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Runtime.InteropServices; namespace DiscImageChef.Decoders.Floppy @@ -161,9 +160,9 @@ namespace DiscImageChef.Decoders.Floppy /// public IBMSectorSizeCode sectorSize; /// - /// CRC16 from to end of + /// CRC16 from to end of /// - public UInt16 crc; + public ushort crc; } /// @@ -192,7 +191,7 @@ namespace DiscImageChef.Decoders.Floppy /// /// CRC16 from to end of /// - public UInt16 crc; + public ushort crc; } } } diff --git a/DiscImageChef.Decoders/Floppy/System34.cs b/DiscImageChef.Decoders/Floppy/System34.cs index fb70d686..17821eda 100644 --- a/DiscImageChef.Decoders/Floppy/System34.cs +++ b/DiscImageChef.Decoders/Floppy/System34.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Runtime.InteropServices; namespace DiscImageChef.Decoders.Floppy @@ -162,9 +161,9 @@ namespace DiscImageChef.Decoders.Floppy /// public IBMSectorSizeCode sectorSize; /// - /// CRC16 from to end of + /// CRC16 from to end of /// - public UInt16 crc; + public ushort crc; } /// @@ -193,7 +192,7 @@ namespace DiscImageChef.Decoders.Floppy /// /// CRC16 from to end of /// - public UInt16 crc; + public ushort crc; } } } diff --git a/DiscImageChef.Decoders/Floppy/System3740.cs b/DiscImageChef.Decoders/Floppy/System3740.cs index bb9442ff..b476dfa4 100644 --- a/DiscImageChef.Decoders/Floppy/System3740.cs +++ b/DiscImageChef.Decoders/Floppy/System3740.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Runtime.InteropServices; namespace DiscImageChef.Decoders.Floppy @@ -152,7 +151,7 @@ namespace DiscImageChef.Decoders.Floppy /// /// CRC16 from to end of /// - public UInt16 crc; + public ushort crc; } /// @@ -176,7 +175,7 @@ namespace DiscImageChef.Decoders.Floppy /// /// CRC16 from to end of /// - public UInt16 crc; + public ushort crc; } } } diff --git a/DiscImageChef.Decoders/SCSI/DiscStructureCapabilities.cs b/DiscImageChef.Decoders/SCSI/DiscStructureCapabilities.cs index 21ac3360..e6b53ab9 100644 --- a/DiscImageChef.Decoders/SCSI/DiscStructureCapabilities.cs +++ b/DiscImageChef.Decoders/SCSI/DiscStructureCapabilities.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Collections.Generic; namespace DiscImageChef.Decoders.SCSI diff --git a/DiscImageChef.Decoders/SCSI/EVPD.cs b/DiscImageChef.Decoders/SCSI/EVPD.cs index f2cff3ee..dab8f65e 100644 --- a/DiscImageChef.Decoders/SCSI/EVPD.cs +++ b/DiscImageChef.Decoders/SCSI/EVPD.cs @@ -31,7 +31,6 @@ // ****************************************************************************/ using System; -using DiscImageChef; namespace DiscImageChef.Decoders.SCSI { diff --git a/DiscImageChef.Decoders/SCSI/Enums.cs b/DiscImageChef.Decoders/SCSI/Enums.cs index 004519c8..385d5ba0 100644 --- a/DiscImageChef.Decoders/SCSI/Enums.cs +++ b/DiscImageChef.Decoders/SCSI/Enums.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.SCSI { public enum PeripheralQualifiers : byte diff --git a/DiscImageChef.Decoders/SCSI/Inquiry.cs b/DiscImageChef.Decoders/SCSI/Inquiry.cs index e4a9556d..1b20580c 100644 --- a/DiscImageChef.Decoders/SCSI/Inquiry.cs +++ b/DiscImageChef.Decoders/SCSI/Inquiry.cs @@ -448,7 +448,7 @@ namespace DiscImageChef.Decoders.SCSI if(response.VersionDescriptors != null) { - foreach(UInt16 VersionDescriptor in response.VersionDescriptors) + foreach(ushort VersionDescriptor in response.VersionDescriptors) { switch(VersionDescriptor) { @@ -2140,7 +2140,7 @@ namespace DiscImageChef.Decoders.SCSI /// Array of version descriptors /// Bytes 58 to 73 /// - public UInt16[] VersionDescriptors; + public ushort[] VersionDescriptors; /// /// Reserved /// Bytes 74 to 95 diff --git a/DiscImageChef.Decoders/SCSI/MMC/AACS.cs b/DiscImageChef.Decoders/SCSI/MMC/AACS.cs index 0564ab94..45eff4a1 100644 --- a/DiscImageChef.Decoders/SCSI/MMC/AACS.cs +++ b/DiscImageChef.Decoders/SCSI/MMC/AACS.cs @@ -58,7 +58,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -82,7 +82,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -106,7 +106,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -130,7 +130,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -154,7 +154,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// Data length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -178,7 +178,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// Data Length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -187,7 +187,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// /// Byte 3 /// Number of LBA extents the drive can store. - /// if(MaxLBAExtents == 0 && DataLength > 2), 256 extents can be stored + /// if(MaxLBAExtents == 0 && DataLength > 2), 256 extents can be stored /// public byte MaxLBAExtents; /// @@ -208,12 +208,12 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 8 to 11 /// Start LBA of extent /// - public UInt32 StartLBA; + public uint StartLBA; /// /// Bytes 12 to 15 /// Extent length /// - public UInt32 LBACount; + public uint LBACount; } public static AACSVolumeIdentifier? DecodeAACSVolumeIdentifier(byte[] AACSVIResponse) diff --git a/DiscImageChef.Decoders/SCSI/MMC/CPRM.cs b/DiscImageChef.Decoders/SCSI/MMC/CPRM.cs index 7c6cc13e..7d7a7b37 100644 --- a/DiscImageChef.Decoders/SCSI/MMC/CPRM.cs +++ b/DiscImageChef.Decoders/SCSI/MMC/CPRM.cs @@ -58,7 +58,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// Data Length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs b/DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs index f0ab764e..13992fda 100644 --- a/DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs +++ b/DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs @@ -58,7 +58,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// 32 + OPCTablesNumber*8 /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2, bits 7 to 5 /// 000b @@ -88,17 +88,17 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Byte 9 (MSB) and byte 4 (LSB) /// Number of sessions /// - public UInt16 Sessions; + public ushort Sessions; /// /// Byte 10 (MSB) and byte 5 (LSB) /// Number of first track in last session /// - public UInt16 FirstTrackLastSession; + public ushort FirstTrackLastSession; /// /// Byte 11 (MSB) and byte 6 (LSB) /// Number of last track in last session /// - public UInt16 LastTrackLastSession; + public ushort LastTrackLastSession; /// /// Byte 7, bit 7 /// If set, DiscIdentification is valid @@ -143,22 +143,22 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 12 to 15 /// Disc identification number from PMA /// - public UInt32 DiscIdentification; + public uint DiscIdentification; /// /// Bytes 16 to 19 /// Last Session Lead-in Start Address (MSF for CD, LBA for others) /// - public UInt32 LastSessionLeadInStartLBA; + public uint LastSessionLeadInStartLBA; /// /// Bytes 20 to 23 /// Last Possible Lead-out Start Address (MSF for CD, LBA for others) /// - public UInt32 LastPossibleLeadOutStartLBA; + public uint LastPossibleLeadOutStartLBA; /// /// Bytes 24 to 31 /// Disc barcode /// - public UInt64 DiscBarcode; + public ulong DiscBarcode; /// /// Byte 32 /// Disc application code @@ -182,7 +182,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// kilobytes/sec this OPC table applies to /// - public UInt16 Speed; + public ushort Speed; /// /// Bytes 2 to 7 /// OPC values @@ -196,7 +196,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// 10 /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2, bits 7 to 5 /// 001b @@ -216,22 +216,22 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 4 to 5 /// Maximum possible number of the tracks on the disc /// - public UInt16 MaxTracks; + public ushort MaxTracks; /// /// Bytes 6 to 7 /// Number of the assigned tracks on the disc /// - public UInt16 AssignedTracks; + public ushort AssignedTracks; /// /// Bytes 8 to 9 /// Maximum possible number of appendable tracks on the disc /// - public UInt16 MaxAppendableTracks; + public ushort MaxAppendableTracks; /// /// Bytes 10 to 11 /// Current number of appendable tracks on the disc /// - public UInt16 AppendableTracks; + public ushort AppendableTracks; } public struct POWResourcesInformation @@ -240,7 +240,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// 14 /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2, bits 7 to 5 /// 010b @@ -260,17 +260,17 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 4 to 7 /// Remaining POW replacements /// - public UInt32 RemainingPOWReplacements; + public uint RemainingPOWReplacements; /// /// Bytes 8 to 11 /// Remaining POW reallocation map entries /// - public UInt32 RemainingPOWReallocation; + public uint RemainingPOWReallocation; /// /// Bytes 12 to 15 /// Number of remaining POW updates /// - public UInt32 RemainingPOWUpdates; + public uint RemainingPOWUpdates; } public static StandardDiscInformation? Decode000b(byte[] response) diff --git a/DiscImageChef.Decoders/SCSI/MMC/Enums.cs b/DiscImageChef.Decoders/SCSI/MMC/Enums.cs index eed88105..02bb7aa6 100644 --- a/DiscImageChef.Decoders/SCSI/MMC/Enums.cs +++ b/DiscImageChef.Decoders/SCSI/MMC/Enums.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.SCSI.MMC { public enum FormatLayerTypeCodes : ushort diff --git a/DiscImageChef.Decoders/SCSI/MMC/Features.cs b/DiscImageChef.Decoders/SCSI/MMC/Features.cs index 0a125bce..8f70a46d 100644 --- a/DiscImageChef.Decoders/SCSI/MMC/Features.cs +++ b/DiscImageChef.Decoders/SCSI/MMC/Features.cs @@ -5316,13 +5316,15 @@ namespace DiscImageChef.Decoders.SCSI.MMC try { - DateTime fwDate = new DateTime(Int32.Parse(syear), Int32.Parse(smonth), - Int32.Parse(sday), Int32.Parse(shour), Int32.Parse(sminute), - Int32.Parse(ssecond), DateTimeKind.Utc); + DateTime fwDate = new DateTime(int.Parse(syear), int.Parse(smonth), + int.Parse(sday), int.Parse(shour), int.Parse(sminute), + int.Parse(ssecond), DateTimeKind.Utc); sb.AppendFormat("Drive firmware is dated {0}", fwDate).AppendLine(); } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { } diff --git a/DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs b/DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs index dd3a993a..38ce22e0 100644 --- a/DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs +++ b/DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs @@ -58,7 +58,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// Data Length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved @@ -98,7 +98,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 6 to end /// Recognized format layers /// - public UInt16[] FormatLayers; + public ushort[] FormatLayers; } public static RecognizedFormatLayers? DecodeFormatLayers(byte[] FormatLayersResponse) @@ -122,7 +122,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC decoded.Reserved4 = (byte)((FormatLayersResponse[5] & 0x0C) >> 2); decoded.OnlineFormatLayer = (byte)(FormatLayersResponse[5] & 0x03); - decoded.FormatLayers = new UInt16[(FormatLayersResponse.Length - 6) / 2]; + decoded.FormatLayers = new ushort[(FormatLayersResponse.Length - 6) / 2]; for(int i = 0; i < (FormatLayersResponse.Length - 6) / 2; i++) { @@ -147,7 +147,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC { switch(response.FormatLayers[i]) { - case (UInt16)FormatLayerTypeCodes.BDLayer: + case (ushort)FormatLayerTypeCodes.BDLayer: { sb.AppendFormat("Layer {0} is of type Blu-ray", i).AppendLine(); if(response.DefaultFormatLayer == i) @@ -156,7 +156,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC sb.AppendLine("This is the layer actually in use."); break; } - case (UInt16)FormatLayerTypeCodes.CDLayer: + case (ushort)FormatLayerTypeCodes.CDLayer: { sb.AppendFormat("Layer {0} is of type CD", i).AppendLine(); if(response.DefaultFormatLayer == i) @@ -165,7 +165,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC sb.AppendLine("This is the layer actually in use."); break; } - case (UInt16)FormatLayerTypeCodes.DVDLayer: + case (ushort)FormatLayerTypeCodes.DVDLayer: { sb.AppendFormat("Layer {0} is of type DVD", i).AppendLine(); if(response.DefaultFormatLayer == i) @@ -174,7 +174,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC sb.AppendLine("This is the layer actually in use."); break; } - case (UInt16)FormatLayerTypeCodes.HDDVDLayer: + case (ushort)FormatLayerTypeCodes.HDDVDLayer: { sb.AppendFormat("Layer {0} is of type HD DVD", i).AppendLine(); if(response.DefaultFormatLayer == i) diff --git a/DiscImageChef.Decoders/SCSI/MMC/WriteProtect.cs b/DiscImageChef.Decoders/SCSI/MMC/WriteProtect.cs index 42a50e9a..24f31aa9 100644 --- a/DiscImageChef.Decoders/SCSI/MMC/WriteProtect.cs +++ b/DiscImageChef.Decoders/SCSI/MMC/WriteProtect.cs @@ -58,7 +58,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC /// Bytes 0 to 1 /// Data Length /// - public UInt16 DataLength; + public ushort DataLength; /// /// Byte 2 /// Reserved diff --git a/DiscImageChef.Decoders/SCSI/Modes.cs b/DiscImageChef.Decoders/SCSI/Modes.cs index 29975f25..80efbf32 100644 --- a/DiscImageChef.Decoders/SCSI/Modes.cs +++ b/DiscImageChef.Decoders/SCSI/Modes.cs @@ -233,7 +233,7 @@ namespace DiscImageChef.Decoders.SCSI density = "15916 flux transitions per radian"; break; default: - density = String.Format("with unknown density code 0x{0:X2}", (byte)descriptor.Density); + density = string.Format("with unknown density code 0x{0:X2}", (byte)descriptor.Density); break; } @@ -272,7 +272,7 @@ namespace DiscImageChef.Decoders.SCSI sb.AppendLine("\tDevice uses a write cache but doesn't return until cache is flushed"); break; default: - sb.AppendFormat("\tUnknown buffered mode code 0x{0:X2}", (byte)header.Value.BufferedMode).AppendLine(); + sb.AppendFormat("\tUnknown buffered mode code 0x{0:X2}", header.Value.BufferedMode).AppendLine(); break; } @@ -463,7 +463,7 @@ namespace DiscImageChef.Decoders.SCSI medium = "Exatape 75m"; break; default: - medium = String.Format("unknown medium type 0x{0:X2}", (byte)header.Value.MediumType); + medium = string.Format("unknown medium type 0x{0:X2}", (byte)header.Value.MediumType); break; } @@ -601,7 +601,7 @@ namespace DiscImageChef.Decoders.SCSI density = "AIT-3"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -623,7 +623,7 @@ namespace DiscImageChef.Decoders.SCSI density = "LTO Ultrium-5 WORM"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -636,7 +636,7 @@ namespace DiscImageChef.Decoders.SCSI density = "LTO Ultrium"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -649,7 +649,7 @@ namespace DiscImageChef.Decoders.SCSI density = "LTO Ultrium-2"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -665,7 +665,7 @@ namespace DiscImageChef.Decoders.SCSI density = "DDS-3"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -681,7 +681,7 @@ namespace DiscImageChef.Decoders.SCSI density = "DDS-4"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -694,7 +694,7 @@ namespace DiscImageChef.Decoders.SCSI density = "DAT-72"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -708,7 +708,7 @@ namespace DiscImageChef.Decoders.SCSI density = "LTO Ultrium-3"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -721,7 +721,7 @@ namespace DiscImageChef.Decoders.SCSI density = "DDS cleaning cartridge"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -735,7 +735,7 @@ namespace DiscImageChef.Decoders.SCSI density = "LTO Ultrium-4"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -749,7 +749,7 @@ namespace DiscImageChef.Decoders.SCSI density = "LTO Ultrium-5"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -763,7 +763,7 @@ namespace DiscImageChef.Decoders.SCSI density = "LTO Ultrium-6"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -777,7 +777,7 @@ namespace DiscImageChef.Decoders.SCSI density = "LTO Ultrium-7"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -799,7 +799,7 @@ namespace DiscImageChef.Decoders.SCSI density = "LTO Ultrium-5 in CD emulation mode"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -833,7 +833,7 @@ namespace DiscImageChef.Decoders.SCSI density = "VXA-1"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -876,7 +876,7 @@ namespace DiscImageChef.Decoders.SCSI density = "VXA-3"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -914,7 +914,7 @@ namespace DiscImageChef.Decoders.SCSI density = "DLTtape III compressed"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -946,7 +946,7 @@ namespace DiscImageChef.Decoders.SCSI density = "DLTtape IIIxt compressed"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1000,7 +1000,7 @@ namespace DiscImageChef.Decoders.SCSI density = "DLTtape IV at 98250 bpi compressed"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1039,7 +1039,7 @@ namespace DiscImageChef.Decoders.SCSI density = "Super DLTtape I at 133000 bpi compressed"; break;*/ default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1052,7 +1052,7 @@ namespace DiscImageChef.Decoders.SCSI density = "Super DLTtape II"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1069,7 +1069,7 @@ namespace DiscImageChef.Decoders.SCSI density = "VStape I compressed"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1082,7 +1082,7 @@ namespace DiscImageChef.Decoders.SCSI density = "DLTtape S4"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1104,7 +1104,7 @@ namespace DiscImageChef.Decoders.SCSI density = "EXB-8500 compressed"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1129,7 +1129,7 @@ namespace DiscImageChef.Decoders.SCSI density = "Mammoth"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1154,7 +1154,7 @@ namespace DiscImageChef.Decoders.SCSI density = "Mammoth"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1179,7 +1179,7 @@ namespace DiscImageChef.Decoders.SCSI density = "Mammoth"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1201,7 +1201,7 @@ namespace DiscImageChef.Decoders.SCSI density = "Mammoth-2"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1214,7 +1214,7 @@ namespace DiscImageChef.Decoders.SCSI density = "DC-2900SL"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1227,7 +1227,7 @@ namespace DiscImageChef.Decoders.SCSI density = "DC-9250"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1240,7 +1240,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLR-32"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1253,7 +1253,7 @@ namespace DiscImageChef.Decoders.SCSI density = "MRL1-26GBSL"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1266,7 +1266,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLRtape-50"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1279,7 +1279,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLRtape-50 SL"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1292,7 +1292,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLR-32 SL"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1305,7 +1305,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLR-5"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1318,7 +1318,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLR-5 SL"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1331,7 +1331,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLRtape-7"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1344,7 +1344,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLRtape-7 SL"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1357,7 +1357,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLRtape-24"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1370,7 +1370,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLRtape-24 SL"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1383,7 +1383,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLRtape-140"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1396,7 +1396,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLRtape-40"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1409,7 +1409,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLRtape-60 or SLRtape-75"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1422,7 +1422,7 @@ namespace DiscImageChef.Decoders.SCSI density = "SLRtape-100"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } @@ -1435,13 +1435,13 @@ namespace DiscImageChef.Decoders.SCSI density = "SLR40, SLR60 or SLR100"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } } break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } @@ -1583,7 +1583,7 @@ namespace DiscImageChef.Decoders.SCSI density = "ANSI X3.200: 356 mm double-sided optical disc with 56350 tracks"; break; default: - density = String.Format("unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("unknown density code 0x{0:X2}", descriptor.Density); break; } @@ -1787,7 +1787,7 @@ namespace DiscImageChef.Decoders.SCSI density = "LTO Ultrium-5"; break; default: - density = String.Format("with unknown density code 0x{0:X2}", descriptor.Density); + density = string.Format("with unknown density code 0x{0:X2}", descriptor.Density); break; } @@ -1811,8 +1811,6 @@ namespace DiscImageChef.Decoders.SCSI break; } #endregion Multimedia device mode header - default: - break; } return sb.ToString(); @@ -2244,7 +2242,7 @@ namespace DiscImageChef.Decoders.SCSI if(page.BusyTimeoutPeriod == 0xFFFF) sb.AppendLine("\tThere is no limit on the maximum time that is allowed to remain busy"); else - sb.AppendFormat("\tA maximum of {0} ms are allowed to remain busy", (int)page.BusyTimeoutPeriod * 100).AppendLine(); + sb.AppendFormat("\tA maximum of {0} ms are allowed to remain busy", page.BusyTimeoutPeriod * 100).AppendLine(); } if(page.ExtendedSelfTestCompletionTime > 0) @@ -2372,17 +2370,17 @@ namespace DiscImageChef.Decoders.SCSI if(page.BufferEmptyRatio > 0) sb.AppendFormat("\t{0} ratio of buffer that shall be empty prior to attempting a reselection", page.BufferEmptyRatio).AppendLine(); if(page.BusInactivityLimit > 0) - sb.AppendFormat("\t{0} µs maximum permitted to assert BSY without a REQ/ACK handshake", (int)page.BusInactivityLimit * 100).AppendLine(); + sb.AppendFormat("\t{0} µs maximum permitted to assert BSY without a REQ/ACK handshake", page.BusInactivityLimit * 100).AppendLine(); if(page.DisconnectTimeLimit > 0) - sb.AppendFormat("\t{0} µs maximum permitted wait after releasing the bus before attempting reselection", (int)page.DisconnectTimeLimit * 100).AppendLine(); + sb.AppendFormat("\t{0} µs maximum permitted wait after releasing the bus before attempting reselection", page.DisconnectTimeLimit * 100).AppendLine(); if(page.ConnectTimeLimit > 0) - sb.AppendFormat("\t{0} µs allowed to use the bus before disconnecting, if granted the privilege and not restricted", (int)page.ConnectTimeLimit * 100).AppendLine(); + sb.AppendFormat("\t{0} µs allowed to use the bus before disconnecting, if granted the privilege and not restricted", page.ConnectTimeLimit * 100).AppendLine(); if(page.MaxBurstSize > 0) - sb.AppendFormat("\t{0} bytes maximum can be transferred before disconnecting", (int)page.MaxBurstSize * 512).AppendLine(); + sb.AppendFormat("\t{0} bytes maximum can be transferred before disconnecting", page.MaxBurstSize * 512).AppendLine(); if(page.FirstBurstSize > 0) - sb.AppendFormat("\t{0} bytes maximum can be transferred for a command along with the disconnect command", (int)page.FirstBurstSize * 512).AppendLine(); + sb.AppendFormat("\t{0} bytes maximum can be transferred for a command along with the disconnect command", page.FirstBurstSize * 512).AppendLine(); - if(page.DIMM) + if(page.DIMM) sb.AppendLine("\tTarget shall not transfer data for a command during the same interconnect tenancy"); if(page.EMDP) sb.AppendLine("\tTarget is allowed to re-order the data transfer"); @@ -3853,7 +3851,7 @@ namespace DiscImageChef.Decoders.SCSI sb.AppendFormat("\tActive partition: {0}", page.ActivePartition).AppendLine(); sb.AppendFormat("\tWrite buffer shall have a full ratio of {0} before being flushed to medium", page.WriteBufferFullRatio).AppendLine(); sb.AppendFormat("\tRead buffer shall have an empty ratio of {0} before more data is read from medium", page.ReadBufferEmptyRatio).AppendLine(); - sb.AppendFormat("\tDrive will delay {0} ms before buffered data is forcefully written to the medium even before buffer is full", (int)page.WriteDelayTime * 100).AppendLine(); + sb.AppendFormat("\tDrive will delay {0} ms before buffered data is forcefully written to the medium even before buffer is full", page.WriteDelayTime * 100).AppendLine(); if(page.DBR) { sb.AppendLine("\tDrive supports recovering data from buffer"); @@ -6261,7 +6259,7 @@ namespace DiscImageChef.Decoders.SCSI #region Mode Page 0x1C: Timer & Protect page /// - /// Timer & Protect page + /// Timer & Protect page /// Page code 0x1C /// 8 bytes in INF-8070 /// diff --git a/DiscImageChef.Decoders/SCSI/SSC/BlockLimits.cs b/DiscImageChef.Decoders/SCSI/SSC/BlockLimits.cs index f5f48d88..075be429 100644 --- a/DiscImageChef.Decoders/SCSI/SSC/BlockLimits.cs +++ b/DiscImageChef.Decoders/SCSI/SSC/BlockLimits.cs @@ -88,7 +88,9 @@ namespace DiscImageChef.Decoders.SCSI.SSC sb.AppendFormat("Device's minimum block size is {0} bytes", decoded.Value.minBlockLen).AppendLine(); if(decoded.Value.granularity > 0) - sb.AppendFormat("Device's needs a block size granularity of 2^{0} ({1}) bytes", decoded.Value.granularity, Math.Pow(2, (double)decoded.Value.granularity)).AppendLine(); +#pragma warning disable IDE0004 // Remove Unnecessary Cast + sb.AppendFormat("Device's needs a block size granularity of 2^{0} ({1}) bytes", decoded.Value.granularity, Math.Pow(2, (double)decoded.Value.granularity)).AppendLine(); +#pragma warning restore IDE0004 // Remove Unnecessary Cast } return sb.ToString(); diff --git a/DiscImageChef.Decoders/SCSI/SSC/DensitySupport.cs b/DiscImageChef.Decoders/SCSI/SSC/DensitySupport.cs index c2864343..f4ab771b 100644 --- a/DiscImageChef.Decoders/SCSI/SSC/DensitySupport.cs +++ b/DiscImageChef.Decoders/SCSI/SSC/DensitySupport.cs @@ -166,8 +166,10 @@ namespace DiscImageChef.Decoders.SCSI.SSC if(descriptor.defaultDensity) sb.AppendLine("\tThis is the default density on the drive"); sb.AppendFormat("\tDensity has {0} bits per mm, with {1} tracks in a {2} mm width tape", +#pragma warning disable IDE0004 // Remove Unnecessary Cast descriptor.bpmm, descriptor.tracks, (double)((double)descriptor.width / (double)10)).AppendLine(); - sb.AppendFormat("\tDensity maximum capacity is {0} megabytes", descriptor.capacity).AppendLine(); +#pragma warning restore IDE0004 // Remove Unnecessary Cast + sb.AppendFormat("\tDensity maximum capacity is {0} megabytes", descriptor.capacity).AppendLine(); sb.AppendFormat("\tDensity description: {0}", descriptor.description).AppendLine(); sb.AppendLine(); } @@ -256,8 +258,10 @@ namespace DiscImageChef.Decoders.SCSI.SSC } sb.AppendFormat("\tMedium has a nominal length of {0} m in a {1} mm width tape", +#pragma warning disable IDE0004 // Remove Unnecessary Cast descriptor.length, (double)((double)descriptor.width / (double)10)).AppendLine(); - sb.AppendFormat("\tMedium description: {0}", descriptor.description).AppendLine(); +#pragma warning restore IDE0004 // Remove Unnecessary Cast + sb.AppendFormat("\tMedium description: {0}", descriptor.description).AppendLine(); sb.AppendLine(); } diff --git a/DiscImageChef.Decoders/SCSI/Sense.cs b/DiscImageChef.Decoders/SCSI/Sense.cs index b2ada4e0..fe6f0f7b 100644 --- a/DiscImageChef.Decoders/SCSI/Sense.cs +++ b/DiscImageChef.Decoders/SCSI/Sense.cs @@ -396,9 +396,9 @@ namespace DiscImageChef.Decoders.SCSI if(!sense.HasValue) return null; - return sense.Value.AddressValid ? String.Format("Error class {0} type {1} happened on block {2}\n", + return sense.Value.AddressValid ? string.Format("Error class {0} type {1} happened on block {2}\n", sense.Value.ErrorClass, sense.Value.ErrorType, sense.Value.LBA) : - String.Format("Error class {0} type {1}\n", sense.Value.ErrorClass, + string.Format("Error class {0} type {1}\n", sense.Value.ErrorClass, sense.Value.ErrorType); } @@ -499,7 +499,7 @@ namespace DiscImageChef.Decoders.SCSI /// /// The information value /// Descriptor. - public static UInt64 DecodeDescriptor00(byte[] descriptor) + public static ulong DecodeDescriptor00(byte[] descriptor) { if(descriptor.Length != 12 || descriptor[0] != 0x00) return 0; @@ -523,7 +523,7 @@ namespace DiscImageChef.Decoders.SCSI /// /// The command-specific information sense data descriptor. /// Descriptor. - public static UInt64 DecodeDescriptor01(byte[] descriptor) + public static ulong DecodeDescriptor01(byte[] descriptor) { if(descriptor.Length != 12 || descriptor[0] != 0x01) return 0; @@ -640,9 +640,9 @@ namespace DiscImageChef.Decoders.SCSI throw new NotImplementedException("Check SBC-3"); } - public static string PrettifyDescriptor00(UInt64 information) + public static string PrettifyDescriptor00(ulong information) { - return String.Format("On logical block {0}\n", information); + return string.Format("On logical block {0}\n", information); } public static string PrettifyDescriptor00(byte[] descriptor) @@ -1884,7 +1884,7 @@ namespace DiscImageChef.Decoders.SCSI case 0x00: return "RAM FAILURE"; default: - return String.Format("DIAGNOSTIC FAILURE ON COMPONENT {0:X2}h", ASCQ); + return string.Format("DIAGNOSTIC FAILURE ON COMPONENT {0:X2}h", ASCQ); } case 0x41: switch(ASCQ) @@ -2031,7 +2031,7 @@ namespace DiscImageChef.Decoders.SCSI } break; case 0x4E: - return String.Format("OVERLAPPED COMMANDS ATTEMPTED FOR TASK TAG {0:X2}h", ASCQ); + return string.Format("OVERLAPPED COMMANDS ATTEMPTED FOR TASK TAG {0:X2}h", ASCQ); case 0x50: switch(ASCQ) { @@ -2566,7 +2566,7 @@ namespace DiscImageChef.Decoders.SCSI } break; case 0x70: - return String.Format("DECOMPRESSION EXCEPTION SHORT ALGORITHM ID OF {0:X2}h", ASCQ); + return string.Format("DECOMPRESSION EXCEPTION SHORT ALGORITHM ID OF {0:X2}h", ASCQ); case 0x71: switch(ASCQ) { @@ -2684,10 +2684,10 @@ namespace DiscImageChef.Decoders.SCSI } return ASC >= 0x80 ? ASCQ >= 0x80 ? - String.Format("VENDOR-SPECIFIC ASC {0:X2}h WITH VENDOR-SPECIFIC ASCQ {1:X2}h", ASC, ASCQ) : - String.Format("VENDOR-SPECIFIC ASC {0:X2}h WITH ASCQ {1:X2}h", ASC, ASCQ) : - ASCQ >= 0x80 ? String.Format("ASC {0:X2}h WITH VENDOR-SPECIFIC ASCQ {1:X2}h", ASC, ASCQ) : - String.Format("ASC {0:X2}h WITH ASCQ {1:X2}h", ASC, ASCQ); + string.Format("VENDOR-SPECIFIC ASC {0:X2}h WITH VENDOR-SPECIFIC ASCQ {1:X2}h", ASC, ASCQ) : + string.Format("VENDOR-SPECIFIC ASC {0:X2}h WITH ASCQ {1:X2}h", ASC, ASCQ) : + ASCQ >= 0x80 ? string.Format("ASC {0:X2}h WITH VENDOR-SPECIFIC ASCQ {1:X2}h", ASC, ASCQ) : + string.Format("ASC {0:X2}h WITH ASCQ {1:X2}h", ASC, ASCQ); } } } diff --git a/DiscImageChef.Decoders/SCSI/Types.cs b/DiscImageChef.Decoders/SCSI/Types.cs index 3f5e88f4..f858aec8 100644 --- a/DiscImageChef.Decoders/SCSI/Types.cs +++ b/DiscImageChef.Decoders/SCSI/Types.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.SCSI { public enum MediumTypes : byte @@ -827,7 +825,7 @@ namespace DiscImageChef.Decoders.SCSI /// Mammoth = 0x27, /// - /// IBM 3490 & 3490E + /// IBM 3490 & 3490E /// IBM3490E = 0x28, /// diff --git a/DiscImageChef.Decoders/SCSI/VendorString.cs b/DiscImageChef.Decoders/SCSI/VendorString.cs index 61d31900..6b7c0720 100644 --- a/DiscImageChef.Decoders/SCSI/VendorString.cs +++ b/DiscImageChef.Decoders/SCSI/VendorString.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Decoders.SCSI { public static class VendorString diff --git a/DiscImageChef.Decoders/Xbox/DMI.cs b/DiscImageChef.Decoders/Xbox/DMI.cs index a19eb8e1..bca141a3 100644 --- a/DiscImageChef.Decoders/Xbox/DMI.cs +++ b/DiscImageChef.Decoders/Xbox/DMI.cs @@ -83,13 +83,13 @@ namespace DiscImageChef.Decoders.Xbox /// Bytes 4 to 7 /// 0x02 in XGD2 and XGD3 /// - public UInt32 Version; + public uint Version; /// /// Bytes 20 to 27 /// DMI timestamp /// - public Int64 Timestamp; + public long Timestamp; /// /// Bytes 36 to 51 diff --git a/DiscImageChef.Devices/ChangeLog b/DiscImageChef.Devices/ChangeLog index 1f2af695..96423165 100644 --- a/DiscImageChef.Devices/ChangeLog +++ b/DiscImageChef.Devices/ChangeLog @@ -1,3 +1,33 @@ +2016-07-28 Natalia Portillo + + * Command.cs: + * Enums.cs: + * Command.cs: + * Enums.cs: + * Enums.cs: + * Structs.cs: + * Command.cs: + * Commands.cs: + * Variables.cs: + * Destructor.cs: + * Constructor.cs: + * Cfa.cs: + * SSC.cs: + * SPC.cs: + * SMC.cs: + * NEC.cs: + * MCPT.cs: + * MMC.cs: + * Atapi.cs: + * Ata48.cs: + * Smart.cs: + * Ata28.cs: + * AtaCHS.cs: + * Pioneer.cs: + * HL-DT-ST.cs: + * Certance.cs: + * ArchiveCorp.cs: Refactor and code cleanup. + 2016-02-10 Natalia Portillo * Device/AtaCommands/Ata28.cs: diff --git a/DiscImageChef.Devices/Command.cs b/DiscImageChef.Devices/Command.cs index 6c18956f..c5e7138d 100644 --- a/DiscImageChef.Devices/Command.cs +++ b/DiscImageChef.Devices/Command.cs @@ -120,7 +120,7 @@ namespace DiscImageChef.Devices return Linux.Command.SendScsiCommand((int)fd, cdb, ref buffer, out senseBuffer, timeout, dir, out duration, out sense); } default: - throw new InvalidOperationException(String.Format("Platform {0} not yet supported.", ptID)); + throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptID)); } } @@ -152,7 +152,7 @@ namespace DiscImageChef.Devices transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense); } default: - throw new InvalidOperationException(String.Format("Platform {0} not yet supported.", ptID)); + throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptID)); } } @@ -184,7 +184,7 @@ namespace DiscImageChef.Devices transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense); } default: - throw new InvalidOperationException(String.Format("Platform {0} not yet supported.", ptID)); + throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptID)); } } @@ -216,7 +216,7 @@ namespace DiscImageChef.Devices transferRegister, ref buffer, timeout, transferBlocks, out duration, out sense); } default: - throw new InvalidOperationException(String.Format("Platform {0} not yet supported.", ptID)); + throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", ptID)); } } } diff --git a/DiscImageChef.Devices/Device/AtaCommands/Ata28.cs b/DiscImageChef.Devices/Device/AtaCommands/Ata28.cs index 228b85e6..cdb53b36 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/Ata28.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/Ata28.cs @@ -30,44 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -// /*************************************************************************** -// The Disc Image Chef -// ---------------------------------------------------------------------------- -// -// Filename : Ata28.cs -// Version : 1.0 -// Author(s) : Natalia Portillo -// -// Component : Component -// -// Revision : $Revision$ -// Last change by : $Author$ -// Date : $Date$ -// -// --[ Description ] ---------------------------------------------------------- -// -// Description -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright (C) 2011-2015 Claunia.com -// ****************************************************************************/ -// //$Id$ -using System; using DiscImageChef.Console; using DiscImageChef.Decoders.ATA; diff --git a/DiscImageChef.Devices/Device/AtaCommands/Ata48.cs b/DiscImageChef.Devices/Device/AtaCommands/Ata48.cs index 21e036b2..d6da16f4 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/Ata48.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/Ata48.cs @@ -30,44 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -// /*************************************************************************** -// The Disc Image Chef -// ---------------------------------------------------------------------------- -// -// Filename : Ata48.cs -// Version : 1.0 -// Author(s) : Natalia Portillo -// -// Component : Component -// -// Revision : $Revision$ -// Last change by : $Author$ -// Date : $Date$ -// -// --[ Description ] ---------------------------------------------------------- -// -// Description -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright (C) 2011-2015 Claunia.com -// ****************************************************************************/ -// //$Id$ -using System; using DiscImageChef.Console; using DiscImageChef.Decoders.ATA; diff --git a/DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs b/DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs index 070b8b7a..24c3fa7c 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs @@ -30,44 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -// /*************************************************************************** -// The Disc Image Chef -// ---------------------------------------------------------------------------- -// -// Filename : AtaCommands.cs -// Version : 1.0 -// Author(s) : Natalia Portillo -// -// Component : Direct device access -// -// Revision : $Revision$ -// Last change by : $Author$ -// Date : $Date$ -// -// --[ Description ] ---------------------------------------------------------- -// -// Contains ATA commands -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright (C) 2011-2015 Claunia.com -// ****************************************************************************/ -// //$Id$ -using System; using DiscImageChef.Console; using DiscImageChef.Decoders.ATA; diff --git a/DiscImageChef.Devices/Device/AtaCommands/Atapi.cs b/DiscImageChef.Devices/Device/AtaCommands/Atapi.cs index 7195ca14..79c038a9 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/Atapi.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/Atapi.cs @@ -30,44 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -// /*************************************************************************** -// The Disc Image Chef -// ---------------------------------------------------------------------------- -// -// Filename : AtapiCommands.cs -// Version : 1.0 -// Author(s) : Natalia Portillo -// -// Component : Direct device access -// -// Revision : $Revision$ -// Last change by : $Author$ -// Date : $Date$ -// -// --[ Description ] ---------------------------------------------------------- -// -// Contains ATAPI commands -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright (C) 2011-2015 Claunia.com -// ****************************************************************************/ -// //$Id$ -using System; using DiscImageChef.Console; using DiscImageChef.Decoders.ATA; diff --git a/DiscImageChef.Devices/Device/AtaCommands/Cfa.cs b/DiscImageChef.Devices/Device/AtaCommands/Cfa.cs index 8b6ee6d3..17ef2d03 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/Cfa.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/Cfa.cs @@ -30,44 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -// /*************************************************************************** -// The Disc Image Chef -// ---------------------------------------------------------------------------- -// -// Filename : Cfa.cs -// Version : 1.0 -// Author(s) : Natalia Portillo -// -// Component : Component -// -// Revision : $Revision$ -// Last change by : $Author$ -// Date : $Date$ -// -// --[ Description ] ---------------------------------------------------------- -// -// Description -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright (C) 2011-2015 Claunia.com -// ****************************************************************************/ -// //$Id$ -using System; using DiscImageChef.Console; using DiscImageChef.Decoders.ATA; diff --git a/DiscImageChef.Devices/Device/AtaCommands/MCPT.cs b/DiscImageChef.Devices/Device/AtaCommands/MCPT.cs index 4af86c47..3e0bc351 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/MCPT.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/MCPT.cs @@ -30,44 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -// /*************************************************************************** -// The Disc Image Chef -// ---------------------------------------------------------------------------- -// -// Filename : MCPT.cs -// Version : 1.0 -// Author(s) : Natalia Portillo -// -// Component : Component -// -// Revision : $Revision$ -// Last change by : $Author$ -// Date : $Date$ -// -// --[ Description ] ---------------------------------------------------------- -// -// Description -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright (C) 2011-2015 Claunia.com -// ****************************************************************************/ -// //$Id$ -using System; using DiscImageChef.Console; using DiscImageChef.Decoders.ATA; diff --git a/DiscImageChef.Devices/Device/AtaCommands/Smart.cs b/DiscImageChef.Devices/Device/AtaCommands/Smart.cs index ec6af918..98f968c5 100644 --- a/DiscImageChef.Devices/Device/AtaCommands/Smart.cs +++ b/DiscImageChef.Devices/Device/AtaCommands/Smart.cs @@ -30,44 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -// /*************************************************************************** -// The Disc Image Chef -// ---------------------------------------------------------------------------- -// -// Filename : Smart.cs -// Version : 1.0 -// Author(s) : Natalia Portillo -// -// Component : Component -// -// Revision : $Revision$ -// Last change by : $Author$ -// Date : $Date$ -// -// --[ Description ] ---------------------------------------------------------- -// -// Description -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright (C) 2011-2015 Claunia.com -// ****************************************************************************/ -// //$Id$ -using System; using DiscImageChef.Console; using DiscImageChef.Decoders.ATA; diff --git a/DiscImageChef.Devices/Device/Commands.cs b/DiscImageChef.Devices/Device/Commands.cs index bef3b1b6..d01f617f 100644 --- a/DiscImageChef.Devices/Device/Commands.cs +++ b/DiscImageChef.Devices/Device/Commands.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using DiscImageChef.Decoders.ATA; namespace DiscImageChef.Devices diff --git a/DiscImageChef.Devices/Device/Constructor.cs b/DiscImageChef.Devices/Device/Constructor.cs index dfe32b8b..e2b1ecbe 100644 --- a/DiscImageChef.Devices/Device/Constructor.cs +++ b/DiscImageChef.Devices/Device/Constructor.cs @@ -66,7 +66,6 @@ namespace DiscImageChef.Devices lastError = Marshal.GetLastWin32Error(); } - //throw new NotImplementedException(); break; } case Interop.PlatformID.Linux: @@ -79,15 +78,14 @@ namespace DiscImageChef.Devices lastError = Marshal.GetLastWin32Error(); } - //throw new NotImplementedException(); break; } default: - throw new InvalidOperationException(String.Format("Platform {0} not yet supported.", platformID)); + throw new InvalidOperationException(string.Format("Platform {0} not yet supported.", platformID)); } if(error) - throw new SystemException(String.Format("Error {0} opening device.", lastError)); + throw new SystemException(string.Format("Error {0} opening device.", lastError)); type = DeviceType.Unknown; scsiType = Decoders.SCSI.PeripheralDeviceTypes.UnknownDevice; @@ -101,12 +99,12 @@ namespace DiscImageChef.Devices bool scsiSense = ScsiInquiry(out inqBuf, out senseBuf); if(error) - throw new SystemException(String.Format("Error {0} trying device.", lastError)); + throw new SystemException(string.Format("Error {0} trying device.", lastError)); #region USB - if(platformID == DiscImageChef.Interop.PlatformID.Linux) + if(platformID == Interop.PlatformID.Linux) { - if(devicePath.StartsWith("/dev/sd") || devicePath.StartsWith("/dev/sr") || devicePath.StartsWith("/dev/st")) + if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) || devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) || devicePath.StartsWith("/dev/st", StringComparison.Ordinal)) { string devPath = devicePath.Substring(5); if(System.IO.Directory.Exists("/sys/block/" + devPath)) @@ -178,9 +176,9 @@ namespace DiscImageChef.Devices #endregion USB #region FireWire - if(platformID == DiscImageChef.Interop.PlatformID.Linux) + if(platformID == Interop.PlatformID.Linux) { - if(devicePath.StartsWith("/dev/sd") || devicePath.StartsWith("/dev/sr") || devicePath.StartsWith("/dev/st")) + if(devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) || devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) || devicePath.StartsWith("/dev/st", StringComparison.Ordinal)) { string devPath = devicePath.Substring(5); if(System.IO.Directory.Exists("/sys/block/" + devPath)) @@ -331,7 +329,7 @@ namespace DiscImageChef.Devices { foreach(char c in serial) { - if(Char.IsControl(c)) + if(char.IsControl(c)) serial = usbSerialString; } } @@ -344,13 +342,13 @@ namespace DiscImageChef.Devices if(string.IsNullOrEmpty(model)) model = firewireModelName; if(string.IsNullOrEmpty(serial)) - serial = String.Format("{0:X16}", firewireGuid); + serial = string.Format("{0:X16}", firewireGuid); else { foreach(char c in serial) { - if(Char.IsControl(c)) - serial = String.Format("{0:X16}", firewireGuid); + if(char.IsControl(c)) + serial = string.Format("{0:X16}", firewireGuid); } } } diff --git a/DiscImageChef.Devices/Device/Destructor.cs b/DiscImageChef.Devices/Device/Destructor.cs index f35de1b8..61ce1eb3 100644 --- a/DiscImageChef.Devices/Device/Destructor.cs +++ b/DiscImageChef.Devices/Device/Destructor.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using Microsoft.Win32.SafeHandles; namespace DiscImageChef.Devices @@ -39,7 +38,7 @@ namespace DiscImageChef.Devices { /// /// Releases unmanaged resources and performs other cleanup operations before the - /// is reclaimed by garbage collection. + /// is reclaimed by garbage collection. /// ~Device() { diff --git a/DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs b/DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs index d0507ddc..9e380fa3 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using DiscImageChef.Console; namespace DiscImageChef.Devices diff --git a/DiscImageChef.Devices/Device/ScsiCommands/Certance.cs b/DiscImageChef.Devices/Device/ScsiCommands/Certance.cs index a5b9111d..7efafd54 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/Certance.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/Certance.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using DiscImageChef.Console; namespace DiscImageChef.Devices diff --git a/DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs b/DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs index ce06d50a..7d469d77 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using DiscImageChef.Console; namespace DiscImageChef.Devices diff --git a/DiscImageChef.Devices/Device/ScsiCommands/MMC.cs b/DiscImageChef.Devices/Device/ScsiCommands/MMC.cs index 913c15f2..9396be50 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/MMC.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/MMC.cs @@ -95,7 +95,9 @@ namespace DiscImageChef.Devices if(sense) return true; +#pragma warning disable IDE0004 // Cast is necessary or an invalid bitshift happens ushort confLength = (ushort)(((int)buffer[2] << 8) + buffer[3] + 4); +#pragma warning restore IDE0004 // Cast is necessary or an invalid bitshift happens buffer = new byte[confLength]; cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(buffer.Length & 0xFF); @@ -147,7 +149,9 @@ namespace DiscImageChef.Devices if(sense) return true; +#pragma warning disable IDE0004 // Cast is necessary or an invalid bitshift happens ushort strctLength = (ushort)(((int)buffer[0] << 8) + buffer[1] + 2); +#pragma warning restore IDE0004 // Cast is necessary or an invalid bitshift happens buffer = new byte[strctLength]; cdb[8] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[9] = (byte)(buffer.Length & 0xFF); @@ -304,7 +308,9 @@ namespace DiscImageChef.Devices lastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); error = lastError != 0; +#pragma warning disable IDE0004 // Cast is necessary or an invalid bitshift happens uint strctLength = (uint)(((int)tmpBuffer[0] << 8) + tmpBuffer[1] + 2); +#pragma warning restore IDE0004 // Cast is necessary or an invalid bitshift happens buffer = new byte[strctLength]; if(buffer.Length <= tmpBuffer.Length) @@ -361,7 +367,9 @@ namespace DiscImageChef.Devices lastError = SendScsiCommand(cdb, ref tmpBuffer, out senseBuffer, timeout, ScsiDirection.In, out duration, out sense); error = lastError != 0; +#pragma warning disable IDE0004 // Cast is necessary or an invalid bitshift happens uint strctLength = (uint)(((int)tmpBuffer[0] << 8) + tmpBuffer[1] + 2); +#pragma warning restore IDE0004 // Cast is necessary or an invalid bitshift happens buffer = new byte[strctLength]; Array.Copy(tmpBuffer, 0, buffer, 0, buffer.Length); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/NEC.cs b/DiscImageChef.Devices/Device/ScsiCommands/NEC.cs index 712199ad..259efa65 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/NEC.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/NEC.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using DiscImageChef.Console; namespace DiscImageChef.Devices diff --git a/DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs b/DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs index 3d8c9da8..aeb0a409 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using DiscImageChef.Console; namespace DiscImageChef.Devices diff --git a/DiscImageChef.Devices/Device/ScsiCommands/SMC.cs b/DiscImageChef.Devices/Device/ScsiCommands/SMC.cs index 0a60d16b..495d2af5 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/SMC.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/SMC.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using DiscImageChef.Console; namespace DiscImageChef.Devices @@ -80,7 +79,9 @@ namespace DiscImageChef.Devices if(sense) return true; +#pragma warning disable IDE0004 // Cast is necessary or an invalid bitshift happens uint attrLen = (uint)(((int)buffer[0] << 24) + ((int)buffer[1] << 16) + ((int)buffer[2] << 8) + buffer[3] + 4); +#pragma warning restore IDE0004 // Cast is necessary or an invalid bitshift happens buffer = new byte[attrLen]; cdb[10] = (byte)((buffer.Length & 0xFF000000) >> 24); cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/SPC.cs b/DiscImageChef.Devices/Device/ScsiCommands/SPC.cs index 2fd63645..20e8e529 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/SPC.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/SPC.cs @@ -356,7 +356,9 @@ namespace DiscImageChef.Devices if(sense) return true; +#pragma warning disable IDE0004 // Cast is necessary or an invalid bitshift happens ushort modeLength = (ushort)(((int)buffer[0] << 8) + buffer[1] + 2); +#pragma warning restore IDE0004 // Cast is necessary or an invalid bitshift happens buffer = new byte[modeLength]; cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(buffer.Length & 0xFF); @@ -577,7 +579,9 @@ namespace DiscImageChef.Devices if(sense) return true; +#pragma warning disable IDE0004 // Cast is necessary or an invalid bitshift happens uint strctLength = (uint)(((int)buffer[0] << 24) + ((int)buffer[1] << 16) + ((int)buffer[2] << 8) + buffer[3] + 4); +#pragma warning restore IDE0004 // Cast is necessary or an invalid bitshift happens buffer = new byte[strctLength]; cdb[6] = (byte)((buffer.Length & 0xFF000000) >> 24); cdb[7] = (byte)((buffer.Length & 0xFF0000) >> 16); diff --git a/DiscImageChef.Devices/Device/ScsiCommands/SSC.cs b/DiscImageChef.Devices/Device/ScsiCommands/SSC.cs index f7162e16..47961d3c 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/SSC.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/SSC.cs @@ -900,7 +900,9 @@ namespace DiscImageChef.Devices if(sense) return true; +#pragma warning disable IDE0004 // Cast is necessary or an invalid bitshift happens ushort availableLength = (ushort)(((int)buffer[0] << 8) + buffer[1] + 2); +#pragma warning restore IDE0004 // Cast is necessary or an invalid bitshift happens buffer = new byte[availableLength]; cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(buffer.Length & 0xFF); diff --git a/DiscImageChef.Devices/Device/Variables.cs b/DiscImageChef.Devices/Device/Variables.cs index be6e46ef..3cf6ffc6 100644 --- a/DiscImageChef.Devices/Device/Variables.cs +++ b/DiscImageChef.Devices/Device/Variables.cs @@ -30,9 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; -using Microsoft.Win32.SafeHandles; - namespace DiscImageChef.Devices { public partial class Device @@ -97,7 +94,7 @@ namespace DiscImageChef.Devices } /// - /// Gets a value indicating whether this is in error. + /// Gets a value indicating whether this is in error. /// /// true if error; otherwise, false. public bool Error diff --git a/DiscImageChef.Devices/FreeBSD/Command.cs b/DiscImageChef.Devices/FreeBSD/Command.cs index 3908595a..43bac30d 100644 --- a/DiscImageChef.Devices/FreeBSD/Command.cs +++ b/DiscImageChef.Devices/FreeBSD/Command.cs @@ -31,7 +31,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; namespace DiscImageChef.Devices.FreeBSD { public class Command diff --git a/DiscImageChef.Devices/FreeBSD/Enums.cs b/DiscImageChef.Devices/FreeBSD/Enums.cs index 09b05779..94de701e 100644 --- a/DiscImageChef.Devices/FreeBSD/Enums.cs +++ b/DiscImageChef.Devices/FreeBSD/Enums.cs @@ -35,7 +35,7 @@ using System; namespace DiscImageChef.Devices.FreeBSD { [Flags] - enum FileFlags : int + enum FileFlags { /// /// O_RDONLY diff --git a/DiscImageChef.Devices/FreeBSD/Structs.cs b/DiscImageChef.Devices/FreeBSD/Structs.cs index 65246b77..0db0ab97 100644 --- a/DiscImageChef.Devices/FreeBSD/Structs.cs +++ b/DiscImageChef.Devices/FreeBSD/Structs.cs @@ -72,8 +72,8 @@ namespace DiscImageChef.Devices.FreeBSD struct cam_pinfo { - public UInt32 priority; - public UInt32 generation; + public uint priority; + public uint generation; public int index; } @@ -107,7 +107,7 @@ namespace DiscImageChef.Devices.FreeBSD struct timeval { - public Int64 tv_sec; + public long tv_sec; /// long public IntPtr tv_usec; } @@ -125,22 +125,22 @@ namespace DiscImageChef.Devices.FreeBSD public camq_entry xpt_links; public camq_entry sim_links; public camq_entry periph_links; - public UInt32 retry_count; + public uint retry_count; public IntPtr cbfcnp; public xpt_opcode func_code; - public UInt32 status; + public uint status; public IntPtr path; public uint path_id; public uint target_id; - public UInt64 target_lun; - public UInt32 flags; - public UInt32 xflags; + public ulong target_lun; + public uint flags; + public uint xflags; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public IntPtr[] periph_priv; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public IntPtr[] sim_priv; public ccb_qos_area qos; - public UInt32 timeout; + public uint timeout; public timeval softtimeout; } @@ -164,7 +164,7 @@ namespace DiscImageChef.Devices.FreeBSD /// Ptr to the data buf/SG list public IntPtr data_ptr; /// Data transfer length - public UInt32 dxfer_len; + public uint dxfer_len; /// Autosense storage public scsi_sense_data sense_data; /// Number of bytes to autosense @@ -172,25 +172,25 @@ namespace DiscImageChef.Devices.FreeBSD /// Number of bytes for the CDB public byte cdb_len; /// Number of SG list entries - public UInt16 sglist_cnt; + public short sglist_cnt; /// Returned SCSI status public byte scsi_status; /// Autosense resid length: 2's comp public sbyte sense_resid; /// Transfer residual length: 2's comp - public Int32 resid; + public int resid; /// Union for CDB bytes/pointer public IntPtr cdb_io; /// Pointer to the message buffer public IntPtr msg_ptr; /// Number of bytes for the Message - public UInt16 msg_len; + public short msg_len; /// What to do for tag queueing. The tag action should be either the define below (to send a non-tagged transaction) or one of the defined scsi tag messages from scsi_message.h. public byte tag_action; /// tag id from initator (target mode) - public UInt32 tag_id; + public uint tag_id; /// initiator id of who selected - public UInt32 init_id; + public uint init_id; } /// @@ -208,15 +208,15 @@ namespace DiscImageChef.Devices.FreeBSD /// Ptr to the data buf/SG list public IntPtr data_ptr; /// Data transfer length - public UInt32 dxfer_len; + public uint dxfer_len; /// Transfer residual length: 2's comp - public Int32 resid; + public int resid; /// What to do for tag queueing. The tag action should be either the define below (to send a non-tagged transaction) or one of the defined scsi tag messages from scsi_message.h. public byte tag_action; /// tag id from initator (target mode) - public UInt32 tag_id; + public uint tag_id; /// initiator id of who selected - public UInt32 init_id; + public uint init_id; } } diff --git a/DiscImageChef.Devices/Linux/Command.cs b/DiscImageChef.Devices/Linux/Command.cs index dc691d83..0daf42e1 100644 --- a/DiscImageChef.Devices/Linux/Command.cs +++ b/DiscImageChef.Devices/Linux/Command.cs @@ -92,7 +92,7 @@ namespace DiscImageChef.Devices.Linux sense |= (io_hdr.info & SgInfo.OkMask) != SgInfo.Ok; if(io_hdr.duration > 0) - duration = (double)io_hdr.duration; + duration = io_hdr.duration; else duration = (end - start).TotalMilliseconds; @@ -335,7 +335,7 @@ namespace DiscImageChef.Devices.Linux if(Interop.DetectOS.Is64Bit()) { - long result64 = Extern.readlink64(path, buf, (long)4096); + long result64 = Extern.readlink64(path, buf, 4096); if(result64 <= 0) return null; diff --git a/DiscImageChef.Devices/Linux/Enums.cs b/DiscImageChef.Devices/Linux/Enums.cs index 415f5021..a71e8d7d 100644 --- a/DiscImageChef.Devices/Linux/Enums.cs +++ b/DiscImageChef.Devices/Linux/Enums.cs @@ -36,7 +36,7 @@ using System; namespace DiscImageChef.Devices.Linux { [Flags] - enum FileFlags : int + enum FileFlags { /// /// O_RDONLY @@ -111,7 +111,7 @@ namespace DiscImageChef.Devices.Linux /// /// Direction of SCSI transfer /// - enum ScsiIoctlDirection : int + enum ScsiIoctlDirection { /// /// No data transfer happens diff --git a/DiscImageChef.Devices/Windows/Enums.cs b/DiscImageChef.Devices/Windows/Enums.cs index 7b5e7ee1..2e484d6a 100644 --- a/DiscImageChef.Devices/Windows/Enums.cs +++ b/DiscImageChef.Devices/Windows/Enums.cs @@ -32,7 +32,6 @@ // ****************************************************************************/ using System; -using System.Runtime.InteropServices; namespace DiscImageChef.Devices.Windows { diff --git a/DiscImageChef.DiscImages/Apple2MG.cs b/DiscImageChef.DiscImages/Apple2MG.cs index 78b4a349..f1cc1b4c 100644 --- a/DiscImageChef.DiscImages/Apple2MG.cs +++ b/DiscImageChef.DiscImages/Apple2MG.cs @@ -49,71 +49,71 @@ namespace DiscImageChef.ImagePlugins /// /// Offset 0x00, magic /// - public UInt32 magic; + public uint magic; /// /// Offset 0x04, disk image creator ID /// - public UInt32 creator; + public uint creator; /// /// Offset 0x08, header size, constant 0x0040 /// - public UInt16 headerSize; + public ushort headerSize; /// /// Offset 0x0A, disk image version /// - public UInt16 version; + public ushort version; /// /// Offset 0x0C, disk image format /// - public UInt32 imageFormat; + public uint imageFormat; /// /// Offset 0x10, flags and volume number /// - public UInt32 flags; + public uint flags; /// /// Offset 0x14, blocks for ProDOS, 0 otherwise /// - public UInt32 blocks; + public uint blocks; /// /// Offset 0x18, offset to data /// - public UInt32 dataOffset; + public uint dataOffset; /// /// Offset 0x1C, data size in bytes /// - public UInt32 dataSize; + public uint dataSize; /// /// Offset 0x20, offset to optional comment /// - public UInt32 commentOffset; + public uint commentOffset; /// /// Offset 0x24, length of optional comment /// - public UInt32 commentSize; + public uint commentSize; /// /// Offset 0x28, offset to creator specific chunk /// - public UInt32 creatorSpecificOffset; + public uint creatorSpecificOffset; /// /// Offset 0x2C, creator specific chunk size /// - public UInt32 creatorSpecificSize; + public uint creatorSpecificSize; /// /// Offset 0x30, reserved, should be zero /// - public UInt32 reserved1; + public uint reserved1; /// /// Offset 0x34, reserved, should be zero /// - public UInt32 reserved2; + public uint reserved2; /// /// Offset 0x38, reserved, should be zero /// - public UInt32 reserved3; + public uint reserved3; /// /// Offset 0x3C, reserved, should be zero /// - public UInt32 reserved4; + public uint reserved4; } #endregion @@ -123,39 +123,39 @@ namespace DiscImageChef.ImagePlugins /// /// Magic number, "2IMG" /// - public const UInt32 MAGIC = 0x474D4932; + public const uint MAGIC = 0x474D4932; /// /// Disk image created by ASIMOV2, "!nfc" /// - public const UInt32 CreatorAsimov = 0x63666E21; + public const uint CreatorAsimov = 0x63666E21; /// /// Disk image created by Bernie ][ the Rescue, "B2TR" /// - public const UInt32 CreatorBernie = 0x52543242; + public const uint CreatorBernie = 0x52543242; /// /// Disk image created by Catakig, "CTKG" /// - public const UInt32 CreatorCatakig = 0x474B5443; + public const uint CreatorCatakig = 0x474B5443; /// /// Disk image created by Sheppy's ImageMaker, "ShIm" /// - public const UInt32 CreatorSheppy = 0x6D496853; + public const uint CreatorSheppy = 0x6D496853; /// /// Disk image created by Sweet16, "WOOF" /// - public const UInt32 CreatorSweet = 0x464F4F57; + public const uint CreatorSweet = 0x464F4F57; /// /// Disk image created by XGS, "XGS!" /// - public const UInt32 CreatorXGS = 0x21534758; + public const uint CreatorXGS = 0x21534758; - public const UInt32 DOSSectorOrder = 0x00000000; - public const UInt32 ProDOSSectorOrder = 0x00000001; - public const UInt32 NIBSectorOrder = 0x00000002; + public const uint DOSSectorOrder = 0x00000000; + public const uint ProDOSSectorOrder = 0x00000001; + public const uint NIBSectorOrder = 0x00000002; - public const UInt32 LockedDisk = 0x80000000; - public const UInt32 ValidVolumeNumber = 0x00000100; - public const UInt32 VolumeNumberMask = 0x000000FF; + public const uint LockedDisk = 0x80000000; + public const uint ValidVolumeNumber = 0x00000100; + public const uint VolumeNumberMask = 0x000000FF; #endregion @@ -203,34 +203,34 @@ namespace DiscImageChef.ImagePlugins byte[] header = new byte[64]; stream.Read(header, 0, 64); - UInt32 magic = BitConverter.ToUInt32(header, 0x00); + uint magic = BitConverter.ToUInt32(header, 0x00); if(magic != MAGIC) return false; - UInt32 dataoff = BitConverter.ToUInt32(header, 0x18); + uint dataoff = BitConverter.ToUInt32(header, 0x18); if(dataoff > stream.Length) return false; - UInt32 datasize = BitConverter.ToUInt32(header, 0x1C); + uint datasize = BitConverter.ToUInt32(header, 0x1C); // There seems to be incorrect endian in some images on the wild if(datasize == 0x00800C00) datasize = 0x000C8000; if(dataoff + datasize > stream.Length) return false; - UInt32 commentoff = BitConverter.ToUInt32(header, 0x20); + uint commentoff = BitConverter.ToUInt32(header, 0x20); if(commentoff > stream.Length) return false; - UInt32 commentsize = BitConverter.ToUInt32(header, 0x24); + uint commentsize = BitConverter.ToUInt32(header, 0x24); if(commentoff + commentsize > stream.Length) return false; - UInt32 creatoroff = BitConverter.ToUInt32(header, 0x28); + uint creatoroff = BitConverter.ToUInt32(header, 0x28); if(creatoroff > stream.Length) return false; - UInt32 creatorsize = BitConverter.ToUInt32(header, 0x2C); + uint creatorsize = BitConverter.ToUInt32(header, 0x2C); return creatoroff + creatorsize <= stream.Length; } @@ -331,7 +331,7 @@ namespace DiscImageChef.ImagePlugins ImageInfo.imageApplication = "XGS"; break; default: - ImageInfo.imageApplication = String.Format("Unknown creator code \"{0}\"", Encoding.ASCII.GetString(creator)); + ImageInfo.imageApplication = string.Format("Unknown creator code \"{0}\"", Encoding.ASCII.GetString(creator)); break; } @@ -454,10 +454,10 @@ namespace DiscImageChef.ImagePlugins public override byte[] ReadSectors(ulong sectorAddress, uint length) { if(sectorAddress > ImageInfo.sectors - 1) - throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found"); + throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); if(sectorAddress + length > ImageInfo.sectors) - throw new ArgumentOutOfRangeException("length", "Requested more sectors than available"); + throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); byte[] buffer = new byte[length * ImageInfo.sectorSize]; @@ -579,7 +579,7 @@ namespace DiscImageChef.ImagePlugins return null; } - public override List GetPartitions() + public override List GetPartitions() { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } diff --git a/DiscImageChef.DiscImages/CDRDAO.cs b/DiscImageChef.DiscImages/CDRDAO.cs index a4e8a48f..1aca29d7 100644 --- a/DiscImageChef.DiscImages/CDRDAO.cs +++ b/DiscImageChef.DiscImages/CDRDAO.cs @@ -49,11 +49,11 @@ namespace DiscImageChef.ImagePlugins struct CDRDAOTrackFile { /// Track # - public UInt32 sequence; + public uint sequence; /// Path of file containing track public string datafile; /// Offset of track start in file - public UInt64 offset; + public ulong offset; /// Type of file public string filetype; } @@ -61,7 +61,7 @@ namespace DiscImageChef.ImagePlugins struct CDRDAOTrack { /// Track # - public UInt32 sequence; + public uint sequence; /// Track title (from CD-Text) public string title; /// Track genre (from CD-Text) @@ -81,11 +81,11 @@ namespace DiscImageChef.ImagePlugins /// File struct for this track public CDRDAOTrackFile trackfile; /// Indexes on this track - public Dictionary indexes; + public Dictionary indexes; /// Track pre-gap in sectors - public UInt64 pregap; + public ulong pregap; /// Track post-gap in sectors - public UInt64 postgap; + public ulong postgap; /// Digical Copy Permitted public bool flag_dcp; /// Track is quadraphonic @@ -93,11 +93,11 @@ namespace DiscImageChef.ImagePlugins /// Track has preemphasis public bool flag_pre; /// Bytes per sector - public UInt16 bps; + public ushort bps; /// Sectors in track - public UInt64 sectors; + public ulong sectors; /// Starting sector in track - public UInt64 startSector; + public ulong startSector; /// Track type public string tracktype; public bool subchannel; @@ -165,8 +165,8 @@ namespace DiscImageChef.ImagePlugins StreamReader tocStream; FileStream imageStream; /// Dictionary, index is track #, value is TrackFile - Dictionary offsetmap; - List partitions; + Dictionary offsetmap; + List partitions; CDRDAODisc discimage; #endregion @@ -476,7 +476,7 @@ namespace DiscImageChef.ImagePlugins currenttrack.bps = 2336; break; default: - throw new NotSupportedException(String.Format("Track mode {0} is unsupported", MatchTrack.Groups["type"].Value)); + throw new NotSupportedException(string.Format("Track mode {0} is unsupported", MatchTrack.Groups["type"].Value)); } switch(MatchTrack.Groups["subchan"].Value) @@ -491,7 +491,7 @@ namespace DiscImageChef.ImagePlugins currenttrack.subchannel = true; break; default: - throw new NotSupportedException(String.Format("Track subchannel mode {0} is unsupported", MatchTrack.Groups["subchan"].Value)); + throw new NotSupportedException(string.Format("Track subchannel mode {0} is unsupported", MatchTrack.Groups["subchan"].Value)); } currenttrack.tracktype = MatchTrack.Groups["type"].Value; @@ -685,7 +685,7 @@ namespace DiscImageChef.ImagePlugins /* else // Non-empty unknown field { - throw new FeatureUnsupportedImageException(String.Format("Found unknown field defined at line {0}: \"{1}\"", line, _line)); + throw new FeatureUnsupportedImageException(string.Format("Found unknown field defined at line {0}: \"{1}\"", line, _line)); } */ } @@ -811,7 +811,7 @@ namespace DiscImageChef.ImagePlugins Partition partition = new Partition(); // Index 01 - partition.PartitionDescription = String.Format("Track {0}.", discimage.tracks[i].sequence); + partition.PartitionDescription = string.Format("Track {0}.", discimage.tracks[i].sequence); partition.PartitionName = discimage.tracks[i].title; partition.PartitionStartSector = discimage.tracks[i].startSector; partition.PartitionLength = (discimage.tracks[i].sectors - index0_len) * discimage.tracks[i].bps; @@ -961,17 +961,17 @@ namespace DiscImageChef.ImagePlugins return ImageInfo.imageHasPartitions; } - public override UInt64 GetImageSize() + public override ulong GetImageSize() { return ImageInfo.imageSize; } - public override UInt64 GetSectors() + public override ulong GetSectors() { return ImageInfo.sectors; } - public override UInt32 GetSectorSize() + public override uint GetSectorSize() { return ImageInfo.sectorSize; } @@ -993,27 +993,27 @@ namespace DiscImageChef.ImagePlugins } } - public override byte[] ReadSector(UInt64 sectorAddress) + public override byte[] ReadSector(ulong sectorAddress) { return ReadSectors(sectorAddress, 1); } - public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag) + public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) { return ReadSectorsTag(sectorAddress, 1, tag); } - public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track) + public override byte[] ReadSector(ulong sectorAddress, uint track) { return ReadSectors(sectorAddress, 1, track); } - public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag) + public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag) { return ReadSectorsTag(sectorAddress, 1, track, tag); } - public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length) + public override byte[] ReadSectors(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) { @@ -1030,10 +1030,10 @@ namespace DiscImageChef.ImagePlugins } } - throw new ArgumentOutOfRangeException("sectorAddress", String.Format("Sector address {0} not found", sectorAddress)); + throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); } - public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag) + public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { foreach(KeyValuePair kvp in offsetmap) { @@ -1050,10 +1050,10 @@ namespace DiscImageChef.ImagePlugins } } - throw new ArgumentOutOfRangeException("sectorAddress", String.Format("Sector address {0} not found", sectorAddress)); + throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); } - public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track) + public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track) { CDRDAOTrack _track = new CDRDAOTrack(); @@ -1069,10 +1069,10 @@ namespace DiscImageChef.ImagePlugins } if(_track.sequence == 0) - throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image"); + throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); if(length > _track.sectors) - throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks"); + throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); uint sector_offset; uint sector_size; @@ -1155,7 +1155,7 @@ namespace DiscImageChef.ImagePlugins return buffer; } - public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag) + public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag) { CDRDAOTrack _track = new CDRDAOTrack(); @@ -1171,17 +1171,17 @@ namespace DiscImageChef.ImagePlugins } if(_track.sequence == 0) - throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image"); + throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); if(length > _track.sectors) - throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks"); + throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); uint sector_offset; uint sector_size; uint sector_skip = 0; if(!_track.subchannel && tag == SectorTagType.CDSectorSubchannel) - throw new ArgumentException("No tags in image for requested track", "tag"); + throw new ArgumentException("No tags in image for requested track", nameof(tag)); switch(tag) { @@ -1215,7 +1215,7 @@ namespace DiscImageChef.ImagePlugins case SectorTagType.CDTrackISRC: return Encoding.UTF8.GetBytes(_track.isrc); default: - throw new ArgumentException("Unsupported tag requested", "tag"); + throw new ArgumentException("Unsupported tag requested", nameof(tag)); } switch(_track.tracktype) @@ -1228,7 +1228,7 @@ namespace DiscImageChef.ImagePlugins sector_size = 96; break; } - throw new ArgumentException("No tags in image for requested track", "tag"); + throw new ArgumentException("No tags in image for requested track", nameof(tag)); case CDRDAOTrackTypeMode2Form2: case CDRDAOTrackTypeMode2Mix: if(tag == SectorTagType.CDSectorSubchannel) @@ -1237,7 +1237,7 @@ namespace DiscImageChef.ImagePlugins sector_size = 96; break; } - throw new ArgumentException("No tags in image for requested track", "tag"); + throw new ArgumentException("No tags in image for requested track", nameof(tag)); case CDRDAOTrackTypeAudio: if(tag == SectorTagType.CDSectorSubchannel) { @@ -1245,7 +1245,7 @@ namespace DiscImageChef.ImagePlugins sector_size = 96; break; } - throw new ArgumentException("No tags in image for requested track", "tag"); + throw new ArgumentException("No tags in image for requested track", nameof(tag)); case CDRDAOTrackTypeMode1Raw: { switch(tag) @@ -1271,7 +1271,7 @@ namespace DiscImageChef.ImagePlugins break; } case SectorTagType.CDSectorSubHeader: - throw new ArgumentException("Unsupported tag requested for this track", "tag"); + throw new ArgumentException("Unsupported tag requested for this track", nameof(tag)); case SectorTagType.CDSectorECC: { sector_offset = 2076; @@ -1301,7 +1301,7 @@ namespace DiscImageChef.ImagePlugins break; } default: - throw new ArgumentException("Unsupported tag requested", "tag"); + throw new ArgumentException("Unsupported tag requested", nameof(tag)); } break; } @@ -1341,17 +1341,17 @@ namespace DiscImageChef.ImagePlugins return buffer; } - public override byte[] ReadSectorLong(UInt64 sectorAddress) + public override byte[] ReadSectorLong(ulong sectorAddress) { return ReadSectorsLong(sectorAddress, 1); } - public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track) + public override byte[] ReadSectorLong(ulong sectorAddress, uint track) { return ReadSectorsLong(sectorAddress, 1, track); } - public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length) + public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) { @@ -1368,10 +1368,10 @@ namespace DiscImageChef.ImagePlugins } } - throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found"); + throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } - public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track) + public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track) { CDRDAOTrack _track = new CDRDAOTrack(); @@ -1387,10 +1387,10 @@ namespace DiscImageChef.ImagePlugins } if(_track.sequence == 0) - throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image"); + throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); if(length > _track.sectors) - throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks"); + throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); uint sector_offset; uint sector_size; @@ -1574,25 +1574,25 @@ namespace DiscImageChef.ImagePlugins throw new NotImplementedException(); } - public override bool? VerifySector(UInt64 sectorAddress) + public override bool? VerifySector(ulong sectorAddress) { byte[] buffer = ReadSectorLong(sectorAddress); return Checksums.CDChecksums.CheckCDSector(buffer); } - public override bool? VerifySector(UInt64 sectorAddress, UInt32 track) + public override bool? VerifySector(ulong sectorAddress, uint track) { byte[] buffer = ReadSectorLong(sectorAddress, track); return Checksums.CDChecksums.CheckCDSector(buffer); } - public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List FailingLBAs, out List UnknownLBAs) + public override bool? VerifySectors(ulong sectorAddress, uint length, out List FailingLBAs, out List UnknownLBAs) { byte[] buffer = ReadSectorsLong(sectorAddress, length); int bps = (int)(buffer.Length / length); byte[] sector = new byte[bps]; - FailingLBAs = new List(); - UnknownLBAs = new List(); + FailingLBAs = new List(); + UnknownLBAs = new List(); for(int i = 0; i < length; i++) { @@ -1617,13 +1617,13 @@ namespace DiscImageChef.ImagePlugins return true; } - public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List FailingLBAs, out List UnknownLBAs) + public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List FailingLBAs, out List UnknownLBAs) { byte[] buffer = ReadSectorsLong(sectorAddress, length, track); int bps = (int)(buffer.Length / length); byte[] sector = new byte[bps]; - FailingLBAs = new List(); - UnknownLBAs = new List(); + FailingLBAs = new List(); + UnknownLBAs = new List(); for(int i = 0; i < length; i++) { @@ -1657,7 +1657,7 @@ namespace DiscImageChef.ImagePlugins #region Private methods - static UInt16 CDRDAOTrackTypeToBytesPerSector(string trackType) + static ushort CDRDAOTrackTypeToBytesPerSector(string trackType) { switch(trackType) { @@ -1678,7 +1678,7 @@ namespace DiscImageChef.ImagePlugins } } - static UInt16 CDRDAOTrackTypeToCookedBytesPerSector(string trackType) + static ushort CDRDAOTrackTypeToCookedBytesPerSector(string trackType) { switch(trackType) { diff --git a/DiscImageChef.DiscImages/CDRWin.cs b/DiscImageChef.DiscImages/CDRWin.cs index da9d94c7..a3f252f6 100644 --- a/DiscImageChef.DiscImages/CDRWin.cs +++ b/DiscImageChef.DiscImages/CDRWin.cs @@ -36,7 +36,6 @@ using System.IO; using System.Text; using System.Text.RegularExpressions; using System.Collections.Generic; -using DiscImageChef; using DiscImageChef.Console; using DiscImageChef.CommonTypes; @@ -49,11 +48,11 @@ namespace DiscImageChef.ImagePlugins struct CDRWinTrackFile { /// Track # - public UInt32 sequence; + public uint sequence; /// Path of file containing track public string datafile; /// Offset of track start in file - public UInt64 offset; + public ulong offset; /// Type of file public string filetype; } @@ -61,7 +60,7 @@ namespace DiscImageChef.ImagePlugins struct CDRWinTrack { /// Track # - public UInt32 sequence; + public uint sequence; /// Track title (from CD-Text) public string title; /// Track genre (from CD-Text) @@ -79,11 +78,11 @@ namespace DiscImageChef.ImagePlugins /// File struct for this track public CDRWinTrackFile trackfile; /// Indexes on this track - public Dictionary indexes; + public Dictionary indexes; /// Track pre-gap in sectors - public UInt64 pregap; + public ulong pregap; /// Track post-gap in sectors - public UInt64 postgap; + public ulong postgap; /// Digical Copy Permitted public bool flag_dcp; /// Track is quadraphonic @@ -93,13 +92,13 @@ namespace DiscImageChef.ImagePlugins /// Track has SCMS public bool flag_scms; /// Bytes per sector - public UInt16 bps; + public ushort bps; /// Sectors in track - public UInt64 sectors; + public ulong sectors; /// Track type public string tracktype; /// Track session - public UInt16 session; + public ushort session; } #endregion @@ -248,9 +247,9 @@ namespace DiscImageChef.ImagePlugins StreamReader cueStream; FileStream imageStream; /// Dictionary, index is track #, value is TrackFile - Dictionary offsetmap; + Dictionary offsetmap; CDRWinDisc discimage; - List partitions; + List partitions; #endregion @@ -443,7 +442,7 @@ namespace DiscImageChef.ImagePlugins { uint track_seq = uint.Parse(MatchTrack.Groups[1].Value); if(track_count + 1 != track_seq) - throw new FeatureUnsupportedImageException(String.Format("Found TRACK {0} out of order in line {1}", track_seq, line)); + throw new FeatureUnsupportedImageException(string.Format("Found TRACK {0} out of order in line {1}", track_seq, line)); track_count++; } @@ -482,12 +481,12 @@ namespace DiscImageChef.ImagePlugins } else if(MatchDiskType.Success && intrack) { - throw new FeatureUnsupportedImageException(String.Format("Found REM ORIGINAL MEDIA TYPE field after a track in line {0}", line)); + throw new FeatureUnsupportedImageException(string.Format("Found REM ORIGINAL MEDIA TYPE field after a track in line {0}", line)); } else if(MatchSession.Success) { DicConsole.DebugWriteLine("CDRWin plugin", "Found REM SESSION at line {0}", line); - currentsession = Byte.Parse(MatchSession.Groups[1].Value); + currentsession = byte.Parse(MatchSession.Groups[1].Value); // What happens between sessions } @@ -543,7 +542,7 @@ namespace DiscImageChef.ImagePlugins if(!intrack) discimage.barcode = MatchBarCode.Groups[1].Value; else - throw new FeatureUnsupportedImageException(String.Format("Found barcode field in incorrect place at line {0}", line)); + throw new FeatureUnsupportedImageException(string.Format("Found barcode field in incorrect place at line {0}", line)); } else if(MatchCDText.Success) { @@ -551,7 +550,7 @@ namespace DiscImageChef.ImagePlugins if(!intrack) discimage.cdtextfile = MatchCDText.Groups[1].Value; else - throw new FeatureUnsupportedImageException(String.Format("Found CD-Text file field in incorrect place at line {0}", line)); + throw new FeatureUnsupportedImageException(string.Format("Found CD-Text file field in incorrect place at line {0}", line)); } else if(MatchComposer.Success) { @@ -567,7 +566,7 @@ namespace DiscImageChef.ImagePlugins if(!intrack) discimage.disk_id = MatchDiskID.Groups[1].Value; else - throw new FeatureUnsupportedImageException(String.Format("Found CDDB ID field in incorrect place at line {0}", line)); + throw new FeatureUnsupportedImageException(string.Format("Found CDDB ID field in incorrect place at line {0}", line)); } else if(MatchFile.Success) { @@ -612,11 +611,11 @@ namespace DiscImageChef.ImagePlugins currentfile.datafile = path + Path.PathSeparator + currentfile.datafile; if(!File.Exists(currentfile.datafile)) - throw new FeatureUnsupportedImageException(String.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value)); + throw new FeatureUnsupportedImageException(string.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value)); } } else - throw new FeatureUnsupportedImageException(String.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value)); + throw new FeatureUnsupportedImageException(string.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value)); } else if((currentfile.datafile[1] == ':' && currentfile.datafile[2] == '\\') || (currentfile.datafile[0] == '\\' && currentfile.datafile[1] == '\\') || @@ -634,11 +633,11 @@ namespace DiscImageChef.ImagePlugins currentfile.datafile = path + Path.PathSeparator + currentfile.datafile; if(!File.Exists(currentfile.datafile)) - throw new FeatureUnsupportedImageException(String.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value)); + throw new FeatureUnsupportedImageException(string.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value)); } } else - throw new FeatureUnsupportedImageException(String.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value)); + throw new FeatureUnsupportedImageException(string.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value)); } else { @@ -646,7 +645,7 @@ namespace DiscImageChef.ImagePlugins currentfile.datafile = path + Path.DirectorySeparatorChar + currentfile.datafile; if(!File.Exists(currentfile.datafile)) - throw new FeatureUnsupportedImageException(String.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value)); + throw new FeatureUnsupportedImageException(string.Format("File \"{0}\" not found.", MatchFile.Groups[1].Value)); } } @@ -661,9 +660,9 @@ namespace DiscImageChef.ImagePlugins case CDRWinDiskTypeAIFF: case CDRWinDiskTypeRIFF: case CDRWinDiskTypeMP3: - throw new FeatureSupportedButNotImplementedImageException(String.Format("Unsupported file type {0}", currentfile.filetype)); + throw new FeatureSupportedButNotImplementedImageException(string.Format("Unsupported file type {0}", currentfile.filetype)); default: - throw new FeatureUnsupportedImageException(String.Format("Unknown file type {0}", currentfile.filetype)); + throw new FeatureUnsupportedImageException(string.Format("Unknown file type {0}", currentfile.filetype)); } currentfile.offset = 0; @@ -673,9 +672,8 @@ namespace DiscImageChef.ImagePlugins { DicConsole.DebugWriteLine("CDRWin plugin", "Found FLAGS at line {0}", line); if(!intrack) - throw new FeatureUnsupportedImageException(String.Format("Found FLAGS field in incorrect place at line {0}", line)); + throw new FeatureUnsupportedImageException(string.Format("Found FLAGS field in incorrect place at line {0}", line)); - const string FlagsRegEx = "FLAGS\\s+(((?DCP)|(?4CH)|(?
PRE)|(?SCMS))\\s*)+$";
                             currenttrack.flag_dcp |= MatchFile.Groups["dcp"].Value == "DCP";
                             currenttrack.flag_4ch |= MatchFile.Groups["quad"].Value == "4CH";
                             currenttrack.flag_pre |= MatchFile.Groups["pre"].Value == "PRE";
@@ -693,14 +691,14 @@ namespace DiscImageChef.ImagePlugins
                         {
                             DicConsole.DebugWriteLine("CDRWin plugin", "Found INDEX at line {0}", line);
                             if(!intrack)
-                                throw new FeatureUnsupportedImageException(String.Format("Found INDEX before a track {0}", line));
+                                throw new FeatureUnsupportedImageException(string.Format("Found INDEX before a track {0}", line));
                             else
                             {
                                 int index = int.Parse(MatchIndex.Groups[1].Value);
                                 ulong offset = CDRWinMSFToLBA(MatchIndex.Groups[2].Value);
 
                                 if((index != 0 && index != 1) && currenttrack.indexes.Count == 0)
-                                    throw new FeatureUnsupportedImageException(String.Format("Found INDEX {0} before INDEX 00 or INDEX 01", index));
+                                    throw new FeatureUnsupportedImageException(string.Format("Found INDEX {0} before INDEX 00 or INDEX 01", index));
 
                                 if((index == 0 || (index == 1 && !currenttrack.indexes.ContainsKey(0))))
                                 {
@@ -728,7 +726,7 @@ namespace DiscImageChef.ImagePlugins
                         {
                             DicConsole.DebugWriteLine("CDRWin plugin", "Found ISRC at line {0}", line);
                             if(!intrack)
-                                throw new FeatureUnsupportedImageException(String.Format("Found ISRC before a track {0}", line));
+                                throw new FeatureUnsupportedImageException(string.Format("Found ISRC before a track {0}", line));
                             currenttrack.isrc = MatchISRC.Groups[1].Value;
                         }
                         else if(MatchMCN.Success)
@@ -737,7 +735,7 @@ namespace DiscImageChef.ImagePlugins
                             if(!intrack)
                                 discimage.mcn = MatchMCN.Groups[1].Value;
                             else
-                                throw new FeatureUnsupportedImageException(String.Format("Found CATALOG field in incorrect place at line {0}", line));
+                                throw new FeatureUnsupportedImageException(string.Format("Found CATALOG field in incorrect place at line {0}", line));
                         }
                         else if(MatchPerformer.Success)
                         {
@@ -755,7 +753,7 @@ namespace DiscImageChef.ImagePlugins
                                 currenttrack.postgap = CDRWinMSFToLBA(MatchPostgap.Groups[1].Value);
                             }
                             else
-                                throw new FeatureUnsupportedImageException(String.Format("Found POSTGAP field before a track at line {0}", line));
+                                throw new FeatureUnsupportedImageException(string.Format("Found POSTGAP field before a track at line {0}", line));
                         }
                         else if(MatchPregap.Success)
                         {
@@ -765,7 +763,7 @@ namespace DiscImageChef.ImagePlugins
                                 currenttrack.pregap = CDRWinMSFToLBA(MatchPregap.Groups[1].Value);
                             }
                             else
-                                throw new FeatureUnsupportedImageException(String.Format("Found PREGAP field before a track at line {0}", line));
+                                throw new FeatureUnsupportedImageException(string.Format("Found PREGAP field before a track at line {0}", line));
                         }
                         else if(MatchSongWriter.Success)
                         {
@@ -787,7 +785,7 @@ namespace DiscImageChef.ImagePlugins
                         {
                             DicConsole.DebugWriteLine("CDRWin plugin", "Found TRACK at line {0}", line);
                             if(currentfile.datafile == "")
-                                throw new FeatureUnsupportedImageException(String.Format("Found TRACK field before a file is defined at line {0}", line));
+                                throw new FeatureUnsupportedImageException(string.Format("Found TRACK field before a file is defined at line {0}", line));
                             if(intrack)
                             {
                                 if(currenttrack.indexes.ContainsKey(0) && currenttrack.pregap == 0)
@@ -814,7 +812,7 @@ namespace DiscImageChef.ImagePlugins
                         }
                         else // Non-empty unknown field
                         {
-                            throw new FeatureUnsupportedImageException(String.Format("Found unknown field defined at line {0}: \"{1}\"", line, _line));
+                            throw new FeatureUnsupportedImageException(string.Format("Found unknown field defined at line {0}: \"{1}\"", line, _line));
                         }
                     }
                 }
@@ -1044,7 +1042,7 @@ namespace DiscImageChef.ImagePlugins
 
                 DicConsole.DebugWriteLine("CDRWin plugin", "Building offset map");
 
-                partitions = new List();
+                partitions = new List();
 
                 ulong byte_offset = 0;
                 ulong sector_offset = 0;
@@ -1062,11 +1060,11 @@ namespace DiscImageChef.ImagePlugins
                     if(discimage.tracks[i].sequence == 1 && i != 0)
                         throw new ImageNotSupportedException("Unordered tracks");
 
-                    CommonTypes.Partition partition = new CommonTypes.Partition();
+                    Partition partition = new Partition();
 
                     if(discimage.tracks[i].pregap > 0)
                     {
-                        partition.PartitionDescription = String.Format("Track {0} pregap.", discimage.tracks[i].sequence);
+                        partition.PartitionDescription = string.Format("Track {0} pregap.", discimage.tracks[i].sequence);
                         partition.PartitionName = discimage.tracks[i].title;
                         partition.PartitionStartSector = sector_offset;
                         partition.PartitionLength = discimage.tracks[i].pregap * discimage.tracks[i].bps;
@@ -1094,17 +1092,17 @@ namespace DiscImageChef.ImagePlugins
                         }
 
                         partitions.Add(partition);
-                        partition = new CommonTypes.Partition();
+                        partition = new Partition();
                     }
 
                     index_zero |= discimage.tracks[i].indexes.TryGetValue(0, out index_zero_offset);
 
                     if(!discimage.tracks[i].indexes.TryGetValue(1, out index_one_offset))
-                        throw new ImageNotSupportedException(String.Format("Track {0} lacks index 01", discimage.tracks[i].sequence));
+                        throw new ImageNotSupportedException(string.Format("Track {0} lacks index 01", discimage.tracks[i].sequence));
 
                     if(index_zero && index_one_offset > index_zero_offset)
                     {
-                        partition.PartitionDescription = String.Format("Track {0} index 00.", discimage.tracks[i].sequence);
+                        partition.PartitionDescription = string.Format("Track {0} index 00.", discimage.tracks[i].sequence);
                         partition.PartitionName = discimage.tracks[i].title;
                         partition.PartitionStartSector = sector_offset;
                         partition.PartitionLength = (index_one_offset - index_zero_offset) * discimage.tracks[i].bps;
@@ -1133,11 +1131,11 @@ namespace DiscImageChef.ImagePlugins
                         }
 
                         partitions.Add(partition);
-                        partition = new CommonTypes.Partition();
+                        partition = new Partition();
                     }
 
                     // Index 01
-                    partition.PartitionDescription = String.Format("Track {0}.", discimage.tracks[i].sequence);
+                    partition.PartitionDescription = string.Format("Track {0}.", discimage.tracks[i].sequence);
                     partition.PartitionName = discimage.tracks[i].title;
                     partition.PartitionStartSector = sector_offset;
                     partition.PartitionLength = (discimage.tracks[i].sectors - index0_len) * discimage.tracks[i].bps;
@@ -1165,12 +1163,12 @@ namespace DiscImageChef.ImagePlugins
                     }
 
                     partitions.Add(partition);
-                    partition = new CommonTypes.Partition();
+                    partition = new Partition();
                 }
 
                 // Print offset map
                 DicConsole.DebugWriteLine("CDRWin plugin", "printing partition map");
-                foreach(CommonTypes.Partition partition in partitions)
+                foreach(Partition partition in partitions)
                 {
                     DicConsole.DebugWriteLine("CDRWin plugin", "Partition sequence: {0}", partition.PartitionSequence);
                     DicConsole.DebugWriteLine("CDRWin plugin", "\tPartition name: {0}", partition.PartitionName);
@@ -1296,17 +1294,17 @@ namespace DiscImageChef.ImagePlugins
             return ImageInfo.imageHasPartitions;
         }
 
-        public override UInt64 GetImageSize()
+        public override ulong GetImageSize()
         {
             return ImageInfo.imageSize;
         }
 
-        public override UInt64 GetSectors()
+        public override ulong GetSectors()
         {
             return ImageInfo.sectors;
         }
 
-        public override UInt32 GetSectorSize()
+        public override uint GetSectorSize()
         {
             return ImageInfo.sectorSize;
         }
@@ -1335,27 +1333,27 @@ namespace DiscImageChef.ImagePlugins
             }
         }
 
-        public override byte[] ReadSector(UInt64 sectorAddress)
+        public override byte[] ReadSector(ulong sectorAddress)
         {
             return ReadSectors(sectorAddress, 1);
         }
 
-        public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
+        public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
         {
             return ReadSectorsTag(sectorAddress, 1, tag);
         }
 
-        public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
+        public override byte[] ReadSector(ulong sectorAddress, uint track)
         {
             return ReadSectors(sectorAddress, 1, track);
         }
 
-        public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
+        public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
         {
             return ReadSectorsTag(sectorAddress, 1, track, tag);
         }
 
-        public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
+        public override byte[] ReadSectors(ulong sectorAddress, uint length)
         {
             foreach(KeyValuePair kvp in offsetmap)
             {
@@ -1372,10 +1370,10 @@ namespace DiscImageChef.ImagePlugins
                 }
             }
 
-            throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
+            throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
         }
 
-        public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
+        public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
         {
             foreach(KeyValuePair kvp in offsetmap)
             {
@@ -1392,10 +1390,10 @@ namespace DiscImageChef.ImagePlugins
                 }
             }
 
-            throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
+            throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
         }
 
-        public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
+        public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
         {
             CDRWinTrack _track = new CDRWinTrack();
 
@@ -1411,10 +1409,10 @@ namespace DiscImageChef.ImagePlugins
             }
 
             if(_track.sequence == 0)
-                throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
+                throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
 
             if(length > _track.sectors)
-                throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
+                throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
 
             uint sector_offset;
             uint sector_size;
@@ -1510,7 +1508,7 @@ namespace DiscImageChef.ImagePlugins
             return buffer;
         }
 
-        public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
+        public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
         {
             CDRWinTrack _track = new CDRWinTrack();
 
@@ -1526,10 +1524,10 @@ namespace DiscImageChef.ImagePlugins
             }
 
             if(_track.sequence == 0)
-                throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
+                throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
 
             if(length > _track.sectors)
-                throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
+                throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
 
             uint sector_offset;
             uint sector_size;
@@ -1569,7 +1567,7 @@ namespace DiscImageChef.ImagePlugins
                 case SectorTagType.CDTrackText:
                     throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
                 default:
-                    throw new ArgumentException("Unsupported tag requested", "tag");
+                    throw new ArgumentException("Unsupported tag requested", nameof(tag));
             }
 
             switch(_track.tracktype)
@@ -1577,7 +1575,7 @@ namespace DiscImageChef.ImagePlugins
                 case CDRWinTrackTypeMode1:
                 case CDRWinTrackTypeMode2Form1:
                 case CDRWinTrackTypeMode2Form2:
-                    throw new ArgumentException("No tags in image for requested track", "tag");
+                    throw new ArgumentException("No tags in image for requested track", nameof(tag));
                 case CDRWinTrackTypeMode2Formless:
                 case CDRWinTrackTypeCDI:
                     {
@@ -1589,7 +1587,7 @@ namespace DiscImageChef.ImagePlugins
                             case SectorTagType.CDSectorECC:
                             case SectorTagType.CDSectorECC_P:
                             case SectorTagType.CDSectorECC_Q:
-                                throw new ArgumentException("Unsupported tag requested for this track", "tag");
+                                throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
                             case SectorTagType.CDSectorSubHeader:
                                 {
                                     sector_offset = 0;
@@ -1605,12 +1603,12 @@ namespace DiscImageChef.ImagePlugins
                                     break;
                                 }
                             default:
-                                throw new ArgumentException("Unsupported tag requested", "tag");
+                                throw new ArgumentException("Unsupported tag requested", nameof(tag));
                         }
                         break;
                     }
                 case CDRWinTrackTypeAudio:
-                    throw new ArgumentException("There are no tags on audio tracks", "tag");
+                    throw new ArgumentException("There are no tags on audio tracks", nameof(tag));
                 case CDRWinTrackTypeMode1Raw:
                     {
                         switch(tag)
@@ -1631,7 +1629,7 @@ namespace DiscImageChef.ImagePlugins
                                 }
                             case SectorTagType.CDSectorSubchannel:
                             case SectorTagType.CDSectorSubHeader:
-                                throw new ArgumentException("Unsupported tag requested for this track", "tag");
+                                throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
                             case SectorTagType.CDSectorECC:
                                 {
                                     sector_offset = 2076;
@@ -1661,7 +1659,7 @@ namespace DiscImageChef.ImagePlugins
                                     break;
                                 }
                             default:
-                                throw new ArgumentException("Unsupported tag requested", "tag");
+                                throw new ArgumentException("Unsupported tag requested", nameof(tag));
                         }
                         break;
                     }
@@ -1671,7 +1669,7 @@ namespace DiscImageChef.ImagePlugins
                 case CDRWinTrackTypeCDG:
                     {
                         if(tag != SectorTagType.CDSectorSubchannel)
-                            throw new ArgumentException("Unsupported tag requested for this track", "tag");
+                            throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
 
                         sector_offset = 2352;
                         sector_size = 96;
@@ -1708,17 +1706,17 @@ namespace DiscImageChef.ImagePlugins
             return buffer;
         }
 
-        public override byte[] ReadSectorLong(UInt64 sectorAddress)
+        public override byte[] ReadSectorLong(ulong sectorAddress)
         {
             return ReadSectorsLong(sectorAddress, 1);
         }
 
-        public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
+        public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
         {
             return ReadSectorsLong(sectorAddress, 1, track);
         }
 
-        public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
+        public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
         {
             foreach(KeyValuePair kvp in offsetmap)
             {
@@ -1735,10 +1733,10 @@ namespace DiscImageChef.ImagePlugins
                 }
             }
 
-            throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
+            throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
         }
 
-        public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
+        public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
         {
             CDRWinTrack _track = new CDRWinTrack();
 
@@ -1754,10 +1752,10 @@ namespace DiscImageChef.ImagePlugins
             }
 
             if(_track.sequence == 0)
-                throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
+                throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
 
             if(length > _track.sectors)
-                throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
+                throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
 
             uint sector_offset;
             uint sector_size;
@@ -1884,7 +1882,7 @@ namespace DiscImageChef.ImagePlugins
             return ImageInfo.mediaType;
         }
 
-        public override List GetPartitions()
+        public override List GetPartitions()
         {
             return partitions;
         }
@@ -1893,7 +1891,7 @@ namespace DiscImageChef.ImagePlugins
         {
             List tracks = new List();
 
-            UInt64 previousStartSector = 0;
+            ulong previousStartSector = 0;
 
             foreach(CDRWinTrack cdr_track in discimage.tracks)
             {
@@ -1939,7 +1937,7 @@ namespace DiscImageChef.ImagePlugins
             throw new ImageNotSupportedException("Session does not exist in disc image");
         }
 
-        public override List GetSessionTracks(UInt16 session)
+        public override List GetSessionTracks(ushort session)
         {
             List tracks = new List();
 
@@ -1984,25 +1982,25 @@ namespace DiscImageChef.ImagePlugins
             return discimage.sessions;
         }
 
-        public override bool? VerifySector(UInt64 sectorAddress)
+        public override bool? VerifySector(ulong sectorAddress)
         {
             byte[] buffer = ReadSectorLong(sectorAddress);
             return Checksums.CDChecksums.CheckCDSector(buffer);
         }
 
-        public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
+        public override bool? VerifySector(ulong sectorAddress, uint track)
         {
             byte[] buffer = ReadSectorLong(sectorAddress, track);
             return Checksums.CDChecksums.CheckCDSector(buffer);
         }
 
-        public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List FailingLBAs, out List UnknownLBAs)
+        public override bool? VerifySectors(ulong sectorAddress, uint length, out List FailingLBAs, out List UnknownLBAs)
         {
             byte[] buffer = ReadSectorsLong(sectorAddress, length);
             int bps = (int)(buffer.Length / length);
             byte[] sector = new byte[bps];
-            FailingLBAs = new List();
-            UnknownLBAs = new List();
+            FailingLBAs = new List();
+            UnknownLBAs = new List();
 
             for(int i = 0; i < length; i++)
             {
@@ -2027,13 +2025,13 @@ namespace DiscImageChef.ImagePlugins
             return true;
         }
 
-        public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List FailingLBAs, out List UnknownLBAs)
+        public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List FailingLBAs, out List UnknownLBAs)
         {
             byte[] buffer = ReadSectorsLong(sectorAddress, length, track);
             int bps = (int)(buffer.Length / length);
             byte[] sector = new byte[bps];
-            FailingLBAs = new List();
-            UnknownLBAs = new List();
+            FailingLBAs = new List();
+            UnknownLBAs = new List();
 
             for(int i = 0; i < length; i++)
             {
@@ -2067,22 +2065,22 @@ namespace DiscImageChef.ImagePlugins
 
         #region Private methods
 
-        static UInt64 CDRWinMSFToLBA(string MSF)
+        static ulong CDRWinMSFToLBA(string MSF)
         {
             string[] MSFElements;
-            UInt64 minute, second, frame, sectors;
+            ulong minute, second, frame, sectors;
 
             MSFElements = MSF.Split(':');
-            minute = UInt64.Parse(MSFElements[0]);
-            second = UInt64.Parse(MSFElements[1]);
-            frame = UInt64.Parse(MSFElements[2]);
+            minute = ulong.Parse(MSFElements[0]);
+            second = ulong.Parse(MSFElements[1]);
+            frame = ulong.Parse(MSFElements[2]);
 
             sectors = (minute * 60 * 75) + (second * 75) + frame;
 
             return sectors;
         }
 
-        static UInt16 CDRWinTrackTypeToBytesPerSector(string trackType)
+        static ushort CDRWinTrackTypeToBytesPerSector(string trackType)
         {
             switch(trackType)
             {
@@ -2106,7 +2104,7 @@ namespace DiscImageChef.ImagePlugins
             }
         }
 
-        static UInt16 CDRWinTrackTypeToCookedBytesPerSector(string trackType)
+        static ushort CDRWinTrackTypeToCookedBytesPerSector(string trackType)
         {
             switch(trackType)
             {
diff --git a/DiscImageChef.DiscImages/ChangeLog b/DiscImageChef.DiscImages/ChangeLog
index cec09519..4fae713f 100644
--- a/DiscImageChef.DiscImages/ChangeLog
+++ b/DiscImageChef.DiscImages/ChangeLog
@@ -1,3 +1,17 @@
+2016-07-28  Natalia Portillo  
+
+	* VHD.cs:
+	* GDI.cs:
+	* Nero.cs:
+	* CDRDAO.cs:
+	* CDRWin.cs:
+	* Apple2MG.cs:
+	* TeleDisk.cs:
+	* ImageInfo.cs:
+	* DiskCopy42.cs:
+	* ImagePlugin.cs:
+	* ZZZRawImage.cs: Refactor and code cleanup.
+
 2016-02-03  Natalia Portillo  
 
 	* CDRWin.cs:
diff --git a/DiscImageChef.DiscImages/DiskCopy42.cs b/DiscImageChef.DiscImages/DiskCopy42.cs
index 6aa1d7e7..bd891989 100644
--- a/DiscImageChef.DiscImages/DiskCopy42.cs
+++ b/DiscImageChef.DiscImages/DiskCopy42.cs
@@ -49,13 +49,13 @@ namespace DiscImageChef.ImagePlugins
             /// 0x00, 64 bytes, pascal string, disk name or "-not a Macintosh disk-", filled with garbage
             public string diskName;
             /// 0x40, size of data in bytes (usually sectors*512)
-            public UInt32 dataSize;
+            public uint dataSize;
             /// 0x44, size of tags in bytes (usually sectors*12)
-            public UInt32 tagSize;
+            public uint tagSize;
             /// 0x48, checksum of data bytes
-            public UInt32 dataChecksum;
+            public uint dataChecksum;
             /// 0x4C, checksum of tag bytes
-            public UInt32 tagChecksum;
+            public uint tagChecksum;
             /// 0x50, format of disk, see constants
             public byte format;
             /// 0x51, format of sectors, see constants
@@ -114,11 +114,11 @@ namespace DiscImageChef.ImagePlugins
         #region Internal variables
 
         /// Start of data sectors in disk image, should be 0x58
-        UInt32 dataOffset;
+        uint dataOffset;
         /// Start of tags in disk image, after data sectors
-        UInt32 tagOffset;
+        uint tagOffset;
         /// Bytes per tag, should be 12
-        UInt32 bptag;
+        uint bptag;
         /// Header of opened image
         DC42Header header;
         /// Disk image file
@@ -372,33 +372,33 @@ namespace DiscImageChef.ImagePlugins
             return true;
         }
 
-        public override bool? VerifySector(UInt64 sectorAddress)
+        public override bool? VerifySector(ulong sectorAddress)
         {
             return null;
         }
 
-        public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
+        public override bool? VerifySector(ulong sectorAddress, uint track)
         {
             return null;
         }
 
-        public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List FailingLBAs, out List UnknownLBAs)
+        public override bool? VerifySectors(ulong sectorAddress, uint length, out List FailingLBAs, out List UnknownLBAs)
         {
-            FailingLBAs = new List();
-            UnknownLBAs = new List();
+            FailingLBAs = new List();
+            UnknownLBAs = new List();
 
-            for(UInt64 i = sectorAddress; i < sectorAddress + length; i++)
+            for(ulong i = sectorAddress; i < sectorAddress + length; i++)
                 UnknownLBAs.Add(i);
 
             return null;
         }
 
-        public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List FailingLBAs, out List UnknownLBAs)
+        public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List FailingLBAs, out List UnknownLBAs)
         {
-            FailingLBAs = new List();
-            UnknownLBAs = new List();
+            FailingLBAs = new List();
+            UnknownLBAs = new List();
 
-            for(UInt64 i = sectorAddress; i < sectorAddress + length; i++)
+            for(ulong i = sectorAddress; i < sectorAddress + length; i++)
                 UnknownLBAs.Add(i);
 
             return null;
@@ -408,12 +408,12 @@ namespace DiscImageChef.ImagePlugins
         {
             byte[] data = new byte[header.dataSize];
             byte[] tags = new byte[header.tagSize];
-            UInt32 dataChk;
-            UInt32 tagsChk = 0;
+            uint dataChk;
+            uint tagsChk = 0;
 
             DicConsole.DebugWriteLine("DC42 plugin", "Reading data");
             FileStream datastream = new FileStream(dc42ImagePath, FileMode.Open, FileAccess.Read);
-            datastream.Seek((long)(dataOffset), SeekOrigin.Begin);
+            datastream.Seek((dataOffset), SeekOrigin.Begin);
             datastream.Read(data, 0, (int)header.dataSize);
             datastream.Close();
 
@@ -426,7 +426,7 @@ namespace DiscImageChef.ImagePlugins
             {
                 DicConsole.DebugWriteLine("DC42 plugin", "Reading tags");
                 FileStream tagstream = new FileStream(dc42ImagePath, FileMode.Open, FileAccess.Read);
-                tagstream.Seek((long)(tagOffset), SeekOrigin.Begin);
+                tagstream.Seek((tagOffset), SeekOrigin.Begin);
                 tagstream.Read(tags, 0, (int)header.tagSize);
                 tagstream.Close();
 
@@ -444,38 +444,38 @@ namespace DiscImageChef.ImagePlugins
             return ImageInfo.imageHasPartitions;
         }
 
-        public override UInt64 GetImageSize()
+        public override ulong GetImageSize()
         {
             return ImageInfo.imageSize;
         }
 
-        public override UInt64 GetSectors()
+        public override ulong GetSectors()
         {
             return ImageInfo.sectors;
         }
 
-        public override UInt32 GetSectorSize()
+        public override uint GetSectorSize()
         {
             return ImageInfo.sectorSize;
         }
 
-        public override byte[] ReadSector(UInt64 sectorAddress)
+        public override byte[] ReadSector(ulong sectorAddress)
         {
             return ReadSectors(sectorAddress, 1);
         }
 
-        public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
+        public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
         {
             return ReadSectorsTag(sectorAddress, 1, tag);
         }
 
-        public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
+        public override byte[] ReadSectors(ulong sectorAddress, uint length)
         {
             if(sectorAddress > ImageInfo.sectors - 1)
-                throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
+                throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
 
             if(sectorAddress + length > ImageInfo.sectors)
-                throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
+                throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
 
             byte[] buffer = new byte[length * ImageInfo.sectorSize];
 
@@ -490,19 +490,19 @@ namespace DiscImageChef.ImagePlugins
             return buffer;
         }
 
-        public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
+        public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
         {
             if(tag != SectorTagType.AppleSectorTag)
-                throw new FeatureUnsupportedImageException(String.Format("Tag {0} not supported by image format", tag));
+                throw new FeatureUnsupportedImageException(string.Format("Tag {0} not supported by image format", tag));
 
             if(header.tagSize == 0)
                 throw new FeatureNotPresentImageException("Disk image does not have tags");
 
             if(sectorAddress > ImageInfo.sectors - 1)
-                throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
+                throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
 
             if(sectorAddress + length > ImageInfo.sectors)
-                throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
+                throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
 
             byte[] buffer = new byte[length * bptag];
 
@@ -517,18 +517,18 @@ namespace DiscImageChef.ImagePlugins
             return buffer;
         }
 
-        public override byte[] ReadSectorLong(UInt64 sectorAddress)
+        public override byte[] ReadSectorLong(ulong sectorAddress)
         {
             return ReadSectorsLong(sectorAddress, 1);
         }
 
-        public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
+        public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
         {
             if(sectorAddress > ImageInfo.sectors - 1)
-                throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
+                throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
 
             if(sectorAddress + length > ImageInfo.sectors)
-                throw new ArgumentOutOfRangeException("length", "Requested more sectors than available");
+                throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
 
             byte[] data = ReadSectors(sectorAddress, length);
             byte[] tags = ReadSectorsTag(sectorAddress, length, SectorTagType.AppleSectorTag);
@@ -650,7 +650,7 @@ namespace DiscImageChef.ImagePlugins
             return ImageInfo.driveSerialNumber;
         }
 
-        public override List GetPartitions()
+        public override List GetPartitions()
         {
             throw new FeatureUnsupportedImageException("Feature not supported by image format");
         }
@@ -665,7 +665,7 @@ namespace DiscImageChef.ImagePlugins
             throw new FeatureUnsupportedImageException("Feature not supported by image format");
         }
 
-        public override List GetSessionTracks(UInt16 session)
+        public override List GetSessionTracks(ushort session)
         {
             throw new FeatureUnsupportedImageException("Feature not supported by image format");
         }
@@ -675,32 +675,32 @@ namespace DiscImageChef.ImagePlugins
             throw new FeatureUnsupportedImageException("Feature not supported by image format");
         }
 
-        public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
+        public override byte[] ReadSector(ulong sectorAddress, uint track)
         {
             throw new FeatureUnsupportedImageException("Feature not supported by image format");
         }
 
-        public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
+        public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
         {
             throw new FeatureUnsupportedImageException("Feature not supported by image format");
         }
 
-        public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
+        public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
         {
             throw new FeatureUnsupportedImageException("Feature not supported by image format");
         }
 
-        public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
+        public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
         {
             throw new FeatureUnsupportedImageException("Feature not supported by image format");
         }
 
-        public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
+        public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
         {
             throw new FeatureUnsupportedImageException("Feature not supported by image format");
         }
 
-        public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
+        public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
         {
             throw new FeatureUnsupportedImageException("Feature not supported by image format");
         }
@@ -709,13 +709,13 @@ namespace DiscImageChef.ImagePlugins
 
         #region Private methods
 
-        private static UInt32 DC42CheckSum(byte[] buffer)
+        private static uint DC42CheckSum(byte[] buffer)
         {
-            UInt32 dc42chk = 0;
+            uint dc42chk = 0;
             if((buffer.Length & 0x01) == 0x01)
                 return 0xFFFFFFFF;
 
-            for(UInt32 i = 0; i < buffer.Length; i += 2)
+            for(uint i = 0; i < buffer.Length; i += 2)
             {
                 dc42chk += (uint)(buffer[i] << 8);
                 dc42chk += buffer[i + 1];
diff --git a/DiscImageChef.DiscImages/GDI.cs b/DiscImageChef.DiscImages/GDI.cs
index c6929c75..a8e03417 100644
--- a/DiscImageChef.DiscImages/GDI.cs
+++ b/DiscImageChef.DiscImages/GDI.cs
@@ -48,7 +48,7 @@ namespace DiscImageChef.ImagePlugins
         struct GDITrack
         {
             /// Track #
-            public UInt32 sequence;
+            public uint sequence;
             /// Track file
             public string trackfile;
             /// Track byte offset in file
@@ -58,9 +58,9 @@ namespace DiscImageChef.ImagePlugins
             /// Track starting sector
             public ulong startSector;
             /// Bytes per sector
-            public UInt16 bps;
+            public ushort bps;
             /// Sectors in track
-            public UInt64 sectors;
+            public ulong sectors;
             /// Track type
             public TrackType tracktype;
             /// Track session
@@ -87,7 +87,7 @@ namespace DiscImageChef.ImagePlugins
         StreamReader gdiStream;
         FileStream imageStream;
         /// Dictionary, index is track #, value is track number, or 0 if a TOC
-        Dictionary offsetmap;
+        Dictionary offsetmap;
         GDIDisc discimage;
         List partitions;
         ulong densitySeparationSectors;
@@ -224,7 +224,7 @@ namespace DiscImageChef.ImagePlugins
                         TrackMatch = RegexTrack.Match(_line);
 
                         if(!TrackMatch.Success)
-                            throw new ImageNotSupportedException(String.Format("Unknown line \"{0}\" at line {1}", _line, line));
+                            throw new ImageNotSupportedException(string.Format("Unknown line \"{0}\" at line {1}", _line, line));
 
                         tracksFound++;
 
@@ -379,7 +379,7 @@ namespace DiscImageChef.ImagePlugins
                     Partition partition = new Partition();
 
                     // Index 01
-                    partition.PartitionDescription = String.Format("Track {0}.", discimage.tracks[i].sequence);
+                    partition.PartitionDescription = string.Format("Track {0}.", discimage.tracks[i].sequence);
                     partition.PartitionName = null;
                     partition.PartitionStartSector = discimage.tracks[i].startSector;
                     partition.PartitionLength = discimage.tracks[i].sectors * discimage.tracks[i].bps;
@@ -443,17 +443,17 @@ namespace DiscImageChef.ImagePlugins
             return ImageInfo.imageHasPartitions;
         }
 
-        public override UInt64 GetImageSize()
+        public override ulong GetImageSize()
         {
             return ImageInfo.imageSize;
         }
 
-        public override UInt64 GetSectors()
+        public override ulong GetSectors()
         {
             return ImageInfo.sectors;
         }
 
-        public override UInt32 GetSectorSize()
+        public override uint GetSectorSize()
         {
             return ImageInfo.sectorSize;
         }
@@ -463,27 +463,27 @@ namespace DiscImageChef.ImagePlugins
             throw new FeatureSupportedButNotImplementedImageException("Feature not supported by image format");
         }
 
-        public override byte[] ReadSector(UInt64 sectorAddress)
+        public override byte[] ReadSector(ulong sectorAddress)
         {
             return ReadSectors(sectorAddress, 1);
         }
 
-        public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag)
+        public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
         {
             return ReadSectorsTag(sectorAddress, 1, tag);
         }
 
-        public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track)
+        public override byte[] ReadSector(ulong sectorAddress, uint track)
         {
             return ReadSectors(sectorAddress, 1, track);
         }
 
-        public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag)
+        public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
         {
             return ReadSectorsTag(sectorAddress, 1, track, tag);
         }
 
-        public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length)
+        public override byte[] ReadSectors(ulong sectorAddress, uint length)
         {
             foreach(KeyValuePair kvp in offsetmap)
             {
@@ -505,10 +505,10 @@ namespace DiscImageChef.ImagePlugins
             if(sectorAddress >= transitionStart && sectorAddress < (densitySeparationSectors + transitionStart))
                 return ReadSectors((sectorAddress - transitionStart), length, 0);
 
-            throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
+            throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
         }
 
-        public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag)
+        public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
         {
             foreach(KeyValuePair kvp in offsetmap)
             {
@@ -530,15 +530,15 @@ namespace DiscImageChef.ImagePlugins
             if(sectorAddress >= transitionStart && sectorAddress < (densitySeparationSectors + transitionStart))
                 return ReadSectorsTag((sectorAddress - transitionStart), length, 0, tag);
 
-            throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
+            throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
         }
 
-        public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track)
+        public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
         {
             if(track == 0)
             {
                 if((sectorAddress + length) > densitySeparationSectors)
-                    throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
+                    throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
 
                 return new byte[length * 2352];
             }
@@ -557,10 +557,10 @@ namespace DiscImageChef.ImagePlugins
             }
 
             if(_track.sequence == 0)
-                throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
+                throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
 
             if((sectorAddress + length) > _track.sectors)
-                throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
+                throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
 
             uint sector_offset;
             uint sector_size;
@@ -642,17 +642,17 @@ namespace DiscImageChef.ImagePlugins
             return buffer;
         }
 
-        public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag)
+        public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
         {
             if(track == 0)
             {
                 if((sectorAddress + length) > densitySeparationSectors)
-                    throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
+                    throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
 
                 if(tag == SectorTagType.CDTrackFlags)
                     return new byte[] { 0x00 };
 
-                throw new ArgumentException("Unsupported tag requested for this track", "tag");
+                throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
             }
 
             GDITrack _track = new GDITrack();
@@ -669,10 +669,10 @@ namespace DiscImageChef.ImagePlugins
             }
 
             if(_track.sequence == 0)
-                throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
+                throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
 
             if(length > _track.sectors)
-                throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
+                throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
 
             uint sector_offset;
             uint sector_size;
@@ -696,13 +696,13 @@ namespace DiscImageChef.ImagePlugins
                         return flags;
                     }
                 default:
-                    throw new ArgumentException("Unsupported tag requested", "tag");
+                    throw new ArgumentException("Unsupported tag requested", nameof(tag));
             }
 
             switch(_track.tracktype)
             {
                 case TrackType.Audio:
-                    throw new ArgumentException("There are no tags on audio tracks", "tag");
+                    throw new ArgumentException("There are no tags on audio tracks", nameof(tag));
                 case TrackType.CDMode1:
                     {
                         if(_track.bps != 2352)
@@ -726,7 +726,7 @@ namespace DiscImageChef.ImagePlugins
                                 }
                             case SectorTagType.CDSectorSubchannel:
                             case SectorTagType.CDSectorSubHeader:
-                                throw new ArgumentException("Unsupported tag requested for this track", "tag");
+                                throw new ArgumentException("Unsupported tag requested for this track", nameof(tag));
                             case SectorTagType.CDSectorECC:
                                 {
                                     sector_offset = 2076;
@@ -756,7 +756,7 @@ namespace DiscImageChef.ImagePlugins
                                     break;
                                 }
                             default:
-                                throw new ArgumentException("Unsupported tag requested", "tag");
+                                throw new ArgumentException("Unsupported tag requested", nameof(tag));
                         }
                         break;
                     }
@@ -811,17 +811,17 @@ namespace DiscImageChef.ImagePlugins
             return buffer;
         }
 
-        public override byte[] ReadSectorLong(UInt64 sectorAddress)
+        public override byte[] ReadSectorLong(ulong sectorAddress)
         {
             return ReadSectorsLong(sectorAddress, 1);
         }
 
-        public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track)
+        public override byte[] ReadSectorLong(ulong sectorAddress, uint track)
         {
             return ReadSectorsLong(sectorAddress, 1, track);
         }
 
-        public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length)
+        public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
         {
             foreach(KeyValuePair kvp in offsetmap)
             {
@@ -838,15 +838,15 @@ namespace DiscImageChef.ImagePlugins
                 }
             }
 
-            throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found");
+            throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
         }
 
-        public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track)
+        public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
         {
             if(track == 0)
             {
                 if((sectorAddress + length) > densitySeparationSectors)
-                    throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
+                    throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
 
                 return new byte[length * 2352];
             }
@@ -865,10 +865,10 @@ namespace DiscImageChef.ImagePlugins
             }
 
             if(_track.sequence == 0)
-                throw new ArgumentOutOfRangeException("track", "Track does not exist in disc image");
+                throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
 
             if((sectorAddress + length) > _track.sectors)
-                throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks");
+                throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks");
 
             uint sector_offset;
             uint sector_size;
@@ -1049,7 +1049,7 @@ namespace DiscImageChef.ImagePlugins
             throw new ImageNotSupportedException("Session does not exist in disc image");
         }
 
-        public override List GetSessionTracks(UInt16 session)
+        public override List GetSessionTracks(ushort session)
         {
             List tracks = new List();
             bool expectedDensity;
@@ -1105,25 +1105,25 @@ namespace DiscImageChef.ImagePlugins
             return discimage.sessions;
         }
 
-        public override bool? VerifySector(UInt64 sectorAddress)
+        public override bool? VerifySector(ulong sectorAddress)
         {
             byte[] buffer = ReadSectorLong(sectorAddress);
             return Checksums.CDChecksums.CheckCDSector(buffer);
         }
 
-        public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
+        public override bool? VerifySector(ulong sectorAddress, uint track)
         {
             byte[] buffer = ReadSectorLong(sectorAddress, track);
             return Checksums.CDChecksums.CheckCDSector(buffer);
         }
 
-        public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List FailingLBAs, out List UnknownLBAs)
+        public override bool? VerifySectors(ulong sectorAddress, uint length, out List FailingLBAs, out List UnknownLBAs)
         {
             byte[] buffer = ReadSectorsLong(sectorAddress, length);
             int bps = (int)(buffer.Length / length);
             byte[] sector = new byte[bps];
-            FailingLBAs = new List();
-            UnknownLBAs = new List();
+            FailingLBAs = new List();
+            UnknownLBAs = new List();
 
             for(int i = 0; i < length; i++)
             {
@@ -1148,13 +1148,13 @@ namespace DiscImageChef.ImagePlugins
             return true;
         }
 
-        public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List FailingLBAs, out List UnknownLBAs)
+        public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List FailingLBAs, out List UnknownLBAs)
         {
             byte[] buffer = ReadSectorsLong(sectorAddress, length, track);
             int bps = (int)(buffer.Length / length);
             byte[] sector = new byte[bps];
-            FailingLBAs = new List();
-            UnknownLBAs = new List();
+            FailingLBAs = new List();
+            UnknownLBAs = new List();
 
             for(int i = 0; i < length; i++)
             {
diff --git a/DiscImageChef.DiscImages/ImageInfo.cs b/DiscImageChef.DiscImages/ImageInfo.cs
index c0efb306..829335aa 100644
--- a/DiscImageChef.DiscImages/ImageInfo.cs
+++ b/DiscImageChef.DiscImages/ImageInfo.cs
@@ -40,9 +40,9 @@ namespace DiscImageChef.ImagePlugins
     {
         public bool imageHasPartitions;
         public bool imageHasSessions;
-        public UInt64 imageSize;
-        public UInt64 sectors;
-        public UInt32 sectorSize;
+        public ulong imageSize;
+        public ulong sectors;
+        public uint sectorSize;
         public List readableMediaTags;
         public List readableSectorTags;
         public string imageVersion;
diff --git a/DiscImageChef.DiscImages/ImagePlugin.cs b/DiscImageChef.DiscImages/ImagePlugin.cs
index 74120e10..48b68ad2 100644
--- a/DiscImageChef.DiscImages/ImagePlugin.cs
+++ b/DiscImageChef.DiscImages/ImagePlugin.cs
@@ -80,19 +80,19 @@ namespace DiscImageChef.ImagePlugins
         /// Gets the size of the image, without headers.
         /// 
/// The image size. - public abstract UInt64 GetImageSize(); + public abstract ulong GetImageSize(); /// /// Gets the number of sectors in the image. /// /// Sectors in image. - public abstract UInt64 GetSectors(); + public abstract ulong GetSectors(); /// /// Returns the size of the biggest sector, counting user data only. /// /// Biggest sector size (user data only). - public abstract UInt32 GetSectorSize(); + public abstract uint GetSectorSize(); // Image reading functions @@ -108,7 +108,7 @@ namespace DiscImageChef.ImagePlugins ///
/// The sector's user data. /// Sector address (LBA). - public abstract byte[] ReadSector(UInt64 sectorAddress); + public abstract byte[] ReadSector(ulong sectorAddress); /// /// Reads a sector's tag. @@ -116,7 +116,7 @@ namespace DiscImageChef.ImagePlugins /// The sector's tag. /// Sector address (LBA). /// Tag type. - public abstract byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag); + public abstract byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag); /// /// Reads a sector's user data, relative to track. @@ -124,7 +124,7 @@ namespace DiscImageChef.ImagePlugins /// The sector's user data. /// Sector address (relative LBA). /// Track. - public abstract byte[] ReadSector(UInt64 sectorAddress, UInt32 track); + public abstract byte[] ReadSector(ulong sectorAddress, uint track); /// /// Reads a sector's tag, relative to track. @@ -133,7 +133,7 @@ namespace DiscImageChef.ImagePlugins /// Sector address (relative LBA). /// Track. /// Tag type. - public abstract byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag); + public abstract byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag); /// /// Reads user data from several sectors. @@ -141,7 +141,7 @@ namespace DiscImageChef.ImagePlugins /// The sectors user data. /// Starting sector address (LBA). /// How many sectors to read. - public abstract byte[] ReadSectors(UInt64 sectorAddress, UInt32 length); + public abstract byte[] ReadSectors(ulong sectorAddress, uint length); /// /// Reads tag from several sectors. @@ -150,7 +150,7 @@ namespace DiscImageChef.ImagePlugins /// Starting sector address (LBA). /// How many sectors to read. /// Tag type. - public abstract byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag); + public abstract byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag); /// /// Reads user data from several sectors, relative to track. @@ -159,7 +159,7 @@ namespace DiscImageChef.ImagePlugins /// Starting sector address (relative LBA). /// How many sectors to read. /// Track. - public abstract byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track); + public abstract byte[] ReadSectors(ulong sectorAddress, uint length, uint track); /// /// Reads tag from several sectors, relative to track. @@ -169,14 +169,14 @@ namespace DiscImageChef.ImagePlugins /// How many sectors to read. /// Track. /// Tag type. - public abstract byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag); + public abstract byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag); /// /// Reads a complete sector (user data + all tags). /// /// The complete sector. Format depends on disk type. /// Sector address (LBA). - public abstract byte[] ReadSectorLong(UInt64 sectorAddress); + public abstract byte[] ReadSectorLong(ulong sectorAddress); /// /// Reads a complete sector (user data + all tags), relative to track. @@ -184,7 +184,7 @@ namespace DiscImageChef.ImagePlugins /// The complete sector. Format depends on disk type. /// Sector address (relative LBA). /// Track. - public abstract byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track); + public abstract byte[] ReadSectorLong(ulong sectorAddress, uint track); /// /// Reads several complete sector (user data + all tags). @@ -192,7 +192,7 @@ namespace DiscImageChef.ImagePlugins /// The complete sectors. Format depends on disk type. /// Starting sector address (LBA). /// How many sectors to read. - public abstract byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length); + public abstract byte[] ReadSectorsLong(ulong sectorAddress, uint length); /// /// Reads several complete sector (user data + all tags), relative to track. @@ -201,7 +201,7 @@ namespace DiscImageChef.ImagePlugins /// Starting sector address (relative LBA). /// How many sectors to read. /// Track. - public abstract byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track); + public abstract byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track); // Image information functions @@ -337,7 +337,7 @@ namespace DiscImageChef.ImagePlugins /// reads can be relative to them. /// /// The partitions. - public abstract List GetPartitions(); + public abstract List GetPartitions(); /// /// Gets the disc track extents (start, length). @@ -357,7 +357,7 @@ namespace DiscImageChef.ImagePlugins /// /// The track exents for that session. /// Session. - public abstract List GetSessionTracks(UInt16 session); + public abstract List GetSessionTracks(ushort session); /// /// Gets the sessions (optical discs only). @@ -371,7 +371,7 @@ namespace DiscImageChef.ImagePlugins /// /// True if correct, false if incorrect, null if uncheckable. /// Sector address (LBA). - public abstract bool? VerifySector(UInt64 sectorAddress); + public abstract bool? VerifySector(ulong sectorAddress); /// /// Verifies a sector, relative to track. @@ -379,7 +379,7 @@ namespace DiscImageChef.ImagePlugins /// True if correct, false if incorrect, null if uncheckable. /// Sector address (relative LBA). /// Track. - public abstract bool? VerifySector(UInt64 sectorAddress, UInt32 track); + public abstract bool? VerifySector(ulong sectorAddress, uint track); /// /// Verifies several sectors. @@ -389,7 +389,7 @@ namespace DiscImageChef.ImagePlugins /// How many sectors to read. /// List of incorrect sectors /// List of uncheckable sectors - public abstract bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List FailingLBAs, out List UnknownLBAs); + public abstract bool? VerifySectors(ulong sectorAddress, uint length, out List FailingLBAs, out List UnknownLBAs); /// /// Verifies several sectors, relative to track. @@ -400,7 +400,7 @@ namespace DiscImageChef.ImagePlugins /// Track. /// List of incorrect sectors /// List of uncheckable sectors - public abstract bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List FailingLBAs, out List UnknownLBAs); + public abstract bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List FailingLBAs, out List UnknownLBAs); /// /// Verifies media image internal checksum. @@ -446,21 +446,21 @@ namespace DiscImageChef.ImagePlugins public struct Track { /// Track number, 1-started - public UInt32 TrackSequence; + public uint TrackSequence; /// Partition type public TrackType TrackType; /// Track starting sector - public UInt64 TrackStartSector; + public ulong TrackStartSector; /// Track ending sector - public UInt64 TrackEndSector; + public ulong TrackEndSector; /// Track pre-gap - public UInt64 TrackPregap; + public ulong TrackPregap; /// Session this track belongs to - public UInt16 TrackSession; + public ushort TrackSession; /// Information that does not find space in this struct public string TrackDescription; /// Indexes, 00 to 99 and sector offset - public Dictionary Indexes; + public Dictionary Indexes; /// Which file stores this track public string TrackFile; /// Starting at which byte is this track stored @@ -512,15 +512,15 @@ namespace DiscImageChef.ImagePlugins public struct Session { /// Session number, 1-started - public UInt16 SessionSequence; + public ushort SessionSequence; /// First track present on this session - public UInt32 StartTrack; + public uint StartTrack; /// Last track present on this session - public UInt32 EndTrack; + public uint EndTrack; /// First sector present on this session - public UInt64 StartSector; + public ulong StartSector; /// Last sector present on this session - public UInt64 EndSector; + public ulong EndSector; } /// @@ -722,7 +722,7 @@ namespace DiscImageChef.ImagePlugins System.Runtime.Serialization.StreamingContext context) { if(info == null) - throw new ArgumentNullException("info"); + throw new ArgumentNullException(nameof(info)); } } @@ -758,7 +758,7 @@ namespace DiscImageChef.ImagePlugins System.Runtime.Serialization.StreamingContext context) { if(info == null) - throw new ArgumentNullException("info"); + throw new ArgumentNullException(nameof(info)); } } @@ -794,7 +794,7 @@ namespace DiscImageChef.ImagePlugins System.Runtime.Serialization.StreamingContext context) { if(info == null) - throw new ArgumentNullException("info"); + throw new ArgumentNullException(nameof(info)); } } @@ -830,7 +830,7 @@ namespace DiscImageChef.ImagePlugins System.Runtime.Serialization.StreamingContext context) { if(info == null) - throw new ArgumentNullException("info"); + throw new ArgumentNullException(nameof(info)); } } @@ -866,7 +866,7 @@ namespace DiscImageChef.ImagePlugins System.Runtime.Serialization.StreamingContext context) { if(info == null) - throw new ArgumentNullException("info"); + throw new ArgumentNullException(nameof(info)); } } } \ No newline at end of file diff --git a/DiscImageChef.DiscImages/Nero.cs b/DiscImageChef.DiscImages/Nero.cs index 69b82305..dc59313e 100644 --- a/DiscImageChef.DiscImages/Nero.cs +++ b/DiscImageChef.DiscImages/Nero.cs @@ -33,7 +33,6 @@ using System; using System.IO; using System.Collections.Generic; -using DiscImageChef; using DiscImageChef.Console; using DiscImageChef.CommonTypes; @@ -48,12 +47,12 @@ namespace DiscImageChef.ImagePlugins /// /// "NERO" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Offset of first chunk in file /// - public UInt32 FirstChunkOffset; + public uint FirstChunkOffset; } struct NeroV2Footer @@ -61,12 +60,12 @@ namespace DiscImageChef.ImagePlugins /// /// "NER5" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Offset of first chunk in file /// - public UInt64 FirstChunkOffset; + public ulong FirstChunkOffset; } struct NeroV2CueEntry @@ -94,7 +93,7 @@ namespace DiscImageChef.ImagePlugins /// /// LBA sector start for this entry /// - public Int32 LBAStart; + public int LBAStart; } struct NeroV2Cuesheet @@ -102,12 +101,12 @@ namespace DiscImageChef.ImagePlugins /// /// "CUEX" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size /// - public UInt32 ChunkSize; + public uint ChunkSize; /// /// Cuesheet entries @@ -135,7 +134,7 @@ namespace DiscImageChef.ImagePlugins /// /// Always zero /// - public UInt16 Dummy; + public ushort Dummy; /// /// MSF start sector's minute for this entry @@ -158,12 +157,12 @@ namespace DiscImageChef.ImagePlugins /// /// "CUES" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size /// - public UInt32 ChunkSize; + public uint ChunkSize; /// /// Cuesheet entries @@ -181,32 +180,32 @@ namespace DiscImageChef.ImagePlugins /// /// Size of sector inside image (in bytes) /// - public UInt16 SectorSize; + public ushort SectorSize; /// /// Sector mode in image /// - public UInt16 Mode; + public ushort Mode; /// /// Unknown /// - public UInt16 Unknown; + public ushort Unknown; /// /// Index 0 start /// - public UInt32 Index0; + public uint Index0; /// /// Index 1 start /// - public UInt32 Index1; + public uint Index1; /// /// End of track + 1 /// - public UInt32 EndOfTrack; + public uint EndOfTrack; } struct NeroV1DAO @@ -214,17 +213,17 @@ namespace DiscImageChef.ImagePlugins /// /// "DAOI" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size (big endian) /// - public UInt32 ChunkSizeBe; + public uint ChunkSizeBe; /// /// Chunk size (little endian) /// - public UInt32 ChunkSizeLe; + public uint ChunkSizeLe; /// /// UPC (14 bytes, null-padded) @@ -234,7 +233,7 @@ namespace DiscImageChef.ImagePlugins /// /// TOC type /// - public UInt16 TocType; + public ushort TocType; /// /// First track @@ -262,32 +261,32 @@ namespace DiscImageChef.ImagePlugins /// /// Size of sector inside image (in bytes) /// - public UInt16 SectorSize; + public ushort SectorSize; /// /// Sector mode in image /// - public UInt16 Mode; + public ushort Mode; /// /// Seems to be always 0. /// - public UInt16 Unknown; + public ushort Unknown; /// /// Index 0 start /// - public UInt64 Index0; + public ulong Index0; /// /// Index 1 start /// - public UInt64 Index1; + public ulong Index1; /// /// End of track + 1 /// - public UInt64 EndOfTrack; + public ulong EndOfTrack; } struct NeroV2DAO @@ -295,17 +294,17 @@ namespace DiscImageChef.ImagePlugins /// /// "DAOX" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size (big endian) /// - public UInt32 ChunkSizeBe; + public uint ChunkSizeBe; /// /// Chunk size (little endian) /// - public UInt32 ChunkSizeLe; + public uint ChunkSizeLe; /// /// UPC (14 bytes, null-padded) @@ -315,7 +314,7 @@ namespace DiscImageChef.ImagePlugins /// /// TOC type /// - public UInt16 TocType; + public ushort TocType; /// /// First track @@ -363,7 +362,7 @@ namespace DiscImageChef.ImagePlugins /// /// CRC /// - public UInt16 CRC; + public ushort CRC; } struct NeroCDText @@ -371,12 +370,12 @@ namespace DiscImageChef.ImagePlugins /// /// "CDTX" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size /// - public UInt32 ChunkSize; + public uint ChunkSize; /// /// CD-TEXT packs @@ -389,27 +388,27 @@ namespace DiscImageChef.ImagePlugins /// /// Offset of track on image /// - public UInt32 Offset; + public uint Offset; /// /// Length of track in bytes /// - public UInt32 Length; + public uint Length; /// /// Track mode /// - public UInt32 Mode; + public uint Mode; /// /// LBA track start (plus 150 lead in sectors) /// - public UInt32 StartLBA; + public uint StartLBA; /// /// Unknown /// - public UInt32 Unknown; + public uint Unknown; } struct NeroV1TAO @@ -417,12 +416,12 @@ namespace DiscImageChef.ImagePlugins /// /// "ETNF" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size /// - public UInt32 ChunkSize; + public uint ChunkSize; /// /// CD-TEXT packs @@ -435,32 +434,32 @@ namespace DiscImageChef.ImagePlugins /// /// Offset of track on image /// - public UInt64 Offset; + public ulong Offset; /// /// Length of track in bytes /// - public UInt64 Length; + public ulong Length; /// /// Track mode /// - public UInt32 Mode; + public uint Mode; /// /// LBA track start (plus 150 lead in sectors) /// - public UInt32 StartLBA; + public uint StartLBA; /// /// Unknown /// - public UInt32 Unknown; + public uint Unknown; /// /// Track length in sectors /// - public UInt32 Sectors; + public uint Sectors; } struct NeroV2TAO @@ -468,12 +467,12 @@ namespace DiscImageChef.ImagePlugins /// /// "ETN2" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size /// - public UInt32 ChunkSize; + public uint ChunkSize; /// /// CD-TEXT packs @@ -486,17 +485,17 @@ namespace DiscImageChef.ImagePlugins /// /// "SINF" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size /// - public UInt32 ChunkSize; + public uint ChunkSize; /// /// Tracks in session /// - public UInt32 Tracks; + public uint Tracks; } struct NeroMediaType @@ -504,17 +503,17 @@ namespace DiscImageChef.ImagePlugins /// /// "MTYP" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size /// - public UInt32 ChunkSize; + public uint ChunkSize; /// /// Media type /// - public UInt32 Type; + public uint Type; } struct NeroDiscInformation @@ -522,17 +521,17 @@ namespace DiscImageChef.ImagePlugins /// /// "DINF" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size /// - public UInt32 ChunkSize; + public uint ChunkSize; /// /// Unknown /// - public UInt32 Unknown; + public uint Unknown; } struct NeroTOCChunk @@ -540,17 +539,17 @@ namespace DiscImageChef.ImagePlugins /// /// "TOCT" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size /// - public UInt32 ChunkSize; + public uint ChunkSize; /// /// Unknown /// - public UInt16 Unknown; + public ushort Unknown; } struct NeroRELOChunk @@ -558,17 +557,17 @@ namespace DiscImageChef.ImagePlugins /// /// "RELO" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size /// - public UInt32 ChunkSize; + public uint ChunkSize; /// /// Unknown /// - public UInt32 Unknown; + public uint Unknown; } struct NeroEndOfChunkChain @@ -576,28 +575,28 @@ namespace DiscImageChef.ImagePlugins /// /// "END!" /// - public UInt32 ChunkID; + public uint ChunkID; /// /// Chunk size /// - public UInt32 ChunkSize; + public uint ChunkSize; } // Internal use only struct NeroTrack { public byte[] ISRC; - public UInt16 SectorSize; - public UInt64 Offset; - public UInt64 Length; - public UInt64 EndOfTrack; - public UInt32 Mode; - public UInt64 StartLBA; - public UInt64 Sectors; - public UInt64 Index0; - public UInt64 Index1; - public UInt32 Sequence; + public ushort SectorSize; + public ulong Offset; + public ulong Length; + public ulong EndOfTrack; + public uint Mode; + public ulong StartLBA; + public ulong Sectors; + public ulong Index0; + public ulong Index1; + public uint Sequence; } #endregion @@ -605,49 +604,49 @@ namespace DiscImageChef.ImagePlugins #region Internal consts // "NERO" - public const UInt32 NeroV1FooterID = 0x4E45524F; + public const uint NeroV1FooterID = 0x4E45524F; // "NER5" - public const UInt32 NeroV2FooterID = 0x4E455235; + public const uint NeroV2FooterID = 0x4E455235; // "CUES" - public const UInt32 NeroV1CUEID = 0x43554553; + public const uint NeroV1CUEID = 0x43554553; // "CUEX" - public const UInt32 NeroV2CUEID = 0x43554558; + public const uint NeroV2CUEID = 0x43554558; // "ETNF" - public const UInt32 NeroV1TAOID = 0x45544E46; + public const uint NeroV1TAOID = 0x45544E46; // "ETN2" - public const UInt32 NeroV2TAOID = 0x45544E32; + public const uint NeroV2TAOID = 0x45544E32; // "DAOI" - public const UInt32 NeroV1DAOID = 0x44414F49; + public const uint NeroV1DAOID = 0x44414F49; // "DAOX" - public const UInt32 NeroV2DAOID = 0x44414F58; + public const uint NeroV2DAOID = 0x44414F58; // "CDTX" - public const UInt32 NeroCDTextID = 0x43445458; + public const uint NeroCDTextID = 0x43445458; // "SINF" - public const UInt32 NeroSessionID = 0x53494E46; + public const uint NeroSessionID = 0x53494E46; // "MTYP" - public const UInt32 NeroDiskTypeID = 0x4D545950; + public const uint NeroDiskTypeID = 0x4D545950; // "DINF" - public const UInt32 NeroDiscInfoID = 0x44494E46; + public const uint NeroDiscInfoID = 0x44494E46; // "TOCT" - public const UInt32 NeroTOCID = 0x544F4354; + public const uint NeroTOCID = 0x544F4354; // "RELO" - public const UInt32 NeroReloID = 0x52454C4F; + public const uint NeroReloID = 0x52454C4F; // "END!" - public const UInt32 NeroEndID = 0x454E4421; + public const uint NeroEndID = 0x454E4421; public enum DAOMode : ushort { @@ -662,6 +661,7 @@ namespace DiscImageChef.ImagePlugins DataM2RawSub = 0x0011 } + [Flags] public enum NeroMediaTypes : uint { /// @@ -834,7 +834,7 @@ namespace DiscImageChef.ImagePlugins FileStream imageStream; FileInfo imageInfo; bool imageNewFormat; - Dictionary neroSessions; + Dictionary neroSessions; NeroV1Cuesheet neroCuesheetV1; NeroV2Cuesheet neroCuesheetV2; NeroV1DAO neroDAOV1; @@ -851,9 +851,9 @@ namespace DiscImageChef.ImagePlugins Dictionary TrackISRCs; byte[] UPC; Dictionary neroTracks; - Dictionary offsetmap; + Dictionary offsetmap; List imageSessions; - List ImagePartitions; + List ImagePartitions; #endregion @@ -868,11 +868,11 @@ namespace DiscImageChef.ImagePlugins ImageInfo = new ImageInfo(); ImageInfo.readableSectorTags = new List(); ImageInfo.readableMediaTags = new List(); - neroSessions = new Dictionary(); + neroSessions = new Dictionary(); neroTracks = new Dictionary(); offsetmap = new Dictionary(); imageSessions = new List(); - ImagePartitions = new List(); + ImagePartitions = new List(); } // Due to .cue format, this method must parse whole file, ignoring errors (those will be thrown by OpenImage()). @@ -978,8 +978,8 @@ namespace DiscImageChef.ImagePlugins while(parsing) { byte[] ChunkHeaderBuffer = new byte[8]; - UInt32 ChunkID; - UInt32 ChunkLength; + uint ChunkID; + uint ChunkLength; imageStream.Read(ChunkHeaderBuffer, 0, 8); ChunkID = BigEndianBitConverter.ToUInt32(ChunkHeaderBuffer, 0); @@ -1374,7 +1374,7 @@ namespace DiscImageChef.ImagePlugins { DicConsole.DebugWriteLine("Nero plugin", "Found \"SINF\" chunk, parsing {0} bytes", ChunkLength); - UInt32 sessionTracks; + uint sessionTracks; byte[] tmpbuffer = new byte[4]; imageStream.Read(tmpbuffer, 0, 4); sessionTracks = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); @@ -1608,12 +1608,12 @@ namespace DiscImageChef.ImagePlugins offsetmap.Add(_track.TrackSequence, _track.TrackStartSector); DicConsole.DebugWriteLine("Nero plugin", "\t\t Offset[{0}]: {1}", _track.TrackSequence, _track.TrackStartSector); - CommonTypes.Partition partition; + Partition partition; if(_neroTrack.Index0 < _neroTrack.Index1) { - partition = new CommonTypes.Partition(); - partition.PartitionDescription = String.Format("Track {0} Index 0", _track.TrackSequence); + partition = new Partition(); + partition.PartitionDescription = string.Format("Track {0} Index 0", _track.TrackSequence); partition.PartitionLength = (_neroTrack.Index1 - _neroTrack.Index0); partition.PartitionName = StringHandlers.CToString(_neroTrack.ISRC); partition.PartitionSectors = partition.PartitionLength / _neroTrack.SectorSize; @@ -1625,8 +1625,8 @@ namespace DiscImageChef.ImagePlugins PartitionSequence++; } - partition = new CommonTypes.Partition(); - partition.PartitionDescription = String.Format("Track {0} Index 1", _track.TrackSequence); + partition = new Partition(); + partition.PartitionDescription = string.Format("Track {0} Index 1", _track.TrackSequence); partition.PartitionLength = (_neroTrack.EndOfTrack - _neroTrack.Index1); partition.PartitionName = StringHandlers.CToString(_neroTrack.ISRC); partition.PartitionSectors = partition.PartitionLength / _neroTrack.SectorSize; @@ -1658,17 +1658,17 @@ namespace DiscImageChef.ImagePlugins return true; } - public override UInt64 GetImageSize() + public override ulong GetImageSize() { return ImageInfo.imageSize; } - public override UInt64 GetSectors() + public override ulong GetSectors() { return ImageInfo.sectors; } - public override UInt32 GetSectorSize() + public override uint GetSectorSize() { return ImageInfo.sectorSize; } @@ -1686,27 +1686,27 @@ namespace DiscImageChef.ImagePlugins } } - public override byte[] ReadSector(UInt64 sectorAddress) + public override byte[] ReadSector(ulong sectorAddress) { return ReadSectors(sectorAddress, 1); } - public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag) + public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) { return ReadSectorsTag(sectorAddress, 1, tag); } - public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track) + public override byte[] ReadSector(ulong sectorAddress, uint track) { return ReadSectors(sectorAddress, 1, track); } - public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag) + public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag) { return ReadSectorsTag(sectorAddress, 1, track, tag); } - public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length) + public override byte[] ReadSectors(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) { @@ -1723,10 +1723,10 @@ namespace DiscImageChef.ImagePlugins } } - throw new ArgumentOutOfRangeException("sectorAddress", String.Format("Sector address {0} not found", sectorAddress)); + throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); } - public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag) + public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { foreach(KeyValuePair kvp in offsetmap) { @@ -1743,18 +1743,18 @@ namespace DiscImageChef.ImagePlugins } } - throw new ArgumentOutOfRangeException("sectorAddress", String.Format("Sector address {0} not found", sectorAddress)); + throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); } - public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track) + public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track) { NeroTrack _track; if(!neroTracks.TryGetValue(track, out _track)) - throw new ArgumentOutOfRangeException("track", "Track not found"); + throw new ArgumentOutOfRangeException(nameof(track), "Track not found"); if(length > _track.Sectors) - throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks"); + throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); uint sector_offset; uint sector_size; @@ -1849,15 +1849,15 @@ namespace DiscImageChef.ImagePlugins return buffer; } - public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag) + public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag) { NeroTrack _track; if(!neroTracks.TryGetValue(track, out _track)) - throw new ArgumentOutOfRangeException("track", "Track not found"); + throw new ArgumentOutOfRangeException(nameof(track), "Track not found"); if(length > _track.Sectors) - throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks"); + throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); uint sector_offset; uint sector_size; @@ -1889,14 +1889,14 @@ namespace DiscImageChef.ImagePlugins case SectorTagType.CDTrackText: throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); default: - throw new ArgumentException("Unsupported tag requested", "tag"); + throw new ArgumentException("Unsupported tag requested", nameof(tag)); } switch((DAOMode)_track.Mode) { case DAOMode.Data: case DAOMode.DataM2F1: - throw new ArgumentException("No tags in image for requested track", "tag"); + throw new ArgumentException("No tags in image for requested track", nameof(tag)); case DAOMode.DataM2F2: { switch(tag) @@ -1907,7 +1907,7 @@ namespace DiscImageChef.ImagePlugins case SectorTagType.CDSectorECC: case SectorTagType.CDSectorECC_P: case SectorTagType.CDSectorECC_Q: - throw new ArgumentException("Unsupported tag requested for this track", "tag"); + throw new ArgumentException("Unsupported tag requested for this track", nameof(tag)); case SectorTagType.CDSectorSubHeader: { sector_offset = 0; @@ -1923,12 +1923,12 @@ namespace DiscImageChef.ImagePlugins break; } default: - throw new ArgumentException("Unsupported tag requested", "tag"); + throw new ArgumentException("Unsupported tag requested", nameof(tag)); } break; } case DAOMode.Audio: - throw new ArgumentException("There are no tags on audio tracks", "tag"); + throw new ArgumentException("There are no tags on audio tracks", nameof(tag)); case DAOMode.DataRaw: { switch(tag) @@ -1949,7 +1949,7 @@ namespace DiscImageChef.ImagePlugins } case SectorTagType.CDSectorSubchannel: case SectorTagType.CDSectorSubHeader: - throw new ArgumentException("Unsupported tag requested for this track", "tag"); + throw new ArgumentException("Unsupported tag requested for this track", nameof(tag)); case SectorTagType.CDSectorECC: { sector_offset = 2076; @@ -1979,7 +1979,7 @@ namespace DiscImageChef.ImagePlugins break; } default: - throw new ArgumentException("Unsupported tag requested", "tag"); + throw new ArgumentException("Unsupported tag requested", nameof(tag)); } break; } @@ -2012,7 +2012,7 @@ namespace DiscImageChef.ImagePlugins break; } case SectorTagType.CDSectorSubHeader: - throw new ArgumentException("Unsupported tag requested for this track", "tag"); + throw new ArgumentException("Unsupported tag requested for this track", nameof(tag)); case SectorTagType.CDSectorECC: { sector_offset = 2076; @@ -2042,14 +2042,14 @@ namespace DiscImageChef.ImagePlugins break; } default: - throw new ArgumentException("Unsupported tag requested", "tag"); + throw new ArgumentException("Unsupported tag requested", nameof(tag)); } break; } case DAOMode.AudioSub: { if(tag != SectorTagType.CDSectorSubchannel) - throw new ArgumentException("Unsupported tag requested for this track", "tag"); + throw new ArgumentException("Unsupported tag requested for this track", nameof(tag)); sector_offset = 2352; sector_size = 96; @@ -2085,17 +2085,17 @@ namespace DiscImageChef.ImagePlugins return buffer; } - public override byte[] ReadSectorLong(UInt64 sectorAddress) + public override byte[] ReadSectorLong(ulong sectorAddress) { return ReadSectorsLong(sectorAddress, 1); } - public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track) + public override byte[] ReadSectorLong(ulong sectorAddress, uint track) { return ReadSectorsLong(sectorAddress, 1, track); } - public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length) + public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) { @@ -2112,18 +2112,18 @@ namespace DiscImageChef.ImagePlugins } } - throw new ArgumentOutOfRangeException("sectorAddress", String.Format("Sector address {0} not found", sectorAddress)); + throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); } - public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track) + public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track) { NeroTrack _track; if(!neroTracks.TryGetValue(track, out _track)) - throw new ArgumentOutOfRangeException("track", "Track not found"); + throw new ArgumentOutOfRangeException(nameof(track), "Track not found"); if(length > _track.Sectors) - throw new ArgumentOutOfRangeException("length", "Requested more sectors than present in track, won't cross tracks"); + throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); uint sector_offset; uint sector_size; @@ -2234,7 +2234,7 @@ namespace DiscImageChef.ImagePlugins return ImageInfo.mediaType; } - public override List GetPartitions() + public override List GetPartitions() { return ImagePartitions; } @@ -2249,7 +2249,7 @@ namespace DiscImageChef.ImagePlugins return GetSessionTracks(session.SessionSequence); } - public override List GetSessionTracks(UInt16 session) + public override List GetSessionTracks(ushort session) { List sessionTracks = new List(); foreach(Track _track in imageTracks) @@ -2264,25 +2264,25 @@ namespace DiscImageChef.ImagePlugins return imageSessions; } - public override bool? VerifySector(UInt64 sectorAddress) + public override bool? VerifySector(ulong sectorAddress) { byte[] buffer = ReadSectorLong(sectorAddress); return Checksums.CDChecksums.CheckCDSector(buffer); } - public override bool? VerifySector(UInt64 sectorAddress, UInt32 track) + public override bool? VerifySector(ulong sectorAddress, uint track) { byte[] buffer = ReadSectorLong(sectorAddress, track); return Checksums.CDChecksums.CheckCDSector(buffer); } - public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List FailingLBAs, out List UnknownLBAs) + public override bool? VerifySectors(ulong sectorAddress, uint length, out List FailingLBAs, out List UnknownLBAs) { byte[] buffer = ReadSectorsLong(sectorAddress, length); int bps = (int)(buffer.Length / length); byte[] sector = new byte[bps]; - FailingLBAs = new List(); - UnknownLBAs = new List(); + FailingLBAs = new List(); + UnknownLBAs = new List(); for(int i = 0; i < length; i++) { @@ -2307,13 +2307,13 @@ namespace DiscImageChef.ImagePlugins return true; } - public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List FailingLBAs, out List UnknownLBAs) + public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List FailingLBAs, out List UnknownLBAs) { byte[] buffer = ReadSectorsLong(sectorAddress, length, track); int bps = (int)(buffer.Length / length); byte[] sector = new byte[bps]; - FailingLBAs = new List(); - UnknownLBAs = new List(); + FailingLBAs = new List(); + UnknownLBAs = new List(); for(int i = 0; i < length; i++) { @@ -2423,7 +2423,7 @@ namespace DiscImageChef.ImagePlugins } } - static UInt16 NeroTrackModeToBytesPerSector(DAOMode mode) + static ushort NeroTrackModeToBytesPerSector(DAOMode mode) { switch(mode) { diff --git a/DiscImageChef.DiscImages/TeleDisk.cs b/DiscImageChef.DiscImages/TeleDisk.cs index 90a71bb1..68a31109 100644 --- a/DiscImageChef.DiscImages/TeleDisk.cs +++ b/DiscImageChef.DiscImages/TeleDisk.cs @@ -33,15 +33,13 @@ using System; using System.IO; using System.Collections.Generic; - -// Created following notes from Dave Dunfield -// http://www.classiccmp.org/dunfield/img54306/td0notes.txt using DiscImageChef.Console; using DiscImageChef.CommonTypes; - namespace DiscImageChef.ImagePlugins { + // Created following notes from Dave Dunfield + // http://www.classiccmp.org/dunfield/img54306/td0notes.txt class TeleDisk : ImagePlugin { #region Internal Structures @@ -49,7 +47,7 @@ namespace DiscImageChef.ImagePlugins struct TD0Header { /// "TD" or "td" depending on compression - public UInt16 signature; + public ushort signature; /// Sequence, but TeleDisk seems to complaing if != 0 public byte sequence; /// Random, same byte for all disks in the same set @@ -67,15 +65,15 @@ namespace DiscImageChef.ImagePlugins /// Sides of disk public byte sides; /// CRC of all the previous - public UInt16 crc; + public ushort crc; } struct TDCommentBlockHeader { /// CRC of comment block after crc field - public UInt16 crc; + public ushort crc; /// Length of comment - public UInt16 length; + public ushort length; public byte year; public byte month; public byte day; @@ -115,7 +113,7 @@ namespace DiscImageChef.ImagePlugins struct TDDataHeader { /// Size of all data (encoded) + next field (1) - public UInt16 dataSize; + public ushort dataSize; /// Encoding used for data block public byte dataEncoding; } @@ -125,9 +123,9 @@ namespace DiscImageChef.ImagePlugins #region Internal Constants // "TD" as little endian uint. - const UInt16 tdMagic = 0x4454; + const ushort tdMagic = 0x4454; // "td" as little endian uint. Means whole file is compressed (aka Advanced Compression) - const UInt16 tdAdvCompMagic = 0x6474; + const ushort tdAdvCompMagic = 0x6474; // DataRates const byte DataRate250kbps = 0x00; @@ -151,7 +149,7 @@ namespace DiscImageChef.ImagePlugins const byte CommentBlockPresent = 0x80; // CRC polynomial - const UInt16 TeleDiskCRCPoly = 0xA097; + const ushort TeleDiskCRCPoly = 0xA097; // Sector sizes table const byte SectorSize128 = 0x00; @@ -191,11 +189,11 @@ namespace DiscImageChef.ImagePlugins TD0Header header; TDCommentBlockHeader commentHeader; byte[] commentBlock; - Dictionary sectorsData; + Dictionary sectorsData; // LBA, data - UInt32 totalDiskSize; + uint totalDiskSize; bool ADiskCRCHasFailed; - List SectorsWhereCRCHasFailed; + List SectorsWhereCRCHasFailed; #endregion @@ -222,7 +220,7 @@ namespace DiscImageChef.ImagePlugins ImageInfo.driveModel = null; ImageInfo.driveSerialNumber = null; ADiskCRCHasFailed = false; - SectorsWhereCRCHasFailed = new List(); + SectorsWhereCRCHasFailed = new List(); } public override bool IdentifyImage(string imagePath) @@ -251,7 +249,7 @@ namespace DiscImageChef.ImagePlugins byte[] headerBytesForCRC = new byte[10]; Array.Copy(headerBytes, headerBytesForCRC, 10); - UInt16 calculatedHeaderCRC = TeleDiskCRC(0x0000, headerBytesForCRC); + ushort calculatedHeaderCRC = TeleDiskCRC(0x0000, headerBytesForCRC); DicConsole.DebugWriteLine("TeleDisk plugin", "header.signature = 0x{0:X4}", header.signature); DicConsole.DebugWriteLine("TeleDisk plugin", "header.sequence = 0x{0:X2}", header.sequence); @@ -309,12 +307,12 @@ namespace DiscImageChef.ImagePlugins header.crc = BitConverter.ToUInt16(headerBytes, 10); ImageInfo.imageName = Path.GetFileNameWithoutExtension(imagePath); - ImageInfo.imageVersion = String.Format("{0}.{1}", (header.version & 0xF0) >> 4, header.version & 0x0F); + ImageInfo.imageVersion = string.Format("{0}.{1}", (header.version & 0xF0) >> 4, header.version & 0x0F); ImageInfo.imageApplication = ImageInfo.imageVersion; byte[] headerBytesForCRC = new byte[10]; Array.Copy(headerBytes, headerBytesForCRC, 10); - UInt16 calculatedHeaderCRC = TeleDiskCRC(0x0000, headerBytesForCRC); + ushort calculatedHeaderCRC = TeleDiskCRC(0x0000, headerBytesForCRC); DicConsole.DebugWriteLine("TeleDisk plugin", "header.signature = 0x{0:X4}", header.signature); DicConsole.DebugWriteLine("TeleDisk plugin", "header.sequence = 0x{0:X2}", header.sequence); @@ -377,7 +375,7 @@ namespace DiscImageChef.ImagePlugins Array.Copy(commentHeaderBytes, 2, commentBlockForCRC, 0, 8); Array.Copy(commentBlock, 0, commentBlockForCRC, 8, commentHeader.length); - UInt16 cmtcrc = TeleDiskCRC(0, commentBlockForCRC); + ushort cmtcrc = TeleDiskCRC(0, commentBlockForCRC); DicConsole.DebugWriteLine("TeleDisk plugin", "Comment header"); DicConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.crc = 0x{0:X4}", commentHeader.crc); @@ -486,7 +484,7 @@ namespace DiscImageChef.ImagePlugins DicConsole.DebugWriteLine("TeleDisk plugin", "\t\tSector flags: 0x{0:X2}", TDSector.flags); DicConsole.DebugWriteLine("TeleDisk plugin", "\t\tSector CRC (plus headers): 0x{0:X2}", TDSector.crc); - UInt32 LBA = (uint)((TDSector.cylinder * header.sides * spt) + (TDSector.head * spt) + (TDSector.sectorNumber - 1)); + uint LBA = (uint)((TDSector.cylinder * header.sides * spt) + (TDSector.head * spt) + (TDSector.sectorNumber - 1)); if((TDSector.flags & FlagsSectorDataless) != FlagsSectorDataless && (TDSector.flags & FlagsSectorSkipped) != FlagsSectorSkipped) { stream.Read(dataSizeBytes, 0, 2); @@ -508,7 +506,7 @@ namespace DiscImageChef.ImagePlugins DicConsole.DebugWriteLine("TeleDisk plugin", "Sector LBA {0} calculated CRC 0x{1:X2} differs from stored CRC 0x{2:X2}", LBA, TDSectorCalculatedCRC, TDSector.crc); if((TDSector.flags & FlagsSectorNoID) != FlagsSectorNoID) if(!sectorsData.ContainsKey(LBA) && (TDSector.flags & FlagsSectorDuplicate) != FlagsSectorDuplicate) - SectorsWhereCRCHasFailed.Add((UInt64)LBA); + SectorsWhereCRCHasFailed.Add(LBA); } } else @@ -537,7 +535,7 @@ namespace DiscImageChef.ImagePlugins decodedData = new byte[8192]; break; default: - throw new ImageNotSupportedException(String.Format("Sector size {0} for cylinder {1} head {2} sector {3} is incorrect.", + throw new ImageNotSupportedException(string.Format("Sector size {0} for cylinder {1} head {2} sector {3} is incorrect.", TDSector.sectorSize, TDSector.cylinder, TDSector.head, TDSector.sectorNumber)); } ArrayHelpers.ArrayFill(decodedData, (byte)0); @@ -585,33 +583,33 @@ namespace DiscImageChef.ImagePlugins return ImageInfo.imageHasPartitions; } - public override UInt64 GetImageSize() + public override ulong GetImageSize() { return ImageInfo.imageSize; } - public override UInt64 GetSectors() + public override ulong GetSectors() { return ImageInfo.sectors; } - public override UInt32 GetSectorSize() + public override uint GetSectorSize() { return ImageInfo.sectorSize; } - public override byte[] ReadSector(UInt64 sectorAddress) + public override byte[] ReadSector(ulong sectorAddress) { return ReadSectors(sectorAddress, 1); } - public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length) + public override byte[] ReadSectors(ulong sectorAddress, uint length) { if(sectorAddress > (ulong)sectorsData.Count - 1) - throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found"); + throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); if(sectorAddress + length > (ulong)sectorsData.Count) - throw new ArgumentOutOfRangeException("length", "Requested more sectors than available"); + throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); byte[] data = new byte[1]; // To make compiler happy bool first = true; @@ -620,12 +618,12 @@ namespace DiscImageChef.ImagePlugins for(ulong i = sectorAddress; i < (sectorAddress + length); i++) { if(!sectorsData.ContainsKey((uint)i)) - throw new ImageNotSupportedException(String.Format("Requested sector {0} not found", i)); + throw new ImageNotSupportedException(string.Format("Requested sector {0} not found", i)); byte[] sector; if(!sectorsData.TryGetValue((uint)i, out sector)) - throw new ImageNotSupportedException(String.Format("Error reading sector {0}", i)); + throw new ImageNotSupportedException(string.Format("Error reading sector {0}", i)); if(first) { @@ -644,12 +642,12 @@ namespace DiscImageChef.ImagePlugins return data; } - public override byte[] ReadSectorLong(UInt64 sectorAddress) + public override byte[] ReadSectorLong(ulong sectorAddress) { return ReadSectors(sectorAddress, 1); } - public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length) + public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { return ReadSectors(sectorAddress, length); } @@ -694,34 +692,34 @@ namespace DiscImageChef.ImagePlugins return ImageInfo.mediaType; } - public override bool? VerifySector(UInt64 sectorAddress) + public override bool? VerifySector(ulong sectorAddress) { return !SectorsWhereCRCHasFailed.Contains(sectorAddress); } - public override bool? VerifySector(UInt64 sectorAddress, UInt32 track) + public override bool? VerifySector(ulong sectorAddress, uint track) { return null; } - public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List FailingLBAs, out List UnknownLBAs) + public override bool? VerifySectors(ulong sectorAddress, uint length, out List FailingLBAs, out List UnknownLBAs) { - FailingLBAs = new List(); - UnknownLBAs = new List(); + FailingLBAs = new List(); + UnknownLBAs = new List(); - for(UInt64 i = sectorAddress; i < sectorAddress + length; i++) + for(ulong i = sectorAddress; i < sectorAddress + length; i++) if(SectorsWhereCRCHasFailed.Contains(sectorAddress)) FailingLBAs.Add(sectorAddress); return FailingLBAs.Count <= 0; } - public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List FailingLBAs, out List UnknownLBAs) + public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List FailingLBAs, out List UnknownLBAs) { - FailingLBAs = new List(); - UnknownLBAs = new List(); + FailingLBAs = new List(); + UnknownLBAs = new List(); - for(UInt64 i = sectorAddress; i < sectorAddress + length; i++) + for(ulong i = sectorAddress; i < sectorAddress + length; i++) UnknownLBAs.Add(i); return null; @@ -734,20 +732,20 @@ namespace DiscImageChef.ImagePlugins #region Private methods - static UInt16 TeleDiskCRC(UInt16 crc, byte[] buffer) + static ushort TeleDiskCRC(ushort crc, byte[] buffer) { int counter = 0; while(counter < buffer.Length) { - crc ^= (UInt16)((buffer[counter] & 0xFF) << 8); + crc ^= (ushort)((buffer[counter] & 0xFF) << 8); for(int i = 0; i < 8; i++) { if((crc & 0x8000) > 0) - crc = (UInt16)((crc << 1) ^ TeleDiskCRCPoly); + crc = (ushort)((crc << 1) ^ TeleDiskCRCPoly); else - crc = (UInt16)(crc << 1); + crc = (ushort)(crc << 1); } counter++; @@ -783,7 +781,7 @@ namespace DiscImageChef.ImagePlugins decodedData = new byte[8192]; break; default: - throw new ImageNotSupportedException(String.Format("Sector size {0} is incorrect.", sectorSize)); + throw new ImageNotSupportedException(string.Format("Sector size {0} is incorrect.", sectorSize)); } switch(encodingType) @@ -797,7 +795,7 @@ namespace DiscImageChef.ImagePlugins int outs = 0; while(ins < encodedData.Length) { - UInt16 repeatNumber; + ushort repeatNumber; byte[] repeatValue = new byte[2]; repeatNumber = BitConverter.ToUInt16(encodedData, ins); @@ -856,7 +854,7 @@ namespace DiscImageChef.ImagePlugins break; } default: - throw new ImageNotSupportedException(String.Format("Data encoding {0} is incorrect.", encodingType)); + throw new ImageNotSupportedException(string.Format("Data encoding {0} is incorrect.", encodingType)); } return decodedData; @@ -877,24 +875,24 @@ namespace DiscImageChef.ImagePlugins // Acorn disk uses 256 bytes/sector if(ImageInfo.sectorSize == 256) return MediaType.ACORN_525_SS_DD_40; - else // DOS disks use 512 bytes/sector - return MediaType.DOS_525_SS_DD_8; + // DOS disks use 512 bytes/sector + return MediaType.DOS_525_SS_DD_8; } case 184320: { // Atari disk uses 256 bytes/sector if(ImageInfo.sectorSize == 256) return MediaType.ATARI_525_DD; - else // DOS disks use 512 bytes/sector - return MediaType.DOS_525_SS_DD_9; + // DOS disks use 512 bytes/sector + return MediaType.DOS_525_SS_DD_9; } case 327680: { // Acorn disk uses 256 bytes/sector if(ImageInfo.sectorSize == 256) return MediaType.ACORN_525_SS_DD_80; - else // DOS disks use 512 bytes/sector - return MediaType.DOS_525_DS_DD_8; + // DOS disks use 512 bytes/sector + return MediaType.DOS_525_DS_DD_8; } case 368640: return MediaType.DOS_525_DS_DD_9; @@ -1011,8 +1009,8 @@ namespace DiscImageChef.ImagePlugins // DEC disk uses 256 bytes/sector if(ImageInfo.sectorSize == 256) return MediaType.RX02; - else // ECMA disks use 128 bytes/sector - return MediaType.ECMA_59; + // ECMA disks use 128 bytes/sector + return MediaType.ECMA_59; } case 1261568: return MediaType.NEC_8_DD; @@ -1042,12 +1040,12 @@ namespace DiscImageChef.ImagePlugins #region Unsupported features - public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag) + public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag) + public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } @@ -1117,7 +1115,7 @@ namespace DiscImageChef.ImagePlugins return ImageInfo.driveSerialNumber; } - public override List GetPartitions() + public override List GetPartitions() { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } @@ -1132,7 +1130,7 @@ namespace DiscImageChef.ImagePlugins throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override List GetSessionTracks(UInt16 session) + public override List GetSessionTracks(ushort session) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } @@ -1142,32 +1140,32 @@ namespace DiscImageChef.ImagePlugins throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track) + public override byte[] ReadSector(ulong sectorAddress, uint track) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag) + public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track) + public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag) + public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track) + public override byte[] ReadSectorLong(ulong sectorAddress, uint track) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track) + public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } diff --git a/DiscImageChef.DiscImages/VHD.cs b/DiscImageChef.DiscImages/VHD.cs index 6d18ccdf..21314445 100644 --- a/DiscImageChef.DiscImages/VHD.cs +++ b/DiscImageChef.DiscImages/VHD.cs @@ -55,58 +55,58 @@ namespace DiscImageChef.ImagePlugins /// /// Offset 0x00, File magic number, /// - public UInt64 cookie; + public ulong cookie; /// /// Offset 0x08, Specific feature support /// - public UInt32 features; + public uint features; /// /// Offset 0x0C, File format version /// - public UInt32 version; + public uint version; /// /// Offset 0x10, Offset from beginning of file to next structure /// - public UInt64 offset; + public ulong offset; /// /// Offset 0x18, Creation date seconds since 2000/01/01 00:00:00 UTC /// - public UInt32 timestamp; + public uint timestamp; /// /// Offset 0x1C, Application that created this disk image /// - public UInt32 creatorApplication; + public uint creatorApplication; /// /// Offset 0x20, Version of the application that created this disk image /// - public UInt32 creatorVersion; + public uint creatorVersion; /// /// Offset 0x24, Host operating system of the application that created this disk image /// - public UInt32 creatorHostOS; + public uint creatorHostOS; /// /// Offset 0x28, Original hard disk size, in bytes /// - public UInt64 originalSize; + public ulong originalSize; /// /// Offset 0x30, Current hard disk size, in bytes /// - public UInt64 currentSize; + public ulong currentSize; /// /// Offset 0x38, CHS geometry /// Cylinder mask = 0xFFFF0000 /// Heads mask = 0x0000FF00 /// Sectors mask = 0x000000FF /// - public UInt32 diskGeometry; + public uint diskGeometry; /// /// Offset 0x3C, Disk image type /// - public UInt32 diskType; + public uint diskType; /// /// Offset 0x40, Checksum for this structure /// - public UInt32 checksum; + public uint checksum; /// /// Offset 0x44, UUID, used to associate parent with differencing disk images /// @@ -126,23 +126,23 @@ namespace DiscImageChef.ImagePlugins /// /// Offset 0x00, Describes the platform specific type this entry belongs to /// - public UInt32 platformCode; + public uint platformCode; /// /// Offset 0x04, Describes the number of 512 bytes sectors used by this entry /// - public UInt32 platformDataSpace; + public uint platformDataSpace; /// /// Offset 0x08, Describes this entry's size in bytes /// - public UInt32 platformDataLength; + public uint platformDataLength; /// /// Offset 0x0c, Reserved /// - public UInt32 reserved; + public uint reserved; /// /// Offset 0x10, Offset on disk image this entry resides on /// - public UInt64 platformDataOffset; + public ulong platformDataOffset; } struct DynamicDiskHeader @@ -150,33 +150,33 @@ namespace DiscImageChef.ImagePlugins /// /// Offset 0x00, Header magic, /// - public UInt64 cookie; + public ulong cookie; /// /// Offset 0x08, Offset to next structure on disk image. /// Currently unused, 0xFFFFFFFF /// - public UInt64 dataOffset; + public ulong dataOffset; /// /// Offset 0x10, Offset of the Block Allocation Table (BAT) /// - public UInt64 tableOffset; + public ulong tableOffset; /// /// Offset 0x18, Version of this header /// - public UInt32 headerVersion; + public uint headerVersion; /// /// Offset 0x1C, Maximum entries present in the BAT /// - public UInt32 maxTableEntries; + public uint maxTableEntries; /// /// Offset 0x20, Size of a block in bytes /// Should always be a power of two of 512 /// - public UInt32 blockSize; + public uint blockSize; /// /// Offset 0x24, Checksum of this header /// - public UInt32 checksum; + public uint checksum; /// /// Offset 0x28, UUID of parent disk image for differencing type /// @@ -184,11 +184,11 @@ namespace DiscImageChef.ImagePlugins /// /// Offset 0x38, Timestamp of parent disk image /// - public UInt32 parentTimestamp; + public uint parentTimestamp; /// /// Offset 0x3C, Reserved /// - public UInt32 reserved; + public uint reserved; /// /// Offset 0x40, 512 bytes UTF-16 of parent disk image filename /// @@ -207,7 +207,7 @@ namespace DiscImageChef.ImagePlugins struct BATSector { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] - public UInt32[] blockPointer; + public uint[] blockPointer; } #endregion @@ -217,134 +217,134 @@ namespace DiscImageChef.ImagePlugins /// /// File magic number, "conectix" /// - const UInt64 ImageCookie = 0x636F6E6563746978; + const ulong ImageCookie = 0x636F6E6563746978; /// /// Dynamic disk header magic, "cxsparse" /// - const UInt64 DynamicCookie = 0x6378737061727365; + const ulong DynamicCookie = 0x6378737061727365; /// /// Disk image is candidate for deletion on shutdown /// - const UInt32 FeaturesTemporary = 0x00000001; + const uint FeaturesTemporary = 0x00000001; /// /// Unknown, set from Virtual PC for Mac 7 onwards /// - const UInt32 FeaturesReserved = 0x00000002; + const uint FeaturesReserved = 0x00000002; /// /// Unknown /// - const UInt32 FeaturesUnknown = 0x00000100; + const uint FeaturesUnknown = 0x00000100; /// /// Only known version /// - const UInt32 Version1 = 0x00010000; + const uint Version1 = 0x00010000; /// /// Created by Virtual PC, "vpc " /// - const UInt32 CreatorVirtualPC = 0x76706320; + const uint CreatorVirtualPC = 0x76706320; /// /// Created by Virtual Server, "vs " /// - const UInt32 CreatorVirtualServer = 0x76732020; + const uint CreatorVirtualServer = 0x76732020; /// /// Created by QEMU, "qemu" /// - const UInt32 CreatorQEMU = 0x71656D75; + const uint CreatorQEMU = 0x71656D75; /// /// Created by VirtualBox, "vbox" /// - const UInt32 CreatorVirtualBox = 0x76626F78; + const uint CreatorVirtualBox = 0x76626F78; /// /// Disk image created by Virtual Server 2004 /// - const UInt32 VersionVirtualServer2004 = 0x00010000; + const uint VersionVirtualServer2004 = 0x00010000; /// /// Disk image created by Virtual PC 2004 /// - const UInt32 VersionVirtualPC2004 = 0x00050000; + const uint VersionVirtualPC2004 = 0x00050000; /// /// Disk image created by Virtual PC 2007 /// - const UInt32 VersionVirtualPC2007 = 0x00050003; + const uint VersionVirtualPC2007 = 0x00050003; /// /// Disk image created by Virtual PC for Mac 5, 6 or 7 /// - const UInt32 VersionVirtualPCMac = 0x00040000; + const uint VersionVirtualPCMac = 0x00040000; /// /// Disk image created in Windows, "Wi2k" /// - const UInt32 CreatorWindows = 0x5769326B; + const uint CreatorWindows = 0x5769326B; /// /// Disk image created in Macintosh, "Mac " /// - const UInt32 CreatorMacintosh = 0x4D616320; + const uint CreatorMacintosh = 0x4D616320; /// /// Seen in Virtual PC for Mac for dynamic and fixed images /// - const UInt32 CreatorMacintoshOld = 0x00000000; + const uint CreatorMacintoshOld = 0x00000000; /// /// Disk image type is none, useless? /// - const UInt32 typeNone = 0; + const uint typeNone = 0; /// /// Deprecated disk image type /// - const UInt32 typeDeprecated1 = 1; + const uint typeDeprecated1 = 1; /// /// Fixed disk image type /// - const UInt32 typeFixed = 2; + const uint typeFixed = 2; /// /// Dynamic disk image type /// - const UInt32 typeDynamic = 3; + const uint typeDynamic = 3; /// /// Differencing disk image type /// - const UInt32 typeDifferencing = 4; + const uint typeDifferencing = 4; /// /// Deprecated disk image type /// - const UInt32 typeDeprecated2 = 5; + const uint typeDeprecated2 = 5; /// /// Deprecated disk image type /// - const UInt32 typeDeprecated3 = 6; + const uint typeDeprecated3 = 6; /// /// Means platform locator is unused /// - const UInt32 platformCodeUnused = 0x00000000; + const uint platformCodeUnused = 0x00000000; /// /// Stores a relative path string for Windows, unknown locale used, deprecated, "Wi2r" /// - const UInt32 platformCodeWindowsRelative = 0x57693272; + const uint platformCodeWindowsRelative = 0x57693272; /// /// Stores an absolute path string for Windows, unknown locale used, deprecated, "Wi2k" /// - const UInt32 platformCodeWindowsAbsolute = 0x5769326B; + const uint platformCodeWindowsAbsolute = 0x5769326B; /// /// Stores a relative path string for Windows in UTF-16, "W2ru" /// - const UInt32 platformCodeWindowsRelativeU = 0x57327275; + const uint platformCodeWindowsRelativeU = 0x57327275; /// /// Stores an absolute path string for Windows in UTF-16, "W2ku" /// - const UInt32 platformCodeWindowsAbsoluteU = 0x57326B75; + const uint platformCodeWindowsAbsoluteU = 0x57326B75; /// /// Stores a Mac OS alias as a blob, "Mac " /// - const UInt32 platformCodeMacintoshAlias = 0x4D616320; + const uint platformCodeMacintoshAlias = 0x4D616320; /// /// Stores a Mac OS X URI (RFC-2396) absolute path in UTF-8, "MacX" /// - const UInt32 platformCodeMacintoshURI = 0x4D616358; + const uint platformCodeMacintoshURI = 0x4D616358; #endregion @@ -355,8 +355,8 @@ namespace DiscImageChef.ImagePlugins DateTime thisDateTime; DateTime parentDateTime; string thisPath; - UInt32[] blockAllocationTable; - UInt32 bitmapSize; + uint[] blockAllocationTable; + uint bitmapSize; byte[][] locatorEntriesData; ImagePlugin parentImage; @@ -393,8 +393,8 @@ namespace DiscImageChef.ImagePlugins public override bool IdentifyImage(string imagePath) { FileStream imageStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read); - UInt64 headerCookie; - UInt64 footerCookie; + ulong headerCookie; + ulong footerCookie; byte[] headerCookieBytes = new byte[8]; byte[] footerCookieBytes = new byte[8]; @@ -439,10 +439,10 @@ namespace DiscImageChef.ImagePlugins BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; - UInt32 headerChecksum = BigEndianBitConverter.ToUInt32(header, 0x40); - UInt32 footerChecksum = BigEndianBitConverter.ToUInt32(footer, 0x40); - UInt64 headerCookie = BigEndianBitConverter.ToUInt64(header, 0); - UInt64 footerCookie = BigEndianBitConverter.ToUInt64(footer, 0); + uint headerChecksum = BigEndianBitConverter.ToUInt32(header, 0x40); + uint footerChecksum = BigEndianBitConverter.ToUInt32(footer, 0x40); + ulong headerCookie = BigEndianBitConverter.ToUInt64(header, 0); + ulong footerCookie = BigEndianBitConverter.ToUInt64(footer, 0); header[0x40] = 0; header[0x41] = 0; @@ -453,14 +453,14 @@ namespace DiscImageChef.ImagePlugins footer[0x42] = 0; footer[0x43] = 0; - UInt32 headerCalculatedChecksum = VHDChecksum(header); - UInt32 footerCalculatedChecksum = VHDChecksum(footer); + uint headerCalculatedChecksum = VHDChecksum(header); + uint footerCalculatedChecksum = VHDChecksum(footer); DicConsole.DebugWriteLine("VirtualPC plugin", "Header checksum = 0x{0:X8}, calculated = 0x{1:X8}", headerChecksum, headerCalculatedChecksum); DicConsole.DebugWriteLine("VirtualPC plugin", "Header checksum = 0x{0:X8}, calculated = 0x{1:X8}", footerChecksum, footerCalculatedChecksum); byte[] usableHeader; - UInt32 usableChecksum; + uint usableChecksum; if(headerCookie == ImageCookie && headerChecksum == headerCalculatedChecksum) { @@ -524,7 +524,7 @@ namespace DiscImageChef.ImagePlugins if(thisFooter.version == Version1) ImageInfo.imageVersion = "1.0"; else - throw new ImageNotSupportedException(String.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType)); + throw new ImageNotSupportedException(string.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType)); switch(thisFooter.creatorApplication) { @@ -538,7 +538,7 @@ namespace DiscImageChef.ImagePlugins } case CreatorVirtualBox: { - ImageInfo.imageApplicationVersion = String.Format("{0}.{1:D2}", (thisFooter.creatorVersion & 0xFFFF0000) >> 16, (thisFooter.creatorVersion & 0x0000FFFF)); + ImageInfo.imageApplicationVersion = string.Format("{0}.{1:D2}", (thisFooter.creatorVersion & 0xFFFF0000) >> 16, (thisFooter.creatorVersion & 0x0000FFFF)); switch(thisFooter.creatorHostOS) { case CreatorMacintosh: @@ -550,7 +550,7 @@ namespace DiscImageChef.ImagePlugins ImageInfo.imageApplication = "VirtualBox"; break; default: - ImageInfo.imageApplication = String.Format("VirtualBox for unknown OS \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.creatorHostOS))); + ImageInfo.imageApplication = string.Format("VirtualBox for unknown OS \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.creatorHostOS))); break; } break; @@ -564,7 +564,7 @@ namespace DiscImageChef.ImagePlugins ImageInfo.imageApplicationVersion = "2004"; break; default: - ImageInfo.imageApplicationVersion = String.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion); + ImageInfo.imageApplicationVersion = string.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion); break; } break; @@ -582,7 +582,7 @@ namespace DiscImageChef.ImagePlugins ImageInfo.imageApplicationVersion = "5, 6 or 7"; break; default: - ImageInfo.imageApplicationVersion = String.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion); + ImageInfo.imageApplicationVersion = string.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion); break; } break; @@ -602,21 +602,21 @@ namespace DiscImageChef.ImagePlugins ImageInfo.imageApplicationVersion = "2007"; break; default: - ImageInfo.imageApplicationVersion = String.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion); + ImageInfo.imageApplicationVersion = string.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion); break; } break; default: - ImageInfo.imageApplication = String.Format("Virtual PC for unknown OS \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.creatorHostOS))); - ImageInfo.imageApplicationVersion = String.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion); + ImageInfo.imageApplication = string.Format("Virtual PC for unknown OS \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.creatorHostOS))); + ImageInfo.imageApplicationVersion = string.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion); break; } break; } default: { - ImageInfo.imageApplication = String.Format("Unknown application \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.creatorHostOS))); - ImageInfo.imageApplicationVersion = String.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion); + ImageInfo.imageApplication = string.Format("Unknown application \"{0}\"", Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.creatorHostOS))); + ImageInfo.imageApplicationVersion = string.Format("Unknown version 0x{0:X8}", thisFooter.creatorVersion); break; } } @@ -637,14 +637,14 @@ namespace DiscImageChef.ImagePlugins byte[] dynamicBytes = new byte[1024]; imageStream.Read(dynamicBytes, 0, 1024); - UInt32 dynamicChecksum = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x24); + uint dynamicChecksum = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x24); dynamicBytes[0x24] = 0; dynamicBytes[0x25] = 0; dynamicBytes[0x26] = 0; dynamicBytes[0x27] = 0; - UInt32 dynamicChecksumCalculated = VHDChecksum(dynamicBytes); + uint dynamicChecksumCalculated = VHDChecksum(dynamicBytes); DicConsole.DebugWriteLine("VirtualPC plugin", "Dynamic header checksum = 0x{0:X8}, calculated = 0x{1:X8}", dynamicChecksum, dynamicChecksumCalculated); @@ -711,7 +711,7 @@ namespace DiscImageChef.ImagePlugins DicConsole.DebugWriteLine("VirtualPC plugin", "dynamic.reserved2's SHA1 = 0x{0}", sha1Ctx.End()); if(thisDynamic.headerVersion != Version1) - throw new ImageNotSupportedException(String.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType)); + throw new ImageNotSupportedException(string.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType)); DateTime startTime = DateTime.UtcNow; @@ -730,7 +730,7 @@ namespace DiscImageChef.ImagePlugins */ // How many sectors uses the BAT - UInt32 batSectorCount = (uint)Math.Ceiling(((double)thisDynamic.maxTableEntries * 4) / 512); + uint batSectorCount = (uint)Math.Ceiling(((double)thisDynamic.maxTableEntries * 4) / 512); byte[] batSectorBytes = new byte[512]; BATSector batSector = new BATSector(); @@ -891,7 +891,7 @@ namespace DiscImageChef.ImagePlugins } default: { - throw new ImageNotSupportedException(String.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType)); + throw new ImageNotSupportedException(string.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType)); } } } @@ -978,14 +978,14 @@ namespace DiscImageChef.ImagePlugins case typeDifferencing: { // Block number for BAT searching - UInt32 blockNumber = (uint)Math.Floor((double)(sectorAddress / (thisDynamic.blockSize / 512))); + uint blockNumber = (uint)Math.Floor((double)(sectorAddress / (thisDynamic.blockSize / 512))); // Sector number inside of block - UInt32 sectorInBlock = (uint)(sectorAddress % (thisDynamic.blockSize / 512)); + uint sectorInBlock = (uint)(sectorAddress % (thisDynamic.blockSize / 512)); byte[] bitmap = new byte[bitmapSize * 512]; // Offset of block in file - UInt32 blockOffset = blockAllocationTable[blockNumber] * 512; + uint blockOffset = blockAllocationTable[blockNumber] * 512; int bitmapByte = (int)Math.Floor((double)sectorInBlock / 8); int bitmapBit = (int)(sectorInBlock % 8); @@ -1021,10 +1021,10 @@ namespace DiscImageChef.ImagePlugins */ byte[] data = new byte[512]; - UInt32 sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock; + uint sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock; thisStream = new FileStream(thisPath, FileMode.Open, FileAccess.Read); - thisStream.Seek((long)(sectorOffset * 512), SeekOrigin.Begin); + thisStream.Seek((sectorOffset * 512), SeekOrigin.Begin); thisStream.Read(data, 0, 512); thisStream.Close(); @@ -1070,11 +1070,11 @@ namespace DiscImageChef.ImagePlugins FileStream thisStream; // Block number for BAT searching - UInt32 blockNumber = (uint)Math.Floor((double)(sectorAddress / (thisDynamic.blockSize / 512))); + uint blockNumber = (uint)Math.Floor((double)(sectorAddress / (thisDynamic.blockSize / 512))); // Sector number inside of block - UInt32 sectorInBlock = (uint)(sectorAddress % (thisDynamic.blockSize / 512)); + uint sectorInBlock = (uint)(sectorAddress % (thisDynamic.blockSize / 512)); // How many sectors before reaching end of block - UInt32 remainingInBlock = (thisDynamic.blockSize / 512) - sectorInBlock; + uint remainingInBlock = (thisDynamic.blockSize / 512) - sectorInBlock; // Data that can be read in this block byte[] prefix; @@ -1082,7 +1082,7 @@ namespace DiscImageChef.ImagePlugins byte[] suffix = null; // How many sectors to read from this block - UInt32 sectorsToReadHere; + uint sectorsToReadHere; // Asked to read more sectors than are remaining in block if(length > remainingInBlock) @@ -1094,14 +1094,14 @@ namespace DiscImageChef.ImagePlugins sectorsToReadHere = length; // Offset of sector in file - UInt32 sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock; + uint sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock; prefix = new byte[sectorsToReadHere * 512]; // 0xFFFFFFFF means unallocated if(sectorOffset != 0xFFFFFFFF) { thisStream = new FileStream(thisPath, FileMode.Open, FileAccess.Read); - thisStream.Seek((long)(sectorOffset * 512), SeekOrigin.Begin); + thisStream.Seek((sectorOffset * 512), SeekOrigin.Begin); thisStream.Read(prefix, 0, (int)(512 * sectorsToReadHere)); thisStream.Close(); } @@ -1140,7 +1140,7 @@ namespace DiscImageChef.ImagePlugins } default: { - throw new ImageNotSupportedException(String.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType)); + throw new ImageNotSupportedException(string.Format("(VirtualPC plugin): Unknown image type {0} found. Please submit a bug with an example image.", thisFooter.diskType)); } } } @@ -1149,9 +1149,9 @@ namespace DiscImageChef.ImagePlugins #region private methods - static UInt32 VHDChecksum(byte[] data) + static uint VHDChecksum(byte[] data) { - UInt32 checksum = 0; + uint checksum = 0; foreach(byte b in data) checksum += b; return ~checksum; @@ -1271,7 +1271,7 @@ namespace DiscImageChef.ImagePlugins return null; } - public override List GetPartitions() + public override List GetPartitions() { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } diff --git a/DiscImageChef.DiscImages/ZZZRawImage.cs b/DiscImageChef.DiscImages/ZZZRawImage.cs index c55feb24..08cd5e15 100644 --- a/DiscImageChef.DiscImages/ZZZRawImage.cs +++ b/DiscImageChef.DiscImages/ZZZRawImage.cs @@ -281,27 +281,27 @@ namespace DiscImageChef.ImagePlugins return ImageInfo.imageHasPartitions; } - public override UInt64 GetImageSize() + public override ulong GetImageSize() { return ImageInfo.imageSize; } - public override UInt64 GetSectors() + public override ulong GetSectors() { return ImageInfo.sectors; } - public override UInt32 GetSectorSize() + public override uint GetSectorSize() { return ImageInfo.sectorSize; } - public override byte[] ReadSector(UInt64 sectorAddress) + public override byte[] ReadSector(ulong sectorAddress) { return ReadSectors(sectorAddress, 1); } - public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length) + public override byte[] ReadSectors(ulong sectorAddress, uint length) { if(differentTrackZeroSize) { @@ -310,10 +310,10 @@ namespace DiscImageChef.ImagePlugins else { if(sectorAddress > ImageInfo.sectors - 1) - throw new ArgumentOutOfRangeException("sectorAddress", "Sector address not found"); + throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); if(sectorAddress + length > ImageInfo.sectors) - throw new ArgumentOutOfRangeException("length", "Requested more sectors than available"); + throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); byte[] buffer = new byte[length * ImageInfo.sectorSize]; @@ -355,33 +355,33 @@ namespace DiscImageChef.ImagePlugins return ImageInfo.mediaType; } - public override bool? VerifySector(UInt64 sectorAddress) + public override bool? VerifySector(ulong sectorAddress) { return null; } - public override bool? VerifySector(UInt64 sectorAddress, UInt32 track) + public override bool? VerifySector(ulong sectorAddress, uint track) { return null; } - public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List FailingLBAs, out List UnknownLBAs) + public override bool? VerifySectors(ulong sectorAddress, uint length, out List FailingLBAs, out List UnknownLBAs) { - FailingLBAs = new List(); - UnknownLBAs = new List(); + FailingLBAs = new List(); + UnknownLBAs = new List(); - for(UInt64 i = sectorAddress; i < sectorAddress + length; i++) + for(ulong i = sectorAddress; i < sectorAddress + length; i++) UnknownLBAs.Add(i); return null; } - public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List FailingLBAs, out List UnknownLBAs) + public override bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List FailingLBAs, out List UnknownLBAs) { - FailingLBAs = new List(); - UnknownLBAs = new List(); + FailingLBAs = new List(); + UnknownLBAs = new List(); - for(UInt64 i = sectorAddress; i < sectorAddress + length; i++) + for(ulong i = sectorAddress; i < sectorAddress + length; i++) UnknownLBAs.Add(i); return null; @@ -421,7 +421,7 @@ namespace DiscImageChef.ImagePlugins if(ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc) { if(session.SessionSequence != 1) - throw new ArgumentOutOfRangeException("session", "Only a single session is supported"); + throw new ArgumentOutOfRangeException(nameof(session), "Only a single session is supported"); Track trk = new Track(); trk.TrackBytesPerSector = (int)ImageInfo.sectorSize; @@ -443,12 +443,12 @@ namespace DiscImageChef.ImagePlugins throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override List GetSessionTracks(UInt16 session) + public override List GetSessionTracks(ushort session) { if(ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc) { if(session != 1) - throw new ArgumentOutOfRangeException("session", "Only a single session is supported"); + throw new ArgumentOutOfRangeException(nameof(session), "Only a single session is supported"); Track trk = new Track(); trk.TrackBytesPerSector = (int)ImageInfo.sectorSize; @@ -488,12 +488,12 @@ namespace DiscImageChef.ImagePlugins throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSector(UInt64 sectorAddress, UInt32 track) + public override byte[] ReadSector(ulong sectorAddress, uint track) { if(ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc) { if(track != 1) - throw new ArgumentOutOfRangeException("track", "Only a single session is supported"); + throw new ArgumentOutOfRangeException(nameof(track), "Only a single session is supported"); return ReadSector(sectorAddress); } @@ -501,12 +501,12 @@ namespace DiscImageChef.ImagePlugins throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectors(UInt64 sectorAddress, UInt32 length, UInt32 track) + public override byte[] ReadSectors(ulong sectorAddress, uint length, uint track) { if(ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc) { if(track != 1) - throw new ArgumentOutOfRangeException("track", "Only a single session is supported"); + throw new ArgumentOutOfRangeException(nameof(track), "Only a single session is supported"); return ReadSectors(sectorAddress, length); } @@ -514,12 +514,12 @@ namespace DiscImageChef.ImagePlugins throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectorLong(UInt64 sectorAddress, UInt32 track) + public override byte[] ReadSectorLong(ulong sectorAddress, uint track) { if(ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc) { if(track != 1) - throw new ArgumentOutOfRangeException("track", "Only a single session is supported"); + throw new ArgumentOutOfRangeException(nameof(track), "Only a single session is supported"); return ReadSector(sectorAddress); } @@ -527,12 +527,12 @@ namespace DiscImageChef.ImagePlugins throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length, UInt32 track) + public override byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track) { if(ImageInfo.xmlMediaType == XmlMediaType.OpticalDisc) { if(track != 1) - throw new ArgumentOutOfRangeException("track", "Only a single session is supported"); + throw new ArgumentOutOfRangeException(nameof(track), "Only a single session is supported"); return ReadSectors(sectorAddress, length); } @@ -682,22 +682,22 @@ namespace DiscImageChef.ImagePlugins #region Unsupported features - public override byte[] ReadSectorTag(UInt64 sectorAddress, SectorTagType tag) + public override byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, SectorTagType tag) + public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectorLong(UInt64 sectorAddress) + public override byte[] ReadSectorLong(ulong sectorAddress) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectorsLong(UInt64 sectorAddress, UInt32 length) + public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } @@ -782,17 +782,17 @@ namespace DiscImageChef.ImagePlugins return ImageInfo.driveSerialNumber; } - public override List GetPartitions() + public override List GetPartitions() { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectorTag(UInt64 sectorAddress, UInt32 track, SectorTagType tag) + public override byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } - public override byte[] ReadSectorsTag(UInt64 sectorAddress, UInt32 length, UInt32 track, SectorTagType tag) + public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag) { throw new FeatureUnsupportedImageException("Feature not supported by image format"); } diff --git a/DiscImageChef.Filesystems/APFS.cs b/DiscImageChef.Filesystems/APFS.cs index 571f6918..13bf23ab 100644 --- a/DiscImageChef.Filesystems/APFS.cs +++ b/DiscImageChef.Filesystems/APFS.cs @@ -33,7 +33,6 @@ using System; using System.Runtime.InteropServices; using System.Text; -using DiscImageChef.Console; using System.Collections.Generic; namespace DiscImageChef.Filesystems @@ -58,13 +57,13 @@ namespace DiscImageChef.Filesystems [StructLayout(LayoutKind.Sequential, Pack = 1)] struct ApfsContainerSuperBlock { - public UInt64 unknown1; // Varies between copies of the superblock - public UInt64 unknown2; - public UInt64 unknown3; // Varies by 1 between copies of the superblock - public UInt64 unknown4; - public UInt32 magic; - public UInt32 blockSize; - public UInt64 containerBlocks; + public ulong unknown1; // Varies between copies of the superblock + public ulong unknown2; + public ulong unknown3; // Varies by 1 between copies of the superblock + public ulong unknown4; + public uint magic; + public uint blockSize; + public ulong containerBlocks; } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) diff --git a/DiscImageChef.Filesystems/Acorn.cs b/DiscImageChef.Filesystems/Acorn.cs index ebc779b3..77f2b6aa 100644 --- a/DiscImageChef.Filesystems/Acorn.cs +++ b/DiscImageChef.Filesystems/Acorn.cs @@ -127,7 +127,7 @@ namespace DiscImageChef.Filesystems bytes *= 0x100000000; bytes += drSb.disc_size; - if(bytes > (imagePlugin.GetSectors() * (ulong)imagePlugin.GetSectorSize())) + if(bytes > (imagePlugin.GetSectors() * imagePlugin.GetSectorSize())) return false; return true; @@ -193,7 +193,7 @@ namespace DiscImageChef.Filesystems zones *= 0x100000000; zones += drSb.nzones; - if(bytes > (imagePlugin.GetSectors() * (ulong)imagePlugin.GetSectorSize())) + if(bytes > (imagePlugin.GetSectors() * imagePlugin.GetSectorSize())) return; string discname = StringHandlers.CToString(drSb.disc_name); diff --git a/DiscImageChef.Filesystems/AmigaDOS.cs b/DiscImageChef.Filesystems/AmigaDOS.cs index 8211f687..8f3146a2 100644 --- a/DiscImageChef.Filesystems/AmigaDOS.cs +++ b/DiscImageChef.Filesystems/AmigaDOS.cs @@ -32,8 +32,6 @@ using System; using System.Text; -using DiscImageChef; -using DiscImageChef.PartPlugins; using System.Collections.Generic; using DiscImageChef.Console; @@ -61,15 +59,15 @@ namespace DiscImageChef.Filesystems /// /// Offset 0x00, "DOSx" disk type /// - public UInt32 diskType; + public uint diskType; /// /// Offset 0x04, Checksum /// - public UInt32 checksum; + public uint checksum; /// /// Offset 0x08, Pointer to root block, mostly invalid /// - public UInt32 root_ptr; + public uint root_ptr; /// /// Offset 0x0C, Boot code, til completion /// @@ -81,55 +79,55 @@ namespace DiscImageChef.Filesystems /// /// Offset 0x00, block type, value = T_HEADER (2) /// - public UInt32 type; + public uint type; /// /// Offset 0x04, unused /// - public UInt32 headerKey; + public uint headerKey; /// /// Offset 0x08, unused /// - public UInt32 highSeq; + public uint highSeq; /// /// Offset 0x0C, longs used by hash table /// - public UInt32 hashTableSize; + public uint hashTableSize; /// /// Offset 0x10, unused /// - public UInt32 firstData; + public uint firstData; /// /// Offset 0x14, Rootblock checksum /// - public UInt32 checksum; + public uint checksum; /// /// Offset 0x18, Hashtable, size = (block size / 4) - 56 or size = hashTableSize /// - public UInt32[] hashTable; + public uint[] hashTable; /// /// Offset 0x18+hashTableSize*4+0, bitmap flag, 0xFFFFFFFF if valid /// - public UInt32 bitmapFlag; + public uint bitmapFlag; /// /// Offset 0x18+hashTableSize*4+4, bitmap pages, 25 entries /// - public UInt32[] bitmapPages; + public uint[] bitmapPages; /// /// Offset 0x18+hashTableSize*4+104, pointer to bitmap extension block /// - public UInt32 bitmapExtensionBlock; + public uint bitmapExtensionBlock; /// /// Offset 0x18+hashTableSize*4+108, last root alteration days since 1978/01/01 /// - public UInt32 rDays; + public uint rDays; /// /// Offset 0x18+hashTableSize*4+112, last root alteration minutes past midnight /// - public UInt32 rMins; + public uint rMins; /// /// Offset 0x18+hashTableSize*4+116, last root alteration ticks (1/50 secs) /// - public UInt32 rTicks; + public uint rTicks; /// /// Offset 0x18+hashTableSize*4+120, disk name, pascal string, 32 bytes /// @@ -137,51 +135,51 @@ namespace DiscImageChef.Filesystems /// /// Offset 0x18+hashTableSize*4+152, unused /// - public UInt32 reserved1; + public uint reserved1; /// /// Offset 0x18+hashTableSize*4+156, unused /// - public UInt32 reserved2; + public uint reserved2; /// /// Offset 0x18+hashTableSize*4+160, last disk alteration days since 1978/01/01 /// - public UInt32 vDays; + public uint vDays; /// /// Offset 0x18+hashTableSize*4+164, last disk alteration minutes past midnight /// - public UInt32 vMins; + public uint vMins; /// /// Offset 0x18+hashTableSize*4+168, last disk alteration ticks (1/50 secs) /// - public UInt32 vTicks; + public uint vTicks; /// /// Offset 0x18+hashTableSize*4+172, filesystem creation days since 1978/01/01 /// - public UInt32 cDays; + public uint cDays; /// /// Offset 0x18+hashTableSize*4+176, filesystem creation minutes since 1978/01/01 /// - public UInt32 cMins; + public uint cMins; /// /// Offset 0x18+hashTableSize*4+180, filesystem creation ticks since 1978/01/01 /// - public UInt32 cTicks; + public uint cTicks; /// /// Offset 0x18+hashTableSize*4+184, unused /// - public UInt32 nextHash; + public uint nextHash; /// /// Offset 0x18+hashTableSize*4+188, unused /// - public UInt32 parentDir; + public uint parentDir; /// /// Offset 0x18+hashTableSize*4+192, first directory cache block /// - public UInt32 extension; + public uint extension; /// /// Offset 0x18+hashTableSize*4+196, block secondary type = ST_ROOT (1) /// - public UInt32 sec_type; + public uint sec_type; } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -193,7 +191,7 @@ namespace DiscImageChef.Filesystems byte[] sector = imagePlugin.ReadSector(0 + partitionStart); - UInt32 magic = BigEndianBitConverter.ToUInt32(sector, 0x00); + uint magic = BigEndianBitConverter.ToUInt32(sector, 0x00); if((magic & 0x6D754600) != 0x6D754600 && (magic & 0x444F5300) != 0x444F5300) @@ -211,13 +209,13 @@ namespace DiscImageChef.Filesystems sector = imagePlugin.ReadSector(root_ptr); - UInt32 type = BigEndianBitConverter.ToUInt32(sector, 0x00); - UInt32 hashTableSize = BigEndianBitConverter.ToUInt32(sector, 0x0C); + uint type = BigEndianBitConverter.ToUInt32(sector, 0x00); + uint hashTableSize = BigEndianBitConverter.ToUInt32(sector, 0x0C); if((0x18 + hashTableSize * 4 + 196) > sector.Length) return false; - UInt32 sec_type = BigEndianBitConverter.ToUInt32(sector, (int)(0x18 + hashTableSize * 4 + 196)); + uint sec_type = BigEndianBitConverter.ToUInt32(sector, (int)(0x18 + hashTableSize * 4 + 196)); return type == 2 && sec_type == 1; } @@ -363,10 +361,10 @@ namespace DiscImageChef.Filesystems xmlFSType.ClusterSize = (int)imagePlugin.GetSectorSize(); } - static UInt32 AmigaChecksum(byte[] data) + static uint AmigaChecksum(byte[] data) { BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; - UInt32 sum = 0; + uint sum = 0; for(int i = 0; i < data.Length; i += 4) sum += BigEndianBitConverter.ToUInt32(data, i); diff --git a/DiscImageChef.Filesystems/AppleHFS.cs b/DiscImageChef.Filesystems/AppleHFS.cs index 0ac0aab9..9230383f 100644 --- a/DiscImageChef.Filesystems/AppleHFS.cs +++ b/DiscImageChef.Filesystems/AppleHFS.cs @@ -33,29 +33,26 @@ using System; using System.Collections.Generic; using System.Text; -using DiscImageChef; - -// Information from Inside Macintosh -// https://developer.apple.com/legacy/library/documentation/mac/pdf/Files/File_Manager.pdf using DiscImageChef.Console; - namespace DiscImageChef.Filesystems { + // Information from Inside Macintosh + // https://developer.apple.com/legacy/library/documentation/mac/pdf/Files/File_Manager.pdf class AppleHFS : Filesystem { /// /// "BD", HFS magic /// - const UInt16 HFS_MAGIC = 0x4244; + const ushort HFS_MAGIC = 0x4244; /// /// "H+", HFS+ magic /// - const UInt16 HFSP_MAGIC = 0x482B; + const ushort HFSP_MAGIC = 0x482B; /// /// "LK", HFS bootblock magic /// - const UInt16 HFSBB_MAGIC = 0x4C4B; + const ushort HFSBB_MAGIC = 0x4C4B; public AppleHFS() { @@ -75,7 +72,7 @@ namespace DiscImageChef.Filesystems return false; byte[] mdb_sector; - UInt16 drSigWord; + ushort drSigWord; if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448 || imagePlugin.GetSectorSize() == 2048) { @@ -128,7 +125,7 @@ namespace DiscImageChef.Filesystems byte[] bb_sector; byte[] mdb_sector; - UInt16 drSigWord; + ushort drSigWord; bool APMFromHDDOnCD = false; @@ -395,14 +392,14 @@ namespace DiscImageChef.Filesystems xmlFSType.Type = "HFS"; xmlFSType.VolumeName = MDB.drVN; if(MDB.drFndrInfo6 != 0 && MDB.drFndrInfo7 != 0) - xmlFSType.VolumeSerial = String.Format("{0:X8}{1:x8}", MDB.drFndrInfo6, MDB.drFndrInfo7); + xmlFSType.VolumeSerial = string.Format("{0:X8}{1:x8}", MDB.drFndrInfo6, MDB.drFndrInfo7); return; } - static byte[] Read2048SectorAs512(ImagePlugins.ImagePlugin imagePlugin, UInt64 LBA) + static byte[] Read2048SectorAs512(ImagePlugins.ImagePlugin imagePlugin, ulong LBA) { - UInt64 LBA2k = LBA / 4; + ulong LBA2k = LBA / 4; int Remainder = (int)(LBA % 4); byte[] buffer = imagePlugin.ReadSector(LBA2k); @@ -419,86 +416,86 @@ namespace DiscImageChef.Filesystems struct HFS_MasterDirectoryBlock // Should be sector 2 in volume { /// 0x000, Signature, 0x4244 - public UInt16 drSigWord; + public ushort drSigWord; /// 0x002, Volume creation date - public UInt32 drCrDate; + public uint drCrDate; /// 0x006, Volume last modification date - public UInt32 drLsMod; + public uint drLsMod; /// 0x00A, Volume attributes - public UInt16 drAtrb; + public ushort drAtrb; /// 0x00C, Files in root directory - public UInt16 drNmFls; + public ushort drNmFls; /// 0x00E, Start 512-byte sector of volume bitmap - public UInt16 drVBMSt; + public ushort drVBMSt; /// 0x010, Allocation block to begin next allocation - public UInt16 drAllocPtr; + public ushort drAllocPtr; /// 0x012, Allocation blocks - public UInt16 drNmAlBlks; + public ushort drNmAlBlks; /// 0x014, Bytes per allocation block - public UInt32 drAlBlkSiz; + public uint drAlBlkSiz; /// 0x018, Bytes to allocate when extending a file - public UInt32 drClpSiz; + public uint drClpSiz; /// 0x01C, Start 512-byte sector of first allocation block - public UInt16 drAlBlSt; + public ushort drAlBlSt; /// 0x01E, CNID for next file - public UInt32 drNxtCNID; + public uint drNxtCNID; /// 0x022, Free allocation blocks - public UInt16 drFreeBks; + public ushort drFreeBks; /// 0x024, Volume name (28 bytes) public string drVN; /// 0x040, Volume last backup time - public UInt32 drVolBkUp; + public uint drVolBkUp; /// 0x044, Volume backup sequence number - public UInt16 drVSeqNum; + public ushort drVSeqNum; /// 0x046, Filesystem write count - public UInt32 drWrCnt; + public uint drWrCnt; /// 0x04A, Bytes to allocate when extending the extents B-Tree - public UInt32 drXTClpSiz; + public uint drXTClpSiz; /// 0x04E, Bytes to allocate when extending the catalog B-Tree - public UInt32 drCTClpSiz; + public uint drCTClpSiz; /// 0x052, Number of directories in root directory - public UInt16 drNmRtDirs; + public ushort drNmRtDirs; /// 0x054, Number of files in the volume - public UInt32 drFilCnt; + public uint drFilCnt; /// 0x058, Number of directories in the volume - public UInt32 drDirCnt; + public uint drDirCnt; /// 0x05C, finderInfo[0], CNID for bootable system's directory - public UInt32 drFndrInfo0; + public uint drFndrInfo0; /// 0x060, finderInfo[1], CNID of the directory containing the boot application - public UInt32 drFndrInfo1; + public uint drFndrInfo1; /// 0x064, finderInfo[2], CNID of the directory that should be opened on boot - public UInt32 drFndrInfo2; + public uint drFndrInfo2; /// 0x068, finderInfo[3], CNID for Mac OS 8 or 9 directory - public UInt32 drFndrInfo3; + public uint drFndrInfo3; /// 0x06C, finderInfo[4], Reserved - public UInt32 drFndrInfo4; + public uint drFndrInfo4; /// 0x070, finderInfo[5], CNID for Mac OS X directory - public UInt32 drFndrInfo5; + public uint drFndrInfo5; /// 0x074, finderInfo[6], first part of Mac OS X volume ID - public UInt32 drFndrInfo6; + public uint drFndrInfo6; /// 0x078, finderInfo[7], second part of Mac OS X volume ID - public UInt32 drFndrInfo7; + public uint drFndrInfo7; // If wrapping HFS+ /// 0x07C, Embedded volume signature, "H+" if HFS+ is embedded ignore following two fields if not - public UInt16 drEmbedSigWord; + public ushort drEmbedSigWord; /// 0x07E, Starting block number of embedded HFS+ volume - public UInt16 xdrStABNt; + public ushort xdrStABNt; /// 0x080, Allocation blocks used by embedded volume - public UInt16 xdrNumABlks; + public ushort xdrNumABlks; // If not /// 0x07C, Size in blocks of volume cache - public UInt16 drVCSize; + public ushort drVCSize; /// 0x07E, Size in blocks of volume bitmap cache - public UInt16 drVBMCSize; + public ushort drVBMCSize; /// 0x080, Size in blocks of volume common cache - public UInt16 drCtlCSize; + public ushort drCtlCSize; // End of variable variables :D /// 0x082, Bytes in the extents B-Tree /// 3 HFS extents following, 32 bits each - public UInt32 drXTFlSize; + public uint drXTFlSize; /// 0x092, Bytes in the catalog B-Tree /// 3 HFS extents following, 32 bits each - public UInt32 drCTFlSize; + public uint drCTFlSize; } /// @@ -507,15 +504,15 @@ namespace DiscImageChef.Filesystems struct HFS_BootBlock // Should be sectors 0 and 1 in volume { /// 0x000, Signature, 0x4C4B if bootable - public UInt16 signature; + public ushort signature; /// 0x002, Branch - public UInt32 branch; + public uint branch; /// 0x006, Boot block flags public byte boot_flags; /// 0x007, Boot block version public byte boot_version; /// 0x008, Allocate secondary buffers - public Int16 sec_sv_pages; + public short sec_sv_pages; /// 0x00A, System file name (16 bytes) public string system_name; /// 0x01A, Finder file name (16 bytes) @@ -531,15 +528,15 @@ namespace DiscImageChef.Filesystems /// 0x06A, Clipboard file name (16 bytes) public string clipbrd_name; /// 0x07A, 1/4 of maximum opened at a time files - public UInt16 max_files; + public ushort max_files; /// 0x07C, Event queue size - public UInt16 queue_size; + public ushort queue_size; /// 0x07E, Heap size on a Mac with 128KiB of RAM - public UInt32 heap_128k; + public uint heap_128k; /// 0x082, Heap size on a Mac with 256KiB of RAM - public UInt32 heap_256k; + public uint heap_256k; /// 0x086, Heap size on a Mac with 512KiB of RAM or more - public UInt32 heap_512k; + public uint heap_512k; } public override Errno Mount() diff --git a/DiscImageChef.Filesystems/AppleHFSPlus.cs b/DiscImageChef.Filesystems/AppleHFSPlus.cs index 8ddc67ae..a80c4e5d 100644 --- a/DiscImageChef.Filesystems/AppleHFSPlus.cs +++ b/DiscImageChef.Filesystems/AppleHFSPlus.cs @@ -32,26 +32,25 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; -// Information from Apple TechNote 1150: https://developer.apple.com/legacy/library/technotes/tn/tn1150.html namespace DiscImageChef.Filesystems { + // Information from Apple TechNote 1150: https://developer.apple.com/legacy/library/technotes/tn/tn1150.html class AppleHFSPlus : Filesystem { /// /// "BD", HFS magic /// - const UInt16 HFS_MAGIC = 0x4244; + const ushort HFS_MAGIC = 0x4244; /// /// "H+", HFS+ magic /// - const UInt16 HFSP_MAGIC = 0x482B; + const ushort HFSP_MAGIC = 0x482B; /// /// "HX", HFSX magic /// - const UInt16 HFSX_MAGIC = 0x4858; + const ushort HFSX_MAGIC = 0x4858; public AppleHFSPlus() { @@ -70,10 +69,10 @@ namespace DiscImageChef.Filesystems if((2 + partitionStart) >= imagePlugin.GetSectors()) return false; - UInt16 drSigWord; - UInt16 xdrStABNt; - UInt16 drAlBlSt; - UInt32 drAlBlkSiz; + ushort drSigWord; + ushort xdrStABNt; + ushort drAlBlSt; + uint drAlBlkSiz; byte[] vh_sector; ulong hfsp_offset; @@ -118,10 +117,10 @@ namespace DiscImageChef.Filesystems { information = ""; - UInt16 drSigWord; - UInt16 xdrStABNt; - UInt16 drAlBlSt; - UInt32 drAlBlkSiz; + ushort drSigWord; + ushort xdrStABNt; + ushort drAlBlSt; + uint drAlBlkSiz; HFSPlusVolumeHeader HPVH = new HFSPlusVolumeHeader(); ulong hfsp_offset; @@ -271,8 +270,7 @@ namespace DiscImageChef.Filesystems xmlFSType.BackupDate = DateHandlers.MacToDateTime(HPVH.backupDate); xmlFSType.BackupDateSpecified = true; } - if(HPVH.drFndrInfo0 != 0 || HPVH.drFndrInfo3 != 0 || HPVH.drFndrInfo5 != 0) - xmlFSType.Bootable = true; + xmlFSType.Bootable |= (HPVH.drFndrInfo0 != 0 || HPVH.drFndrInfo3 != 0 || HPVH.drFndrInfo5 != 0); xmlFSType.Clusters = HPVH.totalBlocks; xmlFSType.ClusterSize = (int)HPVH.blockSize; if(HPVH.createDate > 0) @@ -295,7 +293,7 @@ namespace DiscImageChef.Filesystems if(HPVH.signature == 0x4858) xmlFSType.Type = "HFSX"; if(HPVH.drFndrInfo6 != 0 && HPVH.drFndrInfo7 != 0) - xmlFSType.VolumeSerial = String.Format("{0:X8}{1:x8}", HPVH.drFndrInfo6, HPVH.drFndrInfo7); + xmlFSType.VolumeSerial = string.Format("{0:X8}{1:x8}", HPVH.drFndrInfo6, HPVH.drFndrInfo7); } else { @@ -315,11 +313,11 @@ namespace DiscImageChef.Filesystems struct HFSPlusVolumeHeader { /// 0x000, "H+" for HFS+, "HX" for HFSX - public UInt16 signature; + public ushort signature; /// 0x002, 4 for HFS+, 5 for HFSX - public UInt16 version; + public ushort version; /// 0x004, Volume attributes - public UInt32 attributes; + public uint attributes; /// 0x008, Implementation that last mounted the volume. /// Reserved by Apple: /// "8.10" Mac OS 8.1 to 9.2.2 @@ -328,7 +326,7 @@ namespace DiscImageChef.Filesystems /// "fsck" /sbin/fsck public string lastMountedVersion; /// 0x00C, Allocation block number containing the journal - public UInt32 journalInfoBlock; + public uint journalInfoBlock; /// 0x010, Date of volume creation public ulong createDate; /// 0x018, Date of last volume modification @@ -338,238 +336,238 @@ namespace DiscImageChef.Filesystems /// 0x028, Date of last consistency check public ulong checkedDate; /// 0x030, File on the volume - public UInt32 fileCount; + public uint fileCount; /// 0x034, Folders on the volume - public UInt32 folderCount; + public uint folderCount; /// 0x038, Bytes per allocation block - public UInt32 blockSize; + public uint blockSize; /// 0x03C, Allocation blocks on the volume - public UInt32 totalBlocks; + public uint totalBlocks; /// 0x040, Free allocation blocks - public UInt32 freeBlocks; + public uint freeBlocks; /// 0x044, Hint for next allocation block - public UInt32 nextAllocation; + public uint nextAllocation; /// 0x048, Resource fork clump size - public UInt32 rsrcClumpSize; + public uint rsrcClumpSize; /// 0x04C, Data fork clump size - public UInt32 dataClumpSize; + public uint dataClumpSize; /// 0x050, Next unused CNID - public UInt32 nextCatalogID; + public uint nextCatalogID; /// 0x054, Times that the volume has been mounted writable - public UInt32 writeCount; + public uint writeCount; /// 0x058, Used text encoding hints - public UInt64 encodingsBitmap; + public ulong encodingsBitmap; /// 0x060, finderInfo[0], CNID for bootable system's directory - public UInt32 drFndrInfo0; + public uint drFndrInfo0; /// 0x064, finderInfo[1], CNID of the directory containing the boot application - public UInt32 drFndrInfo1; + public uint drFndrInfo1; /// 0x068, finderInfo[2], CNID of the directory that should be opened on boot - public UInt32 drFndrInfo2; + public uint drFndrInfo2; /// 0x06C, finderInfo[3], CNID for Mac OS 8 or 9 directory - public UInt32 drFndrInfo3; + public uint drFndrInfo3; /// 0x070, finderInfo[4], Reserved - public UInt32 drFndrInfo4; + public uint drFndrInfo4; /// 0x074, finderInfo[5], CNID for Mac OS X directory - public UInt32 drFndrInfo5; + public uint drFndrInfo5; /// 0x078, finderInfo[6], first part of Mac OS X volume ID - public UInt32 drFndrInfo6; + public uint drFndrInfo6; /// 0x07C, finderInfo[7], second part of Mac OS X volume ID - public UInt32 drFndrInfo7; + public uint drFndrInfo7; // HFSPlusForkData allocationFile; /// 0x080 - public UInt64 allocationFile_logicalSize; + public ulong allocationFile_logicalSize; /// 0x088 - public UInt32 allocationFile_clumpSize; + public uint allocationFile_clumpSize; /// 0x08C - public UInt32 allocationFile_totalBlocks; + public uint allocationFile_totalBlocks; /// 0x090 - public UInt32 allocationFile_extents_startBlock0; + public uint allocationFile_extents_startBlock0; /// 0x094 - public UInt32 allocationFile_extents_blockCount0; + public uint allocationFile_extents_blockCount0; /// 0x098 - public UInt32 allocationFile_extents_startBlock1; + public uint allocationFile_extents_startBlock1; /// 0x09C - public UInt32 allocationFile_extents_blockCount1; + public uint allocationFile_extents_blockCount1; /// 0x0A0 - public UInt32 allocationFile_extents_startBlock2; + public uint allocationFile_extents_startBlock2; /// 0x0A4 - public UInt32 allocationFile_extents_blockCount2; + public uint allocationFile_extents_blockCount2; /// 0x0A8 - public UInt32 allocationFile_extents_startBlock3; + public uint allocationFile_extents_startBlock3; /// 0x0AC - public UInt32 allocationFile_extents_blockCount3; + public uint allocationFile_extents_blockCount3; /// 0x0B0 - public UInt32 allocationFile_extents_startBlock4; + public uint allocationFile_extents_startBlock4; /// 0x0B4 - public UInt32 allocationFile_extents_blockCount4; + public uint allocationFile_extents_blockCount4; /// 0x0B8 - public UInt32 allocationFile_extents_startBlock5; + public uint allocationFile_extents_startBlock5; /// 0x0BC - public UInt32 allocationFile_extents_blockCount5; + public uint allocationFile_extents_blockCount5; /// 0x0C0 - public UInt32 allocationFile_extents_startBlock6; + public uint allocationFile_extents_startBlock6; /// 0x0C4 - public UInt32 allocationFile_extents_blockCount6; + public uint allocationFile_extents_blockCount6; /// 0x0C8 - public UInt32 allocationFile_extents_startBlock7; + public uint allocationFile_extents_startBlock7; /// 0x0CC - public UInt32 allocationFile_extents_blockCount7; + public uint allocationFile_extents_blockCount7; // HFSPlusForkData extentsFile; /// 0x0D0 - public UInt64 extentsFile_logicalSize; + public ulong extentsFile_logicalSize; /// 0x0D8 - public UInt32 extentsFile_clumpSize; + public uint extentsFile_clumpSize; /// 0x0DC - public UInt32 extentsFile_totalBlocks; + public uint extentsFile_totalBlocks; /// 0x0E0 - public UInt32 extentsFile_extents_startBlock0; + public uint extentsFile_extents_startBlock0; /// 0x0E4 - public UInt32 extentsFile_extents_blockCount0; + public uint extentsFile_extents_blockCount0; /// 0x0E8 - public UInt32 extentsFile_extents_startBlock1; + public uint extentsFile_extents_startBlock1; /// 0x0EC - public UInt32 extentsFile_extents_blockCount1; + public uint extentsFile_extents_blockCount1; /// 0x0F0 - public UInt32 extentsFile_extents_startBlock2; + public uint extentsFile_extents_startBlock2; /// 0x0F4 - public UInt32 extentsFile_extents_blockCount2; + public uint extentsFile_extents_blockCount2; /// 0x0F8 - public UInt32 extentsFile_extents_startBlock3; + public uint extentsFile_extents_startBlock3; /// 0x0FC - public UInt32 extentsFile_extents_blockCount3; + public uint extentsFile_extents_blockCount3; /// 0x100 - public UInt32 extentsFile_extents_startBlock4; + public uint extentsFile_extents_startBlock4; /// 0x104 - public UInt32 extentsFile_extents_blockCount4; + public uint extentsFile_extents_blockCount4; /// 0x108 - public UInt32 extentsFile_extents_startBlock5; + public uint extentsFile_extents_startBlock5; /// 0x10C - public UInt32 extentsFile_extents_blockCount5; + public uint extentsFile_extents_blockCount5; /// 0x110 - public UInt32 extentsFile_extents_startBlock6; + public uint extentsFile_extents_startBlock6; /// 0x114 - public UInt32 extentsFile_extents_blockCount6; + public uint extentsFile_extents_blockCount6; /// 0x118 - public UInt32 extentsFile_extents_startBlock7; + public uint extentsFile_extents_startBlock7; /// 0x11C - public UInt32 extentsFile_extents_blockCount7; + public uint extentsFile_extents_blockCount7; // HFSPlusForkData catalogFile; /// 0x120 - public UInt64 catalogFile_logicalSize; + public ulong catalogFile_logicalSize; /// 0x128 - public UInt32 catalogFile_clumpSize; + public uint catalogFile_clumpSize; /// 0x12C - public UInt32 catalogFile_totalBlocks; + public uint catalogFile_totalBlocks; /// 0x130 - public UInt32 catalogFile_extents_startBlock0; + public uint catalogFile_extents_startBlock0; /// 0x134 - public UInt32 catalogFile_extents_blockCount0; + public uint catalogFile_extents_blockCount0; /// 0x138 - public UInt32 catalogFile_extents_startBlock1; + public uint catalogFile_extents_startBlock1; /// 0x13C - public UInt32 catalogFile_extents_blockCount1; + public uint catalogFile_extents_blockCount1; /// 0x140 - public UInt32 catalogFile_extents_startBlock2; + public uint catalogFile_extents_startBlock2; /// 0x144 - public UInt32 catalogFile_extents_blockCount2; + public uint catalogFile_extents_blockCount2; /// 0x148 - public UInt32 catalogFile_extents_startBlock3; + public uint catalogFile_extents_startBlock3; /// 0x14C - public UInt32 catalogFile_extents_blockCount3; + public uint catalogFile_extents_blockCount3; /// 0x150 - public UInt32 catalogFile_extents_startBlock4; + public uint catalogFile_extents_startBlock4; /// 0x154 - public UInt32 catalogFile_extents_blockCount4; + public uint catalogFile_extents_blockCount4; /// 0x158 - public UInt32 catalogFile_extents_startBlock5; + public uint catalogFile_extents_startBlock5; /// 0x15C - public UInt32 catalogFile_extents_blockCount5; + public uint catalogFile_extents_blockCount5; /// 0x160 - public UInt32 catalogFile_extents_startBlock6; + public uint catalogFile_extents_startBlock6; /// 0x164 - public UInt32 catalogFile_extents_blockCount6; + public uint catalogFile_extents_blockCount6; /// 0x168 - public UInt32 catalogFile_extents_startBlock7; + public uint catalogFile_extents_startBlock7; /// 0x16C - public UInt32 catalogFile_extents_blockCount7; + public uint catalogFile_extents_blockCount7; // HFSPlusForkData attributesFile; /// 0x170 - public UInt64 attributesFile_logicalSize; + public ulong attributesFile_logicalSize; /// 0x178 - public UInt32 attributesFile_clumpSize; + public uint attributesFile_clumpSize; /// 0x17C - public UInt32 attributesFile_totalBlocks; + public uint attributesFile_totalBlocks; /// 0x180 - public UInt32 attributesFile_extents_startBlock0; + public uint attributesFile_extents_startBlock0; /// 0x184 - public UInt32 attributesFile_extents_blockCount0; + public uint attributesFile_extents_blockCount0; /// 0x188 - public UInt32 attributesFile_extents_startBlock1; + public uint attributesFile_extents_startBlock1; /// 0x18C - public UInt32 attributesFile_extents_blockCount1; + public uint attributesFile_extents_blockCount1; /// 0x190 - public UInt32 attributesFile_extents_startBlock2; + public uint attributesFile_extents_startBlock2; /// 0x194 - public UInt32 attributesFile_extents_blockCount2; + public uint attributesFile_extents_blockCount2; /// 0x198 - public UInt32 attributesFile_extents_startBlock3; + public uint attributesFile_extents_startBlock3; /// 0x19C - public UInt32 attributesFile_extents_blockCount3; + public uint attributesFile_extents_blockCount3; /// 0x1A0 - public UInt32 attributesFile_extents_startBlock4; + public uint attributesFile_extents_startBlock4; /// 0x1A4 - public UInt32 attributesFile_extents_blockCount4; + public uint attributesFile_extents_blockCount4; /// 0x1A8 - public UInt32 attributesFile_extents_startBlock5; + public uint attributesFile_extents_startBlock5; /// 0x1AC - public UInt32 attributesFile_extents_blockCount5; + public uint attributesFile_extents_blockCount5; /// 0x1B0 - public UInt32 attributesFile_extents_startBlock6; + public uint attributesFile_extents_startBlock6; /// 0x1B4 - public UInt32 attributesFile_extents_blockCount6; + public uint attributesFile_extents_blockCount6; /// 0x1B8 - public UInt32 attributesFile_extents_startBlock7; + public uint attributesFile_extents_startBlock7; /// 0x1BC - public UInt32 attributesFile_extents_blockCount7; + public uint attributesFile_extents_blockCount7; // HFSPlusForkData startupFile; /// 0x1C0 - public UInt64 startupFile_logicalSize; + public ulong startupFile_logicalSize; /// 0x1C8 - public UInt32 startupFile_clumpSize; + public uint startupFile_clumpSize; /// 0x1CC - public UInt32 startupFile_totalBlocks; + public uint startupFile_totalBlocks; /// 0x1D0 - public UInt32 startupFile_extents_startBlock0; + public uint startupFile_extents_startBlock0; /// 0x1D4 - public UInt32 startupFile_extents_blockCount0; + public uint startupFile_extents_blockCount0; /// 0x1D8 - public UInt32 startupFile_extents_startBlock1; + public uint startupFile_extents_startBlock1; /// 0x1E0 - public UInt32 startupFile_extents_blockCount1; + public uint startupFile_extents_blockCount1; /// 0x1E4 - public UInt32 startupFile_extents_startBlock2; + public uint startupFile_extents_startBlock2; /// 0x1E8 - public UInt32 startupFile_extents_blockCount2; + public uint startupFile_extents_blockCount2; /// 0x1EC - public UInt32 startupFile_extents_startBlock3; + public uint startupFile_extents_startBlock3; /// 0x1F0 - public UInt32 startupFile_extents_blockCount3; + public uint startupFile_extents_blockCount3; /// 0x1F4 - public UInt32 startupFile_extents_startBlock4; + public uint startupFile_extents_startBlock4; /// 0x1F8 - public UInt32 startupFile_extents_blockCount4; + public uint startupFile_extents_blockCount4; /// 0x1FC - public UInt32 startupFile_extents_startBlock5; + public uint startupFile_extents_startBlock5; /// 0x200 - public UInt32 startupFile_extents_blockCount5; + public uint startupFile_extents_blockCount5; /// 0x204 - public UInt32 startupFile_extents_startBlock6; + public uint startupFile_extents_startBlock6; /// 0x208 - public UInt32 startupFile_extents_blockCount6; + public uint startupFile_extents_blockCount6; /// 0x20C - public UInt32 startupFile_extents_startBlock7; + public uint startupFile_extents_startBlock7; /// 0x210 - public UInt32 startupFile_extents_blockCount7; + public uint startupFile_extents_blockCount7; } public override Errno Mount() diff --git a/DiscImageChef.Filesystems/AppleMFS.cs b/DiscImageChef.Filesystems/AppleMFS.cs index 1e1868c3..87a8c1b9 100644 --- a/DiscImageChef.Filesystems/AppleMFS.cs +++ b/DiscImageChef.Filesystems/AppleMFS.cs @@ -32,17 +32,16 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; -// Information from Inside Macintosh namespace DiscImageChef.Filesystems { + // Information from Inside Macintosh class AppleMFS : Filesystem { - const UInt16 MFS_MAGIC = 0xD2D7; + const ushort MFS_MAGIC = 0xD2D7; // "LK" - const UInt16 MFSBB_MAGIC = 0x4C4B; + const ushort MFSBB_MAGIC = 0x4C4B; public AppleMFS() { @@ -58,7 +57,7 @@ namespace DiscImageChef.Filesystems public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) { - UInt16 drSigWord; + ushort drSigWord; if((2 + partitionStart) >= imagePlugin.GetSectors()) return false; @@ -227,31 +226,31 @@ namespace DiscImageChef.Filesystems struct MFS_MasterDirectoryBlock { /// 0x000, Signature, 0xD2D7 - public UInt16 drSigWord; + public ushort drSigWord; /// 0x002, Volume creation date - public UInt32 drCrDate; + public uint drCrDate; /// 0x006, Volume last backup date - public UInt32 drLsBkUp; + public uint drLsBkUp; /// 0x00A, Volume attributes - public UInt16 drAtrb; + public ushort drAtrb; /// 0x00C, Volume number of files - public UInt16 drNmFls; + public ushort drNmFls; /// 0x00E, First directory block - public UInt16 drDirSt; + public ushort drDirSt; /// 0x010, Length of directory in blocks - public UInt16 drBlLen; + public ushort drBlLen; /// 0x012, Volume allocation blocks - public UInt16 drNmAlBlks; + public ushort drNmAlBlks; /// 0x014, Size of allocation blocks - public UInt32 drAlBlkSiz; + public uint drAlBlkSiz; /// 0x018, Number of bytes to allocate - public UInt32 drClpSiz; + public uint drClpSiz; /// 0x01C, First allocation block in block map - public UInt16 drAlBlSt; + public ushort drAlBlSt; /// 0x01E. Next unused file number - public UInt32 drNxtFNum; + public uint drNxtFNum; /// 0x022, Number of unused allocation blocks - public UInt16 drFreeBks; + public ushort drFreeBks; /// 0x024, Length of volume name public byte drVNSiz; /// 0x025, Characters of volume name @@ -264,9 +263,9 @@ namespace DiscImageChef.Filesystems struct MFS_BootBlock { /// 0x000, Signature, 0x4C4B if bootable - public UInt16 signature; + public ushort signature; /// 0x002, Branch - public UInt32 branch; + public uint branch; /// 0x006, Boot block flags public byte boot_flags; /// 0x007, Boot block version @@ -288,15 +287,15 @@ namespace DiscImageChef.Filesystems /// 0x06A, Clipboard file name (16 bytes) public string clipbrd_name; /// 0x07A, 1/4 of maximum opened at a time files - public UInt16 max_files; + public ushort max_files; /// 0x07C, Event queue size - public UInt16 queue_size; + public ushort queue_size; /// 0x07E, Heap size on a Mac with 128KiB of RAM - public UInt32 heap_128k; + public uint heap_128k; /// 0x082, Heap size on a Mac with 256KiB of RAM - public UInt32 heap_256k; + public uint heap_256k; /// 0x086, Heap size on a Mac with 512KiB of RAM or more - public UInt32 heap_512k; + public uint heap_512k; } public override Errno Mount() diff --git a/DiscImageChef.Filesystems/BFS.cs b/DiscImageChef.Filesystems/BFS.cs index ad2b7c69..019bb383 100644 --- a/DiscImageChef.Filesystems/BFS.cs +++ b/DiscImageChef.Filesystems/BFS.cs @@ -32,25 +32,24 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; -// Information from Practical Filesystem Design, ISBN 1-55860-497-9 namespace DiscImageChef.Filesystems { + // Information from Practical Filesystem Design, ISBN 1-55860-497-9 class BeFS : Filesystem { // Little endian constants (that is, as read by .NET :p) - const UInt32 BEFS_MAGIC1 = 0x42465331; - const UInt32 BEFS_MAGIC2 = 0xDD121031; - const UInt32 BEFS_MAGIC3 = 0x15B6830E; - const UInt32 BEFS_ENDIAN = 0x42494745; + const uint BEFS_MAGIC1 = 0x42465331; + const uint BEFS_MAGIC2 = 0xDD121031; + const uint BEFS_MAGIC3 = 0x15B6830E; + const uint BEFS_ENDIAN = 0x42494745; // Big endian constants - const UInt32 BEFS_CIGAM1 = 0x31534642; - const UInt32 BEFS_NAIDNE = 0x45474942; + const uint BEFS_CIGAM1 = 0x31534642; + const uint BEFS_NAIDNE = 0x45474942; // Common constants - const UInt32 BEFS_CLEAN = 0x434C454E; - const UInt32 BEFS_DIRTY = 0x44495254; + const uint BEFS_CLEAN = 0x434C454E; + const uint BEFS_DIRTY = 0x44495254; public BeFS() { @@ -69,8 +68,8 @@ namespace DiscImageChef.Filesystems if((2 + partitionStart) >= imagePlugin.GetSectors()) return false; - UInt32 magic; - UInt32 magic_be; + uint magic; + uint magic_be; byte[] sb_sector = imagePlugin.ReadSector(0 + partitionStart); @@ -239,53 +238,53 @@ namespace DiscImageChef.Filesystems /// 0x000, Volume name, 32 bytes public string name; /// 0x020, "BFS1", 0x42465331 - public UInt32 magic1; + public uint magic1; /// 0x024, "BIGE", 0x42494745 - public UInt32 fs_byte_order; + public uint fs_byte_order; /// 0x028, Bytes per block - public UInt32 block_size; + public uint block_size; /// 0x02C, 1 << block_shift == block_size - public UInt32 block_shift; + public uint block_shift; /// 0x030, Blocks in volume - public Int64 num_blocks; + public long num_blocks; /// 0x038, Used blocks in volume - public Int64 used_blocks; + public long used_blocks; /// 0x040, Bytes per inode - public Int32 inode_size; + public int inode_size; /// 0x044, 0xDD121031 - public UInt32 magic2; + public uint magic2; /// 0x048, Blocks per allocation group - public Int32 blocks_per_ag; + public int blocks_per_ag; /// 0x04C, 1 << ag_shift == blocks_per_ag - public Int32 ag_shift; + public int ag_shift; /// 0x050, Allocation groups in volume - public Int32 num_ags; + public int num_ags; /// 0x054, 0x434c454e if clean, 0x44495254 if dirty - public UInt32 flags; + public uint flags; /// 0x058, Allocation group of journal - public Int32 log_blocks_ag; + public int log_blocks_ag; /// 0x05C, Start block of journal, inside ag - public UInt16 log_blocks_start; + public ushort log_blocks_start; /// 0x05E, Length in blocks of journal, inside ag - public UInt16 log_blocks_len; + public ushort log_blocks_len; /// 0x060, Start of journal - public Int64 log_start; + public long log_start; /// 0x068, End of journal - public Int64 log_end; + public long log_end; /// 0x070, 0x15B6830E - public UInt32 magic3; + public uint magic3; /// 0x074, Allocation group where root folder's i-node resides - public Int32 root_dir_ag; + public int root_dir_ag; /// 0x078, Start in ag of root folder's i-node - public UInt16 root_dir_start; + public ushort root_dir_start; /// 0x07A, As this is part of inode_addr, this is 1 - public UInt16 root_dir_len; + public ushort root_dir_len; /// 0x07C, Allocation group where indices' i-node resides - public Int32 indices_ag; + public int indices_ag; /// 0x080, Start in ag of indices' i-node - public UInt16 indices_start; + public ushort indices_start; /// 0x082, As this is part of inode_addr, this is 1 - public UInt16 indices_len; + public ushort indices_len; } public override Errno Mount() diff --git a/DiscImageChef.Filesystems/BTRFS.cs b/DiscImageChef.Filesystems/BTRFS.cs index f58f4cd8..24ccadde 100644 --- a/DiscImageChef.Filesystems/BTRFS.cs +++ b/DiscImageChef.Filesystems/BTRFS.cs @@ -43,7 +43,7 @@ namespace DiscImageChef.Filesystems /// /// BTRFS magic "_BHRfS_M" /// - const ulong magic = 0x4D5F53665248425F; + const ulong btrfsMagic = 0x4D5F53665248425F; public BTRFS() { @@ -149,7 +149,7 @@ namespace DiscImageChef.Filesystems DicConsole.DebugWriteLine("BTRFS Plugin", "partitionStart = {0}", partitionStart); DicConsole.DebugWriteLine("BTRFS Plugin", "btrfsSb.magic = 0x{0:X16}", btrfsSb.magic); - return btrfsSb.magic == magic; + return btrfsSb.magic == btrfsMagic; } public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, out string information) diff --git a/DiscImageChef.Filesystems/ChangeLog b/DiscImageChef.Filesystems/ChangeLog index 558cfcbd..f3b9e52f 100644 --- a/DiscImageChef.Filesystems/ChangeLog +++ b/DiscImageChef.Filesystems/ChangeLog @@ -1,3 +1,43 @@ +2016-07-28 Natalia Portillo + + * ODS.cs: + * FFS.cs: + * BFS.cs: + * FAT.cs: + * NTFS.cs: + * APFS.cs: + * HPFS.cs: + * SysV.cs: + * Opera.cs: + * Acorn.cs: + * BTRFS.cs: + * extFS.cs: + * ext2FS.cs: + * ProDOS.cs: + * MinixFS.cs: + * Symbian.cs: + * Structs.cs: + * SolarFS.cs: + * UNIXBFS.cs: + * ISO9660.cs: + * PCEngine.cs: + * Nintendo.cs: + * AppleMFS.cs: + * AppleHFS.cs: + * AmigaDOS.cs: + * Dir.cs: + * Filesystem.cs: + * File.cs: + * Info.cs: + * Xattr.cs: + * Super.cs: + * AppleHFSPlus.cs: + * LisaFS.cs: + * Extent.cs: + * Consts.cs: + * Structs.cs: + * Encoding.cs: Refactor and code cleanup. + 2016-07-28 Natalia Portillo * Encoding.cs: Solve null reference. diff --git a/DiscImageChef.Filesystems/FAT.cs b/DiscImageChef.Filesystems/FAT.cs index df8be8df..5616b842 100644 --- a/DiscImageChef.Filesystems/FAT.cs +++ b/DiscImageChef.Filesystems/FAT.cs @@ -32,16 +32,13 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; - -// TODO: Implement detecting DOS bootable disks -// TODO: Implement detecting Atari TOS bootable disks and printing corresponding fields using DiscImageChef.Console; - namespace DiscImageChef.Filesystems { + // TODO: Implement detecting DOS bootable disks + // TODO: Implement detecting Atari TOS bootable disks and printing corresponding fields class FAT : Filesystem { public FAT() @@ -64,8 +61,8 @@ namespace DiscImageChef.Filesystems byte media_descriptor; // Not present on DOS <= 3, present on TOS but != of first FAT entry byte fats_no; // Must be 1 or 2. Dunno if it can be 0 in the wild, but it CANNOT BE bigger than 2 byte[] fat32_signature = new byte[8]; // "FAT32 " - UInt32 first_fat_entry; // No matter FAT size we read 4 bytes for checking - UInt16 bps, rsectors; + uint first_fat_entry; // No matter FAT size we read 4 bytes for checking + ushort bps, rsectors; byte[] bpb_sector = imagePlugin.ReadSector(0 + partitionStart); byte[] fat_sector = imagePlugin.ReadSector(1 + partitionStart); @@ -81,7 +78,7 @@ namespace DiscImageChef.Filesystems rsectors = BitConverter.ToUInt16(bpb_sector, 0x00E); // Sectors between BPB and FAT, including the BPB sector => [BPB,FAT) if(rsectors == 0) rsectors = 1; - if(imagePlugin.GetSectors() > ((ulong)rsectors + partitionStart)) + if(imagePlugin.GetSectors() > (rsectors + partitionStart)) fat_sector = imagePlugin.ReadSector(rsectors + partitionStart); // First FAT entry else bpb_found = false; @@ -182,10 +179,10 @@ namespace DiscImageChef.Filesystems byte[] dosString; // Space-padded bool isFAT32 = false; - UInt32 first_fat_entry; + uint first_fat_entry; byte media_descriptor, fats_no; string fat32_signature; - UInt16 bps, rsectors; + ushort bps, rsectors; byte[] bpb_sector = imagePlugin.ReadSector(0 + partitionStart); byte[] fat_sector = imagePlugin.ReadSector(1 + partitionStart); @@ -203,7 +200,7 @@ namespace DiscImageChef.Filesystems rsectors = BitConverter.ToUInt16(bpb_sector, 0x00E); // Sectors between BPB and FAT, including the BPB sector => [BPB,FAT) if(rsectors == 0) rsectors = 1; - if(imagePlugin.GetSectors() > ((ulong)rsectors + partitionStart)) + if(imagePlugin.GetSectors() > (rsectors + partitionStart)) fat_sector = imagePlugin.ReadSector(rsectors + partitionStart); // First FAT entry else bpb_found = false; @@ -326,7 +323,7 @@ namespace DiscImageChef.Filesystems sb.AppendFormat("Sector of backup FAT32 parameter block: {0}", FAT32PB.backup_sector).AppendLine(); sb.AppendFormat("Drive number: 0x{0:X2}", FAT32PB.drive_no).AppendLine(); sb.AppendFormat("Volume Serial Number: 0x{0:X8}", FAT32PB.serial_no).AppendLine(); - xmlFSType.VolumeSerial = String.Format("{0:X8}", FAT32PB.serial_no); + xmlFSType.VolumeSerial = string.Format("{0:X8}", FAT32PB.serial_no); if((FAT32PB.nt_flags & 0x01) == 0x01) { sb.AppendLine("Volume should be checked on next mount."); @@ -344,7 +341,7 @@ namespace DiscImageChef.Filesystems { sb.AppendFormat("Drive number: 0x{0:X2}", EPB.drive_no).AppendLine(); sb.AppendFormat("Volume Serial Number: 0x{0:X8}", EPB.serial_no).AppendLine(); - xmlFSType.VolumeSerial = String.Format("{0:X8}", EPB.serial_no); + xmlFSType.VolumeSerial = string.Format("{0:X8}", EPB.serial_no); if(EPB.signature == 0x29) { if((EPB.nt_flags & 0x01) == 0x01) @@ -379,29 +376,29 @@ namespace DiscImageChef.Filesystems /// 0x03, OEM Name, 8 bytes, space-padded public string OEMName; /// 0x0B, Bytes per sector - public UInt16 bps; + public ushort bps; /// 0x0D, Sectors per cluster public byte spc; /// 0x0E, Reserved sectors between BPB and FAT - public UInt16 rsectors; + public ushort rsectors; /// 0x10, Number of FATs public byte fats_no; /// 0x11, Number of entries on root directory - public UInt16 root_ent; + public ushort root_ent; /// 0x13, Sectors in volume - public UInt16 sectors; + public ushort sectors; /// 0x15, Media descriptor public byte media; /// 0x16, Sectors per FAT - public UInt16 spfat; + public ushort spfat; /// 0x18, Sectors per track - public UInt16 sptrk; + public ushort sptrk; /// 0x1A, Heads - public UInt16 heads; + public ushort heads; /// 0x1C, Hidden sectors before BPB - public UInt32 hsectors; + public uint hsectors; /// 0x20, Sectors in volume if > 65535 - public UInt32 big_sectors; + public uint big_sectors; } /// @@ -412,27 +409,27 @@ namespace DiscImageChef.Filesystems public struct AtariBootBlock { /// 0x01C, Atari ST use 16 bit for hidden sectors, probably so did old DOS - public UInt16 hsectors; + public ushort hsectors; /// 0x01E, indicates if COMMAND.PRG must be executed after OS load - public UInt16 xflag; + public ushort xflag; /// 0x020, load mode for, or 0 if fname indicates boot file - public UInt16 ldmode; + public ushort ldmode; /// 0x022, sector from which to boot - public UInt16 bsect; + public ushort bsect; /// 0x024, how many sectors to boot - public UInt16 bsects_no; + public ushort bsects_no; /// 0x026, RAM address where boot should be located - public UInt32 ldaddr; + public uint ldaddr; /// 0x02A, RAM address to copy the FAT and root directory - public UInt32 fatbuf; + public uint fatbuf; /// 0x02E, 11 bytes, name of boot file public string fname; /// 0x039, unused - public UInt16 reserved; + public ushort reserved; /// 0x03B, 451 bytes boot code public byte[] boot_code; /// 0x1FE, the sum of all the BPB+ABB must be 0x1234, so this bigendian value works as adjustment - public UInt16 checksum; + public ushort checksum; } /// DOS Extended Parameter Block @@ -445,7 +442,7 @@ namespace DiscImageChef.Filesystems /// 0x26, EPB signature, 0x28 or 0x29 public byte signature; /// 0x27, Volume serial number - public UInt32 serial_no; + public uint serial_no; /// 0x2B, Volume label, 11 bytes, space-padded /// Present only if signature == 0x29 public string volume_label; @@ -458,17 +455,17 @@ namespace DiscImageChef.Filesystems public struct FAT32ParameterBlock { /// 0x24, Sectors per FAT - public UInt32 spfat; + public uint spfat; /// 0x28, FAT flags - public UInt16 fat_flags; + public ushort fat_flags; /// 0x2A, FAT32 version - public UInt16 version; + public ushort version; /// 0x2C, Cluster of root directory - public UInt32 root_cluster; + public uint root_cluster; /// 0x30, Sector of FSINFO structure - public UInt16 fsinfo_sector; + public ushort fsinfo_sector; /// 0x32, Sector of FAT32PB backup - public UInt16 backup_sector; + public ushort backup_sector; /// 0x34, 12 reserved bytes public byte[] reserved; /// 0x40, Drive number @@ -478,7 +475,7 @@ namespace DiscImageChef.Filesystems /// 0x42, FAT32PB signature, should be 0x29 public byte signature; /// 0x43, Volume serial number - public UInt32 serial_no; + public uint serial_no; /// 0x47, Volume label, 11 bytes, space-padded public string volume_label; /// 0x52, Filesystem type, 8 bytes, space-padded, must be "FAT32 " diff --git a/DiscImageChef.Filesystems/FFS.cs b/DiscImageChef.Filesystems/FFS.cs index 568ef74a..b2d779d5 100644 --- a/DiscImageChef.Filesystems/FFS.cs +++ b/DiscImageChef.Filesystems/FFS.cs @@ -32,15 +32,12 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; - -// Using information from Linux kernel headers using DiscImageChef.Console; - namespace DiscImageChef.Filesystems { + // Using information from Linux kernel headers public class FFSPlugin : Filesystem { public FFSPlugin() @@ -60,7 +57,7 @@ namespace DiscImageChef.Filesystems if((2 + partitionStart) >= imagePlugin.GetSectors()) return false; - UInt32 magic; + uint magic; uint sb_size_in_sectors; byte[] ufs_sb_sectors; @@ -122,7 +119,7 @@ namespace DiscImageChef.Filesystems information = ""; StringBuilder sbInformation = new StringBuilder(); - UInt32 magic = 0; + uint magic = 0; uint sb_size_in_sectors; byte[] ufs_sb_sectors; ulong sb_offset = partitionStart; @@ -330,11 +327,11 @@ namespace DiscImageChef.Filesystems ufs_sb.fs_fsmnt_ufs1 = StringHandlers.CToString(strings_b); /// 0x00D4, 512 bytes, name mounted on ufs_sb.fs_cgrotor_ufs1 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x0000); /// 0x02D4 last cg searched ufs_sb.fs_cs_ufs1 = new byte[124]; - Array.Copy(ufs_sb_sectors, 0x02D8, ufs_sb.fs_cs_ufs1, 0, 124); /// 0x02D8, 124 bytes, UInt32s, list of fs_cs info buffers + Array.Copy(ufs_sb_sectors, 0x02D8, ufs_sb.fs_cs_ufs1, 0, 124); /// 0x02D8, 124 bytes, uints, list of fs_cs info buffers ufs_sb.fs_maxcluster_ufs1 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x0354); /// 0x0354 ufs_sb.fs_cpc_ufs1 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x0358); /// 0x0358 cyl per cycle in postbl ufs_sb.fs_opostbl_ufs1 = new byte[256]; - Array.Copy(ufs_sb_sectors, 0x035C, ufs_sb.fs_opostbl_ufs1, 0, 256); /// 0x035C, 256 bytes, [16][8] matrix of UInt16s, old rotation block list head + Array.Copy(ufs_sb_sectors, 0x035C, ufs_sb.fs_opostbl_ufs1, 0, 256); /// 0x035C, 256 bytes, [16][8] matrix of ushorts, old rotation block list head #endregion UFS1 #region UFS2 strings_b = new byte[468]; @@ -347,7 +344,7 @@ namespace DiscImageChef.Filesystems ufs_sb.fs_pad_ufs2 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x02D0); /// 0x02D0 due to alignment of fs_swuid ufs_sb.fs_cgrotor_ufs2 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x02D4); /// 0x02D4 last cg searched ufs_sb.fs_ocsp_ufs2 = new byte[112]; - Array.Copy(ufs_sb_sectors, 0x02D8, ufs_sb.fs_ocsp_ufs2, 0, 112); /// 0x02D8, 112 bytes, UInt32s, list of fs_cs info buffers + Array.Copy(ufs_sb_sectors, 0x02D8, ufs_sb.fs_ocsp_ufs2, 0, 112); /// 0x02D8, 112 bytes, uints, list of fs_cs info buffers ufs_sb.fs_contigdirs_ufs2 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x0348); /// 0x0348 # of contiguously allocated dirs ufs_sb.fs_csp_ufs2 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x034C); /// 0x034C cg summary info buffer for fs_cs ufs_sb.fs_maxcluster_ufs2 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x0350); /// 0x0350 @@ -355,7 +352,7 @@ namespace DiscImageChef.Filesystems ufs_sb.fs_old_cpc_ufs2 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x0358); /// 0x0358 cyl per cycle in postbl ufs_sb.fs_maxbsize_ufs2 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x035C); /// 0x035C maximum blocking factor permitted ufs_sb.fs_sparecon64_ufs2 = new byte[136]; - Array.Copy(ufs_sb_sectors, 0x0360, ufs_sb.fs_sparecon64_ufs2, 0, 136); /// 0x0360, 136 bytes, UInt64s, old rotation block list head + Array.Copy(ufs_sb_sectors, 0x0360, ufs_sb.fs_sparecon64_ufs2, 0, 136); /// 0x0360, 136 bytes, ulongs, old rotation block list head ufs_sb.fs_sblockloc_ufs2 = BigEndianBitConverter.ToUInt64(ufs_sb_sectors, 0x03E8); /// 0x03E8 byte offset of standard superblock //cylinder summary information*/ ufs_sb.fs_cstotal_ndir_ufs2 = BigEndianBitConverter.ToUInt64(ufs_sb_sectors, 0x03F0); /// 0x03F0 number of directories @@ -556,7 +553,7 @@ namespace DiscImageChef.Filesystems } else { - const UInt32 SunOSEpoch = 0x1A54C580; // We are supposing there cannot be a Sun's fs created before 1/1/1982 00:00:00 + const uint SunOSEpoch = 0x1A54C580; // We are supposing there cannot be a Sun's fs created before 1/1/1982 00:00:00 fs_type_43bsd = true; // There is no way of knowing this is the version, but there is of knowing it is not. @@ -623,10 +620,10 @@ namespace DiscImageChef.Filesystems sbInformation.AppendFormat("First data block LBA: {0}", ufs_sb.fs_dblkno).AppendLine(); sbInformation.AppendFormat("Cylinder group offset in cylinder: {0}", ufs_sb.fs_cgoffset).AppendLine(); sbInformation.AppendFormat("Volume last written on {0}", DateHandlers.UNIXUnsignedToDateTime(ufs_sb.fs_time_t)).AppendLine(); - sbInformation.AppendFormat("{0} blocks in volume ({1} bytes)", ufs_sb.fs_size, (ulong)ufs_sb.fs_size * (ulong)1024).AppendLine(); + sbInformation.AppendFormat("{0} blocks in volume ({1} bytes)", ufs_sb.fs_size, ufs_sb.fs_size * 1024L).AppendLine(); xmlFSType.Clusters = ufs_sb.fs_size; xmlFSType.ClusterSize = (int)ufs_sb.fs_bsize; - sbInformation.AppendFormat("{0} data blocks in volume ({1} bytes)", ufs_sb.fs_dsize, (ulong)ufs_sb.fs_dsize * (ulong)1024).AppendLine(); + sbInformation.AppendFormat("{0} data blocks in volume ({1} bytes)", ufs_sb.fs_dsize, ufs_sb.fs_dsize * 1024L).AppendLine(); sbInformation.AppendFormat("{0} cylinder groups in volume", ufs_sb.fs_ncg).AppendLine(); sbInformation.AppendFormat("{0} bytes in a basic block", ufs_sb.fs_bsize).AppendLine(); sbInformation.AppendFormat("{0} bytes in a frag block", ufs_sb.fs_fsize).AppendLine(); @@ -659,7 +656,7 @@ namespace DiscImageChef.Filesystems if(!fs_type_43bsd && ufs_sb.fs_id_1 > 0 && ufs_sb.fs_id_2 > 0) { sbInformation.AppendFormat("Volume ID: 0x{0:X8}{1:X8}", ufs_sb.fs_id_1, ufs_sb.fs_id_2).AppendLine(); - xmlFSType.VolumeSerial = String.Format("{0:X8}{1:x8}", ufs_sb.fs_id_1, ufs_sb.fs_id_2); + xmlFSType.VolumeSerial = string.Format("{0:X8}{1:x8}", ufs_sb.fs_id_1, ufs_sb.fs_id_2); } else if(fs_type_43bsd && ufs_sb.fs_headswitch_43bsd > 0 && ufs_sb.fs_trkseek_43bsd > 0) { @@ -703,7 +700,7 @@ namespace DiscImageChef.Filesystems sbInformation.AppendFormat("Volume name: \"{0}\"", ufs_sb.fs_volname_ufs2).AppendLine(); xmlFSType.VolumeName = ufs_sb.fs_volname_ufs2; sbInformation.AppendFormat("Volume ID: 0x{0:X16}", ufs_sb.fs_swuid_ufs2).AppendLine(); - xmlFSType.VolumeSerial = String.Format("{0:X16}", ufs_sb.fs_swuid_ufs2); + xmlFSType.VolumeSerial = string.Format("{0:X16}", ufs_sb.fs_swuid_ufs2); sbInformation.AppendFormat("Last searched cylinder group: {0}", ufs_sb.fs_cgrotor_ufs2).AppendLine(); sbInformation.AppendFormat("{0} contiguously allocated directories", ufs_sb.fs_contigdirs_ufs2).AppendLine(); sbInformation.AppendFormat("Standard superblock LBA: {0}", ufs_sb.fs_sblockloc_ufs2).AppendLine(); @@ -762,15 +759,15 @@ namespace DiscImageChef.Filesystems // MAGICs // UFS magic - const UInt32 UFS_MAGIC = 0x00011954; + const uint UFS_MAGIC = 0x00011954; // BorderWare UFS - const UInt32 UFS_MAGIC_BW = 0x0f242697; + const uint UFS_MAGIC_BW = 0x0f242697; // UFS2 magic - const UInt32 UFS2_MAGIC = 0x19540119; + const uint UFS2_MAGIC = 0x19540119; // byteswapped - const UInt32 UFS_CIGAM = 0x54190100; + const uint UFS_CIGAM = 0x54190100; // Incomplete newfs - const UInt32 UFS_BAD_MAGIC = 0x19960408; + const uint UFS_BAD_MAGIC = 0x19960408; /// /// On-disk superblock is quite a mixture of all the UFS/FFS variants @@ -784,93 +781,93 @@ namespace DiscImageChef.Filesystems #region 42BSD /// 0x0000 linked list of file systems - public UInt32 fs_link_42bsd; + public uint fs_link_42bsd; #endregion #region Sun /// 0x0000 file system state flag - public UInt32 fs_state_sun; + public uint fs_state_sun; #endregion #region COMMON /// 0x0004 used for incore super blocks - public UInt32 fs_rlink; + public uint fs_rlink; /// 0x0008 addr of super-block in filesys - public UInt32 fs_sblkno; + public uint fs_sblkno; /// 0x000C offset of cyl-block in filesys - public UInt32 fs_cblkno; + public uint fs_cblkno; /// 0x0010 offset of inode-blocks in filesys - public UInt32 fs_iblkno; + public uint fs_iblkno; /// 0x0014 offset of first data after cg - public UInt32 fs_dblkno; + public uint fs_dblkno; /// 0x0018 cylinder group offset in cylinder - public UInt32 fs_cgoffset; + public uint fs_cgoffset; /// 0x001C used to calc mod fs_ntrak - public UInt32 fs_cgmask; + public uint fs_cgmask; /// 0x0020 last time written -- time_t - public UInt32 fs_time_t; + public uint fs_time_t; /// 0x0024 number of blocks in fs - public UInt32 fs_size; + public uint fs_size; /// 0x0028 number of data blocks in fs - public UInt32 fs_dsize; + public uint fs_dsize; /// 0x002C number of cylinder groups - public UInt32 fs_ncg; + public uint fs_ncg; /// 0x0030 size of basic blocks in fs - public UInt32 fs_bsize; + public uint fs_bsize; /// 0x0034 size of frag blocks in fs - public UInt32 fs_fsize; + public uint fs_fsize; /// 0x0038 number of frags in a block in fs - public UInt32 fs_frag; + public uint fs_frag; // these are configuration parameters /// 0x003C minimum percentage of free blocks - public UInt32 fs_minfree; + public uint fs_minfree; /// 0x0040 num of ms for optimal next block - public UInt32 fs_rotdelay; + public uint fs_rotdelay; /// 0x0044 disk revolutions per second - public UInt32 fs_rps; + public uint fs_rps; // these fields can be computed from the others /// 0x0048 ``blkoff'' calc of blk offsets - public UInt32 fs_bmask; + public uint fs_bmask; /// 0x004C ``fragoff'' calc of frag offsets - public UInt32 fs_fmask; + public uint fs_fmask; /// 0x0050 ``lblkno'' calc of logical blkno - public UInt32 fs_bshift; + public uint fs_bshift; /// 0x0054 ``numfrags'' calc number of frags - public UInt32 fs_fshift; + public uint fs_fshift; // these are configuration parameters /// 0x0058 max number of contiguous blks - public UInt32 fs_maxcontig; + public uint fs_maxcontig; /// 0x005C max number of blks per cyl group - public UInt32 fs_maxbpg; + public uint fs_maxbpg; // these fields can be computed from the others /// 0x0060 block to frag shift - public UInt32 fs_fragshift; + public uint fs_fragshift; /// 0x0064 fsbtodb and dbtofsb shift constant - public UInt32 fs_fsbtodb; + public uint fs_fsbtodb; /// 0x0068 actual size of super block - public UInt32 fs_sbsize; + public uint fs_sbsize; /// 0x006C csum block offset - public UInt32 fs_csmask; + public uint fs_csmask; /// 0x0070 csum block number - public UInt32 fs_csshift; + public uint fs_csshift; /// 0x0074 value of NINDIR - public UInt32 fs_nindir; + public uint fs_nindir; /// 0x0078 value of INOPB - public UInt32 fs_inopb; + public uint fs_inopb; /// 0x007C value of NSPF - public UInt32 fs_nspf; + public uint fs_nspf; // yet another configuration parameter /// 0x0080 optimization preference, see below - public UInt32 fs_optim; + public uint fs_optim; #endregion COMMON @@ -879,23 +876,23 @@ namespace DiscImageChef.Filesystems // these fields are derived from the hardware /// 0x0084 # sectors/track including spares - public UInt32 fs_npsect_sun; + public uint fs_npsect_sun; #endregion Sun #region Sunx86 /// 0x0084 file system state time stamp - public UInt32 fs_state_t_sun86; + public uint fs_state_t_sun86; #endregion Sunx86 #region COMMON /// 0x0088 hardware sector interleave - public UInt32 fs_interleave; + public uint fs_interleave; /// 0x008C sector 0 skew, per track - public UInt32 fs_trackskew; + public uint fs_trackskew; #endregion COMMON @@ -908,18 +905,18 @@ namespace DiscImageChef.Filesystems // there could be problems if they are. /// 0x0090 - public UInt32 fs_id_1; + public uint fs_id_1; /// 0x0094 - public UInt32 fs_id_2; + public uint fs_id_2; #endregion COMMON #region 43BSD /// 0x0090 head switch time, usec - public UInt32 fs_headswitch_43bsd; + public uint fs_headswitch_43bsd; /// 0x0094 track-to-track seek, usec - public UInt32 fs_trkseek_43bsd; + public uint fs_trkseek_43bsd; #endregion 43BSD @@ -927,42 +924,42 @@ namespace DiscImageChef.Filesystems // sizes determined by number of cylinder groups and their sizes /// 0x0098 blk addr of cyl grp summary area - public UInt32 fs_csaddr; + public uint fs_csaddr; /// 0x009C size of cyl grp summary area - public UInt32 fs_cssize; + public uint fs_cssize; /// 0x00A0 cylinder group size - public UInt32 fs_cgsize; + public uint fs_cgsize; // these fields are derived from the hardware /// 0x00A4 tracks per cylinder - public UInt32 fs_ntrak; + public uint fs_ntrak; /// 0x00A8 sectors per track - public UInt32 fs_nsect; + public uint fs_nsect; /// 0x00AC sectors per cylinder - public UInt32 fs_spc; + public uint fs_spc; // this comes from the disk driver partitioning /// 0x00B0 cylinders in file system - public UInt32 fs_ncyl; + public uint fs_ncyl; // these fields can be computed from the others /// 0x00B4 cylinders per group - public UInt32 fs_cpg; + public uint fs_cpg; /// 0x00B8 inodes per cylinder group - public UInt32 fs_ipg; + public uint fs_ipg; /// 0x00BC blocks per group * fs_frag - public UInt32 fs_fpg; + public uint fs_fpg; // this data must be re-computed after crashes // struct ufs_csum fs_cstotal; // cylinder summary information /// 0x00C0 number of directories - public UInt32 fs_cstotal_ndir; + public uint fs_cstotal_ndir; /// 0x00C4 number of free blocks - public UInt32 fs_cstotal_nbfree; + public uint fs_cstotal_nbfree; /// 0x00C8 number of free inodes - public UInt32 fs_cstotal_nifree; + public uint fs_cstotal_nifree; /// 0x00CC number of free frags - public UInt32 fs_cstotal_nffree; + public uint fs_cstotal_nffree; // these fields are cleared at mount time /// 0x00D0 super block modified flag @@ -981,14 +978,14 @@ namespace DiscImageChef.Filesystems /// 0x00D4, 512 bytes, name mounted on public string fs_fsmnt_ufs1; /// 0x02D4 last cg searched - public UInt32 fs_cgrotor_ufs1; - /// 0x02D8, 124 bytes, UInt32s, list of fs_cs info buffers + public uint fs_cgrotor_ufs1; + /// 0x02D8, 124 bytes, uints, list of fs_cs info buffers public byte[] fs_cs_ufs1; /// 0x0354 - public UInt32 fs_maxcluster_ufs1; + public uint fs_maxcluster_ufs1; /// 0x0358 cyl per cycle in postbl - public UInt32 fs_cpc_ufs1; - /// 0x035C, 256 bytes, [16][8] matrix of UInt16s, old rotation block list head + public uint fs_cpc_ufs1; + /// 0x035C, 256 bytes, [16][8] matrix of ushorts, old rotation block list head public byte[] fs_opostbl_ufs1; #endregion UFS1 @@ -1000,60 +997,60 @@ namespace DiscImageChef.Filesystems /// 0x02A8, 32 bytes, volume name public string fs_volname_ufs2; /// 0x02C8 system-wide uid - public UInt64 fs_swuid_ufs2; + public ulong fs_swuid_ufs2; /// 0x02D0 due to alignment of fs_swuid - public UInt32 fs_pad_ufs2; + public uint fs_pad_ufs2; /// 0x02D4 last cg searched - public UInt32 fs_cgrotor_ufs2; - /// 0x02D8, 112 bytes, UInt32s, list of fs_cs info buffers + public uint fs_cgrotor_ufs2; + /// 0x02D8, 112 bytes, uints, list of fs_cs info buffers public byte[] fs_ocsp_ufs2; /// 0x0348 # of contiguously allocated dirs - public UInt32 fs_contigdirs_ufs2; + public uint fs_contigdirs_ufs2; /// 0x034C cg summary info buffer for fs_cs - public UInt32 fs_csp_ufs2; + public uint fs_csp_ufs2; /// 0x0350 - public UInt32 fs_maxcluster_ufs2; + public uint fs_maxcluster_ufs2; /// 0x0354 used by snapshots to track fs - public UInt32 fs_active_ufs2; + public uint fs_active_ufs2; /// 0x0358 cyl per cycle in postbl - public UInt32 fs_old_cpc_ufs2; + public uint fs_old_cpc_ufs2; /// 0x035C maximum blocking factor permitted - public UInt32 fs_maxbsize_ufs2; - /// 0x0360, 136 bytes, UInt64s, old rotation block list head + public uint fs_maxbsize_ufs2; + /// 0x0360, 136 bytes, ulongs, old rotation block list head public byte[] fs_sparecon64_ufs2; /// 0x03E8 byte offset of standard superblock - public UInt64 fs_sblockloc_ufs2; + public ulong fs_sblockloc_ufs2; /// 0x03F0 number of directories - public UInt64 fs_cstotal_ndir_ufs2; + public ulong fs_cstotal_ndir_ufs2; /// 0x03F8 number of free blocks - public UInt64 fs_cstotal_nbfree_ufs2; + public ulong fs_cstotal_nbfree_ufs2; /// 0x0400 number of free inodes - public UInt64 fs_cstotal_nifree_ufs2; + public ulong fs_cstotal_nifree_ufs2; /// 0x0408 number of free frags - public UInt64 fs_cstotal_nffree_ufs2; + public ulong fs_cstotal_nffree_ufs2; /// 0x0410 number of free clusters - public UInt64 fs_cstotal_numclusters_ufs2; + public ulong fs_cstotal_numclusters_ufs2; /// 0x0418 future expansion - public UInt64 fs_cstotal_spare0_ufs2; + public ulong fs_cstotal_spare0_ufs2; /// 0x0420 future expansion - public UInt64 fs_cstotal_spare1_ufs2; + public ulong fs_cstotal_spare1_ufs2; /// 0x0428 future expansion - public UInt64 fs_cstotal_spare2_ufs2; + public ulong fs_cstotal_spare2_ufs2; /// 0x0430 last time written - public UInt32 fs_time_sec_ufs2; + public uint fs_time_sec_ufs2; /// 0x0434 last time written - public UInt32 fs_time_usec_ufs2; + public uint fs_time_usec_ufs2; /// 0x0438 number of blocks in fs - public UInt64 fs_size_ufs2; + public ulong fs_size_ufs2; /// 0x0440 number of data blocks in fs - public UInt64 fs_dsize_ufs2; + public ulong fs_dsize_ufs2; /// 0x0448 blk addr of cyl grp summary area - public UInt64 fs_csaddr_ufs2; + public ulong fs_csaddr_ufs2; /// 0x0450 blocks in process of being freed - public UInt64 fs_pendingblocks_ufs2; + public ulong fs_pendingblocks_ufs2; /// 0x0458 inodes in process of being freed - public UInt32 fs_pendinginodes_ufs2; + public uint fs_pendinginodes_ufs2; #endregion UFS2 @@ -1062,19 +1059,19 @@ namespace DiscImageChef.Filesystems /// 0x045C, 212 bytes, reserved for future constants public byte[] fs_sparecon_sun; /// 0x0530 - public UInt32 fs_reclaim_sun; + public uint fs_reclaim_sun; /// 0x0534 - public UInt32 fs_sparecon2_sun; + public uint fs_sparecon2_sun; /// 0x0538 file system state time stamp - public UInt32 fs_state_t_sun; + public uint fs_state_t_sun; /// 0x053C ~usb_bmask - public UInt32 fs_qbmask0_sun; + public uint fs_qbmask0_sun; /// 0x0540 ~usb_bmask - public UInt32 fs_qbmask1_sun; + public uint fs_qbmask1_sun; /// 0x0544 ~usb_fmask - public UInt32 fs_qfmask0_sun; + public uint fs_qfmask0_sun; /// 0x0548 ~usb_fmask - public UInt32 fs_qfmask1_sun; + public uint fs_qfmask1_sun; #endregion Sun @@ -1083,19 +1080,19 @@ namespace DiscImageChef.Filesystems /// 0x045C, 212 bytes, reserved for future constants public byte[] fs_sparecon_sun86; /// 0x0530 - public UInt32 fs_reclaim_sun86; + public uint fs_reclaim_sun86; /// 0x0534 - public UInt32 fs_sparecon2_sun86; + public uint fs_sparecon2_sun86; /// 0x0538 # sectors/track including spares - public UInt32 fs_npsect_sun86; + public uint fs_npsect_sun86; /// 0x053C ~usb_bmask - public UInt32 fs_qbmask0_sun86; + public uint fs_qbmask0_sun86; /// 0x0540 ~usb_bmask - public UInt32 fs_qbmask1_sun86; + public uint fs_qbmask1_sun86; /// 0x0544 ~usb_fmask - public UInt32 fs_qfmask0_sun86; + public uint fs_qfmask0_sun86; /// 0x0548 ~usb_fmask - public UInt32 fs_qfmask1_sun86; + public uint fs_qfmask1_sun86; #endregion Sunx86 @@ -1104,38 +1101,38 @@ namespace DiscImageChef.Filesystems /// 0x045C, 200 bytes public byte[] fs_sparecon_44bsd; /// 0x0524 size of cluster summary array - public UInt32 fs_contigsumsize_44bsd; + public uint fs_contigsumsize_44bsd; /// 0x0528 max length of an internal symlink - public UInt32 fs_maxsymlinklen_44bsd; + public uint fs_maxsymlinklen_44bsd; /// 0x052C format of on-disk inodes - public UInt32 fs_inodefmt_44bsd; + public uint fs_inodefmt_44bsd; /// 0x0530 max representable file size - public UInt32 fs_maxfilesize0_44bsd; + public uint fs_maxfilesize0_44bsd; /// 0x0534 max representable file size - public UInt32 fs_maxfilesize1_44bsd; + public uint fs_maxfilesize1_44bsd; /// 0x0538 ~usb_bmask - public UInt32 fs_qbmask0_44bsd; + public uint fs_qbmask0_44bsd; /// 0x053C ~usb_bmask - public UInt32 fs_qbmask1_44bsd; + public uint fs_qbmask1_44bsd; /// 0x0540 ~usb_fmask - public UInt32 fs_qfmask0_44bsd; + public uint fs_qfmask0_44bsd; /// 0x0544 ~usb_fmask - public UInt32 fs_qfmask1_44bsd; + public uint fs_qfmask1_44bsd; /// 0x0548 file system state time stamp - public UInt32 fs_state_t_44bsd; + public uint fs_state_t_44bsd; #endregion 44BSD /// 0x054C format of positional layout tables - public UInt32 fs_postblformat; + public uint fs_postblformat; /// 0x0550 number of rotational positions - public UInt32 fs_nrpos; + public uint fs_nrpos; /// 0x0554 (__s16) rotation block list head - public UInt32 fs_postbloff; + public uint fs_postbloff; /// 0x0558 (__u8) blocks for each rotation - public UInt32 fs_rotbloff; + public uint fs_rotbloff; /// 0x055C magic number - public UInt32 fs_magic; + public uint fs_magic; /// 0x0560 list of blocks for each rotation public byte fs_space; // 0x0561 diff --git a/DiscImageChef.Filesystems/Filesystem.cs b/DiscImageChef.Filesystems/Filesystem.cs index 566edb20..a1575ed4 100644 --- a/DiscImageChef.Filesystems/Filesystem.cs +++ b/DiscImageChef.Filesystems/Filesystem.cs @@ -101,7 +101,7 @@ namespace DiscImageChef.Filesystems public abstract Errno Mount(bool debug); /// - /// Frees all internal structures created by + /// Frees all internal structures created by /// public abstract Errno Unmount(); diff --git a/DiscImageChef.Filesystems/HPFS.cs b/DiscImageChef.Filesystems/HPFS.cs index c13106d0..927d70d1 100644 --- a/DiscImageChef.Filesystems/HPFS.cs +++ b/DiscImageChef.Filesystems/HPFS.cs @@ -32,12 +32,11 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; -// Information from an old unnamed document namespace DiscImageChef.Filesystems { + // Information from an old unnamed document class HPFS : Filesystem { public HPFS() @@ -57,7 +56,7 @@ namespace DiscImageChef.Filesystems if((2 + partitionStart) >= imagePlugin.GetSectors()) return false; - UInt32 magic1, magic2; + uint magic1, magic2; byte[] hpfs_sb_sector = imagePlugin.ReadSector(16 + partitionStart); // Seek to superblock, on logical sector 16 magic1 = BitConverter.ToUInt32(hpfs_sb_sector, 0x000); @@ -254,7 +253,7 @@ namespace DiscImageChef.Filesystems xmlFSType.ClusterSize = hpfs_bpb.bps * hpfs_bpb.spc; xmlFSType.Type = "HPFS"; xmlFSType.VolumeName = hpfs_bpb.volume_label; - xmlFSType.VolumeSerial = String.Format("{0:X8}", hpfs_bpb.serial_no); + xmlFSType.VolumeSerial = string.Format("{0:X8}", hpfs_bpb.serial_no); information = sb.ToString(); } @@ -267,33 +266,33 @@ namespace DiscImageChef.Filesystems /// 0x000, Jump to boot code public byte jmp1; /// 0x001, ...; - public UInt16 jmp2; + public ushort jmp2; /// 0x003, OEM Name, 8 bytes, space-padded public string OEMName; /// 0x00B, Bytes per sector - public UInt16 bps; + public ushort bps; /// 0x00D, Sectors per cluster public byte spc; /// 0x00E, Reserved sectors between BPB and... does it have sense in HPFS? - public UInt16 rsectors; + public ushort rsectors; /// 0x010, Number of FATs... seriously? public byte fats_no; /// 0x011, Number of entries on root directory... ok - public UInt16 root_ent; + public ushort root_ent; /// 0x013, Sectors in volume... doubt it - public UInt16 sectors; + public ushort sectors; /// 0x015, Media descriptor public byte media; /// 0x016, Sectors per FAT... again - public UInt16 spfat; + public ushort spfat; /// 0x018, Sectors per track... you're kidding - public UInt16 sptrk; + public ushort sptrk; /// 0x01A, Heads... stop! - public UInt16 heads; + public ushort heads; /// 0x01C, Hidden sectors before BPB - public UInt32 hsectors; + public uint hsectors; /// 0x024, Sectors in volume if > 65535... - public UInt32 big_sectors; + public uint big_sectors; /// 0x028, Drive number public byte drive_no; /// 0x029, Volume flags? @@ -301,7 +300,7 @@ namespace DiscImageChef.Filesystems /// 0x02A, EPB signature, 0x29 public byte signature; /// 0x02B, Volume serial number - public UInt32 serial_no; + public uint serial_no; /// 0x02F, Volume label, 11 bytes, space-padded public string volume_label; /// 0x03A, Filesystem type, 8 bytes, space-padded ("HPFS ") @@ -314,51 +313,51 @@ namespace DiscImageChef.Filesystems struct HPFS_SuperBlock { /// 0x000, 0xF995E849 - public UInt32 magic1; + public uint magic1; /// 0x004, 0xFA53E9C5 - public UInt32 magic2; + public uint magic2; /// 0x008, HPFS version public byte version; /// 0x009, 2 if <= 4 GiB, 3 if > 4 GiB public byte func_version; /// 0x00A, Alignment - public UInt16 dummy; + public ushort dummy; /// 0x00C, LSN pointer to root fnode - public UInt32 root_fnode; + public uint root_fnode; /// 0x010, Sectors on volume - public UInt32 sectors; + public uint sectors; /// 0x014, Bad blocks on volume - public UInt32 badblocks; + public uint badblocks; /// 0x018, LSN pointer to volume bitmap - public UInt32 bitmap_lsn; + public uint bitmap_lsn; /// 0x01C, 0 - public UInt32 zero1; + public uint zero1; /// 0x020, LSN pointer to badblock directory - public UInt32 badblock_lsn; + public uint badblock_lsn; /// 0x024, 0 - public UInt32 zero2; + public uint zero2; /// 0x028, Time of last CHKDSK - public Int32 last_chkdsk; + public int last_chkdsk; /// 0x02C, Time of last optimization - public Int32 last_optim; + public int last_optim; /// 0x030, Sectors of dir band - public UInt32 dband_sectors; + public uint dband_sectors; /// 0x034, Start sector of dir band - public UInt32 dband_start; + public uint dband_start; /// 0x038, Last sector of dir band - public UInt32 dband_last; + public uint dband_last; /// 0x03C, LSN of free space bitmap - public UInt32 dband_bitmap; + public uint dband_bitmap; /// 0x040, Can be used for volume name (32 bytes) - public UInt64 zero3; + public ulong zero3; /// 0x048, ... - public UInt64 zero4; + public ulong zero4; /// 0x04C, ... - public UInt64 zero5; + public ulong zero5; /// 0x050, ...; - public UInt64 zero6; + public ulong zero6; /// 0x058, LSN pointer to ACLs (only HPFS386) - public UInt32 acl_start; + public uint acl_start; } /// @@ -367,33 +366,33 @@ namespace DiscImageChef.Filesystems struct HPFS_SpareBlock { /// 0x000, 0xF9911849 - public UInt32 magic1; + public uint magic1; /// 0x004, 0xFA5229C5 - public UInt32 magic2; + public uint magic2; /// 0x008, HPFS flags public byte flags1; /// 0x009, HPFS386 flags public byte flags2; /// 0x00A, Alignment - public UInt16 dummy; + public ushort dummy; /// 0x00C, LSN of hotfix directory - public UInt32 hotfix_start; + public uint hotfix_start; /// 0x010, Used hotfixes - public UInt32 hotfix_used; + public uint hotfix_used; /// 0x014, Total hotfixes available - public UInt32 hotfix_entries; + public uint hotfix_entries; /// 0x018, Unused spare dnodes - public UInt32 spare_dnodes_free; + public uint spare_dnodes_free; /// 0x01C, Length of spare dnodes list - public UInt32 spare_dnodes; + public uint spare_dnodes; /// 0x020, LSN of codepage directory - public UInt32 codepage_lsn; + public uint codepage_lsn; /// 0x024, Number of codepages used - public UInt32 codepages; + public uint codepages; /// 0x028, SuperBlock CRC32 (only HPFS386) - public UInt32 sb_crc32; + public uint sb_crc32; /// 0x02C, SpareBlock CRC32 (only HPFS386) - public UInt32 sp_crc32; + public uint sp_crc32; } public override Errno Mount() diff --git a/DiscImageChef.Filesystems/ISO9660.cs b/DiscImageChef.Filesystems/ISO9660.cs index 2ff738dc..32913463 100644 --- a/DiscImageChef.Filesystems/ISO9660.cs +++ b/DiscImageChef.Filesystems/ISO9660.cs @@ -33,18 +33,16 @@ using System; using System.Globalization; using System.Text; -using DiscImageChef; using System.Collections.Generic; - -// This is coded following ECMA-119. -// TODO: Differentiate ISO Level 1, 2, 3 and ISO 9660:1999 -// TODO: Apple extensiones, requires XA or advance RR interpretation. -// TODO: Needs a major rewrite using DiscImageChef.Console; namespace DiscImageChef.Filesystems { + // This is coded following ECMA-119. + // TODO: Differentiate ISO Level 1, 2, 3 and ISO 9660:1999 + // TODO: Apple extensiones, requires XA or advance RR interpretation. + // TODO: Needs a major rewrite class ISO9660Plugin : Filesystem { //static bool alreadyLaunched; @@ -440,7 +438,9 @@ namespace DiscImageChef.Filesystems { ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(release_date2), "yyyy.MMM", provider); } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch { } +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } /* diff --git a/DiscImageChef.Filesystems/LisaFS/Consts.cs b/DiscImageChef.Filesystems/LisaFS/Consts.cs index d2c9fb9f..2d0ab3c2 100644 --- a/DiscImageChef.Filesystems/LisaFS/Consts.cs +++ b/DiscImageChef.Filesystems/LisaFS/Consts.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Filesystems.LisaFS { partial class LisaFS : Filesystem @@ -41,18 +39,18 @@ namespace DiscImageChef.Filesystems.LisaFS const byte LisaFSv3 = 0x11; /// Maximum string size in LisaFS const uint E_NAME = 32; - const UInt16 FILEID_FREE = 0x0000; - const UInt16 FILEID_BOOT = 0xAAAA; - const UInt16 FILEID_LOADER = 0xBBBB; - const UInt16 FILEID_MDDF = 0x0001; - const UInt16 FILEID_BITMAP = 0x0002; - const UInt16 FILEID_SRECORD = 0x0003; + const ushort FILEID_FREE = 0x0000; + const ushort FILEID_BOOT = 0xAAAA; + const ushort FILEID_LOADER = 0xBBBB; + const ushort FILEID_MDDF = 0x0001; + const ushort FILEID_BITMAP = 0x0002; + const ushort FILEID_SRECORD = 0x0003; /// "Catalog file" - const UInt16 FILEID_DIRECTORY = 0x0004; - const Int16 FILEID_BOOT_SIGNED = -21846; - const Int16 FILEID_LOADER_SIGNED = -17477; - const UInt16 FILEID_ERASED = 0x7FFF; - const UInt16 FILEID_MAX = FILEID_ERASED; + const ushort FILEID_DIRECTORY = 0x0004; + const short FILEID_BOOT_SIGNED = -21846; + const short FILEID_LOADER_SIGNED = -17477; + const ushort FILEID_ERASED = 0x7FFF; + const ushort FILEID_MAX = FILEID_ERASED; enum FileType : byte { diff --git a/DiscImageChef.Filesystems/LisaFS/Dir.cs b/DiscImageChef.Filesystems/LisaFS/Dir.cs index 7e3ed4a4..a0fb5a92 100644 --- a/DiscImageChef.Filesystems/LisaFS/Dir.cs +++ b/DiscImageChef.Filesystems/LisaFS/Dir.cs @@ -46,7 +46,7 @@ namespace DiscImageChef.Filesystems.LisaFS public override Errno ReadDir(string path, ref List contents) { - Int16 fileId; + short fileId; bool isDir; Errno error = LookupFileId(path, out fileId, out isDir); if(error != Errno.NoError) @@ -75,7 +75,7 @@ namespace DiscImageChef.Filesystems.LisaFS return Errno.NoError; } - Errno ReadCatalog(Int16 fileId, out List catalog) + Errno ReadCatalog(short fileId, out List catalog) { catalog = null; diff --git a/DiscImageChef.Filesystems/LisaFS/Encoding.cs b/DiscImageChef.Filesystems/LisaFS/Encoding.cs index 03d13038..ede61d05 100644 --- a/DiscImageChef.Filesystems/LisaFS/Encoding.cs +++ b/DiscImageChef.Filesystems/LisaFS/Encoding.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; namespace DiscImageChef.Filesystems.LisaFS { partial class LisaFS : Filesystem diff --git a/DiscImageChef.Filesystems/LisaFS/Extent.cs b/DiscImageChef.Filesystems/LisaFS/Extent.cs index 6671dbef..0a35d550 100644 --- a/DiscImageChef.Filesystems/LisaFS/Extent.cs +++ b/DiscImageChef.Filesystems/LisaFS/Extent.cs @@ -50,7 +50,7 @@ namespace DiscImageChef.Filesystems.LisaFS /// Error. /// File identifier. /// Extents file. - Errno ReadExtentsFile(Int16 fileId, out ExtentFile file) + Errno ReadExtentsFile(short fileId, out ExtentFile file) { file = new ExtentFile(); diff --git a/DiscImageChef.Filesystems/LisaFS/File.cs b/DiscImageChef.Filesystems/LisaFS/File.cs index 7d98fbc2..b374d968 100644 --- a/DiscImageChef.Filesystems/LisaFS/File.cs +++ b/DiscImageChef.Filesystems/LisaFS/File.cs @@ -31,12 +31,9 @@ // ****************************************************************************/ using System; -using System.Diagnostics; using DiscImageChef.ImagePlugins; -using System.Runtime.InteropServices; using System.Collections.Generic; using DiscImageChef.Console; -using System.IO; namespace DiscImageChef.Filesystems.LisaFS { @@ -44,7 +41,7 @@ namespace DiscImageChef.Filesystems.LisaFS { public override Errno GetAttributes(string path, ref FileAttributes attributes) { - Int16 fileId; + short fileId; Errno error = LookupFileId(path, out fileId); if(error != Errno.NoError) return error; @@ -62,8 +59,8 @@ namespace DiscImageChef.Filesystems.LisaFS if(offset < 0) return Errno.InvalidArgument; - - Int16 fileId; + + short fileId; bool isDir; Errno error = LookupFileId(path, out fileId, out isDir); if(error != Errno.NoError) @@ -106,7 +103,7 @@ namespace DiscImageChef.Filesystems.LisaFS public override Errno Stat(string path, ref FileEntryInfo stat) { - Int16 fileId; + short fileId; Errno error = LookupFileId(path, out fileId); if(error != Errno.NoError) return error; @@ -114,7 +111,7 @@ namespace DiscImageChef.Filesystems.LisaFS return Stat(fileId, out stat); } - Errno GetAttributes(Int16 fileId, ref FileAttributes attributes) + Errno GetAttributes(short fileId, ref FileAttributes attributes) { if(!mounted) return Errno.AccessDenied; @@ -177,12 +174,12 @@ namespace DiscImageChef.Filesystems.LisaFS return Errno.NoError; } - Errno ReadSystemFile(Int16 fileId, out byte[] buf) + Errno ReadSystemFile(short fileId, out byte[] buf) { return ReadSystemFile(fileId, out buf, false); } - Errno ReadSystemFile(Int16 fileId, out byte[] buf, bool tags) + Errno ReadSystemFile(short fileId, out byte[] buf, bool tags) { buf = null; if(!mounted || !debug) @@ -261,7 +258,7 @@ namespace DiscImageChef.Filesystems.LisaFS return Errno.NoError; } - Errno Stat(Int16 fileId, out FileEntryInfo stat) + Errno Stat(short fileId, out FileEntryInfo stat) { stat = null; @@ -372,12 +369,12 @@ namespace DiscImageChef.Filesystems.LisaFS return Errno.NoError; } - Errno ReadFile(Int16 fileId, out byte[] buf) + Errno ReadFile(short fileId, out byte[] buf) { return ReadFile(fileId, out buf, false); } - Errno ReadFile(Int16 fileId, out byte[] buf, bool tags) + Errno ReadFile(short fileId, out byte[] buf, bool tags) { buf = null; if(!mounted) @@ -438,13 +435,13 @@ namespace DiscImageChef.Filesystems.LisaFS return Errno.NoError; } - Errno LookupFileId(string path, out Int16 fileId) + Errno LookupFileId(string path, out short fileId) { bool temp; return LookupFileId(path, out fileId, out temp); } - Errno LookupFileId(string path, out Int16 fileId, out bool isDir) + Errno LookupFileId(string path, out short fileId, out bool isDir) { fileId = 0; isDir = false; @@ -467,37 +464,37 @@ namespace DiscImageChef.Filesystems.LisaFS if(debug) { - if(String.Compare(pathElements[0], "$MDDF", StringComparison.InvariantCulture) == 0) + if(string.Compare(pathElements[0], "$MDDF", StringComparison.InvariantCulture) == 0) { fileId = (short)FILEID_MDDF; return Errno.NoError; } - if(String.Compare(pathElements[0], "$Boot", StringComparison.InvariantCulture) == 0) + if(string.Compare(pathElements[0], "$Boot", StringComparison.InvariantCulture) == 0) { fileId = FILEID_BOOT_SIGNED; return Errno.NoError; } - if(String.Compare(pathElements[0], "$Loader", StringComparison.InvariantCulture) == 0) + if(string.Compare(pathElements[0], "$Loader", StringComparison.InvariantCulture) == 0) { fileId = FILEID_LOADER_SIGNED; return Errno.NoError; } - if(String.Compare(pathElements[0], "$Bitmap", StringComparison.InvariantCulture) == 0) + if(string.Compare(pathElements[0], "$Bitmap", StringComparison.InvariantCulture) == 0) { fileId = (short)FILEID_BITMAP; return Errno.NoError; } - if(String.Compare(pathElements[0], "$S-Record", StringComparison.InvariantCulture) == 0) + if(string.Compare(pathElements[0], "$S-Record", StringComparison.InvariantCulture) == 0) { fileId = (short)FILEID_SRECORD; return Errno.NoError; } - if(String.Compare(pathElements[0], "$", StringComparison.InvariantCulture) == 0) + if(string.Compare(pathElements[0], "$", StringComparison.InvariantCulture) == 0) { fileId = (short)FILEID_DIRECTORY; isDir = true; @@ -517,7 +514,7 @@ namespace DiscImageChef.Filesystems.LisaFS { string filename = GetString(entry.filename); // Should they be case sensitive? - if(String.Compare(wantedFilename, filename, StringComparison.InvariantCultureIgnoreCase) == 0) + if(string.Compare(wantedFilename, filename, StringComparison.InvariantCultureIgnoreCase) == 0) { fileId = entry.fileID; isDir |= entry.fileType != 0x03; diff --git a/DiscImageChef.Filesystems/LisaFS/Info.cs b/DiscImageChef.Filesystems/LisaFS/Info.cs index 518d6094..af126642 100644 --- a/DiscImageChef.Filesystems/LisaFS/Info.cs +++ b/DiscImageChef.Filesystems/LisaFS/Info.cs @@ -30,48 +30,10 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -// /*************************************************************************** -// The Disc Image Chef -// ---------------------------------------------------------------------------- -// -// Filename : Info.cs -// Version : 1.0 -// Author(s) : Natalia Portillo -// -// Component : Component -// -// Revision : $Revision$ -// Last change by : $Author$ -// Date : $Date$ -// -// --[ Description ] ---------------------------------------------------------- -// -// Description -// -// --[ 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. -// -// ---------------------------------------------------------------------------- -// Copyright (C) 2011-2015 Claunia.com -// ****************************************************************************/ -// //$Id$ using System; using System.Text; using DiscImageChef.Console; using DiscImageChef.ImagePlugins; -using System.Runtime.InteropServices; namespace DiscImageChef.Filesystems.LisaFS { @@ -110,44 +72,44 @@ namespace DiscImageChef.Filesystems.LisaFS if(searchTag.fileID == FILEID_MDDF) { byte[] sector = imagePlugin.ReadSector((ulong)i); - MDDF mddf = new MDDF(); + MDDF info_mddf = new MDDF(); - mddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C); - mddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70); - mddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74); - mddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78); - mddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C); - mddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E); + info_mddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C); + info_mddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70); + info_mddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74); + info_mddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78); + info_mddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C); + info_mddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E); DicConsole.DebugWriteLine("LisaFS plugin", "Current sector = {0}", i); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.mddf_block = {0}", mddf.mddf_block); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.mddf_block = {0}", info_mddf.mddf_block); DicConsole.DebugWriteLine("LisaFS plugin", "Disk size = {0} sectors", imagePlugin.GetSectors()); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size = {0} sectors", mddf.vol_size); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - 1 = {0}", mddf.volsize_minus_one); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - mddf.mddf_block -1 = {0}", mddf.volsize_minus_mddf_minus_one); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size = {0} sectors", info_mddf.vol_size); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - 1 = {0}", info_mddf.volsize_minus_one); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.vol_size - mddf.mddf_block -1 = {0}", info_mddf.volsize_minus_mddf_minus_one); DicConsole.DebugWriteLine("LisaFS plugin", "Disk sector = {0} bytes", imagePlugin.GetSectorSize()); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.blocksize = {0} bytes", mddf.blocksize); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.datasize = {0} bytes", mddf.datasize); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.blocksize = {0} bytes", info_mddf.blocksize); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.datasize = {0} bytes", info_mddf.datasize); - if(mddf.mddf_block != i - before_mddf) + if(info_mddf.mddf_block != i - before_mddf) return false; - if(mddf.vol_size > imagePlugin.GetSectors()) + if(info_mddf.vol_size > imagePlugin.GetSectors()) return false; - if(mddf.vol_size - 1 != mddf.volsize_minus_one) + if(info_mddf.vol_size - 1 != info_mddf.volsize_minus_one) return false; - if(mddf.vol_size - i - 1 != mddf.volsize_minus_mddf_minus_one - before_mddf) + if(info_mddf.vol_size - i - 1 != info_mddf.volsize_minus_mddf_minus_one - before_mddf) return false; - if(mddf.datasize > mddf.blocksize) + if(info_mddf.datasize > info_mddf.blocksize) return false; - if(mddf.blocksize < imagePlugin.GetSectorSize()) + if(info_mddf.blocksize < imagePlugin.GetSectorSize()) return false; - if(mddf.datasize != imagePlugin.GetSectorSize()) + if(info_mddf.datasize != imagePlugin.GetSectorSize()) return false; return true; @@ -199,153 +161,153 @@ namespace DiscImageChef.Filesystems.LisaFS if(searchTag.fileID == FILEID_MDDF) { byte[] sector = imagePlugin.ReadSector((ulong)i); - MDDF mddf = new MDDF(); + MDDF info_mddf = new MDDF(); byte[] pString = new byte[33]; - UInt32 lisa_time; + uint lisa_time; - mddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00); - mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02); - mddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A); + info_mddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00); + info_mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02); + info_mddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A); Array.Copy(sector, 0x0C, pString, 0, 33); - mddf.volname = GetStringFromPascal(pString); - mddf.unknown1 = sector[0x2D]; + info_mddf.volname = GetStringFromPascal(pString); + info_mddf.unknown1 = sector[0x2D]; Array.Copy(sector, 0x2E, pString, 0, 33); // Prevent garbage if(pString[0] <= 32) - mddf.password = GetStringFromPascal(pString); + info_mddf.password = GetStringFromPascal(pString); else - mddf.password = ""; - mddf.unknown2 = sector[0x4F]; - mddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50); - mddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54); + info_mddf.password = ""; + info_mddf.unknown2 = sector[0x4F]; + info_mddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50); + info_mddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54); lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x58); - mddf.dtvc = DateHandlers.LisaToDateTime(lisa_time); + info_mddf.dtvc = DateHandlers.LisaToDateTime(lisa_time); lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x5C); - mddf.dtcc = DateHandlers.LisaToDateTime(lisa_time); + info_mddf.dtcc = DateHandlers.LisaToDateTime(lisa_time); lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x60); - mddf.dtvb = DateHandlers.LisaToDateTime(lisa_time); + info_mddf.dtvb = DateHandlers.LisaToDateTime(lisa_time); lisa_time = BigEndianBitConverter.ToUInt32(sector, 0x64); - mddf.dtvs = DateHandlers.LisaToDateTime(lisa_time); - mddf.unknown3 = BigEndianBitConverter.ToUInt32(sector, 0x68); - mddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C); - mddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70); - mddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74); - mddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78); - mddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C); - mddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E); - mddf.unknown4 = BigEndianBitConverter.ToUInt16(sector, 0x80); - mddf.unknown5 = BigEndianBitConverter.ToUInt32(sector, 0x82); - mddf.unknown6 = BigEndianBitConverter.ToUInt32(sector, 0x86); - mddf.clustersize = BigEndianBitConverter.ToUInt16(sector, 0x8A); - mddf.fs_size = BigEndianBitConverter.ToUInt32(sector, 0x8C); - mddf.unknown7 = BigEndianBitConverter.ToUInt32(sector, 0x90); - mddf.srec_ptr = BigEndianBitConverter.ToUInt32(sector, 0x94); - mddf.unknown9 = BigEndianBitConverter.ToUInt16(sector, 0x98); - mddf.srec_len = BigEndianBitConverter.ToUInt16(sector, 0x9A); - mddf.unknown10 = BigEndianBitConverter.ToUInt32(sector, 0x9C); - mddf.unknown11 = BigEndianBitConverter.ToUInt32(sector, 0xA0); - mddf.unknown12 = BigEndianBitConverter.ToUInt32(sector, 0xA4); - mddf.unknown13 = BigEndianBitConverter.ToUInt32(sector, 0xA8); - mddf.unknown14 = BigEndianBitConverter.ToUInt32(sector, 0xAC); - mddf.filecount = BigEndianBitConverter.ToUInt16(sector, 0xB0); - mddf.unknown15 = BigEndianBitConverter.ToUInt32(sector, 0xB2); - mddf.unknown16 = BigEndianBitConverter.ToUInt32(sector, 0xB6); - mddf.freecount = BigEndianBitConverter.ToUInt32(sector, 0xBA); - mddf.unknown17 = BigEndianBitConverter.ToUInt16(sector, 0xBE); - mddf.unknown18 = BigEndianBitConverter.ToUInt32(sector, 0xC0); - mddf.overmount_stamp = BigEndianBitConverter.ToUInt64(sector, 0xC4); - mddf.serialization = BigEndianBitConverter.ToUInt32(sector, 0xCC); - mddf.unknown19 = BigEndianBitConverter.ToUInt32(sector, 0xD0); - mddf.unknown_timestamp = BigEndianBitConverter.ToUInt32(sector, 0xD4); - mddf.unknown20 = BigEndianBitConverter.ToUInt32(sector, 0xD8); - mddf.unknown21 = BigEndianBitConverter.ToUInt32(sector, 0xDC); - mddf.unknown22 = BigEndianBitConverter.ToUInt32(sector, 0xE0); - mddf.unknown23 = BigEndianBitConverter.ToUInt32(sector, 0xE4); - mddf.unknown24 = BigEndianBitConverter.ToUInt32(sector, 0xE8); - mddf.unknown25 = BigEndianBitConverter.ToUInt32(sector, 0xEC); - mddf.unknown26 = BigEndianBitConverter.ToUInt32(sector, 0xF0); - mddf.unknown27 = BigEndianBitConverter.ToUInt32(sector, 0xF4); - mddf.unknown28 = BigEndianBitConverter.ToUInt32(sector, 0xF8); - mddf.unknown29 = BigEndianBitConverter.ToUInt32(sector, 0xFC); - mddf.unknown30 = BigEndianBitConverter.ToUInt32(sector, 0x100); - mddf.unknown31 = BigEndianBitConverter.ToUInt32(sector, 0x104); - mddf.unknown32 = BigEndianBitConverter.ToUInt32(sector, 0x108); - mddf.unknown33 = BigEndianBitConverter.ToUInt32(sector, 0x10C); - mddf.unknown34 = BigEndianBitConverter.ToUInt32(sector, 0x110); - mddf.unknown35 = BigEndianBitConverter.ToUInt32(sector, 0x114); - mddf.backup_volid = BigEndianBitConverter.ToUInt64(sector, 0x118); - mddf.label_size = BigEndianBitConverter.ToUInt16(sector, 0x120); - mddf.fs_overhead = BigEndianBitConverter.ToUInt16(sector, 0x122); - mddf.result_scavenge = BigEndianBitConverter.ToUInt16(sector, 0x124); - mddf.boot_code = BigEndianBitConverter.ToUInt16(sector, 0x126); - mddf.boot_environ = BigEndianBitConverter.ToUInt16(sector, 0x6C); - mddf.unknown36 = BigEndianBitConverter.ToUInt32(sector, 0x12A); - mddf.unknown37 = BigEndianBitConverter.ToUInt32(sector, 0x12E); - mddf.unknown38 = BigEndianBitConverter.ToUInt32(sector, 0x132); - mddf.vol_sequence = BigEndianBitConverter.ToUInt16(sector, 0x136); - mddf.vol_left_mounted = sector[0x138]; + info_mddf.dtvs = DateHandlers.LisaToDateTime(lisa_time); + info_mddf.unknown3 = BigEndianBitConverter.ToUInt32(sector, 0x68); + info_mddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C); + info_mddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70); + info_mddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74); + info_mddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78); + info_mddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C); + info_mddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E); + info_mddf.unknown4 = BigEndianBitConverter.ToUInt16(sector, 0x80); + info_mddf.unknown5 = BigEndianBitConverter.ToUInt32(sector, 0x82); + info_mddf.unknown6 = BigEndianBitConverter.ToUInt32(sector, 0x86); + info_mddf.clustersize = BigEndianBitConverter.ToUInt16(sector, 0x8A); + info_mddf.fs_size = BigEndianBitConverter.ToUInt32(sector, 0x8C); + info_mddf.unknown7 = BigEndianBitConverter.ToUInt32(sector, 0x90); + info_mddf.srec_ptr = BigEndianBitConverter.ToUInt32(sector, 0x94); + info_mddf.unknown9 = BigEndianBitConverter.ToUInt16(sector, 0x98); + info_mddf.srec_len = BigEndianBitConverter.ToUInt16(sector, 0x9A); + info_mddf.unknown10 = BigEndianBitConverter.ToUInt32(sector, 0x9C); + info_mddf.unknown11 = BigEndianBitConverter.ToUInt32(sector, 0xA0); + info_mddf.unknown12 = BigEndianBitConverter.ToUInt32(sector, 0xA4); + info_mddf.unknown13 = BigEndianBitConverter.ToUInt32(sector, 0xA8); + info_mddf.unknown14 = BigEndianBitConverter.ToUInt32(sector, 0xAC); + info_mddf.filecount = BigEndianBitConverter.ToUInt16(sector, 0xB0); + info_mddf.unknown15 = BigEndianBitConverter.ToUInt32(sector, 0xB2); + info_mddf.unknown16 = BigEndianBitConverter.ToUInt32(sector, 0xB6); + info_mddf.freecount = BigEndianBitConverter.ToUInt32(sector, 0xBA); + info_mddf.unknown17 = BigEndianBitConverter.ToUInt16(sector, 0xBE); + info_mddf.unknown18 = BigEndianBitConverter.ToUInt32(sector, 0xC0); + info_mddf.overmount_stamp = BigEndianBitConverter.ToUInt64(sector, 0xC4); + info_mddf.serialization = BigEndianBitConverter.ToUInt32(sector, 0xCC); + info_mddf.unknown19 = BigEndianBitConverter.ToUInt32(sector, 0xD0); + info_mddf.unknown_timestamp = BigEndianBitConverter.ToUInt32(sector, 0xD4); + info_mddf.unknown20 = BigEndianBitConverter.ToUInt32(sector, 0xD8); + info_mddf.unknown21 = BigEndianBitConverter.ToUInt32(sector, 0xDC); + info_mddf.unknown22 = BigEndianBitConverter.ToUInt32(sector, 0xE0); + info_mddf.unknown23 = BigEndianBitConverter.ToUInt32(sector, 0xE4); + info_mddf.unknown24 = BigEndianBitConverter.ToUInt32(sector, 0xE8); + info_mddf.unknown25 = BigEndianBitConverter.ToUInt32(sector, 0xEC); + info_mddf.unknown26 = BigEndianBitConverter.ToUInt32(sector, 0xF0); + info_mddf.unknown27 = BigEndianBitConverter.ToUInt32(sector, 0xF4); + info_mddf.unknown28 = BigEndianBitConverter.ToUInt32(sector, 0xF8); + info_mddf.unknown29 = BigEndianBitConverter.ToUInt32(sector, 0xFC); + info_mddf.unknown30 = BigEndianBitConverter.ToUInt32(sector, 0x100); + info_mddf.unknown31 = BigEndianBitConverter.ToUInt32(sector, 0x104); + info_mddf.unknown32 = BigEndianBitConverter.ToUInt32(sector, 0x108); + info_mddf.unknown33 = BigEndianBitConverter.ToUInt32(sector, 0x10C); + info_mddf.unknown34 = BigEndianBitConverter.ToUInt32(sector, 0x110); + info_mddf.unknown35 = BigEndianBitConverter.ToUInt32(sector, 0x114); + info_mddf.backup_volid = BigEndianBitConverter.ToUInt64(sector, 0x118); + info_mddf.label_size = BigEndianBitConverter.ToUInt16(sector, 0x120); + info_mddf.fs_overhead = BigEndianBitConverter.ToUInt16(sector, 0x122); + info_mddf.result_scavenge = BigEndianBitConverter.ToUInt16(sector, 0x124); + info_mddf.boot_code = BigEndianBitConverter.ToUInt16(sector, 0x126); + info_mddf.boot_environ = BigEndianBitConverter.ToUInt16(sector, 0x6C); + info_mddf.unknown36 = BigEndianBitConverter.ToUInt32(sector, 0x12A); + info_mddf.unknown37 = BigEndianBitConverter.ToUInt32(sector, 0x12E); + info_mddf.unknown38 = BigEndianBitConverter.ToUInt32(sector, 0x132); + info_mddf.vol_sequence = BigEndianBitConverter.ToUInt16(sector, 0x136); + info_mddf.vol_left_mounted = sector[0x138]; - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown1 = 0x{0:X2} ({0})", mddf.unknown1); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown2 = 0x{0:X2} ({0})", mddf.unknown2); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown3 = 0x{0:X8} ({0})", mddf.unknown3); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown4 = 0x{0:X4} ({0})", mddf.unknown4); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown5 = 0x{0:X8} ({0})", mddf.unknown5); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown6 = 0x{0:X8} ({0})", mddf.unknown6); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown7 = 0x{0:X8} ({0})", mddf.unknown7); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown9 = 0x{0:X4} ({0})", mddf.unknown9); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown10 = 0x{0:X8} ({0})", mddf.unknown10); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown11 = 0x{0:X8} ({0})", mddf.unknown11); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown12 = 0x{0:X8} ({0})", mddf.unknown12); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown13 = 0x{0:X8} ({0})", mddf.unknown13); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown14 = 0x{0:X8} ({0})", mddf.unknown14); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown15 = 0x{0:X8} ({0})", mddf.unknown15); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown16 = 0x{0:X8} ({0})", mddf.unknown16); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown17 = 0x{0:X4} ({0})", mddf.unknown17); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown18 = 0x{0:X8} ({0})", mddf.unknown18); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown19 = 0x{0:X8} ({0})", mddf.unknown19); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown20 = 0x{0:X8} ({0})", mddf.unknown20); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown21 = 0x{0:X8} ({0})", mddf.unknown21); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown22 = 0x{0:X8} ({0})", mddf.unknown22); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown23 = 0x{0:X8} ({0})", mddf.unknown23); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown24 = 0x{0:X8} ({0})", mddf.unknown24); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown25 = 0x{0:X8} ({0})", mddf.unknown25); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown26 = 0x{0:X8} ({0})", mddf.unknown26); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown27 = 0x{0:X8} ({0})", mddf.unknown27); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown28 = 0x{0:X8} ({0})", mddf.unknown28); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown29 = 0x{0:X8} ({0})", mddf.unknown29); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown30 = 0x{0:X8} ({0})", mddf.unknown30); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown31 = 0x{0:X8} ({0})", mddf.unknown31); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown32 = 0x{0:X8} ({0})", mddf.unknown32); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown33 = 0x{0:X8} ({0})", mddf.unknown33); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown34 = 0x{0:X8} ({0})", mddf.unknown34); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown35 = 0x{0:X8} ({0})", mddf.unknown35); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown36 = 0x{0:X8} ({0})", mddf.unknown36); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown37 = 0x{0:X8} ({0})", mddf.unknown37); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown38 = 0x{0:X8} ({0})", mddf.unknown38); - DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown_timestamp = 0x{0:X8} ({0}, {1})", mddf.unknown_timestamp, DateHandlers.LisaToDateTime(mddf.unknown_timestamp)); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown1 = 0x{0:X2} ({0})", info_mddf.unknown1); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown2 = 0x{0:X2} ({0})", info_mddf.unknown2); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown3 = 0x{0:X8} ({0})", info_mddf.unknown3); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown4 = 0x{0:X4} ({0})", info_mddf.unknown4); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown5 = 0x{0:X8} ({0})", info_mddf.unknown5); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown6 = 0x{0:X8} ({0})", info_mddf.unknown6); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown7 = 0x{0:X8} ({0})", info_mddf.unknown7); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown9 = 0x{0:X4} ({0})", info_mddf.unknown9); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown10 = 0x{0:X8} ({0})", info_mddf.unknown10); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown11 = 0x{0:X8} ({0})", info_mddf.unknown11); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown12 = 0x{0:X8} ({0})", info_mddf.unknown12); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown13 = 0x{0:X8} ({0})", info_mddf.unknown13); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown14 = 0x{0:X8} ({0})", info_mddf.unknown14); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown15 = 0x{0:X8} ({0})", info_mddf.unknown15); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown16 = 0x{0:X8} ({0})", info_mddf.unknown16); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown17 = 0x{0:X4} ({0})", info_mddf.unknown17); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown18 = 0x{0:X8} ({0})", info_mddf.unknown18); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown19 = 0x{0:X8} ({0})", info_mddf.unknown19); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown20 = 0x{0:X8} ({0})", info_mddf.unknown20); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown21 = 0x{0:X8} ({0})", info_mddf.unknown21); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown22 = 0x{0:X8} ({0})", info_mddf.unknown22); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown23 = 0x{0:X8} ({0})", info_mddf.unknown23); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown24 = 0x{0:X8} ({0})", info_mddf.unknown24); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown25 = 0x{0:X8} ({0})", info_mddf.unknown25); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown26 = 0x{0:X8} ({0})", info_mddf.unknown26); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown27 = 0x{0:X8} ({0})", info_mddf.unknown27); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown28 = 0x{0:X8} ({0})", info_mddf.unknown28); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown29 = 0x{0:X8} ({0})", info_mddf.unknown29); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown30 = 0x{0:X8} ({0})", info_mddf.unknown30); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown31 = 0x{0:X8} ({0})", info_mddf.unknown31); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown32 = 0x{0:X8} ({0})", info_mddf.unknown32); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown33 = 0x{0:X8} ({0})", info_mddf.unknown33); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown34 = 0x{0:X8} ({0})", info_mddf.unknown34); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown35 = 0x{0:X8} ({0})", info_mddf.unknown35); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown36 = 0x{0:X8} ({0})", info_mddf.unknown36); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown37 = 0x{0:X8} ({0})", info_mddf.unknown37); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown38 = 0x{0:X8} ({0})", info_mddf.unknown38); + DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown_timestamp = 0x{0:X8} ({0}, {1})", info_mddf.unknown_timestamp, DateHandlers.LisaToDateTime(info_mddf.unknown_timestamp)); - if(mddf.mddf_block != i - before_mddf) + if(info_mddf.mddf_block != i - before_mddf) return; - if(mddf.vol_size > imagePlugin.GetSectors()) + if(info_mddf.vol_size > imagePlugin.GetSectors()) return; - if(mddf.vol_size - 1 != mddf.volsize_minus_one) + if(info_mddf.vol_size - 1 != info_mddf.volsize_minus_one) return; - if(mddf.vol_size - i - 1 != mddf.volsize_minus_mddf_minus_one - before_mddf) + if(info_mddf.vol_size - i - 1 != info_mddf.volsize_minus_mddf_minus_one - before_mddf) return; - if(mddf.datasize > mddf.blocksize) + if(info_mddf.datasize > info_mddf.blocksize) return; - if(mddf.blocksize < imagePlugin.GetSectorSize()) + if(info_mddf.blocksize < imagePlugin.GetSectorSize()) return; - if(mddf.datasize != imagePlugin.GetSectorSize()) + if(info_mddf.datasize != imagePlugin.GetSectorSize()) return; - switch(mddf.fsversion) + switch(info_mddf.fsversion) { case LisaFSv1: sb.AppendLine("LisaFS v1"); @@ -357,46 +319,46 @@ namespace DiscImageChef.Filesystems.LisaFS sb.AppendLine("LisaFS v3"); break; default: - sb.AppendFormat("Uknown LisaFS version {0}", mddf.fsversion).AppendLine(); + sb.AppendFormat("Uknown LisaFS version {0}", info_mddf.fsversion).AppendLine(); break; } - sb.AppendFormat("Volume name: \"{0}\"", mddf.volname).AppendLine(); - sb.AppendFormat("Volume password: \"{0}\"", mddf.password).AppendLine(); - sb.AppendFormat("Volume ID: 0x{0:X16}", mddf.volid).AppendLine(); - sb.AppendFormat("Backup volume ID: 0x{0:X16}", mddf.backup_volid).AppendLine(); + sb.AppendFormat("Volume name: \"{0}\"", info_mddf.volname).AppendLine(); + sb.AppendFormat("Volume password: \"{0}\"", info_mddf.password).AppendLine(); + sb.AppendFormat("Volume ID: 0x{0:X16}", info_mddf.volid).AppendLine(); + sb.AppendFormat("Backup volume ID: 0x{0:X16}", info_mddf.backup_volid).AppendLine(); - sb.AppendFormat("Master copy ID: 0x{0:X8}", mddf.master_copy_id).AppendLine(); + sb.AppendFormat("Master copy ID: 0x{0:X8}", info_mddf.master_copy_id).AppendLine(); - sb.AppendFormat("Volume is number {0} of {1}", mddf.volnum, mddf.vol_sequence).AppendLine(); + sb.AppendFormat("Volume is number {0} of {1}", info_mddf.volnum, info_mddf.vol_sequence).AppendLine(); - sb.AppendFormat("Serial number of Lisa computer that created this volume: {0}", mddf.machine_id).AppendLine(); - sb.AppendFormat("Serial number of Lisa computer that can use this volume's software {0}", mddf.serialization).AppendLine(); + sb.AppendFormat("Serial number of Lisa computer that created this volume: {0}", info_mddf.machine_id).AppendLine(); + sb.AppendFormat("Serial number of Lisa computer that can use this volume's software {0}", info_mddf.serialization).AppendLine(); - sb.AppendFormat("Volume created on {0}", mddf.dtvc).AppendLine(); - sb.AppendFormat("Some timestamp, says {0}", mddf.dtcc).AppendLine(); - sb.AppendFormat("Volume backed up on {0}", mddf.dtvb).AppendLine(); - sb.AppendFormat("Volume scavenged on {0}", mddf.dtvs).AppendLine(); - sb.AppendFormat("MDDF is in block {0}", mddf.mddf_block + before_mddf).AppendLine(); + sb.AppendFormat("Volume created on {0}", info_mddf.dtvc).AppendLine(); + sb.AppendFormat("Some timestamp, says {0}", info_mddf.dtcc).AppendLine(); + sb.AppendFormat("Volume backed up on {0}", info_mddf.dtvb).AppendLine(); + sb.AppendFormat("Volume scavenged on {0}", info_mddf.dtvs).AppendLine(); + sb.AppendFormat("MDDF is in block {0}", info_mddf.mddf_block + before_mddf).AppendLine(); sb.AppendFormat("There are {0} reserved blocks before volume", before_mddf).AppendLine(); - sb.AppendFormat("{0} blocks minus one", mddf.volsize_minus_one).AppendLine(); - sb.AppendFormat("{0} blocks minus one minus MDDF offset", mddf.volsize_minus_mddf_minus_one).AppendLine(); - sb.AppendFormat("{0} blocks in volume", mddf.vol_size).AppendLine(); - sb.AppendFormat("{0} bytes per sector (uncooked)", mddf.blocksize).AppendLine(); - sb.AppendFormat("{0} bytes per sector", mddf.datasize).AppendLine(); - sb.AppendFormat("{0} blocks per cluster", mddf.clustersize).AppendLine(); - sb.AppendFormat("{0} blocks in filesystem", mddf.fs_size).AppendLine(); - sb.AppendFormat("{0} files in volume", mddf.filecount).AppendLine(); - sb.AppendFormat("{0} blocks free", mddf.freecount).AppendLine(); - sb.AppendFormat("{0} bytes in LisaInfo", mddf.label_size).AppendLine(); - sb.AppendFormat("Filesystem overhead: {0}", mddf.fs_overhead).AppendLine(); - sb.AppendFormat("Scanvenger result code: 0x{0:X8}", mddf.result_scavenge).AppendLine(); - sb.AppendFormat("Boot code: 0x{0:X8}", mddf.boot_code).AppendLine(); - sb.AppendFormat("Boot environment: 0x{0:X8}", mddf.boot_environ).AppendLine(); - sb.AppendFormat("Overmount stamp: 0x{0:X16}", mddf.overmount_stamp).AppendLine(); - sb.AppendFormat("S-Records start at {0} and spans for {1} blocks", mddf.srec_ptr + mddf.mddf_block + before_mddf, mddf.srec_len).AppendLine(); + sb.AppendFormat("{0} blocks minus one", info_mddf.volsize_minus_one).AppendLine(); + sb.AppendFormat("{0} blocks minus one minus MDDF offset", info_mddf.volsize_minus_mddf_minus_one).AppendLine(); + sb.AppendFormat("{0} blocks in volume", info_mddf.vol_size).AppendLine(); + sb.AppendFormat("{0} bytes per sector (uncooked)", info_mddf.blocksize).AppendLine(); + sb.AppendFormat("{0} bytes per sector", info_mddf.datasize).AppendLine(); + sb.AppendFormat("{0} blocks per cluster", info_mddf.clustersize).AppendLine(); + sb.AppendFormat("{0} blocks in filesystem", info_mddf.fs_size).AppendLine(); + sb.AppendFormat("{0} files in volume", info_mddf.filecount).AppendLine(); + sb.AppendFormat("{0} blocks free", info_mddf.freecount).AppendLine(); + sb.AppendFormat("{0} bytes in LisaInfo", info_mddf.label_size).AppendLine(); + sb.AppendFormat("Filesystem overhead: {0}", info_mddf.fs_overhead).AppendLine(); + sb.AppendFormat("Scanvenger result code: 0x{0:X8}", info_mddf.result_scavenge).AppendLine(); + sb.AppendFormat("Boot code: 0x{0:X8}", info_mddf.boot_code).AppendLine(); + sb.AppendFormat("Boot environment: 0x{0:X8}", info_mddf.boot_environ).AppendLine(); + sb.AppendFormat("Overmount stamp: 0x{0:X16}", info_mddf.overmount_stamp).AppendLine(); + sb.AppendFormat("S-Records start at {0} and spans for {1} blocks", info_mddf.srec_ptr + info_mddf.mddf_block + before_mddf, info_mddf.srec_len).AppendLine(); - if(mddf.vol_left_mounted == 0) + if(info_mddf.vol_left_mounted == 0) sb.AppendLine("Volume is clean"); else sb.AppendLine("Volume is dirty"); @@ -404,26 +366,26 @@ namespace DiscImageChef.Filesystems.LisaFS information = sb.ToString(); xmlFSType = new Schemas.FileSystemType(); - if(DateTime.Compare(mddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0) + if(DateTime.Compare(info_mddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0) { - xmlFSType.BackupDate = mddf.dtvb; + xmlFSType.BackupDate = info_mddf.dtvb; xmlFSType.BackupDateSpecified = true; } - xmlFSType.Clusters = mddf.vol_size; - xmlFSType.ClusterSize = mddf.clustersize * mddf.datasize; - if(DateTime.Compare(mddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0) + xmlFSType.Clusters = info_mddf.vol_size; + xmlFSType.ClusterSize = info_mddf.clustersize * info_mddf.datasize; + if(DateTime.Compare(info_mddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0) { - xmlFSType.CreationDate = mddf.dtvc; + xmlFSType.CreationDate = info_mddf.dtvc; xmlFSType.CreationDateSpecified = true; } - xmlFSType.Dirty = mddf.vol_left_mounted != 0; - xmlFSType.Files = mddf.filecount; + xmlFSType.Dirty = info_mddf.vol_left_mounted != 0; + xmlFSType.Files = info_mddf.filecount; xmlFSType.FilesSpecified = true; - xmlFSType.FreeClusters = mddf.freecount; + xmlFSType.FreeClusters = info_mddf.freecount; xmlFSType.FreeClustersSpecified = true; xmlFSType.Type = "LisaFS"; - xmlFSType.VolumeName = mddf.volname; - xmlFSType.VolumeSerial = String.Format("{0:X16}", mddf.volid); + xmlFSType.VolumeName = info_mddf.volname; + xmlFSType.VolumeSerial = string.Format("{0:X16}", info_mddf.volid); return; } diff --git a/DiscImageChef.Filesystems/LisaFS/LisaFS.cs b/DiscImageChef.Filesystems/LisaFS/LisaFS.cs index d98cd26c..a07cf3b0 100644 --- a/DiscImageChef.Filesystems/LisaFS/LisaFS.cs +++ b/DiscImageChef.Filesystems/LisaFS/LisaFS.cs @@ -32,13 +32,13 @@ using System; -// All information by Natalia Portillo -// Variable names from Lisa API using System.Collections.Generic; using DiscImageChef.ImagePlugins; namespace DiscImageChef.Filesystems.LisaFS { + // All information by Natalia Portillo + // Variable names from Lisa API partial class LisaFS : Filesystem { bool mounted; @@ -51,12 +51,12 @@ namespace DiscImageChef.Filesystems.LisaFS SRecord[] srecords; #region Caches - Dictionary extentCache; - Dictionary systemFileCache; - Dictionary fileCache; - Dictionary> catalogCache; - Dictionary fileSizeCache; - List printedExtents; + Dictionary extentCache; + Dictionary systemFileCache; + Dictionary fileCache; + Dictionary> catalogCache; + Dictionary fileSizeCache; + List printedExtents; #endregion Caches public LisaFS() @@ -65,7 +65,7 @@ namespace DiscImageChef.Filesystems.LisaFS PluginUUID = new Guid("7E6034D1-D823-4248-A54D-239742B28391"); } - public LisaFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public LisaFS(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) { device = imagePlugin; Name = "Apple Lisa File System"; diff --git a/DiscImageChef.Filesystems/LisaFS/Structs.cs b/DiscImageChef.Filesystems/LisaFS/Structs.cs index 1746b0e6..523d062b 100644 --- a/DiscImageChef.Filesystems/LisaFS/Structs.cs +++ b/DiscImageChef.Filesystems/LisaFS/Structs.cs @@ -38,11 +38,11 @@ namespace DiscImageChef.Filesystems.LisaFS struct MDDF { /// 0x00, Filesystem version - public UInt16 fsversion; + public ushort fsversion; /// 0x02, Volume ID - public UInt64 volid; + public ulong volid; /// 0x0A, Volume sequence number - public UInt16 volnum; + public ushort volnum; /// 0x0C, Pascal string, 32+1 bytes, volume name public string volname; /// 0x2D, unknown, possible padding @@ -52,9 +52,9 @@ namespace DiscImageChef.Filesystems.LisaFS /// 0x4F, unknown, possible padding public byte unknown2; /// 0x50, Lisa serial number that init'ed this disk - public UInt32 machine_id; + public uint machine_id; /// 0x54, ID of the master copy ? no idea really - public UInt32 master_copy_id; + public uint master_copy_id; /// 0x58, Date of volume creation public DateTime dtvc; /// 0x5C, Date... @@ -64,127 +64,127 @@ namespace DiscImageChef.Filesystems.LisaFS /// 0x64, Date of volume scavenging public DateTime dtvs; /// 0x68, unknown - public UInt32 unknown3; + public uint unknown3; /// 0x6C, block the MDDF is residing on - public UInt32 mddf_block; + public uint mddf_block; /// 0x70, volsize-1 - public UInt32 volsize_minus_one; + public uint volsize_minus_one; /// 0x74, volsize-1-mddf_block - public UInt32 volsize_minus_mddf_minus_one; + public uint volsize_minus_mddf_minus_one; /// 0x78, Volume size in blocks - public UInt32 vol_size; + public uint vol_size; /// 0x7C, Blocks size of underlying drive (data+tags) - public UInt16 blocksize; + public ushort blocksize; /// 0x7E, Data only block size - public UInt16 datasize; + public ushort datasize; /// 0x80, unknown - public UInt16 unknown4; + public ushort unknown4; /// 0x82, unknown - public UInt32 unknown5; + public uint unknown5; /// 0x86, unknown - public UInt32 unknown6; + public uint unknown6; /// 0x8A, Size in sectors of filesystem clusters - public UInt16 clustersize; + public ushort clustersize; /// 0x8C, Filesystem size in blocks - public UInt32 fs_size; + public uint fs_size; /// 0x90, unknown - public UInt32 unknown7; + public uint unknown7; /// 0x94, Pointer to S-Records - public UInt32 srec_ptr; + public uint srec_ptr; /// 0x98, unknown - public UInt16 unknown9; + public ushort unknown9; /// 0x9A, S-Records length - public UInt16 srec_len; + public ushort srec_len; /// 0x9C, unknown - public UInt32 unknown10; + public uint unknown10; /// 0xA0, unknown - public UInt32 unknown11; + public uint unknown11; /// 0xA4, unknown - public UInt32 unknown12; + public uint unknown12; /// 0xA8, unknown - public UInt32 unknown13; + public uint unknown13; /// 0xAC, unknown - public UInt32 unknown14; + public uint unknown14; /// 0xB0, Files in volume - public UInt16 filecount; + public ushort filecount; /// 0xB2, unknown - public UInt32 unknown15; + public uint unknown15; /// 0xB6, unknown - public UInt32 unknown16; + public uint unknown16; /// 0xBA, Free blocks - public UInt32 freecount; + public uint freecount; /// 0xBE, unknown - public UInt16 unknown17; + public ushort unknown17; /// 0xC0, unknown - public UInt32 unknown18; + public uint unknown18; /// 0xC4, no idea - public UInt64 overmount_stamp; + public ulong overmount_stamp; /// 0xCC, serialization, lisa serial number authorized to use blocked software on this volume - public UInt32 serialization; + public uint serialization; /// 0xD0, unknown - public UInt32 unknown19; + public uint unknown19; /// 0xD4, unknown, possible timestamp - public UInt32 unknown_timestamp; + public uint unknown_timestamp; /// 0xD8, unknown - public UInt32 unknown20; + public uint unknown20; /// 0xDC, unknown - public UInt32 unknown21; + public uint unknown21; /// 0xE0, unknown - public UInt32 unknown22; + public uint unknown22; /// 0xE4, unknown - public UInt32 unknown23; + public uint unknown23; /// 0xE8, unknown - public UInt32 unknown24; + public uint unknown24; /// 0xEC, unknown - public UInt32 unknown25; + public uint unknown25; /// 0xF0, unknown - public UInt32 unknown26; + public uint unknown26; /// 0xF4, unknown - public UInt32 unknown27; + public uint unknown27; /// 0xF8, unknown - public UInt32 unknown28; + public uint unknown28; /// 0xFC, unknown - public UInt32 unknown29; + public uint unknown29; /// 0x100, unknown - public UInt32 unknown30; + public uint unknown30; /// 0x104, unknown - public UInt32 unknown31; + public uint unknown31; /// 0x108, unknown - public UInt32 unknown32; + public uint unknown32; /// 0x10C, unknown - public UInt32 unknown33; + public uint unknown33; /// 0x110, unknown - public UInt32 unknown34; + public uint unknown34; /// 0x114, unknown - public UInt32 unknown35; + public uint unknown35; /// 0x118, ID of volume where this volume was backed up - public UInt64 backup_volid; + public ulong backup_volid; /// 0x120, Size of LisaInfo label - public UInt16 label_size; + public ushort label_size; /// 0x122, not clear - public UInt16 fs_overhead; + public ushort fs_overhead; /// 0x124, Return code of Scavenger - public UInt16 result_scavenge; + public ushort result_scavenge; /// 0x126, No idea - public UInt16 boot_code; + public ushort boot_code; /// 0x128, No idea - public UInt16 boot_environ; + public ushort boot_environ; /// 0x12A, unknown - public UInt32 unknown36; + public uint unknown36; /// 0x12E, unknown - public UInt32 unknown37; + public uint unknown37; /// 0x132, unknown - public UInt32 unknown38; + public uint unknown38; /// 0x136, Total volumes in sequence - public UInt16 vol_sequence; + public ushort vol_sequence; /// 0x138, Volume is dirty? public byte vol_left_mounted; /// Is password present? (On-disk position unknown) public byte passwd_present; /// Opened files (memory-only?) (On-disk position unknown) - public UInt32 opencount; + public uint opencount; /// No idea (On-disk position unknown) - public UInt32 copy_thread; + public uint copy_thread; // Flags are boolean, but Pascal seems to use them as full unsigned 8 bit values /// No idea (On-disk position unknown) public byte privileged; @@ -203,31 +203,31 @@ namespace DiscImageChef.Filesystems.LisaFS struct Tag { /// 0x00 version - public UInt16 version; + public ushort version; /// 0x02 unknown - public UInt16 unknown; + public ushort unknown; /// 0x04 File ID. Negative numbers are extents for the file with same absolute value number - public Int16 fileID; + public short fileID; /// Only in 20 bytes tag at 0x06, mask 0x8000 if valid tag - public UInt16 usedBytes; + public ushort usedBytes; /// Only in 20 bytes tag at 0x08, 3 bytes - public UInt32 absoluteBlock; + public uint absoluteBlock; /// Only in 20 bytes tag at 0x0B, checksum byte public byte checksum; /// 0x06 in 12 bytes tag, 0x0C in 20 bytes tag, relative block - public UInt16 relBlock; + public ushort relBlock; /// /// Next block for this file. /// In 12 bytes tag at 0x08, 2 bytes, 0x8000 bit seems always set, 0x07FF means this is last block. /// In 20 bytes tag at 0x0E, 3 bytes, 0xFFFFFF means this is last block. /// - public UInt32 nextBlock; + public uint nextBlock; /// /// Previous block for this file. /// In 12 bytes tag at 0x0A, 2 bytes, 0x07FF means this is first block. /// In 20 bytes tag at 0x11, 3 bytes, 0xFFFFFF means this is first block. /// - public UInt32 prevBlock; + public uint prevBlock; /// On-memory value for easy first block search. public bool isFirst; @@ -256,23 +256,23 @@ namespace DiscImageChef.Filesystems.LisaFS /// 0x25, lot of values found here, unknown public byte unknown; /// 0x26, file ID, must be positive and bigger than 4 - public Int16 fileID; + public short fileID; /// 0x28, creation date - public UInt32 dtc; + public uint dtc; /// 0x2C, last modification date - public UInt32 dtm; + public uint dtm; /// 0x30, file length in bytes - public Int32 length; + public int length; /// 0x34, file length in bytes, including wasted block space - public Int32 wasted; + public int wasted; /// 0x38, unknown public byte[] tail; } struct Extent { - public Int32 start; - public Int16 length; + public int start; + public short length; } struct ExtentFile @@ -284,7 +284,7 @@ namespace DiscImageChef.Filesystems.LisaFS /// 0x20, unknown public ushort unknown1; /// 0x22, 8 bytes - public UInt64 file_uid; + public ulong file_uid; /// 0x2A, unknown public byte unknown2; /// 0x2B, entry type? gets modified @@ -294,17 +294,17 @@ namespace DiscImageChef.Filesystems.LisaFS /// 0x2D, unknown public byte unknown3; /// 0x2E, creation time - public UInt32 dtc; + public uint dtc; /// 0x32, last access time - public UInt32 dta; + public uint dta; /// 0x36, modification time - public UInt32 dtm; + public uint dtm; /// 0x3A, backup time - public UInt32 dtb; + public uint dtb; /// 0x3E, scavenge time - public UInt32 dts; + public uint dts; /// 0x42, machine serial number - public UInt32 serial; + public uint serial; /// 0x46, unknown public byte unknown4; /// 0x47, locked file @@ -322,13 +322,13 @@ namespace DiscImageChef.Filesystems.LisaFS /// 0x4D, 11 bytes, unknown public byte[] unknown5; /// 0x58, Release number - public UInt16 release; + public ushort release; /// 0x5A, Build number - public UInt16 build; + public ushort build; /// 0x5C, Compatibility level - public UInt16 compatibility; + public ushort compatibility; /// 0x5E, Revision level - public UInt16 revision; + public ushort revision; /// 0x60, unknown public ushort unknown6; /// 0x62, 0x08 set if password is valid @@ -342,9 +342,9 @@ namespace DiscImageChef.Filesystems.LisaFS /// 0x70, 16 bytes, unknown public byte[] unknown8; /// 0x80, 0x200 in v1, file length in blocks - public Int32 length; + public int length; /// 0x84, 0x204 in v1, unknown - public Int32 unknown9; + public int unknown9; /// 0x88, 0x208 in v1, extents, can contain up to 41 extents (85 in v1), dunno LisaOS maximum (never seen more than 3) public Extent[] extents; /// 0x17E, unknown, empty, padding? @@ -356,13 +356,13 @@ namespace DiscImageChef.Filesystems.LisaFS struct SRecord { /// 0x00, block where ExtentsFile for this entry resides - public UInt32 extent_ptr; + public uint extent_ptr; /// 0x04, unknown - public UInt32 unknown; + public uint unknown; /// 0x08, filesize in bytes - public UInt32 filesize; + public uint filesize; /// 0x0C, some kind of flags, meaning unknown - public UInt16 flags; + public ushort flags; } struct CatalogEntryV2 @@ -378,7 +378,7 @@ namespace DiscImageChef.Filesystems.LisaFS /// 0x23, unknown public byte unknown2; /// 0x24, unknown - public Int16 fileID; + public short fileID; /// 0x26, 16 bytes, unknown public byte[] unknown3; } diff --git a/DiscImageChef.Filesystems/LisaFS/Super.cs b/DiscImageChef.Filesystems/LisaFS/Super.cs index 48b5df53..8b74d20c 100644 --- a/DiscImageChef.Filesystems/LisaFS/Super.cs +++ b/DiscImageChef.Filesystems/LisaFS/Super.cs @@ -34,7 +34,6 @@ using System; using System.Collections.Generic; using DiscImageChef.Console; using DiscImageChef.ImagePlugins; -using System.CodeDom.Compiler; namespace DiscImageChef.Filesystems.LisaFS { @@ -84,10 +83,10 @@ namespace DiscImageChef.Filesystems.LisaFS { devTagSize = device.ReadSectorTag(i, SectorTagType.AppleSectorTag).Length; - byte[] sector = device.ReadSector((ulong)i); + byte[] sector = device.ReadSector(i); mddf = new MDDF(); byte[] pString = new byte[33]; - UInt32 lisa_time; + uint lisa_time; mddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00); mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02); @@ -297,7 +296,7 @@ namespace DiscImageChef.Filesystems.LisaFS xmlFSType.FreeClustersSpecified = true; xmlFSType.Type = "LisaFS"; xmlFSType.VolumeName = mddf.volname; - xmlFSType.VolumeSerial = String.Format("{0:X16}", mddf.volid); + xmlFSType.VolumeSerial = string.Format("{0:X16}", mddf.volid); return Errno.NoError; } diff --git a/DiscImageChef.Filesystems/LisaFS/Xattr.cs b/DiscImageChef.Filesystems/LisaFS/Xattr.cs index 9cb93473..756a579b 100644 --- a/DiscImageChef.Filesystems/LisaFS/Xattr.cs +++ b/DiscImageChef.Filesystems/LisaFS/Xattr.cs @@ -34,8 +34,6 @@ using System; using System.Collections.Generic; using System.Text; -using System.Configuration; -using System.CodeDom.Compiler; namespace DiscImageChef.Filesystems.LisaFS { @@ -43,7 +41,7 @@ namespace DiscImageChef.Filesystems.LisaFS { public override Errno ListXAttr(string path, ref List xattrs) { - Int16 fileId; + short fileId; Errno error = LookupFileId(path, out fileId); if(error != Errno.NoError) return error; @@ -53,7 +51,7 @@ namespace DiscImageChef.Filesystems.LisaFS public override Errno GetXattr(string path, string xattr, ref byte[] buf) { - Int16 fileId; + short fileId; Errno error = LookupFileId(path, out fileId); if(error != Errno.NoError) return error; @@ -61,7 +59,7 @@ namespace DiscImageChef.Filesystems.LisaFS return GetXattr(fileId, xattr, out buf); } - Errno ListXAttr(Int16 fileId, ref List xattrs) + Errno ListXAttr(short fileId, ref List xattrs) { xattrs = null; @@ -111,7 +109,7 @@ namespace DiscImageChef.Filesystems.LisaFS return Errno.NoError; } - Errno GetXattr(Int16 fileId, string xattr, out byte[] buf) + Errno GetXattr(short fileId, string xattr, out byte[] buf) { buf = null; diff --git a/DiscImageChef.Filesystems/MinixFS.cs b/DiscImageChef.Filesystems/MinixFS.cs index 9eb01d44..af805a6f 100644 --- a/DiscImageChef.Filesystems/MinixFS.cs +++ b/DiscImageChef.Filesystems/MinixFS.cs @@ -32,34 +32,33 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; -// Information from the Linux kernel namespace DiscImageChef.Filesystems { + // Information from the Linux kernel class MinixFS : Filesystem { - const UInt16 MINIX_MAGIC = 0x137F; + const ushort MINIX_MAGIC = 0x137F; // Minix v1, 14 char filenames - const UInt16 MINIX_MAGIC2 = 0x138F; + const ushort MINIX_MAGIC2 = 0x138F; // Minix v1, 30 char filenames - const UInt16 MINIX2_MAGIC = 0x2468; + const ushort MINIX2_MAGIC = 0x2468; // Minix v2, 14 char filenames - const UInt16 MINIX2_MAGIC2 = 0x2478; + const ushort MINIX2_MAGIC2 = 0x2478; // Minix v2, 30 char filenames - const UInt16 MINIX3_MAGIC = 0x4D5A; + const ushort MINIX3_MAGIC = 0x4D5A; // Minix v3, 60 char filenames // Byteswapped - const UInt16 MINIX_CIGAM = 0x7F13; + const ushort MINIX_CIGAM = 0x7F13; // Minix v1, 14 char filenames - const UInt16 MINIX_CIGAM2 = 0x8F13; + const ushort MINIX_CIGAM2 = 0x8F13; // Minix v1, 30 char filenames - const UInt16 MINIX2_CIGAM = 0x6824; + const ushort MINIX2_CIGAM = 0x6824; // Minix v2, 14 char filenames - const UInt16 MINIX2_CIGAM2 = 0x7824; + const ushort MINIX2_CIGAM2 = 0x7824; // Minix v2, 30 char filenames - const UInt16 MINIX3_CIGAM = 0x5A4D; + const ushort MINIX3_CIGAM = 0x5A4D; // Minix v3, 60 char filenames public MinixFS() @@ -79,7 +78,7 @@ namespace DiscImageChef.Filesystems if((2 + partitionStart) >= imagePlugin.GetSectors()) return false; - UInt16 magic; + ushort magic; byte[] minix_sb_sector = imagePlugin.ReadSector(2 + partitionStart); magic = BitConverter.ToUInt16(minix_sb_sector, 0x010); // Here should reside magic number on Minix V1 & V2 @@ -103,7 +102,7 @@ namespace DiscImageChef.Filesystems bool minix3 = false; int filenamesize; string minixVersion; - UInt16 magic; + ushort magic; byte[] minix_sb_sector = imagePlugin.ReadSector(2 + partitionStart); magic = BigEndianBitConverter.ToUInt16(minix_sb_sector, 0x018); @@ -252,25 +251,25 @@ namespace DiscImageChef.Filesystems public struct MinixSuperBlock { /// 0x00, inodes on volume - public UInt16 s_ninodes; + public ushort s_ninodes; /// 0x02, zones on volume - public UInt16 s_nzones; + public ushort s_nzones; /// 0x04, blocks on inode map - public UInt16 s_imap_blocks; + public ushort s_imap_blocks; /// 0x06, blocks on zone map - public UInt16 s_zmap_blocks; + public ushort s_zmap_blocks; /// 0x08, first data zone - public UInt16 s_firstdatazone; + public ushort s_firstdatazone; /// 0x0A, log2 of blocks/zone - public UInt16 s_log_zone_size; + public ushort s_log_zone_size; /// 0x0C, max file size - public UInt32 s_max_size; + public uint s_max_size; /// 0x10, magic - public UInt16 s_magic; + public ushort s_magic; /// 0x12, filesystem state - public UInt16 s_state; + public ushort s_state; /// 0x14, number of zones - public UInt32 s_zones; + public uint s_zones; } /// @@ -279,29 +278,29 @@ namespace DiscImageChef.Filesystems public struct Minix3SuperBlock { /// 0x00, inodes on volume - public UInt32 s_ninodes; + public uint s_ninodes; /// 0x04, padding - public UInt16 s_pad0; + public ushort s_pad0; /// 0x06, blocks on inode map - public UInt16 s_imap_blocks; + public ushort s_imap_blocks; /// 0x08, blocks on zone map - public UInt16 s_zmap_blocks; + public ushort s_zmap_blocks; /// 0x0A, first data zone - public UInt16 s_firstdatazone; + public ushort s_firstdatazone; /// 0x0C, log2 of blocks/zone - public UInt16 s_log_zone_size; + public ushort s_log_zone_size; /// 0x0E, padding - public UInt16 s_pad1; + public ushort s_pad1; /// 0x10, max file size - public UInt32 s_max_size; + public uint s_max_size; /// 0x14, number of zones - public UInt32 s_zones; + public uint s_zones; /// 0x18, magic - public UInt16 s_magic; + public ushort s_magic; /// 0x1A, padding - public UInt16 s_pad2; + public ushort s_pad2; /// 0x1C, bytes in a block - public UInt16 s_blocksize; + public ushort s_blocksize; /// 0x1E, on-disk structures version public byte s_disk_version; } diff --git a/DiscImageChef.Filesystems/NTFS.cs b/DiscImageChef.Filesystems/NTFS.cs index 3d5c3946..e5021428 100644 --- a/DiscImageChef.Filesystems/NTFS.cs +++ b/DiscImageChef.Filesystems/NTFS.cs @@ -59,7 +59,7 @@ namespace DiscImageChef.Filesystems byte[] eigth_bytes = new byte[8]; byte fats_no; - UInt16 spfat, signature; + ushort spfat, signature; string oem_name; byte[] ntfs_bpb = imagePlugin.ReadSector(0 + partitionStart); @@ -165,7 +165,7 @@ namespace DiscImageChef.Filesystems xmlFSType = new Schemas.FileSystemType(); xmlFSType.ClusterSize = ntfs_bb.spc * ntfs_bb.bps; xmlFSType.Clusters = ntfs_bb.sectors / ntfs_bb.spc; - xmlFSType.VolumeSerial = String.Format("{0:X16}", ntfs_bb.serial_no); + xmlFSType.VolumeSerial = string.Format("{0:X16}", ntfs_bb.serial_no); xmlFSType.Type = "NTFS"; information = sb.ToString(); @@ -180,33 +180,33 @@ namespace DiscImageChef.Filesystems /// 0x000, Jump to boot code public byte jmp1; /// 0x001, ...; - public UInt16 jmp2; + public ushort jmp2; /// 0x003, OEM Name, 8 bytes, space-padded, must be "NTFS " public string OEMName; /// 0x00B, Bytes per sector - public UInt16 bps; + public ushort bps; /// 0x00D, Sectors per cluster public byte spc; /// 0x00E, Reserved sectors, seems 0 - public UInt16 rsectors; + public ushort rsectors; /// 0x010, Number of FATs... obviously, 0 public byte fats_no; /// 0x011, Number of entries on root directory... 0 - public UInt16 root_ent; + public ushort root_ent; /// 0x013, Sectors in volume... 0 - public UInt16 sml_sectors; + public ushort sml_sectors; /// 0x015, Media descriptor public byte media; /// 0x016, Sectors per FAT... 0 - public UInt16 spfat; + public ushort spfat; /// 0x018, Sectors per track, required to boot - public UInt16 sptrk; + public ushort sptrk; /// 0x01A, Heads... required to boot - public UInt16 heads; + public ushort heads; /// 0x01C, Hidden sectors before BPB - public UInt32 hsectors; + public uint hsectors; /// 0x020, Sectors in volume if > 65535... 0 - public UInt32 big_sectors; + public uint big_sectors; /// 0x024, Drive number public byte drive_no; /// 0x025, 0 @@ -229,19 +229,19 @@ namespace DiscImageChef.Filesystems /// 0x041, Alignment public byte dummy2; /// 0x042, Alignment - public UInt16 dummy3; + public ushort dummy3; /// 0x044, Clusters per index block public sbyte index_blk_cts; /// 0x045, Alignment public byte dummy4; /// 0x046, Alignment - public UInt16 dummy5; + public ushort dummy5; /// 0x048, Volume serial number - public UInt64 serial_no; + public ulong serial_no; // End of NTFS superblock, followed by 430 bytes of boot code /// 0x1FE, 0xAA55 - public UInt16 signature2; + public ushort signature2; } public override Errno Mount() diff --git a/DiscImageChef.Filesystems/Nintendo.cs b/DiscImageChef.Filesystems/Nintendo.cs index c748d2b0..e9c2a2a5 100644 --- a/DiscImageChef.Filesystems/Nintendo.cs +++ b/DiscImageChef.Filesystems/Nintendo.cs @@ -32,12 +32,8 @@ using System; using System.Text; -using DiscImageChef; -using DiscImageChef.PartPlugins; using System.Collections.Generic; using DiscImageChef.Console; -using System.Runtime.Remoting.Messaging; -using System.Collections.Generic; namespace DiscImageChef.Filesystems { @@ -67,8 +63,8 @@ namespace DiscImageChef.Filesystems byte[] header = imagePlugin.ReadSectors(0, (0x50000 / imagePlugin.GetSectorSize())); - UInt32 magicGC = BigEndianBitConverter.ToUInt32(header, 0x1C); - UInt32 magicWii = BigEndianBitConverter.ToUInt32(header, 0x18); + uint magicGC = BigEndianBitConverter.ToUInt32(header, 0x1C); + uint magicWii = BigEndianBitConverter.ToUInt32(header, 0x18); if(magicGC == 0xC2339F3D || magicWii == 0x5D1C9EA3) return true; @@ -89,8 +85,8 @@ namespace DiscImageChef.Filesystems bool wii = false; - UInt32 magicGC = BigEndianBitConverter.ToUInt32(header, 0x1C); - UInt32 magicWii = BigEndianBitConverter.ToUInt32(header, 0x18); + uint magicGC = BigEndianBitConverter.ToUInt32(header, 0x1C); + uint magicWii = BigEndianBitConverter.ToUInt32(header, 0x18); if(magicGC == 0xC2339F3D) wii = false; diff --git a/DiscImageChef.Filesystems/ODS.cs b/DiscImageChef.Filesystems/ODS.cs index c34a3194..13e94c3d 100644 --- a/DiscImageChef.Filesystems/ODS.cs +++ b/DiscImageChef.Filesystems/ODS.cs @@ -32,20 +32,19 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; -// Information from VMS File System Internals by Kirby McCoy -// ISBN: 1-55558-056-4 -// With some hints from http://www.decuslib.com/DECUS/vmslt97b/gnusoftware/gccaxp/7_1/vms/hm2def.h -// Expects the home block to be always in sector #1 (does not check deltas) -// Assumes a sector size of 512 bytes (VMS does on HDDs and optical drives, dunno about M.O.) -// Book only describes ODS-2. Need to test ODS-1 and ODS-5 -// There is an ODS with signature "DECFILES11A", yet to be seen -// Time is a 64 bit unsigned integer, tenths of microseconds since 1858/11/17 00:00:00. -// TODO: Implement checksum namespace DiscImageChef.Filesystems { + // Information from VMS File System Internals by Kirby McCoy + // ISBN: 1-55558-056-4 + // With some hints from http://www.decuslib.com/DECUS/vmslt97b/gnusoftware/gccaxp/7_1/vms/hm2def.h + // Expects the home block to be always in sector #1 (does not check deltas) + // Assumes a sector size of 512 bytes (VMS does on HDDs and optical drives, dunno about M.O.) + // Book only describes ODS-2. Need to test ODS-1 and ODS-5 + // There is an ODS with signature "DECFILES11A", yet to be seen + // Time is a 64 bit unsigned integer, tenths of microseconds since 1858/11/17 00:00:00. + // TODO: Implement checksum class ODS : Filesystem { public ODS() @@ -264,7 +263,7 @@ namespace DiscImageChef.Filesystems xmlFSType.ClusterSize = homeblock.cluster * 512; xmlFSType.Clusters = homeblock.cluster; xmlFSType.VolumeName = homeblock.volname; - xmlFSType.VolumeSerial = String.Format("{0:X8}", homeblock.serialnum); + xmlFSType.VolumeSerial = string.Format("{0:X8}", homeblock.serialnum); if(homeblock.credate > 0) { xmlFSType.CreationDate = DateHandlers.VMSToDateTime(homeblock.credate); @@ -282,85 +281,85 @@ namespace DiscImageChef.Filesystems struct ODSHomeBlock { /// 0x000, LBN of THIS home block - public UInt32 homelbn; + public uint homelbn; /// 0x004, LBN of the secondary home block - public UInt32 alhomelbn; + public uint alhomelbn; /// 0x008, LBN of backup INDEXF.SYS;1 - public UInt32 altidxlbn; + public uint altidxlbn; /// 0x00C, High byte contains filesystem version (1, 2 or 5), low byte contains revision (1) - public UInt16 struclev; + public ushort struclev; /// 0x00E, Number of blocks each bit of the volume bitmap represents - public UInt16 cluster; + public ushort cluster; /// 0x010, VBN of THIS home block - public UInt16 homevbn; + public ushort homevbn; /// 0x012, VBN of the secondary home block - public UInt16 alhomevbn; + public ushort alhomevbn; /// 0x014, VBN of backup INDEXF.SYS;1 - public UInt16 altidxvbn; + public ushort altidxvbn; /// 0x016, VBN of the bitmap - public UInt16 ibmapvbn; + public ushort ibmapvbn; /// 0x018, LBN of the bitmap - public UInt32 ibmaplbn; + public uint ibmaplbn; /// 0x01C, Max files on volume - public UInt32 maxfiles; + public uint maxfiles; /// 0x020, Bitmap size in sectors - public UInt16 ibmapsize; + public ushort ibmapsize; /// 0x022, Reserved files, 5 at minimum - public UInt16 resfiles; + public ushort resfiles; /// 0x024, Device type, ODS-2 defines it as always 0 - public UInt16 devtype; + public ushort devtype; /// 0x026, Relative volume number (number of the volume in a set) - public UInt16 rvn; + public ushort rvn; /// 0x028, Total number of volumes in the set this volume is - public UInt16 setcount; + public ushort setcount; /// 0x02A, Flags - public UInt16 volchar; + public ushort volchar; /// 0x02C, User ID of the volume owner - public UInt32 volowner; + public uint volowner; /// 0x030, Security mask (??) - public UInt32 sec_mask; + public uint sec_mask; /// 0x034, Volume permissions (system, owner, group and other) - public UInt16 protect; + public ushort protect; /// 0x036, Default file protection, unsupported in ODS-2 - public UInt16 fileprot; + public ushort fileprot; /// 0x038, Default file record protection - public UInt16 recprot; + public ushort recprot; /// 0x03A, Checksum of all preceding entries - public UInt16 checksum1; + public ushort checksum1; /// 0x03C, Creation date - public UInt64 credate; + public ulong credate; /// 0x044, Window size (pointers for the window) public byte window; /// 0x045, Directories to be stored in cache public byte lru_lim; /// 0x046, Default allocation size in blocks - public UInt16 extend; + public ushort extend; /// 0x048, Minimum file retention period - public UInt64 retainmin; + public ulong retainmin; /// 0x050, Maximum file retention period - public UInt64 retainmax; + public ulong retainmax; /// 0x058, Last modification date - public UInt64 revdate; + public ulong revdate; /// 0x060, Minimum security class, 20 bytes public byte[] min_class; /// 0x074, Maximum security class, 20 bytes public byte[] max_class; /// 0x088, File lookup table FID - public UInt16 filetab_fid1; + public ushort filetab_fid1; /// 0x08A, File lookup table FID - public UInt16 filetab_fid2; + public ushort filetab_fid2; /// 0x08C, File lookup table FID - public UInt16 filetab_fid3; + public ushort filetab_fid3; /// 0x08E, Lowest structure level on the volume - public UInt16 lowstruclev; + public ushort lowstruclev; /// 0x090, Highest structure level on the volume - public UInt16 highstruclev; + public ushort highstruclev; /// 0x092, Volume copy date (??) - public UInt64 copydate; + public ulong copydate; /// 0x09A, 302 bytes public byte[] reserved1; /// 0x1C8, Physical drive serial number - public UInt32 serialnum; + public uint serialnum; /// 0x1CC, Name of the volume set, 12 bytes public string strucname; /// 0x1D8, Volume label, 12 bytes @@ -370,9 +369,9 @@ namespace DiscImageChef.Filesystems /// 0x1F0, ODS-2 defines it as "DECFILE11B", 12 bytes public string format; /// 0x1FC, Reserved - public UInt16 reserved2; + public ushort reserved2; /// 0x1FE, Checksum of preceding 255 words (16 bit units) - public UInt16 checksum2; + public ushort checksum2; } public override Errno Mount() diff --git a/DiscImageChef.Filesystems/Opera.cs b/DiscImageChef.Filesystems/Opera.cs index a82d512f..b6206eb9 100644 --- a/DiscImageChef.Filesystems/Opera.cs +++ b/DiscImageChef.Filesystems/Opera.cs @@ -32,7 +32,6 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; namespace DiscImageChef.Filesystems @@ -154,19 +153,19 @@ namespace DiscImageChef.Filesystems /// 0x028, 32 bytes, volume label public string volume_label; /// 0x048, Volume ID - public Int32 volume_id; + public int volume_id; /// 0x04C, Block size in bytes - public Int32 block_size; + public int block_size; /// 0x050, Blocks in volume - public Int32 block_count; + public int block_count; /// 0x054, Root directory ID - public Int32 root_dirid; + public int root_dirid; /// 0x058, Root directory blocks - public Int32 rootdir_blocks; + public int rootdir_blocks; /// 0x05C, Root directory block size - public Int32 rootdir_bsize; + public int rootdir_bsize; /// 0x060, Last root directory copy - public Int32 last_root_copy; + public int last_root_copy; } public override Errno Mount() diff --git a/DiscImageChef.Filesystems/PCEngine.cs b/DiscImageChef.Filesystems/PCEngine.cs index 182e7e34..3eef3838 100644 --- a/DiscImageChef.Filesystems/PCEngine.cs +++ b/DiscImageChef.Filesystems/PCEngine.cs @@ -32,7 +32,6 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; namespace DiscImageChef.Filesystems diff --git a/DiscImageChef.Filesystems/ProDOS.cs b/DiscImageChef.Filesystems/ProDOS.cs index cd88f173..1ab5c143 100644 --- a/DiscImageChef.Filesystems/ProDOS.cs +++ b/DiscImageChef.Filesystems/ProDOS.cs @@ -32,15 +32,12 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; - -// Information from Apple ProDOS 8 Technical Reference using DiscImageChef.Console; - namespace DiscImageChef.Filesystems { + // Information from Apple ProDOS 8 Technical Reference public class ProDOSPlugin : Filesystem { const byte EmptyStorageType = 0x00; @@ -63,11 +60,11 @@ namespace DiscImageChef.Filesystems const byte ProDOSVersion1 = 0x00; - const UInt32 ProDOSYearMask = 0xFE000000; - const UInt32 ProDOSMonthMask = 0x1E00000; - const UInt32 ProDOSDayMask = 0x1F0000; - const UInt32 ProDOSHourMask = 0x1F00; - const UInt32 ProDOSMinuteMask = 0x3F; + const uint ProDOSYearMask = 0xFE000000; + const uint ProDOSMonthMask = 0x1E00000; + const uint ProDOSDayMask = 0x1F0000; + const uint ProDOSHourMask = 0x1F00; + const uint ProDOSMinuteMask = 0x3F; const byte ProDOSDestroyAttribute = 0x80; const byte ProDOSRenameAttribute = 0x40; @@ -101,7 +98,7 @@ namespace DiscImageChef.Filesystems // Blocks 0 and 1 are boot code byte[] rootDirectoryKeyBlock = imagePlugin.ReadSector(2 + partitionStart); - UInt16 prePointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0); + ushort prePointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0); if(prePointer != 0) return false; @@ -117,11 +114,11 @@ namespace DiscImageChef.Filesystems if(entries_per_block != ProDOSEntriesPerBlock) return false; - UInt16 bit_map_pointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x27); + ushort bit_map_pointer = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x27); if(bit_map_pointer > imagePlugin.GetSectors()) return false; - UInt16 total_blocks = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x29); + ushort total_blocks = BitConverter.ToUInt16(rootDirectoryKeyBlock, 0x29); return total_blocks <= imagePlugin.GetSectors(); } @@ -137,8 +134,8 @@ namespace DiscImageChef.Filesystems byte[] temporal; int year, month, day, hour, minute; - UInt16 temp_timestamp_left, temp_timestamp_right; - UInt32 temp_timestamp; + ushort temp_timestamp_left, temp_timestamp_right; + uint temp_timestamp; rootDirectoryKeyBlock.zero = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x00); rootDirectoryKeyBlock.next_pointer = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x02); @@ -325,17 +322,17 @@ namespace DiscImageChef.Filesystems /// Block address of block for seedling files. /// Offset 0x11, 2 bytes /// - public UInt16 key_pointer; + public ushort key_pointer; /// /// Blocks used by file or directory, including index blocks. /// Offset 0x13, 2 bytes /// - public UInt16 blocks_used; + public ushort blocks_used; /// /// Size of file in bytes /// Offset 0x15, 3 bytes /// - public UInt32 EOF; + public uint EOF; /// /// File creation datetime /// Offset 0x18, 4 bytes @@ -360,7 +357,7 @@ namespace DiscImageChef.Filesystems /// General purpose field to store additional information about file format /// Offset 0x1F, 2 bytes /// - public UInt16 aux_type; + public ushort aux_type; /// /// File last modification date time /// Offset 0x21, 4 bytes @@ -370,7 +367,7 @@ namespace DiscImageChef.Filesystems /// Block address pointer to key block of the directory containing this entry /// Offset 0x25, 2 bytes /// - public UInt16 header_pointer; + public ushort header_pointer; } struct ProDOSRootDirectoryHeader @@ -394,7 +391,7 @@ namespace DiscImageChef.Filesystems /// Reserved for future expansion /// Offset 0x14, 8 bytes /// - public UInt64 reserved; + public ulong reserved; /// /// Creation time of the volume /// Offset 0x1C, 4 bytes @@ -431,18 +428,18 @@ namespace DiscImageChef.Filesystems /// Number of active files in this directory /// Offset 0x25, 2 bytes /// - public UInt16 file_count; + public ushort file_count; /// /// Block address of the first block of the volume's bitmap, /// one for every 4096 blocks or fraction /// Offset 0x27, 2 bytes /// - public UInt16 bit_map_pointer; + public ushort bit_map_pointer; /// /// Total number of blocks in the volume /// Offset 0x29, 2 bytes /// - public UInt16 total_blocks; + public ushort total_blocks; } struct ProDOSDirectoryHeader @@ -466,7 +463,7 @@ namespace DiscImageChef.Filesystems /// Reserved for future expansion /// Offset 0x14, 8 bytes /// - public UInt64 reserved; + public ulong reserved; /// /// Creation time of the volume /// Offset 0x1C, 4 bytes @@ -503,12 +500,12 @@ namespace DiscImageChef.Filesystems /// Number of active files in this directory /// Offset 0x25, 2 bytes /// - public UInt16 file_count; + public ushort file_count; /// /// Block address of parent directory block that contains this entry /// Offset 0x27, 2 bytes /// - public UInt16 parent_pointer; + public ushort parent_pointer; /// /// Entry number within the block indicated in parent_pointer /// Offset 0x29, 1 byte @@ -528,12 +525,12 @@ namespace DiscImageChef.Filesystems /// Always 0 /// Offset 0x00, 2 bytes /// - public UInt16 zero; + public ushort zero; /// /// Pointer to next directory block, 0 if last /// Offset 0x02, 2 bytes /// - public UInt16 next_pointer; + public ushort next_pointer; /// /// Directory header /// Offset 0x04, 39 bytes @@ -552,12 +549,12 @@ namespace DiscImageChef.Filesystems /// Always 0 /// Offset 0x00, 2 bytes /// - public UInt16 zero; + public ushort zero; /// /// Pointer to next directory block, 0 if last /// Offset 0x02, 2 bytes /// - public UInt16 next_pointer; + public ushort next_pointer; /// /// Directory header /// Offset 0x04, 39 bytes @@ -576,12 +573,12 @@ namespace DiscImageChef.Filesystems /// Pointer to previous directory block /// Offset 0x00, 2 bytes /// - public UInt16 zero; + public ushort zero; /// /// Pointer to next directory block, 0 if last /// Offset 0x02, 2 bytes /// - public UInt16 next_pointer; + public ushort next_pointer; /// /// Directory entries /// Offset 0x2F, 39 bytes each, 13 entries @@ -594,7 +591,7 @@ namespace DiscImageChef.Filesystems /// /// Up to 256 pointers to blocks, 0 to indicate the block is sparsed (non-allocated) /// - public UInt16[] block_pointer; + public ushort[] block_pointer; } struct ProDOSMasterIndexBlock @@ -602,7 +599,7 @@ namespace DiscImageChef.Filesystems /// /// Up to 128 pointers to index blocks /// - public UInt16[] index_block_pointer; + public ushort[] index_block_pointer; } } } diff --git a/DiscImageChef.Filesystems/SolarFS.cs b/DiscImageChef.Filesystems/SolarFS.cs index 7b8b369c..547f2731 100644 --- a/DiscImageChef.Filesystems/SolarFS.cs +++ b/DiscImageChef.Filesystems/SolarFS.cs @@ -32,15 +32,12 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; - -// Based on FAT's BPB, cannot find a FAT or directory using DiscImageChef.Console; - namespace DiscImageChef.Filesystems { + // Based on FAT's BPB, cannot find a FAT or directory class SolarFS : Filesystem { public SolarFS() @@ -166,29 +163,29 @@ namespace DiscImageChef.Filesystems /// 0x03, 8 bytes, "SOLAR_OS" public string OEMName; /// 0x0B, Bytes per sector - public UInt16 bps; + public ushort bps; /// 0x0D, unknown, 0x01 public byte unk1; /// 0x0E, unknown, 0x0201 - public UInt16 unk2; + public ushort unk2; /// 0x10, Number of entries on root directory ? (no root directory found) - public UInt16 root_ent; + public ushort root_ent; /// 0x12, Sectors in volume - public UInt16 sectors; + public ushort sectors; /// 0x14, Media descriptor public byte media; /// 0x15, Sectors per FAT ? (no FAT found) - public UInt16 spfat; + public ushort spfat; /// 0x17, Sectors per track - public UInt16 sptrk; + public ushort sptrk; /// 0x19, Heads - public UInt16 heads; + public ushort heads; /// 0x1B, unknown, 10 bytes, zero-filled public byte[] unk3; /// 0x25, 0x29 public byte signature; /// 0x26, unknown, zero-filled - public UInt32 unk4; + public uint unk4; /// 0x2A, 11 bytes, volume name, space-padded public string vol_name; /// 0x35, 8 bytes, "SOL_FS " diff --git a/DiscImageChef.Filesystems/Structs.cs b/DiscImageChef.Filesystems/Structs.cs index 5678dc21..34872168 100644 --- a/DiscImageChef.Filesystems/Structs.cs +++ b/DiscImageChef.Filesystems/Structs.cs @@ -33,7 +33,6 @@ using System; using System.Runtime.InteropServices; -using System.Security.Policy; namespace DiscImageChef.Filesystems { @@ -235,9 +234,9 @@ namespace DiscImageChef.Filesystems public bool IsGuid; [FieldOffset(3)] - public UInt32 Serial32; + public uint Serial32; [FieldOffset(3)] - public UInt64 Serial64; + public ulong Serial64; [FieldOffset(3)] public Guid uuid; } diff --git a/DiscImageChef.Filesystems/Symbian.cs b/DiscImageChef.Filesystems/Symbian.cs index 24c672ab..3c127954 100644 --- a/DiscImageChef.Filesystems/Symbian.cs +++ b/DiscImageChef.Filesystems/Symbian.cs @@ -45,24 +45,24 @@ namespace DiscImageChef.Plugins class SymbianIS : Plugin { // Magics - private const UInt32 SymbianMagic = 0x10000419; - private const UInt32 EPOCMagic = 0x1000006D; - private const UInt32 EPOC6Magic = 0x10003A12; - private const UInt32 Symbian9Magic = 0x10201A7A; + private const uint SymbianMagic = 0x10000419; + private const uint EPOCMagic = 0x1000006D; + private const uint EPOC6Magic = 0x10003A12; + private const uint Symbian9Magic = 0x10201A7A; // Options - private const UInt16 IsUnicode = 0x0001; - private const UInt16 IsDistributable = 0x0002; - private const UInt16 NoCompress = 0x0008; - private const UInt16 ShutdownApps = 0x0010; + private const ushort IsUnicode = 0x0001; + private const ushort IsDistributable = 0x0002; + private const ushort NoCompress = 0x0008; + private const ushort ShutdownApps = 0x0010; // Types - private const UInt16 SISApp = 0x0000; // Application - private const UInt16 SISSystem = 0x0001; // System component (library) - private const UInt16 SISOption = 0x0002; // Optional component - private const UInt16 SISConfig = 0x0003; // Configures an application - private const UInt16 SISPatch = 0x0004; // Patch - private const UInt16 SISUpgrade = 0x0005; // Upgrade + private const ushort SISApp = 0x0000; // Application + private const ushort SISSystem = 0x0001; // System component (library) + private const ushort SISOption = 0x0002; // Optional component + private const ushort SISConfig = 0x0003; // Configures an application + private const ushort SISPatch = 0x0004; // Patch + private const ushort SISUpgrade = 0x0005; // Upgrade private enum LanguageCodes { @@ -173,14 +173,14 @@ namespace DiscImageChef.Plugins public override bool Identify(FileStream fileStream, long offset) { - UInt32 uid1, uid2, uid3; + uint uid1, uid2, uid3; BinaryReader br = new BinaryReader(fileStream); br.BaseStream.Seek(0 + offset, SeekOrigin.Begin); - uid1 = br.ReadUInt32(); - uid2 = br.ReadUInt32(); - uid3 = br.ReadUInt32(); + uid1 = br.Readuint(); + uid2 = br.Readuint(); + uid3 = br.Readuint(); if(uid1 == Symbian9Magic) return true; @@ -200,10 +200,10 @@ namespace DiscImageChef.Plugins information = ""; StringBuilder description = new StringBuilder(); List languages = new List(); - Dictionary capabilities = new Dictionary(); + Dictionary capabilities = new Dictionary(); int ENpos = 0; - UInt32 comp_len; - UInt32 comp_name_ptr; + uint comp_len; + uint comp_name_ptr; byte[] ComponentName_b; string ComponentName = ""; @@ -212,41 +212,41 @@ namespace DiscImageChef.Plugins br.BaseStream.Seek(0 + offset, SeekOrigin.Begin); - sh.uid1 = br.ReadUInt32(); - sh.uid2 = br.ReadUInt32(); - sh.uid3 = br.ReadUInt32(); - sh.uid4 = br.ReadUInt32(); - sh.crc16 = br.ReadUInt16(); - sh.languages = br.ReadUInt16(); - sh.files = br.ReadUInt16(); - sh.requisites = br.ReadUInt16(); - sh.inst_lang = br.ReadUInt16(); - sh.inst_files = br.ReadUInt16(); - sh.inst_drive = br.ReadUInt16(); - sh.capabilities = br.ReadUInt16(); - sh.inst_version = br.ReadUInt32(); - sh.options = br.ReadUInt16(); - sh.type = br.ReadUInt16(); - sh.major = br.ReadUInt16(); - sh.minor = br.ReadUInt16(); - sh.variant = br.ReadUInt32(); - sh.lang_ptr = br.ReadUInt32(); - sh.files_ptr = br.ReadUInt32(); - sh.reqs_ptr = br.ReadUInt32(); - sh.certs_ptr = br.ReadUInt32(); - sh.comp_ptr = br.ReadUInt32(); - sh.sig_ptr = br.ReadUInt32(); - sh.caps_ptr = br.ReadUInt32(); - sh.instspace = br.ReadUInt32(); - sh.maxinsspc = br.ReadUInt32(); - sh.reserved1 = br.ReadUInt64(); - sh.reserved2 = br.ReadUInt64(); + sh.uid1 = br.Readuint(); + sh.uid2 = br.Readuint(); + sh.uid3 = br.Readuint(); + sh.uid4 = br.Readuint(); + sh.crc16 = br.Readushort(); + sh.languages = br.Readushort(); + sh.files = br.Readushort(); + sh.requisites = br.Readushort(); + sh.inst_lang = br.Readushort(); + sh.inst_files = br.Readushort(); + sh.inst_drive = br.Readushort(); + sh.capabilities = br.Readushort(); + sh.inst_version = br.Readuint(); + sh.options = br.Readushort(); + sh.type = br.Readushort(); + sh.major = br.Readushort(); + sh.minor = br.Readushort(); + sh.variant = br.Readuint(); + sh.lang_ptr = br.Readuint(); + sh.files_ptr = br.Readuint(); + sh.reqs_ptr = br.Readuint(); + sh.certs_ptr = br.Readuint(); + sh.comp_ptr = br.Readuint(); + sh.sig_ptr = br.Readuint(); + sh.caps_ptr = br.Readuint(); + sh.instspace = br.Readuint(); + sh.maxinsspc = br.Readuint(); + sh.reserved1 = br.Readulong(); + sh.reserved2 = br.Readulong(); // Go to enumerate languages br.BaseStream.Seek(sh.lang_ptr + offset, SeekOrigin.Begin); for(int i = 0; i < sh.languages; i++) { - UInt16 language = br.ReadUInt16(); + ushort language = br.Readushort(); if(language == 0x0001) ENpos = i; languages.Add(((LanguageCodes)language).ToString("G")); @@ -256,8 +256,8 @@ namespace DiscImageChef.Plugins br.BaseStream.Seek(sh.comp_ptr + offset, SeekOrigin.Begin); for(int i = 0; i < sh.languages; i++) { - comp_len = br.ReadUInt32(); - comp_name_ptr = br.ReadUInt32(); + comp_len = br.Readuint(); + comp_name_ptr = br.Readuint(); if(i == ENpos) { br.BaseStream.Seek(comp_name_ptr + offset, SeekOrigin.Begin); @@ -272,8 +272,8 @@ namespace DiscImageChef.Plugins br.BaseStream.Seek(sh.caps_ptr + offset, SeekOrigin.Begin); for(int i = 0; i < sh.capabilities; i++) { - UInt32 cap_key = br.ReadUInt32(); - UInt32 cap_value = br.ReadUInt32(); + uint cap_key = br.Readuint(); + uint cap_value = br.Readuint(); capabilities.Add(cap_key, cap_value); } @@ -321,7 +321,7 @@ namespace DiscImageChef.Plugins description.AppendFormat("File contains {0} files (pointer: {1})", sh.files, sh.files_ptr).AppendLine(); description.AppendFormat("File contains {0} requisites", sh.requisites).AppendLine(); // description.AppendLine("Capabilities:"); -// foreach(KeyValuePair kvp in capabilities) +// foreach(KeyValuePair kvp in capabilities) // description.AppendFormat("{0} = {1}", kvp.Key, kvp.Value).AppendLine(); } @@ -330,36 +330,36 @@ namespace DiscImageChef.Plugins private struct SymbianHeader { - public UInt32 uid1; // Application UID before SymbianOS 9, magic after - public UInt32 uid2; // EPOC release magic before SOS 9, NULLs after - public UInt32 uid3; // Application UID after SOS 9, magic before - public UInt32 uid4; // Checksum of UIDs 1 to 3 - public UInt16 crc16; // CRC16 of all header - public UInt16 languages; // Number of languages - public UInt16 files; // Number of files - public UInt16 requisites; // Number of requisites - public UInt16 inst_lang; // Installed language (only residual SIS) - public UInt16 inst_files; // Installed files (only residual SIS) - public UInt16 inst_drive; // Installed drive (only residual SIS), NULL or 0x0021 - public UInt16 capabilities; // Number of capabilities - public UInt32 inst_version; // Version of Symbian Installer required - public UInt16 options; // Option flags - public UInt16 type; // Type - public UInt16 major; // Major version of application - public UInt16 minor; // Minor version of application - public UInt32 variant; // Variant when SIS is a prerequisite for other SISs - public UInt32 lang_ptr; // Pointer to language records - public UInt32 files_ptr; // Pointer to file records - public UInt32 reqs_ptr; // Pointer to requisite records - public UInt32 certs_ptr; // Pointer to certificate records - public UInt32 comp_ptr; // Pointer to component name record + public uint uid1; // Application UID before SymbianOS 9, magic after + public uint uid2; // EPOC release magic before SOS 9, NULLs after + public uint uid3; // Application UID after SOS 9, magic before + public uint uid4; // Checksum of UIDs 1 to 3 + public ushort crc16; // CRC16 of all header + public ushort languages; // Number of languages + public ushort files; // Number of files + public ushort requisites; // Number of requisites + public ushort inst_lang; // Installed language (only residual SIS) + public ushort inst_files; // Installed files (only residual SIS) + public ushort inst_drive; // Installed drive (only residual SIS), NULL or 0x0021 + public ushort capabilities; // Number of capabilities + public uint inst_version; // Version of Symbian Installer required + public ushort options; // Option flags + public ushort type; // Type + public ushort major; // Major version of application + public ushort minor; // Minor version of application + public uint variant; // Variant when SIS is a prerequisite for other SISs + public uint lang_ptr; // Pointer to language records + public uint files_ptr; // Pointer to file records + public uint reqs_ptr; // Pointer to requisite records + public uint certs_ptr; // Pointer to certificate records + public uint comp_ptr; // Pointer to component name record // From EPOC Release 6 - public UInt32 sig_ptr; // Pointer to signature record - public UInt32 caps_ptr; // Pointer to capability records - public UInt32 instspace; // Installed space (only residual SIS) - public UInt32 maxinsspc; // Space required - public UInt64 reserved1; // Reserved - public UInt64 reserved2; // Reserved + public uint sig_ptr; // Pointer to signature record + public uint caps_ptr; // Pointer to capability records + public uint instspace; // Installed space (only residual SIS) + public uint maxinsspc; // Space required + public ulong reserved1; // Reserved + public ulong reserved2; // Reserved } } } diff --git a/DiscImageChef.Filesystems/SysV.cs b/DiscImageChef.Filesystems/SysV.cs index 3f6466f7..40fb1f6a 100644 --- a/DiscImageChef.Filesystems/SysV.cs +++ b/DiscImageChef.Filesystems/SysV.cs @@ -32,28 +32,27 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; -// Information from the Linux kernel namespace DiscImageChef.Filesystems { + // Information from the Linux kernel class SysVfs : Filesystem { - const UInt32 XENIX_MAGIC = 0x002B5544; - const UInt32 XENIX_CIGAM = 0x44552B00; - const UInt32 SYSV_MAGIC = 0xFD187E20; - const UInt32 SYSV_CIGAM = 0x207E18FD; + const uint XENIX_MAGIC = 0x002B5544; + const uint XENIX_CIGAM = 0x44552B00; + const uint SYSV_MAGIC = 0xFD187E20; + const uint SYSV_CIGAM = 0x207E18FD; // Rest have no magic. // Per a Linux kernel, Coherent fs has following: const string COH_FNAME = "nonamexxxxx "; const string COH_FPACK = "nopackxxxxx\n"; // SCO AFS - const UInt16 SCO_NFREE = 0xFFFF; + const ushort SCO_NFREE = 0xFFFF; // UNIX 7th Edition has nothing to detect it, so check for a valid filesystem is a must :( - const UInt16 V7_NICINOD = 100; - const UInt16 V7_NICFREE = 50; - const UInt32 V7_MAXSIZE = 0x00FFFFFF; + const ushort V7_NICINOD = 100; + const ushort V7_NICFREE = 50; + const uint V7_MAXSIZE = 0x00FFFFFF; public SysVfs() { @@ -72,15 +71,15 @@ namespace DiscImageChef.Filesystems if((2 + partitionStart) >= imagePlugin.GetSectors()) return false; - UInt32 magic; + uint magic; string s_fname, s_fpack; - UInt16 s_nfree, s_ninode; - UInt32 s_fsize; + ushort s_nfree, s_ninode; + uint s_fsize; /*for(int j = 0; j<=(br.BaseStream.Length/0x200); j++) { br.BaseStream.Seek(offset + j*0x200 + 0x1F8, SeekOrigin.Begin); // System V magic location - magic = br.ReadUInt32(); + magic = br.Readuint(); if(magic == SYSV_MAGIC || magic == SYSV_CIGAM) Console.WriteLine("0x{0:X8}: 0x{1:X8} FOUND", br.BaseStream.Position-4, magic); @@ -88,11 +87,11 @@ namespace DiscImageChef.Filesystems Console.WriteLine("0x{0:X8}: 0x{1:X8}", br.BaseStream.Position-4, magic); }*/ - /*UInt32 number; + /*uint number; br.BaseStream.Seek(offset+0x3A00, SeekOrigin.Begin); while((br.BaseStream.Position) <= (offset+0x3C00)) { - number = br.ReadUInt32(); + number = br.Readuint(); Console.WriteLine("@{0:X8}: 0x{1:X8} ({1})", br.BaseStream.Position-offset-4, number); }*/ @@ -104,7 +103,7 @@ namespace DiscImageChef.Filesystems else sb_size_in_sectors = 1; // If not a single sector can store it - if(imagePlugin.GetSectors() <= (partitionStart + 4 * (ulong)sb_size_in_sectors + (ulong)sb_size_in_sectors)) // Device must be bigger than SB location + SB size + offset + if(imagePlugin.GetSectors() <= (partitionStart + 4 * (ulong)sb_size_in_sectors + sb_size_in_sectors)) // Device must be bigger than SB location + SB size + offset return false; // Superblock can start on 0x000, 0x200, 0x600 and 0x800, not aligned, so we assume 16 (128 bytes/sector) sectors as a safe value @@ -142,8 +141,8 @@ namespace DiscImageChef.Filesystems { // Byteswap s_fsize = ((s_fsize & 0xFF) << 24) + ((s_fsize & 0xFF00) << 8) + ((s_fsize & 0xFF0000) >> 8) + ((s_fsize & 0xFF000000) >> 24); - s_nfree = (UInt16)(s_nfree >> 8); - s_ninode = (UInt16)(s_ninode >> 8); + s_nfree = (ushort)(s_nfree >> 8); + s_ninode = (ushort)(s_ninode >> 8); } if((s_fsize & 0xFF000000) == 0x00 && (s_nfree & 0xFF00) == 0x00 && (s_ninode & 0xFF00) == 0x00) @@ -167,10 +166,10 @@ namespace DiscImageChef.Filesystems StringBuilder sb = new StringBuilder(); BigEndianBitConverter.IsLittleEndian = true; // Start in little endian until we know what are we handling here int start; - UInt32 magic; + uint magic; string s_fname, s_fpack; - UInt16 s_nfree, s_ninode; - UInt32 s_fsize; + ushort s_nfree, s_ninode; + uint s_fsize; bool xenix = false; bool sysv = false; bool sysvr4 = false; @@ -242,8 +241,8 @@ namespace DiscImageChef.Filesystems { // Byteswap s_fsize = ((s_fsize & 0xFF) << 24) + ((s_fsize & 0xFF00) << 8) + ((s_fsize & 0xFF0000) >> 8) + ((s_fsize & 0xFF000000) >> 24); - s_nfree = (UInt16)(s_nfree >> 8); - s_ninode = (UInt16)(s_ninode >> 8); + s_nfree = (ushort)(s_nfree >> 8); + s_ninode = (ushort)(s_ninode >> 8); } if((s_fsize & 0xFF000000) == 0x00 && (s_nfree & 0xFF00) == 0x00 && (s_ninode & 0xFF00) == 0x00) @@ -294,7 +293,7 @@ namespace DiscImageChef.Filesystems xnx_sb.s_magic = BigEndianBitConverter.ToUInt32(sb_sector, 0x3F8); xnx_sb.s_type = BigEndianBitConverter.ToUInt32(sb_sector, 0x3FC); - UInt32 bs = 512; + uint bs = 512; sb.AppendLine("XENIX filesystem"); xmlFSType.Type = "XENIX fs"; switch(xnx_sb.s_type) @@ -364,7 +363,7 @@ namespace DiscImageChef.Filesystems if(sysv) { sb_sector = imagePlugin.ReadSectors((ulong)start + partitionStart, sb_size_in_sectors); - UInt16 pad0, pad1, pad2; + ushort pad0, pad1, pad2; byte[] sysv_strings = new byte[6]; pad0 = BigEndianBitConverter.ToUInt16(sb_sector, 0x002); // First padding @@ -425,7 +424,7 @@ namespace DiscImageChef.Filesystems sysv_sb.s_fpack = StringHandlers.CToString(sysv_strings); } - UInt32 bs = 512; + uint bs = 512; if(sysvr4) { sb.AppendLine("System V Release 4 filesystem"); @@ -617,19 +616,19 @@ namespace DiscImageChef.Filesystems struct XenixSuperBlock { /// 0x000, index of first data zone - public UInt16 s_isize; + public ushort s_isize; /// 0x002, total number of zones of this volume - public UInt32 s_fsize; + public uint s_fsize; // the start of the free block list: /// 0x006, blocks in s_free, <=100 - public UInt16 s_nfree; + public ushort s_nfree; /// 0x008, 100 entries, first free block list chunk - public UInt32[] s_free; + public uint[] s_free; // the cache of free inodes: /// 0x198, number of inodes in s_inode, <= 100 - public UInt16 s_ninode; + public ushort s_ninode; /// 0x19A, 100 entries, some free inodes - public UInt16[] s_inode; + public ushort[] s_inode; /// 0x262, free block list manipulation lock public byte s_flock; /// 0x263, inode cache manipulation lock @@ -639,19 +638,19 @@ namespace DiscImageChef.Filesystems /// 0x265, read-only mounted flag public byte s_ronly; /// 0x266, time of last superblock update - public UInt32 s_time; + public uint s_time; /// 0x26A, total number of free zones - public UInt32 s_tfree; + public uint s_tfree; /// 0x26E, total number of free inodes - public UInt16 s_tinode; + public ushort s_tinode; /// 0x270, blocks per cylinder - public UInt16 s_cylblks; + public ushort s_cylblks; /// 0x272, blocks per gap - public UInt16 s_gapblks; + public ushort s_gapblks; /// 0x274, device information ?? - public UInt16 s_dinfo0; + public ushort s_dinfo0; /// 0x276, device information ?? - public UInt16 s_dinfo1; + public ushort s_dinfo1; /// 0x278, 6 bytes, volume name public string s_fname; /// 0x27E, 6 bytes, pack name @@ -661,33 +660,33 @@ namespace DiscImageChef.Filesystems /// 0x285, 371 bytes public byte[] s_fill; /// 0x3F8, magic - public UInt32 s_magic; + public uint s_magic; /// 0x3FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk, 3 = 2048 bytes/blk) - public UInt32 s_type; + public uint s_type; } struct SystemVRelease4SuperBlock { /// 0x000, index of first data zone - public UInt16 s_isize; + public ushort s_isize; /// 0x002, padding - public UInt16 s_pad0; + public ushort s_pad0; /// 0x004, total number of zones of this volume - public UInt32 s_fsize; + public uint s_fsize; // the start of the free block list: /// 0x008, blocks in s_free, <=100 - public UInt16 s_nfree; + public ushort s_nfree; /// 0x00A, padding - public UInt16 s_pad1; + public ushort s_pad1; /// 0x00C, 50 entries, first free block list chunk - public UInt32[] s_free; + public uint[] s_free; // the cache of free inodes: /// 0x0D4, number of inodes in s_inode, <= 100 - public UInt16 s_ninode; + public ushort s_ninode; /// 0x0D6, padding - public UInt16 s_pad2; + public ushort s_pad2; /// 0x0D8, 100 entries, some free inodes - public UInt16[] s_inode; + public ushort[] s_inode; /// 0x1A0, free block list manipulation lock public byte s_flock; /// 0x1A1, inode cache manipulation lock @@ -697,21 +696,21 @@ namespace DiscImageChef.Filesystems /// 0x1A3, read-only mounted flag public byte s_ronly; /// 0x1A4, time of last superblock update - public UInt32 s_time; + public uint s_time; /// 0x1A8, blocks per cylinder - public UInt16 s_cylblks; + public ushort s_cylblks; /// 0x1AA, blocks per gap - public UInt16 s_gapblks; + public ushort s_gapblks; /// 0x1AC, device information ?? - public UInt16 s_dinfo0; + public ushort s_dinfo0; /// 0x1AE, device information ?? - public UInt16 s_dinfo1; + public ushort s_dinfo1; /// 0x1B0, total number of free zones - public UInt32 s_tfree; + public uint s_tfree; /// 0x1B4, total number of free inodes - public UInt16 s_tinode; + public ushort s_tinode; /// 0x1B6, padding - public UInt16 s_pad3; + public ushort s_pad3; /// 0x1B8, 6 bytes, volume name public string s_fname; /// 0x1BE, 6 bytes, pack name @@ -719,29 +718,29 @@ namespace DiscImageChef.Filesystems /// 0x1C4, 48 bytes public byte[] s_fill; /// 0x1F4, if s_state == (0x7C269D38 - s_time) then filesystem is clean - public UInt32 s_state; + public uint s_state; /// 0x1F8, magic - public UInt32 s_magic; + public uint s_magic; /// 0x1FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk) - public UInt32 s_type; + public uint s_type; } struct SystemVRelease2SuperBlock { /// 0x000, index of first data zone - public UInt16 s_isize; + public ushort s_isize; /// 0x002, total number of zones of this volume - public UInt32 s_fsize; + public uint s_fsize; // the start of the free block list: /// 0x006, blocks in s_free, <=100 - public UInt16 s_nfree; + public ushort s_nfree; /// 0x008, 50 entries, first free block list chunk - public UInt32[] s_free; + public uint[] s_free; // the cache of free inodes: /// 0x0D0, number of inodes in s_inode, <= 100 - public UInt16 s_ninode; + public ushort s_ninode; /// 0x0D2, 100 entries, some free inodes - public UInt16[] s_inode; + public ushort[] s_inode; /// 0x19A, free block list manipulation lock public byte s_flock; /// 0x19B, inode cache manipulation lock @@ -751,19 +750,19 @@ namespace DiscImageChef.Filesystems /// 0x19D, read-only mounted flag public byte s_ronly; /// 0x19E, time of last superblock update - public UInt32 s_time; + public uint s_time; /// 0x1A2, blocks per cylinder - public UInt16 s_cylblks; + public ushort s_cylblks; /// 0x1A4, blocks per gap - public UInt16 s_gapblks; + public ushort s_gapblks; /// 0x1A6, device information ?? - public UInt16 s_dinfo0; + public ushort s_dinfo0; /// 0x1A8, device information ?? - public UInt16 s_dinfo1; + public ushort s_dinfo1; /// 0x1AA, total number of free zones - public UInt32 s_tfree; + public uint s_tfree; /// 0x1AE, total number of free inodes - public UInt16 s_tinode; + public ushort s_tinode; /// 0x1B0, 6 bytes, volume name public string s_fname; /// 0x1B6, 6 bytes, pack name @@ -771,29 +770,29 @@ namespace DiscImageChef.Filesystems /// 0x1BC, 56 bytes public byte[] s_fill; /// 0x1F4, if s_state == (0x7C269D38 - s_time) then filesystem is clean - public UInt32 s_state; + public uint s_state; /// 0x1F8, magic - public UInt32 s_magic; + public uint s_magic; /// 0x1FC, filesystem type (1 = 512 bytes/blk, 2 = 1024 bytes/blk) - public UInt32 s_type; + public uint s_type; } struct UNIX7thEditionSuperBlock { /// 0x000, index of first data zone - public UInt16 s_isize; + public ushort s_isize; /// 0x002, total number of zones of this volume - public UInt32 s_fsize; + public uint s_fsize; // the start of the free block list: /// 0x006, blocks in s_free, <=100 - public UInt16 s_nfree; + public ushort s_nfree; /// 0x008, 50 entries, first free block list chunk - public UInt32[] s_free; + public uint[] s_free; // the cache of free inodes: /// 0x0D0, number of inodes in s_inode, <= 100 - public UInt16 s_ninode; + public ushort s_ninode; /// 0x0D2, 100 entries, some free inodes - public UInt16[] s_inode; + public ushort[] s_inode; /// 0x19A, free block list manipulation lock public byte s_flock; /// 0x19B, inode cache manipulation lock @@ -803,15 +802,15 @@ namespace DiscImageChef.Filesystems /// 0x19D, read-only mounted flag public byte s_ronly; /// 0x19E, time of last superblock update - public UInt32 s_time; + public uint s_time; /// 0x1A2, total number of free zones - public UInt32 s_tfree; + public uint s_tfree; /// 0x1A6, total number of free inodes - public UInt16 s_tinode; + public ushort s_tinode; /// 0x1A8, interleave factor - public UInt16 s_int_m; + public ushort s_int_m; /// 0x1AA, interleave factor - public UInt16 s_int_n; + public ushort s_int_n; /// 0x1AC, 6 bytes, volume name public string s_fname; /// 0x1B2, 6 bytes, pack name @@ -821,19 +820,19 @@ namespace DiscImageChef.Filesystems struct CoherentSuperBlock { /// 0x000, index of first data zone - public UInt16 s_isize; + public ushort s_isize; /// 0x002, total number of zones of this volume - public UInt32 s_fsize; + public uint s_fsize; // the start of the free block list: /// 0x006, blocks in s_free, <=100 - public UInt16 s_nfree; + public ushort s_nfree; /// 0x008, 64 entries, first free block list chunk - public UInt32[] s_free; + public uint[] s_free; // the cache of free inodes: /// 0x108, number of inodes in s_inode, <= 100 - public UInt16 s_ninode; + public ushort s_ninode; /// 0x10A, 100 entries, some free inodes - public UInt16[] s_inode; + public ushort[] s_inode; /// 0x1D2, free block list manipulation lock public byte s_flock; /// 0x1D3, inode cache manipulation lock @@ -843,21 +842,21 @@ namespace DiscImageChef.Filesystems /// 0x1D5, read-only mounted flag public byte s_ronly; /// 0x1D6, time of last superblock update - public UInt32 s_time; + public uint s_time; /// 0x1DE, total number of free zones - public UInt32 s_tfree; + public uint s_tfree; /// 0x1E2, total number of free inodes - public UInt16 s_tinode; + public ushort s_tinode; /// 0x1E4, interleave factor - public UInt16 s_int_m; + public ushort s_int_m; /// 0x1E6, interleave factor - public UInt16 s_int_n; + public ushort s_int_n; /// 0x1E8, 6 bytes, volume name public string s_fname; /// 0x1EE, 6 bytes, pack name public string s_fpack; /// 0x1F4, zero-filled - public UInt32 s_unique; + public uint s_unique; } public override Errno Mount() diff --git a/DiscImageChef.Filesystems/UNIXBFS.cs b/DiscImageChef.Filesystems/UNIXBFS.cs index 8952900d..a069b7f2 100644 --- a/DiscImageChef.Filesystems/UNIXBFS.cs +++ b/DiscImageChef.Filesystems/UNIXBFS.cs @@ -33,17 +33,14 @@ using System; using System.Collections.Generic; using System.Text; -using DiscImageChef; - -// Information from the Linux kernel using DiscImageChef.Console; - namespace DiscImageChef.Filesystems { + // Information from the Linux kernel class BFS : Filesystem { - const UInt32 BFS_MAGIC = 0x1BADFACE; + const uint BFS_MAGIC = 0x1BADFACE; public BFS() { @@ -62,7 +59,7 @@ namespace DiscImageChef.Filesystems if((2 + partitionStart) >= imagePlugin.GetSectors()) return false; - UInt32 magic; + uint magic; magic = BitConverter.ToUInt32(imagePlugin.ReadSector(0 + partitionStart), 0); @@ -118,19 +115,19 @@ namespace DiscImageChef.Filesystems struct BFSSuperBlock { /// 0x00, 0x1BADFACE - public UInt32 s_magic; + public uint s_magic; /// 0x04, start in bytes of volume - public UInt32 s_start; + public uint s_start; /// 0x08, end in bytes of volume - public UInt32 s_end; + public uint s_end; /// 0x0C, unknown :p - public UInt32 s_from; + public uint s_from; /// 0x10, unknown :p - public UInt32 s_to; + public uint s_to; /// 0x14, unknown :p - public Int32 s_bfrom; + public int s_bfrom; /// 0x18, unknown :p - public Int32 s_bto; + public int s_bto; /// 0x1C, 6 bytes, filesystem name public string s_fsname; /// 0x22, 6 bytes, volume name diff --git a/DiscImageChef.Filesystems/ext2FS.cs b/DiscImageChef.Filesystems/ext2FS.cs index f9f72b45..fb7b0c0f 100644 --- a/DiscImageChef.Filesystems/ext2FS.cs +++ b/DiscImageChef.Filesystems/ext2FS.cs @@ -32,12 +32,11 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; -// Information from the Linux kernel namespace DiscImageChef.Filesystems { + // Information from the Linux kernel class ext2FS : Filesystem { public ext2FS() @@ -59,7 +58,7 @@ namespace DiscImageChef.Filesystems byte[] sb_sector = imagePlugin.ReadSector(2 + partitionStart); - UInt16 magic = BitConverter.ToUInt16(sb_sector, 0x038); + ushort magic = BitConverter.ToUInt16(sb_sector, 0x038); if(magic == ext2FSMagic || magic == ext2OldFSMagic) return true; @@ -309,7 +308,7 @@ namespace DiscImageChef.Filesystems byte[] temp_lo, temp_hi; byte[] temp_bytes = new byte[8]; - UInt64 blocks, reserved, free; + ulong blocks, reserved, free; if((supblk.ftr_incompat & EXT4_FEATURE_INCOMPAT_64BIT) == EXT4_FEATURE_INCOMPAT_64BIT) { @@ -624,9 +623,9 @@ namespace DiscImageChef.Filesystems /// /// Same magic for ext2, ext3 and ext4 /// - public const UInt16 ext2FSMagic = 0xEF53; + public const ushort ext2FSMagic = 0xEF53; - public const UInt16 ext2OldFSMagic = 0xEF51; + public const ushort ext2OldFSMagic = 0xEF51; /// /// ext2/3/4 superblock @@ -634,73 +633,73 @@ namespace DiscImageChef.Filesystems public struct ext2FSSuperBlock { /// 0x000, inodes on volume - public UInt32 inodes; + public uint inodes; /// 0x004, blocks on volume - public UInt32 blocks; + public uint blocks; /// 0x008, reserved blocks - public UInt32 reserved_blocks; + public uint reserved_blocks; /// 0x00C, free blocks count - public UInt32 free_blocks; + public uint free_blocks; /// 0x010, free inodes count - public UInt32 free_inodes; + public uint free_inodes; /// 0x014, first data block - public UInt32 first_block; + public uint first_block; /// 0x018, block size - public UInt32 block_size; + public uint block_size; /// 0x01C, fragment size public Int32 frag_size; /// 0x020, blocks per group - public UInt32 blocks_per_grp; + public uint blocks_per_grp; /// 0x024, fragments per group - public UInt32 flags_per_grp; + public uint flags_per_grp; /// 0x028, inodes per group - public UInt32 inodes_per_grp; + public uint inodes_per_grp; /// 0x02C, last mount time - public UInt32 mount_t; + public uint mount_t; /// 0x030, last write time - public UInt32 write_t; + public uint write_t; /// 0x034, mounts count - public UInt16 mount_c; + public ushort mount_c; /// 0x036, max mounts public Int16 max_mount_c; /// 0x038, (little endian) - public UInt16 magic; + public ushort magic; /// 0x03A, filesystem state - public UInt16 state; + public ushort state; /// 0x03C, behaviour on errors - public UInt16 err_behaviour; + public ushort err_behaviour; /// 0x03E, From 0.5b onward - public UInt16 minor_revision; + public ushort minor_revision; /// 0x040, last check time - public UInt32 check_t; + public uint check_t; /// 0x044, max time between checks - public UInt32 check_inv; + public uint check_inv; // From 0.5a onward /// 0x048, Creation OS - public UInt32 creator_os; + public uint creator_os; /// 0x04C, Revison level - public UInt32 revision; + public uint revision; /// 0x050, Default UID for reserved blocks - public UInt16 default_uid; + public ushort default_uid; /// 0x052, Default GID for reserved blocks - public UInt16 default_gid; + public ushort default_gid; // From 0.5b onward /// 0x054, First unreserved inode - public UInt32 first_inode; + public uint first_inode; /// 0x058, inode size - public UInt16 inode_size; + public ushort inode_size; /// 0x05A, Block group number of THIS superblock - public UInt16 block_group_no; + public ushort block_group_no; /// 0x05C, Compatible features set - public UInt32 ftr_compat; + public uint ftr_compat; /// 0x060, Incompatible features set - public UInt32 ftr_incompat; + public uint ftr_incompat; // Found on Linux 2.0.40 /// 0x064, Read-only compatible features set - public UInt32 ftr_ro_compat; + public uint ftr_ro_compat; // Found on Linux 2.1.132 /// 0x068, 16 bytes, UUID @@ -710,108 +709,108 @@ namespace DiscImageChef.Filesystems /// 0x088, 64 bytes, where last mounted public string last_mount_dir; /// 0x0C8, Usage bitmap algorithm, for compression - public UInt32 algo_usage_bmp; + public uint algo_usage_bmp; /// 0x0CC, Block to try to preallocate public byte prealloc_blks; /// 0x0CD, Blocks to try to preallocate for directories public byte prealloc_dir_blks; /// 0x0CE, Per-group desc for online growth - public UInt16 rsrvd_gdt_blocks; + public ushort rsrvd_gdt_blocks; // Found on Linux 2.4 // ext3 /// 0x0D0, 16 bytes, UUID of journal superblock public Guid journal_uuid; /// 0x0E0, inode no. of journal file - public UInt32 journal_inode; + public uint journal_inode; /// 0x0E4, device no. of journal file - public UInt32 journal_dev; + public uint journal_dev; /// 0x0E8, Start of list of inodes to delete - public UInt32 last_orphan; + public uint last_orphan; /// 0x0EC, First byte of 128bit HTREE hash seed - public UInt32 hash_seed_1; + public uint hash_seed_1; /// 0x0F0, Second byte of 128bit HTREE hash seed - public UInt32 hash_seed_2; + public uint hash_seed_2; /// 0x0F4, Third byte of 128bit HTREE hash seed - public UInt32 hash_seed_3; + public uint hash_seed_3; /// 0x0F8, Fourth byte of 128bit HTREE hash seed - public UInt32 hash_seed_4; + public uint hash_seed_4; /// 0x0FC, Hash version public byte hash_version; /// 0x0FD, Journal backup type public byte jnl_backup_type; /// 0x0FE, Size of group descriptor - public UInt16 desc_grp_size; + public ushort desc_grp_size; /// 0x100, Default mount options - public UInt32 default_mnt_opts; + public uint default_mnt_opts; /// 0x104, First metablock block group - public UInt32 first_meta_bg; + public uint first_meta_bg; // Introduced with ext4, some can be ext3 /// 0x108, Filesystem creation time - public UInt32 mkfs_t; + public uint mkfs_t; // Follows 17 uint32 (68 bytes) of journal inode backup // Following 3 fields are valid if EXT4_FEATURE_COMPAT_64BIT is set /// 0x14C, High 32bits of blocks no. - public UInt32 blocks_hi; + public uint blocks_hi; /// 0x150, High 32bits of reserved blocks no. - public UInt32 reserved_blocks_hi; + public uint reserved_blocks_hi; /// 0x154, High 32bits of free blocks no. - public UInt32 free_blocks_hi; + public uint free_blocks_hi; /// 0x158, inodes minimal size in bytes - public UInt16 min_inode_size; + public ushort min_inode_size; /// 0x15A, Bytes reserved by new inodes - public UInt16 rsv_inode_size; + public ushort rsv_inode_size; /// 0x15C, Flags - public UInt32 flags; + public uint flags; /// 0x160, RAID stride - public UInt16 raid_stride; + public ushort raid_stride; /// 0x162, Waiting seconds in MMP check - public UInt16 mmp_interval; + public ushort mmp_interval; /// 0x164, Block for multi-mount protection - public UInt64 mmp_block; + public ulong mmp_block; /// 0x16C, Blocks on all data disks (N*stride) - public UInt32 raid_stripe_width; + public uint raid_stripe_width; /// 0x170, FLEX_BG group size public byte flex_bg_grp_size; /// 0x171 Padding public byte padding; /// 0x172 Padding - public UInt16 padding2; + public ushort padding2; // Following are introduced with ext4 /// 0x174, Kibibytes written in volume lifetime - public UInt64 kbytes_written; + public ulong kbytes_written; /// 0x17C, Active snapshot inode number - public UInt32 snapshot_inum; + public uint snapshot_inum; /// 0x180, Active snapshot sequential ID - public UInt32 snapshot_id; + public uint snapshot_id; /// 0x184, Reserved blocks for active snapshot's future use - public UInt64 snapshot_blocks; + public ulong snapshot_blocks; /// 0x18C, inode number of the on-disk start of the snapshot list - public UInt32 snapshot_list; + public uint snapshot_list; // Optional ext4 error-handling features /// 0x190, total registered filesystem errors - public UInt32 error_count; + public uint error_count; /// 0x194, time on first error - public UInt32 first_error_t; + public uint first_error_t; /// 0x198, inode involved in first error - public UInt32 first_error_inode; + public uint first_error_inode; /// 0x19C, block involved of first error - public UInt64 first_error_block; + public ulong first_error_block; /// 0x1A0, 32 bytes, function where the error happened public string first_error_func; /// 0x1B0, line number where error happened - public UInt32 first_error_line; + public uint first_error_line; /// 0x1B4, time of most recent error - public UInt32 last_error_t; + public uint last_error_t; /// 0x1B8, inode involved in last error - public UInt32 last_error_inode; + public uint last_error_inode; /// 0x1BC, line number where error happened - public UInt32 last_error_line; + public uint last_error_line; /// 0x1C0, block involved of last error - public UInt64 last_error_block; + public ulong last_error_block; /// 0x1C8, 32 bytes, function where the error happened public string last_error_func; // End of optional error-handling features @@ -822,112 +821,112 @@ namespace DiscImageChef.Filesystems // ext? filesystem states /// Cleanly-unmounted volume - public const UInt16 EXT2_VALID_FS = 0x0001; + public const ushort EXT2_VALID_FS = 0x0001; /// Dirty volume - public const UInt16 EXT2_ERROR_FS = 0x0002; + public const ushort EXT2_ERROR_FS = 0x0002; /// Recovering orphan files - public const UInt16 EXT3_ORPHAN_FS = 0x0004; + public const ushort EXT3_ORPHAN_FS = 0x0004; // ext? default mount flags /// Enable debugging messages - public const UInt32 EXT2_DEFM_DEBUG = 0x000001; + public const uint EXT2_DEFM_DEBUG = 0x000001; /// Emulates BSD behaviour on new file creation - public const UInt32 EXT2_DEFM_BSDGROUPS = 0x000002; + public const uint EXT2_DEFM_BSDGROUPS = 0x000002; /// Enable user xattrs - public const UInt32 EXT2_DEFM_XATTR_USER = 0x000004; + public const uint EXT2_DEFM_XATTR_USER = 0x000004; /// Enable POSIX ACLs - public const UInt32 EXT2_DEFM_ACL = 0x000008; + public const uint EXT2_DEFM_ACL = 0x000008; /// Use 16bit UIDs - public const UInt32 EXT2_DEFM_UID16 = 0x000010; + public const uint EXT2_DEFM_UID16 = 0x000010; /// Journal data mode - public const UInt32 EXT3_DEFM_JMODE_DATA = 0x000040; + public const uint EXT3_DEFM_JMODE_DATA = 0x000040; /// Journal ordered mode - public const UInt32 EXT3_DEFM_JMODE_ORDERED = 0x000080; + public const uint EXT3_DEFM_JMODE_ORDERED = 0x000080; /// Journal writeback mode - public const UInt32 EXT3_DEFM_JMODE_WBACK = 0x000100; + public const uint EXT3_DEFM_JMODE_WBACK = 0x000100; // Behaviour on errors /// Continue execution - public const UInt16 EXT2_ERRORS_CONTINUE = 1; + public const ushort EXT2_ERRORS_CONTINUE = 1; /// Remount fs read-only - public const UInt16 EXT2_ERRORS_RO = 2; + public const ushort EXT2_ERRORS_RO = 2; /// Panic - public const UInt16 EXT2_ERRORS_PANIC = 3; + public const ushort EXT2_ERRORS_PANIC = 3; // OS codes - public const UInt32 EXT2_OS_LINUX = 0; - public const UInt32 EXT2_OS_HURD = 1; - public const UInt32 EXT2_OS_MASIX = 2; - public const UInt32 EXT2_OS_FREEBSD = 3; - public const UInt32 EXT2_OS_LITES = 4; + public const uint EXT2_OS_LINUX = 0; + public const uint EXT2_OS_HURD = 1; + public const uint EXT2_OS_MASIX = 2; + public const uint EXT2_OS_FREEBSD = 3; + public const uint EXT2_OS_LITES = 4; // Revision levels /// The good old (original) format - public const UInt32 EXT2_GOOD_OLD_REV = 0; + public const uint EXT2_GOOD_OLD_REV = 0; /// V2 format w/ dynamic inode sizes - public const UInt32 EXT2_DYNAMIC_REV = 1; + public const uint EXT2_DYNAMIC_REV = 1; // Compatible features /// Pre-allocate directories - public const UInt32 EXT2_FEATURE_COMPAT_DIR_PREALLOC = 0x00000001; + public const uint EXT2_FEATURE_COMPAT_DIR_PREALLOC = 0x00000001; /// imagic inodes ? - public const UInt32 EXT2_FEATURE_COMPAT_IMAGIC_INODES = 0x00000002; + public const uint EXT2_FEATURE_COMPAT_IMAGIC_INODES = 0x00000002; /// Has journal (it's ext3) - public const UInt32 EXT3_FEATURE_COMPAT_HAS_JOURNAL = 0x00000004; + public const uint EXT3_FEATURE_COMPAT_HAS_JOURNAL = 0x00000004; /// EA blocks - public const UInt32 EXT2_FEATURE_COMPAT_EXT_ATTR = 0x00000008; + public const uint EXT2_FEATURE_COMPAT_EXT_ATTR = 0x00000008; /// Online filesystem resize reservations - public const UInt32 EXT2_FEATURE_COMPAT_RESIZE_INO = 0x00000010; + public const uint EXT2_FEATURE_COMPAT_RESIZE_INO = 0x00000010; /// Can use hashed indexes on directories - public const UInt32 EXT2_FEATURE_COMPAT_DIR_INDEX = 0x00000020; + public const uint EXT2_FEATURE_COMPAT_DIR_INDEX = 0x00000020; // Read-only compatible features /// Reduced number of superblocks - public const UInt32 EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER = 0x00000001; + public const uint EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER = 0x00000001; /// Can have files bigger than 2GiB - public const UInt32 EXT2_FEATURE_RO_COMPAT_LARGE_FILE = 0x00000002; + public const uint EXT2_FEATURE_RO_COMPAT_LARGE_FILE = 0x00000002; /// Use B-Tree for directories - public const UInt32 EXT2_FEATURE_RO_COMPAT_BTREE_DIR = 0x00000004; + public const uint EXT2_FEATURE_RO_COMPAT_BTREE_DIR = 0x00000004; /// Can have files bigger than 2TiB *ext4* - public const UInt32 EXT4_FEATURE_RO_COMPAT_HUGE_FILE = 0x00000008; + public const uint EXT4_FEATURE_RO_COMPAT_HUGE_FILE = 0x00000008; /// Group descriptor checksums and sparse inode table *ext4* - public const UInt32 EXT4_FEATURE_RO_COMPAT_GDT_CSUM = 0x00000010; + public const uint EXT4_FEATURE_RO_COMPAT_GDT_CSUM = 0x00000010; /// More than 32000 directory entries *ext4* - public const UInt32 EXT4_FEATURE_RO_COMPAT_DIR_NLINK = 0x00000020; + public const uint EXT4_FEATURE_RO_COMPAT_DIR_NLINK = 0x00000020; /// Nanosecond timestamps and creation time *ext4* - public const UInt32 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE = 0x00000040; + public const uint EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE = 0x00000040; // Incompatible features /// Uses compression - public const UInt32 EXT2_FEATURE_INCOMPAT_COMPRESSION = 0x00000001; + public const uint EXT2_FEATURE_INCOMPAT_COMPRESSION = 0x00000001; /// Filetype in directory entries - public const UInt32 EXT2_FEATURE_INCOMPAT_FILETYPE = 0x00000002; + public const uint EXT2_FEATURE_INCOMPAT_FILETYPE = 0x00000002; /// Journal needs recovery *ext3* - public const UInt32 EXT3_FEATURE_INCOMPAT_RECOVER = 0x00000004; + public const uint EXT3_FEATURE_INCOMPAT_RECOVER = 0x00000004; /// Has journal on another device *ext3* - public const UInt32 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV = 0x00000008; + public const uint EXT3_FEATURE_INCOMPAT_JOURNAL_DEV = 0x00000008; /// Reduced block group backups - public const UInt32 EXT2_FEATURE_INCOMPAT_META_BG = 0x00000010; + public const uint EXT2_FEATURE_INCOMPAT_META_BG = 0x00000010; /// Volume use extents *ext4* - public const UInt32 EXT4_FEATURE_INCOMPAT_EXTENTS = 0x00000040; + public const uint EXT4_FEATURE_INCOMPAT_EXTENTS = 0x00000040; /// Supports volumes bigger than 2^32 blocks *ext4* - public const UInt32 EXT4_FEATURE_INCOMPAT_64BIT = 0x00000080; + public const uint EXT4_FEATURE_INCOMPAT_64BIT = 0x00000080; /// Multi-mount protection *ext4* - public const UInt32 EXT4_FEATURE_INCOMPAT_MMP = 0x00000100; + public const uint EXT4_FEATURE_INCOMPAT_MMP = 0x00000100; /// Flexible block group metadata location *ext4* - public const UInt32 EXT4_FEATURE_INCOMPAT_FLEX_BG = 0x00000200; + public const uint EXT4_FEATURE_INCOMPAT_FLEX_BG = 0x00000200; /// EA in inode *ext4* - public const UInt32 EXT4_FEATURE_INCOMPAT_EA_INODE = 0x00000400; + public const uint EXT4_FEATURE_INCOMPAT_EA_INODE = 0x00000400; /// Data can reside in directory entry *ext4* - public const UInt32 EXT4_FEATURE_INCOMPAT_DIRDATA = 0x00001000; + public const uint EXT4_FEATURE_INCOMPAT_DIRDATA = 0x00001000; // Miscellaneous filesystem flags /// Signed dirhash in use - public const UInt32 EXT2_FLAGS_SIGNED_HASH = 0x00000001; + public const uint EXT2_FLAGS_SIGNED_HASH = 0x00000001; /// Unsigned dirhash in use - public const UInt32 EXT2_FLAGS_UNSIGNED_HASH = 0x00000002; + public const uint EXT2_FLAGS_UNSIGNED_HASH = 0x00000002; /// Testing development code - public const UInt32 EXT2_FLAGS_TEST_FILESYS = 0x00000004; + public const uint EXT2_FLAGS_TEST_FILESYS = 0x00000004; public override Errno Mount() { diff --git a/DiscImageChef.Filesystems/extFS.cs b/DiscImageChef.Filesystems/extFS.cs index f1ba598c..9365f725 100644 --- a/DiscImageChef.Filesystems/extFS.cs +++ b/DiscImageChef.Filesystems/extFS.cs @@ -32,12 +32,11 @@ using System; using System.Text; -using DiscImageChef; using System.Collections.Generic; -// Information from the Linux kernel namespace DiscImageChef.Filesystems { + // Information from the Linux kernel class extFS : Filesystem { public extFS() @@ -59,7 +58,7 @@ namespace DiscImageChef.Filesystems byte[] sb_sector = imagePlugin.ReadSector(2 + partitionStart); // Superblock resides at 0x400 - UInt16 magic = BitConverter.ToUInt16(sb_sector, 0x038); // Here should reside magic number + ushort magic = BitConverter.ToUInt16(sb_sector, 0x038); // Here should reside magic number return magic == extFSMagic; } @@ -106,7 +105,7 @@ namespace DiscImageChef.Filesystems /// /// ext superblock magic /// - public const UInt16 extFSMagic = 0x137D; + public const ushort extFSMagic = 0x137D; /// /// ext superblock @@ -114,35 +113,35 @@ namespace DiscImageChef.Filesystems public struct extFSSuperBlock { /// 0x000, inodes on volume - public UInt32 inodes; + public uint inodes; /// 0x004, zones on volume - public UInt32 zones; + public uint zones; /// 0x008, first free block - public UInt32 firstfreeblk; + public uint firstfreeblk; /// 0x00C, free blocks count - public UInt32 freecountblk; + public uint freecountblk; /// 0x010, first free inode - public UInt32 firstfreeind; + public uint firstfreeind; /// 0x014, free inodes count - public UInt32 freecountind; + public uint freecountind; /// 0x018, first data zone - public UInt32 firstdatazone; + public uint firstdatazone; /// 0x01C, log zone size - public UInt32 logzonesize; + public uint logzonesize; /// 0x020, max zone size - public UInt32 maxsize; + public uint maxsize; /// 0x024, reserved - public UInt32 reserved1; + public uint reserved1; /// 0x028, reserved - public UInt32 reserved2; + public uint reserved2; /// 0x02C, reserved - public UInt32 reserved3; + public uint reserved3; /// 0x030, reserved - public UInt32 reserved4; + public uint reserved4; /// 0x034, reserved - public UInt32 reserved5; + public uint reserved5; /// 0x038, 0x137D (little endian) - public UInt16 magic; + public ushort magic; } public override Errno Mount() diff --git a/DiscImageChef.Helpers/ArrayFill.cs b/DiscImageChef.Helpers/ArrayFill.cs index 436825b8..7c6be86c 100644 --- a/DiscImageChef.Helpers/ArrayFill.cs +++ b/DiscImageChef.Helpers/ArrayFill.cs @@ -33,14 +33,14 @@ namespace DiscImageChef public static void ArrayFill(T[] destinationArray, T value) { // if called with a single value, wrap the value in an array and call the main function - ArrayFill(destinationArray, new T[] { value }); + ArrayFill(destinationArray, new T[] { value }); } public static void ArrayFill(T[] destinationArray, T[] value) { if(destinationArray == null) { - throw new ArgumentNullException("destinationArray"); + throw new ArgumentNullException(nameof(destinationArray)); } if(value.Length > destinationArray.Length) diff --git a/DiscImageChef.Helpers/ArrayIsEmpty.cs b/DiscImageChef.Helpers/ArrayIsEmpty.cs index a443c5e8..8e5375ad 100644 --- a/DiscImageChef.Helpers/ArrayIsEmpty.cs +++ b/DiscImageChef.Helpers/ArrayIsEmpty.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef { public static partial class ArrayHelpers diff --git a/DiscImageChef.Helpers/BigEndianBitConverter.cs b/DiscImageChef.Helpers/BigEndianBitConverter.cs index d1209940..17ecfbf6 100644 --- a/DiscImageChef.Helpers/BigEndianBitConverter.cs +++ b/DiscImageChef.Helpers/BigEndianBitConverter.cs @@ -362,7 +362,7 @@ namespace DiscImageChef /// public static short ToInt16(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToInt16(value, startIndex) : BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(Int16) - startIndex); + return !IsLittleEndian ? BitConverter.ToInt16(value, startIndex) : BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(short) - startIndex); } /// @@ -393,7 +393,7 @@ namespace DiscImageChef /// public static int ToInt32(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToInt32(value, startIndex) : BitConverter.ToInt32(value.Reverse().ToArray(), value.Length - sizeof(Int32) - startIndex); + return !IsLittleEndian ? BitConverter.ToInt32(value, startIndex) : BitConverter.ToInt32(value.Reverse().ToArray(), value.Length - sizeof(int) - startIndex); } /// @@ -424,7 +424,7 @@ namespace DiscImageChef /// public static long ToInt64(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToInt64(value, startIndex) : BitConverter.ToInt64(value.Reverse().ToArray(), value.Length - sizeof(Int64) - startIndex); + return !IsLittleEndian ? BitConverter.ToInt64(value, startIndex) : BitConverter.ToInt64(value.Reverse().ToArray(), value.Length - sizeof(long) - startIndex); } /// @@ -456,7 +456,7 @@ namespace DiscImageChef /// public static float ToSingle(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToSingle(value, startIndex) : BitConverter.ToSingle(value.Reverse().ToArray(), value.Length - sizeof(Single) - startIndex); + return !IsLittleEndian ? BitConverter.ToSingle(value, startIndex) : BitConverter.ToSingle(value.Reverse().ToArray(), value.Length - sizeof(float) - startIndex); } /// @@ -575,7 +575,7 @@ namespace DiscImageChef /// public static ushort ToUInt16(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToUInt16(value, startIndex) : BitConverter.ToUInt16(value.Reverse().ToArray(), value.Length - sizeof(UInt16) - startIndex); + return !IsLittleEndian ? BitConverter.ToUInt16(value, startIndex) : BitConverter.ToUInt16(value.Reverse().ToArray(), value.Length - sizeof(ushort) - startIndex); } /// @@ -606,7 +606,7 @@ namespace DiscImageChef /// public static uint ToUInt32(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToUInt32(value, startIndex) : BitConverter.ToUInt32(value.Reverse().ToArray(), value.Length - sizeof(UInt32) - startIndex); + return !IsLittleEndian ? BitConverter.ToUInt32(value, startIndex) : BitConverter.ToUInt32(value.Reverse().ToArray(), value.Length - sizeof(uint) - startIndex); } /// @@ -637,14 +637,14 @@ namespace DiscImageChef /// public static ulong ToUInt64(byte[] value, int startIndex) { - return !IsLittleEndian ? BitConverter.ToUInt64(value, startIndex) : BitConverter.ToUInt64(value.Reverse().ToArray(), value.Length - sizeof(UInt64) - startIndex); + return !IsLittleEndian ? BitConverter.ToUInt64(value, startIndex) : BitConverter.ToUInt64(value.Reverse().ToArray(), value.Length - sizeof(ulong) - startIndex); } public static Guid ToGuid(byte[] value, int startIndex) { - return new Guid(BigEndianBitConverter.ToUInt32(value, 0 + startIndex), - BigEndianBitConverter.ToUInt16(value, 4 + startIndex), - BigEndianBitConverter.ToUInt16(value, 6 + startIndex), + return new Guid(ToUInt32(value, 0 + startIndex), + ToUInt16(value, 4 + startIndex), + ToUInt16(value, 6 + startIndex), value[8 + startIndex + 0], value[8 + startIndex + 1], value[8 + startIndex + 2], value[8 + startIndex + 3], value[8 + startIndex + 5], value[8 + startIndex + 5], diff --git a/DiscImageChef.Helpers/ChangeLog b/DiscImageChef.Helpers/ChangeLog index e4872eee..4bce3952 100644 --- a/DiscImageChef.Helpers/ChangeLog +++ b/DiscImageChef.Helpers/ChangeLog @@ -1,3 +1,14 @@ +2016-07-28 Natalia Portillo + + * Swapping.cs: + * PrintHex.cs: + * ArrayFill.cs: + * ArrayIsEmpty.cs: + * DateHandlers.cs: + * StringHandlers.cs: + * BigEndianBitConverter.cs: + * EndianAwareBinaryReader.cs: Refactor and code cleanup. + 2016-01-13 Natalia Portillo * ArrayFill.cs: diff --git a/DiscImageChef.Helpers/DateHandlers.cs b/DiscImageChef.Helpers/DateHandlers.cs index e4dcf171..b80804f8 100644 --- a/DiscImageChef.Helpers/DateHandlers.cs +++ b/DiscImageChef.Helpers/DateHandlers.cs @@ -49,17 +49,17 @@ namespace DiscImageChef return MacEpoch.AddTicks((long)(MacTimeStamp * 10000000)); } - public static DateTime LisaToDateTime(UInt32 LisaTimeStamp) + public static DateTime LisaToDateTime(uint LisaTimeStamp) { return LisaEpoch.AddSeconds(LisaTimeStamp); } - public static DateTime UNIXToDateTime(Int32 UNIXTimeStamp) + public static DateTime UNIXToDateTime(int UNIXTimeStamp) { return UNIXEpoch.AddSeconds(UNIXTimeStamp); } - public static DateTime UNIXUnsignedToDateTime(UInt32 UNIXTimeStamp) + public static DateTime UNIXUnsignedToDateTime(uint UNIXTimeStamp) { return UNIXEpoch.AddSeconds(UNIXTimeStamp); } @@ -75,49 +75,49 @@ namespace DiscImageChef fourcharvalue[2] = VDDateTime[2]; fourcharvalue[3] = VDDateTime[3]; DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "year = \"{0}\"", StringHandlers.CToString(fourcharvalue)); - if(!Int32.TryParse(StringHandlers.CToString(fourcharvalue), out year)) + if(!int.TryParse(StringHandlers.CToString(fourcharvalue), out year)) year = 0; // year = Convert.ToInt32(StringHandlers.CToString(fourcharvalue)); twocharvalue[0] = VDDateTime[4]; twocharvalue[1] = VDDateTime[5]; DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "month = \"{0}\"", StringHandlers.CToString(twocharvalue)); - if(!Int32.TryParse(StringHandlers.CToString(twocharvalue), out month)) + if(!int.TryParse(StringHandlers.CToString(twocharvalue), out month)) month = 0; // month = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); twocharvalue[0] = VDDateTime[6]; twocharvalue[1] = VDDateTime[7]; DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "day = \"{0}\"", StringHandlers.CToString(twocharvalue)); - if(!Int32.TryParse(StringHandlers.CToString(twocharvalue), out day)) + if(!int.TryParse(StringHandlers.CToString(twocharvalue), out day)) day = 0; // day = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); twocharvalue[0] = VDDateTime[8]; twocharvalue[1] = VDDateTime[9]; DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hour = \"{0}\"", StringHandlers.CToString(twocharvalue)); - if(!Int32.TryParse(StringHandlers.CToString(twocharvalue), out hour)) + if(!int.TryParse(StringHandlers.CToString(twocharvalue), out hour)) hour = 0; // hour = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); twocharvalue[0] = VDDateTime[10]; twocharvalue[1] = VDDateTime[11]; DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "minute = \"{0}\"", StringHandlers.CToString(twocharvalue)); - if(!Int32.TryParse(StringHandlers.CToString(twocharvalue), out minute)) + if(!int.TryParse(StringHandlers.CToString(twocharvalue), out minute)) minute = 0; // minute = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); twocharvalue[0] = VDDateTime[12]; twocharvalue[1] = VDDateTime[13]; DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "second = \"{0}\"", StringHandlers.CToString(twocharvalue)); - if(!Int32.TryParse(StringHandlers.CToString(twocharvalue), out second)) + if(!int.TryParse(StringHandlers.CToString(twocharvalue), out second)) second = 0; // second = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); twocharvalue[0] = VDDateTime[14]; twocharvalue[1] = VDDateTime[15]; DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hundredths = \"{0}\"", StringHandlers.CToString(twocharvalue)); - if(!Int32.TryParse(StringHandlers.CToString(twocharvalue), out hundredths)) + if(!int.TryParse(StringHandlers.CToString(twocharvalue), out hundredths)) hundredths = 0; // hundredths = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); @@ -128,13 +128,13 @@ namespace DiscImageChef } // C# works in UTC, VMS on Julian Date, some displacement may occur on disks created outside UTC - public static DateTime VMSToDateTime(UInt64 vmsDate) + public static DateTime VMSToDateTime(ulong vmsDate) { double delta = vmsDate * 0.0001; // Tenths of microseconds to milliseconds, will lose some detail return JulianEpoch.AddMilliseconds(delta); } - public static DateTime AmigaToDateTime(UInt32 days, UInt32 minutes, UInt32 ticks) + public static DateTime AmigaToDateTime(uint days, uint minutes, uint ticks) { DateTime temp = AmigaEpoch.AddDays(days); temp = temp.AddMinutes(minutes); diff --git a/DiscImageChef.Helpers/EndianAwareBinaryReader.cs b/DiscImageChef.Helpers/EndianAwareBinaryReader.cs index 301b7e82..19480297 100644 --- a/DiscImageChef.Helpers/EndianAwareBinaryReader.cs +++ b/DiscImageChef.Helpers/EndianAwareBinaryReader.cs @@ -39,7 +39,7 @@ namespace DiscImageChef { public class EndianAwareBinaryReader : BinaryReader { - byte[] buffer = new byte[8]; + readonly byte[] buffer = new byte[8]; public EndianAwareBinaryReader(Stream input, Encoding encoding, bool isLittleEndian) : base(input, encoding) diff --git a/DiscImageChef.Helpers/PrintHex.cs b/DiscImageChef.Helpers/PrintHex.cs index 3d5a502e..61898fd1 100644 --- a/DiscImageChef.Helpers/PrintHex.cs +++ b/DiscImageChef.Helpers/PrintHex.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using DiscImageChef.Console; namespace DiscImageChef diff --git a/DiscImageChef.Helpers/StringHandlers.cs b/DiscImageChef.Helpers/StringHandlers.cs index 16237600..2e43fb5b 100644 --- a/DiscImageChef.Helpers/StringHandlers.cs +++ b/DiscImageChef.Helpers/StringHandlers.cs @@ -1,42 +1,35 @@ -/*************************************************************************** -The Disc Image Chef ----------------------------------------------------------------------------- - -Filename : StringHandlers.cs -Version : 1.0 -Author(s) : Natalia Portillo - -Component : Program tools +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : StringHandlers.cs +// Author(s) : Natalia Portillo +// +// Component : Helpers. +// +// --[ Description ] ---------------------------------------------------------- +// +// Convert byte arrays to C# strings. +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2016 Natalia Portillo +// ****************************************************************************/ -Revision : $Revision$ -Last change by : $Author$ -Date : $Date$ - ---[ Description ] ---------------------------------------------------------- - -Convert byte arrays to C# strings. - ---[ 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 . - ----------------------------------------------------------------------------- -Copyright (C) 2011-2014 Claunia.com -****************************************************************************/ -//$Id$ - -using System; using System.Text; namespace DiscImageChef diff --git a/DiscImageChef.Helpers/Swapping.cs b/DiscImageChef.Helpers/Swapping.cs index 8a182c7d..b255c027 100644 --- a/DiscImageChef.Helpers/Swapping.cs +++ b/DiscImageChef.Helpers/Swapping.cs @@ -30,8 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef { public static class Swapping @@ -92,12 +90,12 @@ namespace DiscImageChef return destination; } - public static UInt32 PDPFromLittleEndian(UInt32 x) + public static uint PDPFromLittleEndian(uint x) { return ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16); } - public static UInt32 PDPFromBigEndian(UInt32 x) + public static uint PDPFromBigEndian(uint x) { return ((x & 0xff00ff) << 8) | ((x & 0xff00ff00) >> 8); } diff --git a/DiscImageChef.Interop/ChangeLog b/DiscImageChef.Interop/ChangeLog index 9f4a31ac..0c91911b 100644 --- a/DiscImageChef.Interop/ChangeLog +++ b/DiscImageChef.Interop/ChangeLog @@ -1,3 +1,7 @@ +2016-07-28 Natalia Portillo + + * DetectOS.cs: Refactor and code cleanup. + 2015-10-19 Natalia Portillo * DiscImageChef.Interop.csproj: diff --git a/DiscImageChef.Interop/DetectOS.cs b/DiscImageChef.Interop/DetectOS.cs index 3b759653..6c10da3e 100644 --- a/DiscImageChef.Interop/DetectOS.cs +++ b/DiscImageChef.Interop/DetectOS.cs @@ -82,18 +82,18 @@ namespace DiscImageChef.Interop [DllImport("libc", SetLastError = true, EntryPoint = "sysctlbyname", CharSet = CharSet.Ansi)] static extern int OSX_sysctlbyname(string name, IntPtr oldp, IntPtr oldlenp, IntPtr newp, uint newlen); - public static Interop.PlatformID GetRealPlatformID() + public static PlatformID GetRealPlatformID() { if((int)Environment.OSVersion.Platform < 4 || (int)Environment.OSVersion.Platform == 5) { - return (Interop.PlatformID)((int)Environment.OSVersion.Platform); + return (PlatformID)((int)Environment.OSVersion.Platform); } utsname unixname; int error = uname(out unixname); if(error != 0) - throw new Exception(String.Format("Unhandled exception calling uname: {0}", Marshal.GetLastWin32Error())); + throw new Exception(string.Format("Unhandled exception calling uname: {0}", Marshal.GetLastWin32Error())); switch(unixname.sysname) { @@ -116,7 +116,7 @@ namespace DiscImageChef.Interop { Marshal.FreeHGlobal(pLen); - throw new Exception(String.Format("Unhandled exception calling uname: {0}", Marshal.GetLastWin32Error())); + throw new Exception(string.Format("Unhandled exception calling uname: {0}", Marshal.GetLastWin32Error())); } int length = Marshal.ReadInt32(pLen); @@ -127,7 +127,7 @@ namespace DiscImageChef.Interop Marshal.FreeHGlobal(pStr); Marshal.FreeHGlobal(pLen); - throw new Exception(String.Format("Unhandled exception calling uname: {0}", Marshal.GetLastWin32Error())); + throw new Exception(string.Format("Unhandled exception calling uname: {0}", Marshal.GetLastWin32Error())); } string machine = Marshal.PtrToStringAnsi(pStr); diff --git a/DiscImageChef.Metadata/ChangeLog b/DiscImageChef.Metadata/ChangeLog index ec002c58..4a0253e6 100644 --- a/DiscImageChef.Metadata/ChangeLog +++ b/DiscImageChef.Metadata/ChangeLog @@ -1,3 +1,7 @@ +2016-07-28 Natalia Portillo + + * DeviceReport.cs: Refactor and code cleanup. + 2016-02-10 Natalia Portillo * DeviceReport.cs: diff --git a/DiscImageChef.Metadata/DeviceReport.cs b/DiscImageChef.Metadata/DeviceReport.cs index 9a1d9cec..aa2c595d 100644 --- a/DiscImageChef.Metadata/DeviceReport.cs +++ b/DiscImageChef.Metadata/DeviceReport.cs @@ -37,8 +37,8 @@ using DiscImageChef.Decoders.SCSI; namespace DiscImageChef.Metadata { - [SerializableAttribute()] - [XmlRootAttribute("DicDeviceReport", Namespace = "", IsNullable = false)] + [Serializable] + [XmlRoot("DicDeviceReport", Namespace = "", IsNullable = false)] public class DeviceReport { public usbType USB; @@ -48,7 +48,7 @@ namespace DiscImageChef.Metadata public scsiType SCSI; public bool CompactFlash; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CompactFlashSpecified; } @@ -157,165 +157,165 @@ namespace DiscImageChef.Metadata public testedMediaType[] RemovableMedias; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool AdditionalPIDSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool APIOSupportedSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ATAPIByteCountSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool BufferTypeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool BufferSizeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CapabilitiesSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool Capabilities2Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool Capabilities3Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CFAPowerModeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CommandSetSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CommandSet2Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CommandSet3Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CommandSet4Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CommandSet5Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CurrentAAMSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CurrentAPMSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool DataSetMgmtSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool DataSetMgmtSizeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool DeviceFormFactorSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool DMAActiveSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool DMASupportedSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool DMATransferTimingModeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool EnhancedSecurityEraseTimeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool EnabledCommandSetSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool EnabledCommandSet2Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool EnabledCommandSet3Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool EnabledCommandSet4Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool EnabledSATAFeaturesSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ExtendedIdentifySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ExtendedUserSectorsSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool FreeFallSensitivitySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool FirmwareRevisionSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool GeneralConfigurationSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool HardwareResetResultSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool InterseekDelaySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MajorVersionSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MasterPasswordRevisionCodeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MaxDownloadMicroMode3Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MaxQueueDepthSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MDMAActiveSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MDMASupportedSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MinDownloadMicroMode3Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MinMDMACycleTimeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MinorVersionSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MinPIOCycleTimeNoFlowSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MinPIOCycleTimeFlowSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ModelSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MultipleMaxSectorsSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MultipleSectorNumberSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool NVCacheCapsSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool NVCacheSizeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool NVCacheWriteSpeedSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool NVEstimatedSpinUpSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool PacketBusReleaseSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool PIOTransferTimingModeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool RecommendedAAMSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool RecommendedMDMACycleTimeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool RemovableStatusSetSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SATACapabilitiesSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SATACapabilities2Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SATAFeaturesSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SCTCommandTransportSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SectorsPerCardSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SecurityEraseTimeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SecurityStatusSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ServiceBusyClearSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SpecificConfigurationSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool StreamAccessLatencySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool StreamMinReqSizeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool StreamPerformanceGranularitySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool StreamTransferTimeDMASpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool StreamTransferTimePIOSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool TransportMajorVersionSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool TransportMinorVersionSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool TrustedComputingSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool UDMAActiveSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool UDMASupportedSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool WRVModeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool WRVSectorCountMode3Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool WRVSectorCountMode2Specified; } @@ -339,7 +339,7 @@ namespace DiscImageChef.Metadata public testedMediaType[] RemovableMedias; public sscType SequentialDevice; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ReadCapabilitiesSpecified; } @@ -385,31 +385,31 @@ namespace DiscImageChef.Metadata public bool WideBus16; public bool WideBus32; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ANSIVersionSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ECMAVersionSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool DeviceTypeModifierSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ISOVersionSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ProductIdentificationSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ProductRevisionLevelSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ResponseDataFormatSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool VendorIdentificationSpecified; } - [SerializableAttribute()] + [Serializable] public class pageType { - [XmlAttributeAttribute()] + [XmlAttribute] public byte page; - [XmlTextAttribute()] + [XmlText] public byte[] value; } @@ -424,11 +424,11 @@ namespace DiscImageChef.Metadata public bool DPOandFUA; public modePageType[] ModePages; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MediumTypeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SpeedSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool BufferedModeSpecified; } @@ -438,22 +438,22 @@ namespace DiscImageChef.Metadata public ulong Blocks; public uint BlockLength; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool BlocksSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool BlockLengthSpecified; } - [SerializableAttribute()] + [Serializable] public class modePageType { - [XmlAttributeAttribute()] + [XmlAttribute] public byte page; - [XmlAttributeAttribute()] + [XmlAttribute] public byte subpage; - [XmlTextAttribute()] + [XmlText] public byte[] value; } @@ -518,21 +518,21 @@ namespace DiscImageChef.Metadata public bool WritesDVDRAM; public Modes.ModePage_2A_WriteDescriptor[] WriteSpeedPerformanceDescriptors; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MaximumSpeedSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportedVolumeLevelsSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool BufferSizeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CurrentSpeedSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MaximumWriteSpeedSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CurrentWriteSpeedSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool RotationControlSelectedSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CurrentWriteSpeedSelectedSpecified; } @@ -636,13 +636,13 @@ namespace DiscImageChef.Metadata public bool DVDMultiRead; public bool EmbeddedChanger; public bool ErrorRecoveryPage; - [XmlElementAttribute(DataType = "date")] + [XmlElement(DataType = "date")] public DateTime FirmwareDate; public byte LoadingMechanismType; public bool Locked; public uint LogicalBlockSize; public bool MultiRead; - public DiscImageChef.Decoders.SCSI.MMC.PhysicalInterfaces PhysicalInterfaceStandard; + public Decoders.SCSI.MMC.PhysicalInterfaces PhysicalInterfaceStandard; public bool PreventJumper; public bool SupportsAACS; public bool SupportsBusEncryption; @@ -663,29 +663,29 @@ namespace DiscImageChef.Metadata public bool SupportsWriteProtectPAC; public ushort VolumeLevels; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool PhysicalInterfaceStandardSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool AACSVersionSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool AGIDsSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool BindingNonceBlocksSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CPRMVersionSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CSSVersionSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ChangerHighestSlotNumberSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool LoadingMechanismTypeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool LogicalBlockSizeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool BlocksPerReadableUnitSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool FirmwareDateSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool VolumeLevelsSpecified; } @@ -749,115 +749,115 @@ namespace DiscImageChef.Metadata public bool SupportsReadLong16; public bool SupportsReadLong; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool BlocksSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool BlockSizeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadAACSSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadADIPSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadATIPSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadBCASpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadC2PointersSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadCMISpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadCorrectedSubchannelSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadCorrectedSubchannelWithC2Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadDCBSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadDDSSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadDMISpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadDiscInformationSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadFullTOCSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadHDCMISpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadLayerCapacitySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadLeadInSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadLeadOutSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadMediaIDSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadMediaSerialSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadPACSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadPFISpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadPMASpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadPQSubchannelSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadPQSubchannelWithC2Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadPRISpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadRWSubchannelSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadRWSubchannelWithC2Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadRecordablePFISpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadSpareAreaInformationSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadTOCSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool DensitySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool LongBlockSizeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ManufacturerSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MediumTypeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool ModelSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsHLDTSTReadRawDVDSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsNECReadCDDASpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsPioneerReadCDDASpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsPioneerReadCDDAMSFSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsPlextorReadCDDASpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsPlextorReadRawDVDSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsRead10Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsRead12Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsRead16Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadCapacity16Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadCapacitySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadCdSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadCdMsfSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadCdRawSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadCdMsfRawSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadLong16Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadLongSpecified; public chsType CHS; @@ -871,21 +871,21 @@ namespace DiscImageChef.Metadata public ushort UnformattedBPT; public ushort UnformattedBPS; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool LBASectorsSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool LBA48SectorsSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool LogicalAlignmentSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool NominalRotationRateSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool PhysicalBlockSizeSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SolidStateDeviceSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool UnformattedBPTSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool UnformattedBPSSpecified; public bool SupportsReadDmaLba; @@ -905,35 +905,35 @@ namespace DiscImageChef.Metadata public bool SupportsReadLongRetry; public bool SupportsSeek; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadDmaLbaSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadDmaRetryLbaSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadLbaSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadRetryLbaSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadLongLbaSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadLongRetryLbaSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsSeekLbaSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadDmaLba48Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadLba48Specified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadDmaSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadDmaRetrySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadRetrySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsReadLongRetrySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool SupportsSeekSpecified; } @@ -947,11 +947,11 @@ namespace DiscImageChef.Metadata public SupportedMedia[] SupportedMediaTypes; public SequentialMedia[] TestedMedia; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool BlockSizeGranularitySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MaxBlockLengthSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MinBlockLengthSpecified; } @@ -994,11 +994,11 @@ namespace DiscImageChef.Metadata public SupportedDensity[] SupportedDensities; public SupportedMedia[] SupportedMediaTypes; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool CanReadMediaSerialSpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool DensitySpecified; - [XmlIgnoreAttribute()] + [XmlIgnore] public bool MediumTypeSpecified; } } diff --git a/DiscImageChef.Partitions/AppleMap.cs b/DiscImageChef.Partitions/AppleMap.cs index 78171ddb..5a437ba7 100644 --- a/DiscImageChef.Partitions/AppleMap.cs +++ b/DiscImageChef.Partitions/AppleMap.cs @@ -33,23 +33,21 @@ using System; using System.Text; using System.Collections.Generic; -using DiscImageChef; - -// Information about structures learnt from Inside Macintosh -// Constants from image testing using DiscImageChef.Console; namespace DiscImageChef.PartPlugins { + // Information about structures learnt from Inside Macintosh + // Constants from image testing class AppleMap : PartPlugin { // "ER" - const UInt16 APM_MAGIC = 0x4552; + const ushort APM_MAGIC = 0x4552; // "PM" - const UInt16 APM_ENTRY = 0x504D; + const ushort APM_ENTRY = 0x504D; // "TS", old entry magic - const UInt16 APM_OLDENT = 0x5453; + const ushort APM_OLDENT = 0x5453; public AppleMap() { @@ -200,9 +198,9 @@ namespace DiscImageChef.PartPlugins return true; } - static byte[] Read2048SectorAs512(ImagePlugins.ImagePlugin imagePlugin, UInt64 LBA) + static byte[] Read2048SectorAs512(ImagePlugins.ImagePlugin imagePlugin, ulong LBA) { - UInt64 LBA2k = LBA / 4; + ulong LBA2k = LBA / 4; int Remainder = (int)(LBA % 4); byte[] buffer = imagePlugin.ReadSector(LBA2k); @@ -249,63 +247,63 @@ namespace DiscImageChef.PartPlugins public struct AppleMapBootEntry { // Signature ("ER") - public UInt16 signature; + public ushort signature; // Byter per sector - public UInt16 sector_size; + public ushort sector_size; // Sectors of the disk - public UInt32 sectors; + public uint sectors; // Reserved - public UInt16 reserved1; + public ushort reserved1; // Reserved - public UInt16 reserved2; + public ushort reserved2; // Reserved - public UInt32 reserved3; + public uint reserved3; // Number of entries of the driver descriptor - public UInt16 driver_entries; + public ushort driver_entries; // First sector of the driver - public UInt32 first_driver_blk; + public uint first_driver_blk; // Size in 512bytes sectors of the driver - public UInt16 driver_size; + public ushort driver_size; // Operating system (MacOS = 1) - public UInt16 operating_system; + public ushort operating_system; } public struct AppleMapPartitionEntry { // Signature ("PM" or "TS") - public UInt16 signature; + public ushort signature; // Reserved - public UInt16 reserved1; + public ushort reserved1; // Number of entries on the partition map, each one sector - public UInt32 entries; + public uint entries; // First sector of the partition - public UInt32 start; + public uint start; // Number of sectos of the partition - public UInt32 sectors; + public uint sectors; // Partition name, 32 bytes, null-padded public string name; // Partition type. 32 bytes, null-padded public string type; // First sector of the data area - public UInt32 first_data_block; + public uint first_data_block; // Number of sectors of the data area - public UInt32 data_sectors; + public uint data_sectors; // Partition status - public UInt32 status; + public uint status; // First sector of the boot code - public UInt32 first_boot_block; + public uint first_boot_block; // Size in bytes of the boot code - public UInt32 boot_size; + public uint boot_size; // Load address of the boot code - public UInt32 load_address; + public uint load_address; // Reserved - public UInt32 reserved2; + public uint reserved2; // Entry point of the boot code - public UInt32 entry_point; + public uint entry_point; // Reserved - public UInt32 reserved3; + public uint reserved3; // Boot code checksum - public UInt32 checksum; + public uint checksum; // Processor type, 16 bytes, null-padded public string processor; } diff --git a/DiscImageChef.Partitions/Atari.cs b/DiscImageChef.Partitions/Atari.cs index fb6da588..3edbe118 100644 --- a/DiscImageChef.Partitions/Atari.cs +++ b/DiscImageChef.Partitions/Atari.cs @@ -33,28 +33,24 @@ using System; using System.Collections.Generic; using System.Text; -using DiscImageChef; - -// Information learnt from XNU source and testing against real disks using DiscImageChef.Console; - namespace DiscImageChef.PartPlugins { class AtariPartitions : PartPlugin { - const UInt32 TypeGEMDOS = 0x0047454D; - const UInt32 TypeBigGEMDOS = 0x0042474D; - const UInt32 TypeExtended = 0x0058474D; - const UInt32 TypeLinux = 0x004C4E58; - const UInt32 TypeSwap = 0x00535750; - const UInt32 TypeRAW = 0x00524157; - const UInt32 TypeNetBSD = 0x004E4244; - const UInt32 TypeNetBSDSwap = 0x004E4253; - const UInt32 TypeSysV = 0x00554E58; - const UInt32 TypeMac = 0x004D4143; - const UInt32 TypeMinix = 0x004D4958; - const UInt32 TypeMinix2 = 0x004D4E58; + const uint TypeGEMDOS = 0x0047454D; + const uint TypeBigGEMDOS = 0x0042474D; + const uint TypeExtended = 0x0058474D; + const uint TypeLinux = 0x004C4E58; + const uint TypeSwap = 0x00535750; + const uint TypeRAW = 0x00524157; + const uint TypeNetBSD = 0x004E4244; + const uint TypeNetBSDSwap = 0x004E4253; + const uint TypeSysV = 0x00554E58; + const uint TypeMac = 0x004D4143; + const uint TypeMinix = 0x004D4958; + const uint TypeMinix2 = 0x004D4E58; public AtariPartitions() { @@ -134,7 +130,7 @@ namespace DiscImageChef.PartPlugins ulong partitionSequence = 0; for(int i = 0; i < 4; i++) { - UInt32 type = table.entries[i].type & 0x00FFFFFF; + uint type = table.entries[i].type & 0x00FFFFFF; if(type == TypeGEMDOS || type == TypeBigGEMDOS || type == TypeLinux || type == TypeSwap || type == TypeRAW || type == TypeNetBSD || @@ -224,7 +220,7 @@ namespace DiscImageChef.PartPlugins for(int j = 0; j < 4; j++) { - UInt32 extendedType = extendedTable.entries[j].type & 0x00FFFFFF; + uint extendedType = extendedTable.entries[j].type & 0x00FFFFFF; if(extendedType == TypeGEMDOS || extendedType == TypeBigGEMDOS || extendedType == TypeLinux || extendedType == TypeSwap || extendedType == TypeRAW || extendedType == TypeNetBSD || @@ -305,7 +301,7 @@ namespace DiscImageChef.PartPlugins { for(int i = 0; i < 8; i++) { - UInt32 type = table.icdEntries[i].type & 0x00FFFFFF; + uint type = table.icdEntries[i].type & 0x00FFFFFF; if(type == TypeGEMDOS || type == TypeBigGEMDOS || type == TypeLinux || type == TypeSwap || type == TypeRAW || type == TypeNetBSD || @@ -393,15 +389,15 @@ namespace DiscImageChef.PartPlugins /// Flag bit 0 = active /// Flag bit 7 = bootable /// - public UInt32 type; + public uint type; /// /// Starting sector /// - public UInt32 start; + public uint start; /// /// Length in sectors /// - public UInt32 length; + public uint length; } struct AtariTable @@ -421,7 +417,7 @@ namespace DiscImageChef.PartPlugins /// /// Disk size in sectors /// - public UInt32 size; + public uint size; /// /// 4 partition entries /// @@ -429,15 +425,15 @@ namespace DiscImageChef.PartPlugins /// /// Starting sector of bad block list /// - public UInt32 badStart; + public uint badStart; /// /// Length in sectors of bad block list /// - public UInt32 badLength; + public uint badLength; /// /// Checksum for bootable disks /// - public UInt16 checksum; + public ushort checksum; } } } \ No newline at end of file diff --git a/DiscImageChef.Partitions/ChangeLog b/DiscImageChef.Partitions/ChangeLog index 9fc506e1..4418a4a3 100644 --- a/DiscImageChef.Partitions/ChangeLog +++ b/DiscImageChef.Partitions/ChangeLog @@ -1,3 +1,13 @@ +2016-07-28 Natalia Portillo + + * GPT.cs: + * MBR.cs: + * RDB.cs: + * Sun.cs: + * NeXT.cs: + * Atari.cs: + * AppleMap.cs: Refactor and code cleanup. + 2016-02-10 Natalia Portillo * Atari.cs: diff --git a/DiscImageChef.Partitions/GPT.cs b/DiscImageChef.Partitions/GPT.cs index 2bf5e52f..e09b3556 100644 --- a/DiscImageChef.Partitions/GPT.cs +++ b/DiscImageChef.Partitions/GPT.cs @@ -103,7 +103,9 @@ namespace DiscImageChef.PartPlugins handle.Free(); entries.Add(entry); } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { } } diff --git a/DiscImageChef.Partitions/MBR.cs b/DiscImageChef.Partitions/MBR.cs index c7411cdb..b07e0ed7 100644 --- a/DiscImageChef.Partitions/MBR.cs +++ b/DiscImageChef.Partitions/MBR.cs @@ -32,14 +32,13 @@ using System; using System.Collections.Generic; -using DiscImageChef; // TODO: Support AAP, AST, SpeedStor and Ontrack extensions namespace DiscImageChef.PartPlugins { class MBR : PartPlugin { - const UInt16 MBRSignature = 0xAA55; + const ushort MBRSignature = 0xAA55; public MBR() { @@ -50,7 +49,7 @@ namespace DiscImageChef.PartPlugins public override bool GetInformation(ImagePlugins.ImagePlugin imagePlugin, out List partitions) { byte cyl_sect1, cyl_sect2; // For decoding cylinder and sector - UInt16 signature; + ushort signature; ulong counter = 0; partitions = new List(); @@ -138,11 +137,11 @@ namespace DiscImageChef.PartPlugins case 0xA9: case 0xB7: // BSD disklabels { - UInt32 magic = BitConverter.ToUInt32(disklabel_sector, 0); + uint magic = BitConverter.ToUInt32(disklabel_sector, 0); if(magic == 0x82564557) { - UInt16 no_parts = BitConverter.ToUInt16(disklabel_sector, 126); + ushort no_parts = BitConverter.ToUInt16(disklabel_sector, 126); // TODO: Handle disklabels bigger than 1 sector or search max no_parts for(int j = 0; j < no_parts; j++) @@ -156,7 +155,7 @@ namespace DiscImageChef.PartPlugins part.PartitionStart = part.PartitionStartSector * imagePlugin.GetSectorSize(); bsd_type = disklabel_sector[134 + j * 16 + 8]; - part.PartitionType = String.Format("BSD: {0}", bsd_type); + part.PartitionType = string.Format("BSD: {0}", bsd_type); part.PartitionName = decodeBSDType(bsd_type); part.PartitionSequence = counter; @@ -175,7 +174,7 @@ namespace DiscImageChef.PartPlugins } case 0x63: // UNIX disklabel { - UInt32 magic; + uint magic; byte[] unix_dl_sector = imagePlugin.ReadSector(entry.lba_start + 29); // UNIX disklabel starts on sector 29 of partition magic = BitConverter.ToUInt32(unix_dl_sector, 4); @@ -255,7 +254,7 @@ namespace DiscImageChef.PartPlugins part.PartitionStart = vtoc_ent.start * dl.bps; part.PartitionLength = vtoc_ent.length * dl.bps; part.PartitionSequence = counter; - part.PartitionType = String.Format("UNIX: {0}", decodeUNIXTAG(vtoc_ent.tag, isNewDL)); + part.PartitionType = string.Format("UNIX: {0}", decodeUNIXTAG(vtoc_ent.tag, isNewDL)); string info = ""; @@ -279,8 +278,8 @@ namespace DiscImageChef.PartPlugins case 0x82: case 0xBF: // Solaris disklabel { - UInt32 magic = BitConverter.ToUInt32(disklabel_sector, 12); // 12 - UInt32 version = BitConverter.ToUInt32(disklabel_sector, 16); // 16 + uint magic = BitConverter.ToUInt32(disklabel_sector, 12); // 12 + uint version = BitConverter.ToUInt32(disklabel_sector, 16); // 16 if(magic == 0x600DDEEE && version == 1) { @@ -362,7 +361,7 @@ namespace DiscImageChef.PartPlugins if(valid) { - part.PartitionType = String.Format("0x{0:X2}", entry.type); + part.PartitionType = string.Format("0x{0:X2}", entry.type); part.PartitionName = decodeMBRType(entry.type); part.PartitionSequence = counter; part.PartitionDescription = entry.status == 0x80 ? "Partition is bootable." : ""; @@ -440,11 +439,11 @@ namespace DiscImageChef.PartPlugins case 0xA9: case 0xB7: // BSD disklabels { - UInt32 magic = BitConverter.ToUInt32(disklabel_sector, 0); + uint magic = BitConverter.ToUInt32(disklabel_sector, 0); if(magic == 0x82564557) { - UInt16 no_parts = BitConverter.ToUInt16(disklabel_sector, 126); + ushort no_parts = BitConverter.ToUInt16(disklabel_sector, 126); // TODO: Handle disklabels bigger than 1 sector or search max no_parts for(int j = 0; j < no_parts; j++) @@ -458,7 +457,7 @@ namespace DiscImageChef.PartPlugins part.PartitionStart = part.PartitionStartSector * imagePlugin.GetSectorSize(); bsd_type = disklabel_sector[134 + j * 16 + 8]; - part.PartitionType = String.Format("BSD: {0}", bsd_type); + part.PartitionType = string.Format("BSD: {0}", bsd_type); part.PartitionName = decodeBSDType(bsd_type); part.PartitionSequence = counter; @@ -477,7 +476,7 @@ namespace DiscImageChef.PartPlugins } case 0x63: // UNIX disklabel { - UInt32 magic; + uint magic; byte[] unix_dl_sector = imagePlugin.ReadSector(entry.lba_start + 29); // UNIX disklabel starts on sector 29 of partition magic = BitConverter.ToUInt32(unix_dl_sector, 4); @@ -557,7 +556,7 @@ namespace DiscImageChef.PartPlugins part.PartitionStart = vtoc_ent.start * dl.bps; part.PartitionLength = vtoc_ent.length * dl.bps; part.PartitionSequence = counter; - part.PartitionType = String.Format("UNIX: {0}", decodeUNIXTAG(vtoc_ent.tag, isNewDL)); + part.PartitionType = string.Format("UNIX: {0}", decodeUNIXTAG(vtoc_ent.tag, isNewDL)); string info = ""; @@ -581,8 +580,8 @@ namespace DiscImageChef.PartPlugins case 0x82: case 0xBF: // Solaris disklabel { - UInt32 magic = BitConverter.ToUInt32(disklabel_sector, 12); // 12 - UInt32 version = BitConverter.ToUInt32(disklabel_sector, 16); // 16 + uint magic = BitConverter.ToUInt32(disklabel_sector, 12); // 12 + uint version = BitConverter.ToUInt32(disklabel_sector, 16); // 16 if(magic == 0x600DDEEE && version == 1) { @@ -665,7 +664,7 @@ namespace DiscImageChef.PartPlugins if(ext_valid) { - part.PartitionType = String.Format("0x{0:X2}", entry2.type); + part.PartitionType = string.Format("0x{0:X2}", entry2.type); part.PartitionName = decodeMBRType(entry2.type); part.PartitionSequence = counter; part.PartitionDescription = entry2.status == 0x80 ? "Partition is bootable." : ""; @@ -689,9 +688,11 @@ namespace DiscImageChef.PartPlugins return partitions.Count != 0; } - static UInt32 CHStoLBA(ushort cyl, byte head, byte sector) + static uint CHStoLBA(ushort cyl, byte head, byte sector) { - return (((UInt32)cyl * 16) + (UInt32)head) * 63 + (UInt32)sector - 1; +#pragma warning disable IDE0004 // Remove Unnecessary Cast + return (((uint)cyl * 16) + (uint)head) * 63 + (uint)sector - 1; +#pragma warning restore IDE0004 // Remove Unnecessary Cast } static string decodeBSDType(byte type) @@ -1056,7 +1057,7 @@ namespace DiscImageChef.PartPlugins // Starting head [0,254] public byte start_sector; // Starting sector [1,63] - public UInt16 start_cylinder; + public ushort start_cylinder; // Starting cylinder [0,1023] public byte type; // Partition type @@ -1064,55 +1065,55 @@ namespace DiscImageChef.PartPlugins // Ending head [0,254] public byte end_sector; // Ending sector [1,63] - public UInt16 end_cylinder; + public ushort end_cylinder; // Ending cylinder [0,1023] - public UInt32 lba_start; + public uint lba_start; // Starting absolute sector - public UInt32 lba_sectors; + public uint lba_sectors; // Total sectors } - const UInt32 UNIXDiskLabel_MAGIC = 0xCA5E600D; - const UInt32 UNIXVTOC_MAGIC = 0x600DDEEE; + const uint UNIXDiskLabel_MAGIC = 0xCA5E600D; + const uint UNIXVTOC_MAGIC = 0x600DDEEE; // Same as Solaris VTOC struct UNIXDiskLabel { - public UInt32 type; + public uint type; // Drive type, seems always 0 - public UInt32 magic; + public uint magic; // UNIXDiskLabel_MAGIC - public UInt32 version; + public uint version; // Only seen 1 public string serial; // 12 bytes, serial number of the device - public UInt32 cyls; + public uint cyls; // data cylinders per device - public UInt32 trks; + public uint trks; // data tracks per cylinder - public UInt32 secs; + public uint secs; // data sectors per track - public UInt32 bps; + public uint bps; // data bytes per sector - public UInt32 start; + public uint start; // first sector of this partition public byte[] unknown1; // 48 bytes - public UInt32 alt_tbl; + public uint alt_tbl; // byte offset of alternate table - public UInt32 alt_len; + public uint alt_len; // byte length of alternate table // From onward here, is not on old version - public UInt32 phys_cyl; + public uint phys_cyl; // physical cylinders per device - public UInt32 phys_trk; + public uint phys_trk; // physical tracks per cylinder - public UInt32 phys_sec; + public uint phys_sec; // physical sectors per track - public UInt32 phys_bytes; + public uint phys_bytes; // physical bytes per sector - public UInt32 unknown2; + public uint unknown2; // - public UInt32 unknown3; + public uint unknown3; // public byte[] pad; // 32bytes @@ -1120,15 +1121,15 @@ namespace DiscImageChef.PartPlugins struct UNIXVTOC { - public UInt32 magic; + public uint magic; // UNIXVTOC_MAGIC - public UInt32 version; + public uint version; // 1 public string name; // 8 bytes - public UInt16 slices; + public ushort slices; // # of slices - public UInt16 unknown; + public ushort unknown; // public byte[] reserved; // 40 bytes @@ -1136,61 +1137,61 @@ namespace DiscImageChef.PartPlugins struct UNIXVTOCEntry { - public UInt16 tag; + public ushort tag; // TAG - public UInt16 flags; + public ushort flags; // Flags (see below) - public UInt32 start; + public uint start; // Start sector - public UInt32 length; + public uint length; // Length of slice in sectors } - const UInt16 UNIX_TAG_EMPTY = 0x0000; + const ushort UNIX_TAG_EMPTY = 0x0000; // empty - const UInt16 UNIX_TAG_BOOT = 0x0001; + const ushort UNIX_TAG_BOOT = 0x0001; // boot - const UInt16 UNIX_TAG_ROOT = 0x0002; + const ushort UNIX_TAG_ROOT = 0x0002; // root - const UInt16 UNIX_TAG_SWAP = 0x0003; + const ushort UNIX_TAG_SWAP = 0x0003; // swap - const UInt16 UNIX_TAG_USER = 0x0004; + const ushort UNIX_TAG_USER = 0x0004; // /usr - const UInt16 UNIX_TAG_WHOLE = 0x0005; + const ushort UNIX_TAG_WHOLE = 0x0005; // whole disk - const UInt16 UNIX_TAG_STAND = 0x0006; + const ushort UNIX_TAG_STAND = 0x0006; // stand partition ?? - const UInt16 UNIX_TAG_ALT_S = 0x0006; + const ushort UNIX_TAG_ALT_S = 0x0006; // alternate sector space - const UInt16 UNIX_TAG_VAR = 0x0007; + const ushort UNIX_TAG_VAR = 0x0007; // /var - const UInt16 UNIX_TAG_OTHER = 0x0007; + const ushort UNIX_TAG_OTHER = 0x0007; // non UNIX - const UInt16 UNIX_TAG_HOME = 0x0008; + const ushort UNIX_TAG_HOME = 0x0008; // /home - const UInt16 UNIX_TAG_ALT_T = 0x0008; + const ushort UNIX_TAG_ALT_T = 0x0008; // alternate track space - const UInt16 UNIX_TAG_ALT_ST = 0x0009; + const ushort UNIX_TAG_ALT_ST = 0x0009; // alternate sector track - const UInt16 UNIX_TAG_NEW_STAND = 0x0009; + const ushort UNIX_TAG_NEW_STAND = 0x0009; // stand partition ?? - const UInt16 UNIX_TAG_CACHE = 0x000A; + const ushort UNIX_TAG_CACHE = 0x000A; // cache - const UInt16 UNIX_TAG_NEW_VAR = 0x000A; + const ushort UNIX_TAG_NEW_VAR = 0x000A; // /var - const UInt16 UNIX_TAG_RESERVED = 0x000B; + const ushort UNIX_TAG_RESERVED = 0x000B; // reserved - const UInt16 UNIX_TAG_NEW_HOME = 0x000B; + const ushort UNIX_TAG_NEW_HOME = 0x000B; // /home - const UInt16 UNIX_TAG_DUMP = 0x000C; + const ushort UNIX_TAG_DUMP = 0x000C; // dump partition - const UInt16 UNIX_TAG_NEW_ALT_ST = 0x000D; + const ushort UNIX_TAG_NEW_ALT_ST = 0x000D; // alternate sector track - const UInt16 UNIX_TAG_VM_PUBLIC = 0x000E; + const ushort UNIX_TAG_VM_PUBLIC = 0x000E; // volume mgt public partition - const UInt16 UNIX_TAG_VM_PRIVATE = 0x000F; + const ushort UNIX_TAG_VM_PRIVATE = 0x000F; // volume mgt private partition - static string decodeUNIXTAG(UInt16 type, bool isNew) + static string decodeUNIXTAG(ushort type, bool isNew) { switch(type) { @@ -1227,7 +1228,7 @@ namespace DiscImageChef.PartPlugins case UNIX_TAG_VM_PRIVATE: return "volume mgt private partition"; default: - return String.Format("Unknown TAG: 0x{0:X4}", type); + return string.Format("Unknown TAG: 0x{0:X4}", type); } } } diff --git a/DiscImageChef.Partitions/NeXT.cs b/DiscImageChef.Partitions/NeXT.cs index 2fb3edee..1fa1ccac 100644 --- a/DiscImageChef.Partitions/NeXT.cs +++ b/DiscImageChef.Partitions/NeXT.cs @@ -33,22 +33,21 @@ using System; using System.Collections.Generic; using System.Text; -using DiscImageChef; // Information learnt from XNU source and testing against real disks namespace DiscImageChef.PartPlugins { class NeXTDisklabel : PartPlugin { - const UInt32 NEXT_MAGIC1 = 0x4E655854; + const uint NEXT_MAGIC1 = 0x4E655854; // "NeXT" - const UInt32 NEXT_MAGIC2 = 0x646C5632; + const uint NEXT_MAGIC2 = 0x646C5632; // "dlV2" - const UInt32 NEXT_MAGIC3 = 0x646C5633; + const uint NEXT_MAGIC3 = 0x646C5633; // "dlV3" - const UInt16 disktabStart = 0xB4; + const ushort disktabStart = 0xB4; // 180 - const UInt16 disktabEntrySize = 0x2C; + const ushort disktabEntrySize = 0x2C; // 44 public NeXTDisklabel() { @@ -62,9 +61,9 @@ namespace DiscImageChef.PartPlugins bool magic_found; byte[] entry_sector; - UInt32 magic; - UInt32 sector_size; - UInt16 front_porch; + uint magic; + uint sector_size; + ushort front_porch; if(imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448) sector_size = 2048; @@ -135,7 +134,7 @@ namespace DiscImageChef.PartPlugins part.PartitionType = entry.type; part.PartitionSequence = (ulong)i; part.PartitionName = entry.mount_point; - part.PartitionSectors = (ulong)entry.sectors; + part.PartitionSectors = entry.sectors; part.PartitionStartSector = ((ulong)entry.start + front_porch); sb.AppendFormat("{0} bytes per block", entry.block_size).AppendLine(); @@ -167,19 +166,19 @@ namespace DiscImageChef.PartPlugins struct NeXTEntry { - public UInt32 start; + public uint start; // Sector of start, counting from front porch - public UInt32 sectors; + public uint sectors; // Length in sectors - public UInt16 block_size; + public ushort block_size; // Filesystem's block size - public UInt16 frag_size; + public ushort frag_size; // Filesystem's fragment size public byte optimization; // 's'pace or 't'ime - public UInt16 cpg; + public ushort cpg; // Cylinders per group - public UInt16 bpi; + public ushort bpi; // Bytes per inode public byte freemin; // % of minimum free space diff --git a/DiscImageChef.Partitions/RDB.cs b/DiscImageChef.Partitions/RDB.cs index 9c80976f..bd038d44 100644 --- a/DiscImageChef.Partitions/RDB.cs +++ b/DiscImageChef.Partitions/RDB.cs @@ -42,230 +42,230 @@ namespace DiscImageChef.PartPlugins /// /// RDB magic number "RDSK" /// - const UInt32 RigidDiskBlockMagic = 0x5244534B; + const uint RigidDiskBlockMagic = 0x5244534B; /// /// Bad block list magic number "BADB" /// - const UInt32 BadBlockListMagic = 0x42414442; + const uint BadBlockListMagic = 0x42414442; /// /// Partition entry magic number "PART" /// - const UInt32 PartitionBlockMagic = 0x50415254; + const uint PartitionBlockMagic = 0x50415254; /// /// Filesystem header magic number "FSHD" /// - const UInt32 FilesystemHeaderMagic = 0x46534844; + const uint FilesystemHeaderMagic = 0x46534844; /// /// LoadSeg block magic number "LSEG" /// - const UInt32 LoadSegMagic = 0x4C534547; + const uint LoadSegMagic = 0x4C534547; /// /// Type ID for Amiga Original File System, "DOS\0" /// - const UInt32 TypeIDOFS = 0x444F5300; + const uint TypeIDOFS = 0x444F5300; /// /// Type ID for Amiga Fast File System, "DOS\1" /// - const UInt32 TypeIDFFS = 0x444F5301; + const uint TypeIDFFS = 0x444F5301; /// /// Type ID for Amiga Original File System with international characters, "DOS\2" /// - const UInt32 TypeIDOFSi = 0x444F5302; + const uint TypeIDOFSi = 0x444F5302; /// /// Type ID for Amiga Fast File System with international characters, "DOS\3" /// - const UInt32 TypeIDFFSi = 0x444F5303; + const uint TypeIDFFSi = 0x444F5303; /// /// Type ID for Amiga Original File System with directory cache, "DOS\4" /// - const UInt32 TypeIDOFSc = 0x444F5304; + const uint TypeIDOFSc = 0x444F5304; /// /// Type ID for Amiga Fast File System with directory cache, "DOS\5" /// - const UInt32 TypeIDFFSc = 0x444F5305; + const uint TypeIDFFSc = 0x444F5305; /// /// Type ID for Amiga Original File System with long filenames, "DOS\6" /// - const UInt32 TypeIDOFS2 = 0x444F5306; + const uint TypeIDOFS2 = 0x444F5306; /// /// Type ID for Amiga Fast File System with long filenames, "DOS\7" /// - const UInt32 TypeIDFFS2 = 0x444F5307; + const uint TypeIDFFS2 = 0x444F5307; /// /// Type ID for Amiga UNIX System V filesystem /// - const UInt32 TypeIDAMIXSysV = 0x554E4900; + const uint TypeIDAMIXSysV = 0x554E4900; /// /// Type ID for Amiga UNIX boot filesystem /// - const UInt32 TypeIDAMIXBoot = 0x554E4901; + const uint TypeIDAMIXBoot = 0x554E4901; /// /// Type ID for Amiga UNIX BSD filesystem /// - const UInt32 TypeIDAMIXFFS = 0x554E4902; + const uint TypeIDAMIXFFS = 0x554E4902; /// /// Type ID for Amiga UNIX Reserved partition (swap) /// - const UInt32 TypeIDAMIXReserved = 0x72657376; + const uint TypeIDAMIXReserved = 0x72657376; /// /// Type ID for ProfessionalFileSystem, "PFS\1" /// - const UInt32 TypeIDPFS = 0x50465301; + const uint TypeIDPFS = 0x50465301; /// /// Type ID for ProfessionalFileSystem, "muAF" /// - const UInt32 TypeIDPFSm = 0x6D754146; + const uint TypeIDPFSm = 0x6D754146; /// /// Type ID for ProfessionalFileSystem, "AFS\1" /// - const UInt32 TypeIDAFS = 0x41465301; + const uint TypeIDAFS = 0x41465301; /// /// Type ID for SmartFileSystem v1, "SFS\0" /// - const UInt32 TypeIDSFS = 0x53465300; + const uint TypeIDSFS = 0x53465300; /// /// Type ID for SmartFileSystem v2, "SFS\2" /// - const UInt32 TypeIDSFS2 = 0x53465302; + const uint TypeIDSFS2 = 0x53465302; /// /// Type ID for JXFS, "JXF\4" /// - const UInt32 TypeIDJXFS = 0x4A584604; + const uint TypeIDJXFS = 0x4A584604; /// /// Type ID for FAT, as set by CrossDOS, "MSD\0" /// - const UInt32 TypeIDCrossDOS = 0x4D534400; + const uint TypeIDCrossDOS = 0x4D534400; /// /// Type ID for HFS, as set by CrossMac, "MAC\0" /// - const UInt32 TypeIDCrossMac = 0x4D414300; + const uint TypeIDCrossMac = 0x4D414300; /// /// Type ID for 4.2UFS, for BFFS, "BFFS" /// - const UInt32 TypeIDBFFS = 0x42464653; + const uint TypeIDBFFS = 0x42464653; /// /// Type ID for Amiga Original File System with multi-user patches, "muF\0" /// - const UInt32 TypeIDmuOFS = 0x6D754600; + const uint TypeIDmuOFS = 0x6D754600; /// /// Type ID for Amiga Fast File System with multi-user patches, "muF\1" /// - const UInt32 TypeIDmuFFS = 0x6D754601; + const uint TypeIDmuFFS = 0x6D754601; /// /// Type ID for Amiga Original File System with international characters and multi-user patches, "muF\2" /// - const UInt32 TypeIDmuOFSi = 0x6D754602; + const uint TypeIDmuOFSi = 0x6D754602; /// /// Type ID for Amiga Fast File System with international characters and multi-user patches, "muF\3" /// - const UInt32 TypeIDmuFFSi = 0x6D754603; + const uint TypeIDmuFFSi = 0x6D754603; /// /// Type ID for Amiga Original File System with directory cache and multi-user patches, "muF\4" /// - const UInt32 TypeIDmuOFSc = 0x6D754604; + const uint TypeIDmuOFSc = 0x6D754604; /// /// Type ID for Amiga Fast File System with directory cache and multi-user patches, "muF\5" /// - const UInt32 TypeIDmuFFSc = 0x6D754605; + const uint TypeIDmuFFSc = 0x6D754605; /// /// Type ID for BSD unused, "BSD\0" /// - const UInt32 TypeIDOldBSDUnused = 0x42534400; + const uint TypeIDOldBSDUnused = 0x42534400; /// /// Type ID for BSD swap, "BSD\1" /// - const UInt32 TypeIDOldBSDSwap = 0x42534401; + const uint TypeIDOldBSDSwap = 0x42534401; /// /// Type ID for BSD 4.2 FFS, "BSD\7" /// - const UInt32 TypeIDOldBSD42FFS = 0x42534407; + const uint TypeIDOldBSD42FFS = 0x42534407; /// /// Type ID for BSD 4.4 LFS, "BSD\9" /// - const UInt32 TypeIDOldBSD44LFS = 0x42534409; + const uint TypeIDOldBSD44LFS = 0x42534409; /// /// Type ID for NetBSD unused root partition, "NBR\0" /// - const UInt32 TypeIDNetBSDRootUnused = 0x4E425200; + const uint TypeIDNetBSDRootUnused = 0x4E425200; /// /// Type ID for NetBSD 4.2 FFS root partition, "NBR\7" /// - const UInt32 TypeIDNetBSDRoot42FFS = 0x4E425207; + const uint TypeIDNetBSDRoot42FFS = 0x4E425207; /// /// Type ID for NetBSD 4.4 LFS root partition, "NBR\9" /// - const UInt32 TypeIDNetBSDRoot44LFS = 0x4E425209; + const uint TypeIDNetBSDRoot44LFS = 0x4E425209; /// /// Type ID for NetBSD unused user partition, "NBR\0" /// - const UInt32 TypeIDNetBSDUserUnused = 0x4E425500; + const uint TypeIDNetBSDUserUnused = 0x4E425500; /// /// Type ID for NetBSD 4.2 FFS user partition, "NBR\7" /// - const UInt32 TypeIDNetBSDUser42FFS = 0x4E425507; + const uint TypeIDNetBSDUser42FFS = 0x4E425507; /// /// Type ID for NetBSD 4.4 LFS user partition, "NBR\9" /// - const UInt32 TypeIDNetBSDUser44LFS = 0x4E425509; + const uint TypeIDNetBSDUser44LFS = 0x4E425509; /// /// Type ID for NetBSD swap partition /// - const UInt32 TypeIDNetBSDSwap = 0x4E425300; + const uint TypeIDNetBSDSwap = 0x4E425300; /// /// Type ID for Linux filesystem partition, "LNX\0" /// - const UInt32 TypeIDLinux = 0x4C4E5800; + const uint TypeIDLinux = 0x4C4E5800; /// /// Type ID for Linux swap partition, "SWP\0" /// - const UInt32 TypeIDLinuxSwap = 0x53575000; + const uint TypeIDLinuxSwap = 0x53575000; /// /// Type ID for RaidFrame partition, "RAID" /// - const UInt32 TypeIDRaidFrame = 0x52414944; + const uint TypeIDRaidFrame = 0x52414944; /// /// Type ID for RaidFrame partition, "RAI\0" /// - const UInt32 TypeIDRaidFrame0 = 0x52414900; + const uint TypeIDRaidFrame0 = 0x52414900; /// /// No disks to be configured after this one /// - const UInt32 FlagsNoDisks = 0x00000001; + const uint FlagsNoDisks = 0x00000001; /// /// No LUNs to be configured after this one /// - const UInt32 FlagsNoLUNs = 0x00000002; + const uint FlagsNoLUNs = 0x00000002; /// /// No target IDs to be configured after this one /// - const UInt32 FlagsNoTargets = 0x00000004; + const uint FlagsNoTargets = 0x00000004; /// /// Don't try to perform reselection with this drive /// - const UInt32 FlagsNoReselection = 0x00000008; + const uint FlagsNoReselection = 0x00000008; /// /// Disk identification is valid /// - const UInt32 FlagsValidDiskID = 0x00000010; + const uint FlagsValidDiskID = 0x00000010; /// /// Controller identification is valid /// - const UInt32 FlagsValidControllerID = 0x00000020; + const uint FlagsValidControllerID = 0x00000020; /// /// Drive supports synchronous SCSI mode /// - const UInt32 FlagsSynchSCSI = 0x00000040; + const uint FlagsSynchSCSI = 0x00000040; /// /// Partition is bootable /// - const UInt32 FlagsBootable = 0x00000001; + const uint FlagsBootable = 0x00000001; /// /// Partition should not be mounted automatically /// - const UInt32 FlagsNoAutomount = 0x00000002; + const uint FlagsNoAutomount = 0x00000002; public AmigaRigidDiskBlock() { @@ -282,163 +282,163 @@ namespace DiscImageChef.PartPlugins /// /// "RDSK" /// - public UInt32 magic; + public uint magic; /// /// Size in longs /// - public UInt32 size; + public uint size; /// /// Checksum /// - public Int32 checksum; + public int checksum; /// /// SCSI target ID, 7 for non-SCSI /// - public UInt32 targetID; + public uint targetID; /// /// Block size in bytes /// - public UInt32 block_size; + public uint block_size; /// /// Flags /// - public UInt32 flags; + public uint flags; /// /// Pointer to first BadBlockList, 0xFFFFFFFF means last block in device /// - public UInt32 badblock_ptr; + public uint badblock_ptr; /// /// Pointer to first PartitionEntry, 0xFFFFFFFF means last block in device /// - public UInt32 partition_ptr; + public uint partition_ptr; /// /// Pointer to first FileSystemHeader, 0xFFFFFFFF means last block in device /// - public UInt32 fsheader_ptr; + public uint fsheader_ptr; /// /// Optional drive specific init code /// - public UInt32 driveinitcode; + public uint driveinitcode; /// /// Reserved, should be 0xFFFFFFFF /// - public UInt32 reserved1; + public uint reserved1; /// /// Reserved, should be 0xFFFFFFFF /// - public UInt32 reserved2; + public uint reserved2; /// /// Reserved, should be 0xFFFFFFFF /// - public UInt32 reserved3; + public uint reserved3; /// /// Reserved, should be 0xFFFFFFFF /// - public UInt32 reserved4; + public uint reserved4; /// /// Reserved, should be 0xFFFFFFFF /// - public UInt32 reserved5; + public uint reserved5; /// /// Reserved, should be 0xFFFFFFFF /// - public UInt32 reserved6; + public uint reserved6; /// /// Cylinders in drive /// - public UInt32 cylinders; + public uint cylinders; /// /// Sectors per track /// - public UInt32 spt; + public uint spt; /// /// Heads in drive /// - public UInt32 heads; + public uint heads; /// /// Drive interleave /// - public UInt32 interleave; + public uint interleave; /// /// Cylinder for parking heads /// - public UInt32 parking; + public uint parking; /// /// Reserved, should be zero /// - public UInt32 reserved7; + public uint reserved7; /// /// Reserved, should be zero /// - public UInt32 reserved8; + public uint reserved8; /// /// Reserved, should be zero /// - public UInt32 reserved9; + public uint reserved9; /// /// Starting cylinder for write precompensation /// - public UInt32 writeprecomp; + public uint writeprecomp; /// /// Starting cylinder for reduced write current /// - public UInt32 reducedwrite; + public uint reducedwrite; /// /// Drive step rate /// - public UInt32 steprate; + public uint steprate; /// /// Reserved, should be zero /// - public UInt32 reserved10; + public uint reserved10; /// /// Reserved, should be zero /// - public UInt32 reserved11; + public uint reserved11; /// /// Reserved, should be zero /// - public UInt32 reserved12; + public uint reserved12; /// /// Reserved, should be zero /// - public UInt32 reserved13; + public uint reserved13; /// /// Reserved, should be zero /// - public UInt32 reserved14; + public uint reserved14; /// /// Low block of RDB reserved blocks /// - public UInt32 RDBBlockLow; + public uint RDBBlockLow; /// /// High block of RDB reserved blocks /// - public UInt32 RDBBlockHigh; + public uint RDBBlockHigh; /// /// Low cylinder for partitionable area /// - public UInt32 LowCylinder; + public uint LowCylinder; /// /// High cylinder for partitionable area /// - public UInt32 HighCylinder; + public uint HighCylinder; /// /// Blocks per cylinder /// - public UInt32 CylBlocks; + public uint CylBlocks; /// /// Seconds for head autoparking /// - public UInt32 AutoParkSeconds; + public uint AutoParkSeconds; /// /// Highest block used by RDB /// - public UInt32 HighRDSKBlock; + public uint HighRDSKBlock; /// /// Reserved, should be zero /// - public UInt32 reserved15; + public uint reserved15; /// /// Disk vendor, 8 bytes /// @@ -466,43 +466,43 @@ namespace DiscImageChef.PartPlugins /// /// Reserved, should be zero /// - public UInt32 reserved16; + public uint reserved16; /// /// Reserved, should be zero /// - public UInt32 reserved17; + public uint reserved17; /// /// Reserved, should be zero /// - public UInt32 reserved18; + public uint reserved18; /// /// Reserved, should be zero /// - public UInt32 reserved19; + public uint reserved19; /// /// Reserved, should be zero /// - public UInt32 reserved20; + public uint reserved20; /// /// Reserved, should be zero /// - public UInt32 reserved21; + public uint reserved21; /// /// Reserved, should be zero /// - public UInt32 reserved22; + public uint reserved22; /// /// Reserved, should be zero /// - public UInt32 reserved23; + public uint reserved23; /// /// Reserved, should be zero /// - public UInt32 reserved24; + public uint reserved24; /// /// Reserved, should be zero /// - public UInt32 reserved25; + public uint reserved25; } /// @@ -513,11 +513,11 @@ namespace DiscImageChef.PartPlugins /// /// Bad block pointer /// - public UInt32 badBlock; + public uint badBlock; /// /// Replacement block pointer /// - public UInt32 goodBlock; + public uint goodBlock; } /// @@ -528,27 +528,27 @@ namespace DiscImageChef.PartPlugins /// /// "BADB" /// - public UInt32 magic; + public uint magic; /// /// Size in longs /// - public UInt32 size; + public uint size; /// /// Checksum /// - public Int32 checksum; + public int checksum; /// /// SCSI target ID, 7 for non-SCSI /// - public UInt32 targetID; + public uint targetID; /// /// Pointer for next BadBlockList /// - public UInt32 next_ptr; + public uint next_ptr; /// /// Reserved /// - public UInt32 reserved; + public uint reserved; /// /// Bad block entries, up to block filling, 8 bytes each /// @@ -563,83 +563,83 @@ namespace DiscImageChef.PartPlugins /// /// Size in longs, should be 16, minimum 11 /// - public UInt32 size; + public uint size; /// /// Block size in longs /// - public UInt32 block_size; + public uint block_size; /// /// Unknown, 0 /// - public UInt32 sec_org; + public uint sec_org; /// /// Heads in drive /// - public UInt32 surfaces; + public uint surfaces; /// /// Sectors per block /// - public UInt32 spb; + public uint spb; /// /// Blocks per track /// - public UInt32 bpt; + public uint bpt; /// /// DOS reserved blocks at start of partition /// - public UInt32 reservedblocks; + public uint reservedblocks; /// /// DOS reserved blocks at end of partition /// - public UInt32 prealloc; + public uint prealloc; /// /// Interleave /// - public UInt32 interleave; + public uint interleave; /// /// First cylinder of a partition, inclusive /// - public UInt32 lowCylinder; + public uint lowCylinder; /// /// Last cylinder of a partition, inclusive /// - public UInt32 highCylinder; + public uint highCylinder; /// /// Buffers, usually 30 /// - public UInt32 numBuffer; + public uint numBuffer; /// /// Type of memory to allocate for buffers /// - public UInt32 bufMemType; + public uint bufMemType; /// /// Maximum transfer, usually 0x7FFFFFFF /// - public UInt32 maxTransfer; + public uint maxTransfer; /// /// Address mask to block out certain memory, usually 0xFFFFFFFE /// - public UInt32 Mask; + public uint Mask; /// /// Boot priority /// - public UInt32 bootPriority; + public uint bootPriority; /// /// Partition type, and filesystem driver identification for AmigaDOS /// - public UInt32 dosType; + public uint dosType; /// /// Default baud rate for SER and AUX handlers /// - public UInt32 baud; + public uint baud; /// /// Flow control values for SER and AUX handlers /// - public UInt32 control; + public uint control; /// /// Since Kickstart 2, how many boot blocks are to be loaded /// - public UInt32 bootBlocks; + public uint bootBlocks; } struct PartitionEntry @@ -647,43 +647,43 @@ namespace DiscImageChef.PartPlugins /// /// "PART" /// - public UInt32 magic; + public uint magic; /// /// Size in longs /// - public UInt32 size; + public uint size; /// /// Checksum /// - public Int32 checksum; + public int checksum; /// /// SCSI target ID, 7 for non-SCSI /// - public UInt32 targetID; + public uint targetID; /// /// Pointer to next PartitionEntry /// - public UInt32 next_ptr; + public uint next_ptr; /// /// Partition flags /// - public UInt32 flags; + public uint flags; /// /// Reserved /// - public UInt32 reserved1; + public uint reserved1; /// /// Reserved /// - public UInt32 reserved2; + public uint reserved2; /// /// Preferred flags for OpenDevice() /// - public UInt32 devFlags; + public uint devFlags; /// /// Length of drive name /// - public UInt32 driveNameLen; + public uint driveNameLen; /// /// Drive name, 31 bytes /// @@ -691,63 +691,63 @@ namespace DiscImageChef.PartPlugins /// /// Reserved /// - public UInt32 reserved3; + public uint reserved3; /// /// Reserved /// - public UInt32 reserved4; + public uint reserved4; /// /// Reserved /// - public UInt32 reserved5; + public uint reserved5; /// /// Reserved /// - public UInt32 reserved6; + public uint reserved6; /// /// Reserved /// - public UInt32 reserved7; + public uint reserved7; /// /// Reserved /// - public UInt32 reserved8; + public uint reserved8; /// /// Reserved /// - public UInt32 reserved9; + public uint reserved9; /// /// Reserved /// - public UInt32 reserved10; + public uint reserved10; /// /// Reserved /// - public UInt32 reserved11; + public uint reserved11; /// /// Reserved /// - public UInt32 reserved12; + public uint reserved12; /// /// Reserved /// - public UInt32 reserved13; + public uint reserved13; /// /// Reserved /// - public UInt32 reserved14; + public uint reserved14; /// /// Reserved /// - public UInt32 reserved15; + public uint reserved15; /// /// Reserved /// - public UInt32 reserved16; + public uint reserved16; /// /// Reserved /// - public UInt32 reserved17; + public uint reserved17; /// /// DOSEnvVec, more information about partition /// @@ -762,39 +762,39 @@ namespace DiscImageChef.PartPlugins /// /// Device node type, =0 /// - public UInt32 type; + public uint type; /// /// DOS task field, =0 /// - public UInt32 task; + public uint task; /// /// Unused, =0 /// - public UInt32 locked; + public uint locked; /// /// Filename handler to LoadSegment, =0 /// - public UInt32 handler; + public uint handler; /// /// Stack size when starting task, =0 /// - public UInt32 stackSize; + public uint stackSize; /// /// Task priority, =0 /// - public UInt32 priority; + public uint priority; /// /// Startup message, =0 /// - public UInt32 startup; + public uint startup; /// /// Pointer to first LoadSegment block /// - public UInt32 seglist_ptr; + public uint seglist_ptr; /// /// BCPL globabl vector when starting task, =0xFFFFFFFF /// - public UInt32 global_vec; + public uint global_vec; } /// @@ -805,49 +805,49 @@ namespace DiscImageChef.PartPlugins /// /// "FSHD" /// - public UInt32 magic; + public uint magic; /// /// Size in longs, 64 /// - public UInt32 size; + public uint size; /// /// Checksum /// - public Int32 checksum; + public int checksum; /// /// SCSI target ID, 7 for non-SCSI /// - public UInt32 targetID; + public uint targetID; /// /// Pointer to next FileSystemHeader block /// - public UInt32 next_ptr; + public uint next_ptr; /// /// Flags, unknown /// - public UInt32 flags; + public uint flags; /// /// Reserved /// - public UInt32 reserved1; + public uint reserved1; /// /// Reserved /// - public UInt32 reserved2; + public uint reserved2; /// /// Partition type, and filesystem driver identification for AmigaDOS /// - public UInt32 dosType; + public uint dosType; /// /// Filesystem version /// Mask 0xFFFF0000, >>16, major version /// Mask 0x0000FFFF, minor version /// - public UInt32 version; + public uint version; /// /// Bits for DeviceNode fields that should be substituted into a standard device node /// - public UInt32 patchFlags; + public uint patchFlags; /// /// Device node /// @@ -862,23 +862,23 @@ namespace DiscImageChef.PartPlugins /// /// "LSEG" /// - public UInt32 magic; + public uint magic; /// /// Size in longs /// - public UInt32 size; + public uint size; /// /// Checksum /// - public Int32 checksum; + public int checksum; /// /// SCSI target ID, 7 for non-SCSI /// - public UInt32 targetID; + public uint targetID; /// /// Pointer to next LoadSegment /// - public UInt32 next_ptr; + public uint next_ptr; /// /// Executable code, with relocation hunks, til end of sector /// @@ -898,7 +898,7 @@ namespace DiscImageChef.PartPlugins return false; byte[] tmpSector = imagePlugin.ReadSector(RDBBlock); - UInt32 magic = BigEndianBitConverter.ToUInt32(tmpSector, 0); + uint magic = BigEndianBitConverter.ToUInt32(tmpSector, 0); DicConsole.DebugWriteLine("Amiga RDB plugin", "Possible magic at block {0} is 0x{1:X8}", RDBBlock, magic); @@ -1061,7 +1061,7 @@ namespace DiscImageChef.PartPlugins DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a BadBlock block", nextBlock); sector = imagePlugin.ReadSector(nextBlock); - UInt32 magic = BigEndianBitConverter.ToUInt32(sector, 0); + uint magic = BigEndianBitConverter.ToUInt32(sector, 0); if(magic != BadBlockListMagic) break; @@ -1107,7 +1107,7 @@ namespace DiscImageChef.PartPlugins DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a PartitionEntry block", nextBlock); sector = imagePlugin.ReadSector(nextBlock); - UInt32 magic = BigEndianBitConverter.ToUInt32(sector, 0); + uint magic = BigEndianBitConverter.ToUInt32(sector, 0); if(magic != PartitionBlockMagic) break; @@ -1227,7 +1227,7 @@ namespace DiscImageChef.PartPlugins DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a FileSystemHeader block", nextBlock); sector = imagePlugin.ReadSector(nextBlock); - UInt32 magic = BigEndianBitConverter.ToUInt32(sector, 0); + uint magic = BigEndianBitConverter.ToUInt32(sector, 0); if(magic != FilesystemHeaderMagic) break; @@ -1290,7 +1290,7 @@ namespace DiscImageChef.PartPlugins DicConsole.DebugWriteLine("Amiga RDB plugin", "Going to block {0} in search of a LoadSegment block", nextBlock); sector = imagePlugin.ReadSector(nextBlock); - UInt32 magicSeg = BigEndianBitConverter.ToUInt32(sector, 0); + uint magicSeg = BigEndianBitConverter.ToUInt32(sector, 0); if(magicSeg != LoadSegMagic) break; @@ -1349,7 +1349,7 @@ namespace DiscImageChef.PartPlugins return true; } - static string AmigaDOSTypeToDescriptionString(UInt32 AmigaDOSType) + static string AmigaDOSTypeToDescriptionString(uint AmigaDOSType) { switch(AmigaDOSType) { @@ -1439,48 +1439,48 @@ namespace DiscImageChef.PartPlugins default: { if((AmigaDOSType & TypeIDOFS) == TypeIDOFS) - return String.Format("Unknown Amiga DOS filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); + return string.Format("Unknown Amiga DOS filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); if((AmigaDOSType & TypeIDAMIXSysV) == TypeIDAMIXSysV) - return String.Format("Unknown Amiga UNIX filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); + return string.Format("Unknown Amiga UNIX filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); if((AmigaDOSType & 0x50465300) == 0x50465300 || (AmigaDOSType & 0x41465300) == 0x41465300) - return String.Format("Unknown ProfessionalFileSystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); + return string.Format("Unknown ProfessionalFileSystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); if((AmigaDOSType & TypeIDSFS) == TypeIDSFS) - return String.Format("Unknown SmartFileSystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); + return string.Format("Unknown SmartFileSystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); if((AmigaDOSType & TypeIDmuOFS) == TypeIDmuOFS) - return String.Format("Unknown Amiga DOS multi-user filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); + return string.Format("Unknown Amiga DOS multi-user filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); if((AmigaDOSType & TypeIDOldBSDUnused) == TypeIDOldBSDUnused) - return String.Format("Unknown BSD filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); + return string.Format("Unknown BSD filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); if((AmigaDOSType & TypeIDNetBSDRootUnused) == TypeIDNetBSDRootUnused) - return String.Format("Unknown NetBSD root filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); + return string.Format("Unknown NetBSD root filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); if((AmigaDOSType & TypeIDNetBSDUserUnused) == TypeIDNetBSDUserUnused) - return String.Format("Unknown NetBSD user filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); + return string.Format("Unknown NetBSD user filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); if((AmigaDOSType & TypeIDNetBSDSwap) == TypeIDNetBSDSwap) - return String.Format("Unknown NetBSD swap filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); + return string.Format("Unknown NetBSD swap filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); if((AmigaDOSType & TypeIDLinux) == TypeIDLinux || (AmigaDOSType & TypeIDLinuxSwap) == TypeIDLinuxSwap) - return String.Format("Unknown Linux filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); + return string.Format("Unknown Linux filesystem type {0}", AmigaDOSTypeToString(AmigaDOSType)); - return String.Format("Unknown partition type {0}", AmigaDOSTypeToString(AmigaDOSType)); + return string.Format("Unknown partition type {0}", AmigaDOSTypeToString(AmigaDOSType)); } } } - static string AmigaDOSTypeToString(UInt32 AmigaDOSType) + static string AmigaDOSTypeToString(uint AmigaDOSType) { return AmigaDOSTypeToString(AmigaDOSType, true); } - static string AmigaDOSTypeToString(UInt32 AmigaDOSType, bool quoted) + static string AmigaDOSTypeToString(uint AmigaDOSType, bool quoted) { byte[] textPart = new byte[3]; string textPartString; @@ -1491,7 +1491,7 @@ namespace DiscImageChef.PartPlugins textPartString = Encoding.ASCII.GetString(textPart); - return quoted ? String.Format("\"{0}\\{1}\"", textPartString, AmigaDOSType & 0xFF) : String.Format("{0}\\{1}", textPartString, AmigaDOSType & 0xFF); + return quoted ? string.Format("\"{0}\\{1}\"", textPartString, AmigaDOSType & 0xFF) : string.Format("{0}\\{1}", textPartString, AmigaDOSType & 0xFF); } } } \ No newline at end of file diff --git a/DiscImageChef.Partitions/Sun.cs b/DiscImageChef.Partitions/Sun.cs index 36dd331e..dcce3d5b 100644 --- a/DiscImageChef.Partitions/Sun.cs +++ b/DiscImageChef.Partitions/Sun.cs @@ -38,8 +38,8 @@ namespace DiscImageChef.PartPlugins { class SunDisklabel : PartPlugin { - const UInt16 SUN_MAGIC = 0xDABE; - const UInt32 VTOC_MAGIC = 0x600DDEEE; + const ushort SUN_MAGIC = 0xDABE; + const uint VTOC_MAGIC = 0x600DDEEE; public enum SunTypes : ushort { @@ -188,11 +188,15 @@ namespace DiscImageChef.PartPlugins { CommonTypes.Partition part = new CommonTypes.Partition(); part.PartitionDescription = SunFlagsToString((SunFlags)sdl.vtoc.infos[i].flags); +#pragma warning disable IDE0004 // Remove Unnecessary Cast part.PartitionLength = (ulong)sdl.partitions[i].num_sectors * (ulong)imagePlugin.GetSectorSize(); +#pragma warning restore IDE0004 // Remove Unnecessary Cast part.PartitionName = ""; part.PartitionSectors = sdl.partitions[i].num_sectors; part.PartitionSequence = (ulong)i; +#pragma warning disable IDE0004 // Remove Unnecessary Cast part.PartitionStart = (ulong)sdl.partitions[i].start_cylinder * (ulong)sectorsPerCylinder * (ulong)imagePlugin.GetSectorSize(); +#pragma warning restore IDE0004 // Remove Unnecessary Cast part.PartitionStartSector = sdl.partitions[i].start_cylinder * sectorsPerCylinder; part.PartitionType = SunIdToString((SunTypes)sdl.vtoc.infos[i].id); diff --git a/DiscImageChef.Settings/ChangeLog b/DiscImageChef.Settings/ChangeLog index 609e2e82..16f75821 100644 --- a/DiscImageChef.Settings/ChangeLog +++ b/DiscImageChef.Settings/ChangeLog @@ -1,3 +1,7 @@ +2016-07-28 Natalia Portillo + + * Settings.cs: Refactor and code cleanup. + 2016-02-03 Natalia Portillo * Settings.cs: diff --git a/DiscImageChef.Settings/Settings.cs b/DiscImageChef.Settings/Settings.cs index 05d26d91..e5b2c083 100644 --- a/DiscImageChef.Settings/Settings.cs +++ b/DiscImageChef.Settings/Settings.cs @@ -457,7 +457,9 @@ namespace DiscImageChef.Settings break; } } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { } } diff --git a/DiscImageChef.sln b/DiscImageChef.sln index 113eab65..5c1f6409 100644 --- a/DiscImageChef.sln +++ b/DiscImageChef.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef", "DiscImageChef\DiscImageChef.csproj", "{7A4B05BE-73C9-4F34-87FE-E80CCF1F732D}" EndProject -Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "Packages", "Packages.mdproj", "{8996EF59-09B9-4920-A3DE-2F8EA2EBBCFF}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Checksums", "DiscImageChef.Checksums\DiscImageChef.Checksums.csproj", "{CC48B324-A532-4A45-87A6-6F91F7141E8D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Helpers", "DiscImageChef.Helpers\DiscImageChef.Helpers.csproj", "{F8BDF57B-1571-4CD0-84B3-B422088D359A}" @@ -31,6 +29,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Settings", "D EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommandLine", "commandline\src\CommandLine\CommandLine.csproj", "{E1BD3C65-49C3-49E7-BABA-C60980CB3F20}" EndProject +Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "Packages", "Packages.mdproj", "{E6A65405-997F-4D37-869B-8B97304C5DD6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -53,8 +53,6 @@ Global {7A4B05BE-73C9-4F34-87FE-E80CCF1F732D}.Debug|x86.Build.0 = Debug|x86 {7A4B05BE-73C9-4F34-87FE-E80CCF1F732D}.Release|x86.ActiveCfg = Release|x86 {7A4B05BE-73C9-4F34-87FE-E80CCF1F732D}.Release|x86.Build.0 = Release|x86 - {8996EF59-09B9-4920-A3DE-2F8EA2EBBCFF}.Debug|x86.ActiveCfg = Debug|Any CPU - {8996EF59-09B9-4920-A3DE-2F8EA2EBBCFF}.Release|x86.ActiveCfg = Release|Any CPU {9183F2E0-A879-4F23-9EE3-C6908F1332B2}.Debug|x86.ActiveCfg = Debug|Any CPU {9183F2E0-A879-4F23-9EE3-C6908F1332B2}.Debug|x86.Build.0 = Debug|Any CPU {9183F2E0-A879-4F23-9EE3-C6908F1332B2}.Release|x86.ActiveCfg = Release|Any CPU @@ -95,6 +93,8 @@ Global {E1BD3C65-49C3-49E7-BABA-C60980CB3F20}.Debug|x86.Build.0 = Debug|Any CPU {E1BD3C65-49C3-49E7-BABA-C60980CB3F20}.Release|x86.ActiveCfg = Release|Any CPU {E1BD3C65-49C3-49E7-BABA-C60980CB3F20}.Release|x86.Build.0 = Release|Any CPU + {E6A65405-997F-4D37-869B-8B97304C5DD6}.Debug|x86.ActiveCfg = Debug|Any CPU + {E6A65405-997F-4D37-869B-8B97304C5DD6}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0 diff --git a/DiscImageChef/ChangeLog b/DiscImageChef/ChangeLog index f124c1f0..a904702a 100644 --- a/DiscImageChef/ChangeLog +++ b/DiscImageChef/ChangeLog @@ -1,3 +1,32 @@ +2016-07-28 Natalia Portillo + + * Main.cs: + * Plugins.cs: + * Options.cs: + * Core/IBGLog.cs: + * Commands/Ls.cs: + * Core/Checksum.cs: + * Commands/Decode.cs: + * Commands/Verify.cs: + * Commands/Compare.cs: + * Commands/Analyze.cs: + * Commands/Formats.cs: + * Commands/Entropy.cs: + * DetectImageFormat.cs: + * Commands/PrintHex.cs: + * DiscImageChef.csproj: + * Commands/Commands.cs: + * Commands/Benchmark.cs: + * Commands/DumpMedia.cs: + * Commands/MediaInfo.cs: + * Commands/MediaScan.cs: + * Commands/DeviceInfo.cs: + * Commands/Statistics.cs: + * Commands/DeviceReport.cs: + * Commands/ExtractFiles.cs: + * Commands/CreateSidecar.cs: + Refactor and code cleanup. + 2016-04-06 Natalia Portillo * Commands/MediaScan.cs: diff --git a/DiscImageChef/Commands/Analyze.cs b/DiscImageChef/Commands/Analyze.cs index c8924627..b1b5cb2a 100644 --- a/DiscImageChef/Commands/Analyze.cs +++ b/DiscImageChef/Commands/Analyze.cs @@ -163,13 +163,13 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Filesystem not identified"); else if(id_plugins.Count > 1) { - DicConsole.WriteLine(String.Format("Identified by {0} plugins", id_plugins.Count)); + DicConsole.WriteLine(string.Format("Identified by {0} plugins", id_plugins.Count)); foreach(string plugin_name in id_plugins) { if(plugins.PluginsList.TryGetValue(plugin_name, out _plugin)) { - DicConsole.WriteLine(String.Format("As identified by {0}.", _plugin.Name)); + DicConsole.WriteLine(string.Format("As identified by {0}.", _plugin.Name)); _plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors, out information); DicConsole.Write(information); Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type); @@ -179,7 +179,7 @@ namespace DiscImageChef.Commands else { plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin); - DicConsole.WriteLine(String.Format("Identified by {0}.", _plugin.Name)); + DicConsole.WriteLine(string.Format("Identified by {0}.", _plugin.Name)); _plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors, out information); DicConsole.Write(information); Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type); @@ -196,13 +196,13 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Filesystem not identified"); else if(id_plugins.Count > 1) { - DicConsole.WriteLine(String.Format("Identified by {0} plugins", id_plugins.Count)); + DicConsole.WriteLine(string.Format("Identified by {0} plugins", id_plugins.Count)); foreach(string plugin_name in id_plugins) { if(plugins.PluginsList.TryGetValue(plugin_name, out _plugin)) { - DicConsole.WriteLine(String.Format("As identified by {0}.", _plugin.Name)); + DicConsole.WriteLine(string.Format("As identified by {0}.", _plugin.Name)); _plugin.GetInformation(_imageFormat, 0, _imageFormat.GetSectors() - 1, out information); DicConsole.Write(information); Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type); @@ -212,7 +212,7 @@ namespace DiscImageChef.Commands else { plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin); - DicConsole.WriteLine(String.Format("Identified by {0}.", _plugin.Name)); + DicConsole.WriteLine(string.Format("Identified by {0}.", _plugin.Name)); _plugin.GetInformation(_imageFormat, 0, _imageFormat.GetSectors() - 1, out information); DicConsole.Write(information); Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type); @@ -221,7 +221,7 @@ namespace DiscImageChef.Commands } catch(Exception ex) { - DicConsole.ErrorWriteLine(String.Format("Error reading file: {0}", ex.Message)); + DicConsole.ErrorWriteLine(string.Format("Error reading file: {0}", ex.Message)); DicConsole.DebugWriteLine("Analyze command", ex.StackTrace); } diff --git a/DiscImageChef/Commands/Benchmark.cs b/DiscImageChef/Commands/Benchmark.cs index 3cfa2cb7..a4d509f7 100644 --- a/DiscImageChef/Commands/Benchmark.cs +++ b/DiscImageChef/Commands/Benchmark.cs @@ -484,7 +484,9 @@ namespace DiscImageChef.Commands double entropy = 0; foreach(ulong l in entTable) { +#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values double frequency = (double)l / (double)bufferSize; +#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values entropy += -(frequency * Math.Log(frequency, 2)); } end = DateTime.Now; diff --git a/DiscImageChef/Commands/Commands.cs b/DiscImageChef/Commands/Commands.cs index b522e333..35c4b0ad 100644 --- a/DiscImageChef/Commands/Commands.cs +++ b/DiscImageChef/Commands/Commands.cs @@ -30,15 +30,10 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; - namespace DiscImageChef.Commands { - public partial class Commands + public class Commands { - public Commands() - { - } } } diff --git a/DiscImageChef/Commands/Compare.cs b/DiscImageChef/Commands/Compare.cs index 980e5168..d4521f12 100644 --- a/DiscImageChef/Commands/Compare.cs +++ b/DiscImageChef/Commands/Compare.cs @@ -121,9 +121,10 @@ namespace DiscImageChef.Commands Dictionary image2DiskTags = new Dictionary(); image1Info.imageHasPartitions = input1Format.ImageHasPartitions(); +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { image1Sessions = input1Format.GetSessions(); } catch { } - if(image1Sessions.Count > 0) - image1Info.imageHasSessions = true; +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body + image1Info.imageHasSessions |= image1Sessions.Count > 0; image1Info.imageSize = input1Format.GetImageSize(); image1Info.sectors = input1Format.GetSectors(); image1Info.sectorSize = input1Format.GetSectorSize(); @@ -153,15 +154,18 @@ namespace DiscImageChef.Commands byte[] temparray = input1Format.ReadDiskTag(disktag); image1DiskTags.Add(disktag, temparray); } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { } } image2Info.imageHasPartitions = input2Format.ImageHasPartitions(); +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { image2Sessions = input2Format.GetSessions(); } catch { } - if(image2Sessions.Count > 0) - image2Info.imageHasSessions = true; +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body + image2Info.imageHasSessions |= image2Sessions.Count > 0; image2Info.imageSize = input2Format.GetImageSize(); image2Info.sectors = input2Format.GetSectors(); image2Info.sectorSize = input2Format.GetSectorSize(); @@ -191,7 +195,9 @@ namespace DiscImageChef.Commands byte[] temparray = input2Format.ReadDiskTag(disktag); image2DiskTags.Add(disktag, temparray); } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { } } @@ -375,7 +381,7 @@ namespace DiscImageChef.Commands sb.AppendLine("Drive serial number differ"); } - UInt64 leastSectors; + ulong leastSectors; if(image1Info.sectors < image2Info.sectors) { imagesDiffer = true; @@ -395,7 +401,7 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Comparing sectors..."); - for(UInt64 sector = 0; sector < leastSectors; sector++) + for(ulong sector = 0; sector < leastSectors; sector++) { DicConsole.Write("\rComparing sector {0} of {1}...", sector + 1, leastSectors); try @@ -416,7 +422,9 @@ namespace DiscImageChef.Commands sector, image1Sector.LongLength, image2Sector.LongLength).AppendLine(); } } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch { } +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } DicConsole.WriteLine(); @@ -430,12 +438,12 @@ namespace DiscImageChef.Commands Core.Statistics.AddCommand("compare"); } - private static void CompareBytes(out bool different, out bool sameSize, byte[] compareArray1, byte[] compareArray2) + static void CompareBytes(out bool different, out bool sameSize, byte[] compareArray1, byte[] compareArray2) { different = false; sameSize = true; - Int64 leastBytes; + long leastBytes; if(compareArray1.LongLength < compareArray2.LongLength) { sameSize = false; @@ -449,7 +457,7 @@ namespace DiscImageChef.Commands else leastBytes = compareArray1.LongLength; - for(Int64 i = 0; i < leastBytes; i++) + for(long i = 0; i < leastBytes; i++) { if(compareArray1[i] != compareArray2[i]) { diff --git a/DiscImageChef/Commands/CreateSidecar.cs b/DiscImageChef/Commands/CreateSidecar.cs index e9243407..4cd98dd6 100644 --- a/DiscImageChef/Commands/CreateSidecar.cs +++ b/DiscImageChef/Commands/CreateSidecar.cs @@ -36,9 +36,7 @@ using System.Collections.Generic; using DiscImageChef.Filesystems; using DiscImageChef.ImagePlugins; using DiscImageChef.Console; -using DiscImageChef.Checksums; using System.IO; -using System.Threading; using DiscImageChef.CommonTypes; using DiscImageChef.PartPlugins; @@ -53,7 +51,7 @@ namespace DiscImageChef.Commands plugins.RegisterAllPlugins(); ImagePlugin _imageFormat; - if(!System.IO.File.Exists(options.InputFile)) + if(!File.Exists(options.InputFile)) { DicConsole.ErrorWriteLine("Specified file does not exist."); return; @@ -99,7 +97,7 @@ namespace DiscImageChef.Commands FileInfo fi = new FileInfo(options.InputFile); FileStream fs = new FileStream(options.InputFile, FileMode.Open, FileAccess.Read); - Core.Checksum imgChkWorker = new DiscImageChef.Core.Checksum(); + Core.Checksum imgChkWorker = new Core.Checksum(); byte[] data; long position = 0; @@ -281,15 +279,15 @@ namespace DiscImageChef.Commands dskType = MediaType.DVDRDL; if(dskType == MediaType.DVDRW && pfi.Value.PartVersion == 3) dskType = MediaType.DVDRWDL; - if(dskType == MediaType.GOD && pfi.Value.DiscSize == DiscImageChef.Decoders.DVD.DVDSize.OneTwenty) + if(dskType == MediaType.GOD && pfi.Value.DiscSize == Decoders.DVD.DVDSize.OneTwenty) dskType = MediaType.WOD; sidecar.OpticalDisc[0].Dimensions = new DimensionsType(); if(dskType == MediaType.UMD) sidecar.OpticalDisc[0].Dimensions.Diameter = 60; - else if(pfi.Value.DiscSize == DiscImageChef.Decoders.DVD.DVDSize.Eighty) + else if(pfi.Value.DiscSize == Decoders.DVD.DVDSize.Eighty) sidecar.OpticalDisc[0].Dimensions.Diameter = 80; - else if(pfi.Value.DiscSize == DiscImageChef.Decoders.DVD.DVDSize.OneTwenty) + else if(pfi.Value.DiscSize == Decoders.DVD.DVDSize.OneTwenty) sidecar.OpticalDisc[0].Dimensions.Diameter = 120; } } @@ -326,22 +324,22 @@ namespace DiscImageChef.Commands Schemas.TrackType xmlTrk = new Schemas.TrackType(); switch(trk.TrackType) { - case DiscImageChef.ImagePlugins.TrackType.Audio: + case ImagePlugins.TrackType.Audio: xmlTrk.TrackType1 = TrackTypeTrackType.audio; break; - case DiscImageChef.ImagePlugins.TrackType.CDMode2Form2: + case ImagePlugins.TrackType.CDMode2Form2: xmlTrk.TrackType1 = TrackTypeTrackType.m2f2; break; - case DiscImageChef.ImagePlugins.TrackType.CDMode2Formless: + case ImagePlugins.TrackType.CDMode2Formless: xmlTrk.TrackType1 = TrackTypeTrackType.mode2; break; - case DiscImageChef.ImagePlugins.TrackType.CDMode2Form1: + case ImagePlugins.TrackType.CDMode2Form1: xmlTrk.TrackType1 = TrackTypeTrackType.m2f1; break; - case DiscImageChef.ImagePlugins.TrackType.CDMode1: + case ImagePlugins.TrackType.CDMode1: xmlTrk.TrackType1 = TrackTypeTrackType.mode1; break; - case DiscImageChef.ImagePlugins.TrackType.Data: + case ImagePlugins.TrackType.Data: switch(sidecar.OpticalDisc[0].DiscType) { case "BD": @@ -397,7 +395,7 @@ namespace DiscImageChef.Commands uint sectorsToRead = 512; - Core.Checksum trkChkWorker = new DiscImageChef.Core.Checksum(); + Core.Checksum trkChkWorker = new Core.Checksum(); ulong sectors = (ulong)(xmlTrk.EndSector - xmlTrk.StartSector + 1); ulong doneSectors = 0; @@ -454,7 +452,7 @@ namespace DiscImageChef.Commands // TODO: Packed subchannel has different size? xmlTrk.SubChannel.Size = (xmlTrk.EndSector - xmlTrk.StartSector + 1) * 96; - Core.Checksum subChkWorker = new DiscImageChef.Core.Checksum(); + Core.Checksum subChkWorker = new Core.Checksum(); sectors = (ulong)(xmlTrk.EndSector - xmlTrk.StartSector + 1); doneSectors = 0; @@ -541,7 +539,9 @@ namespace DiscImageChef.Commands dskType = MediaType.GOD; } } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { //DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name); } @@ -580,7 +580,9 @@ namespace DiscImageChef.Commands dskType = MediaType.GOD; } } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { //DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name); } @@ -737,7 +739,9 @@ namespace DiscImageChef.Commands Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type); } } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { //DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name); } @@ -767,7 +771,9 @@ namespace DiscImageChef.Commands Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type); } } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { //DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name); } @@ -843,7 +849,7 @@ namespace DiscImageChef.Commands } catch(Exception ex) { - DicConsole.ErrorWriteLine(String.Format("Error reading file: {0}", ex.Message)); + DicConsole.ErrorWriteLine(string.Format("Error reading file: {0}", ex.Message)); DicConsole.DebugWriteLine("Analyze command", ex.StackTrace); } @@ -869,7 +875,7 @@ namespace DiscImageChef.Commands f = lba + 450150; } - return String.Format("{0}:{1:D2}:{2:D2}", m, s, f); + return string.Format("{0}:{1:D2}:{2:D2}", m, s, f); } static string DdcdLbaToMsf(long lba) @@ -896,7 +902,7 @@ namespace DiscImageChef.Commands f = lba + 450150 * 2; } - return String.Format("{3}:{0:D2}:{1:D2}:{2:D2}", m, s, f, h); + return string.Format("{3}:{0:D2}:{1:D2}:{2:D2}", m, s, f, h); } } } diff --git a/DiscImageChef/Commands/Decode.cs b/DiscImageChef/Commands/Decode.cs index d5a902d8..4e44294b 100644 --- a/DiscImageChef/Commands/Decode.cs +++ b/DiscImageChef/Commands/Decode.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using DiscImageChef.ImagePlugins; using DiscImageChef.Console; @@ -212,13 +211,13 @@ namespace DiscImageChef.Commands if(options.SectorTags) { - UInt64 length; + ulong length; if(options.Length.ToLowerInvariant() == "all") length = inputFormat.GetSectors() - 1; else { - if(!UInt64.TryParse(options.Length, out length)) + if(!ulong.TryParse(options.Length, out length)) { DicConsole.WriteLine("Value \"{0}\" is not a valid number for length.", options.Length); DicConsole.WriteLine("Not decoding sectors tags"); diff --git a/DiscImageChef/Commands/DeviceInfo.cs b/DiscImageChef/Commands/DeviceInfo.cs index 5e4cf02f..2cee7505 100644 --- a/DiscImageChef/Commands/DeviceInfo.cs +++ b/DiscImageChef/Commands/DeviceInfo.cs @@ -48,16 +48,16 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Device-Info command", "--device={0}", options.DevicePath); DicConsole.DebugWriteLine("Device-Info command", "--output-prefix={0}", options.OutputPrefix); - if(!System.IO.File.Exists(options.DevicePath)) + if(!File.Exists(options.DevicePath)) { DicConsole.ErrorWriteLine("Specified device does not exist."); return; } if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && - options.DevicePath[0] != '/' && Char.IsLetter(options.DevicePath[0])) + options.DevicePath[0] != '/' && char.IsLetter(options.DevicePath[0])) { - options.DevicePath = "\\\\.\\" + Char.ToUpper(options.DevicePath[0]) + ':'; + options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; } Device dev = new Device(options.DevicePath); @@ -119,7 +119,7 @@ namespace DiscImageChef.Commands doWriteFile(options.OutputPrefix, "_ata_identify.bin", "ATA IDENTIFY", ataBuf); - DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(ataBuf)); + DicConsole.WriteLine(Identify.Prettify(ataBuf)); double duration; dev.EnableMediaCardPassThrough(out errorRegisters, dev.Timeout, out duration); @@ -182,7 +182,7 @@ namespace DiscImageChef.Commands doWriteFile(options.OutputPrefix, "_atapi_identify.bin", "ATAPI IDENTIFY", ataBuf); - DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(ataBuf)); + DicConsole.WriteLine(Identify.Prettify(ataBuf)); // ATAPI devices are also SCSI devices goto case DeviceType.SCSI; @@ -232,7 +232,7 @@ namespace DiscImageChef.Commands sb = new StringBuilder(); sb.AppendFormat("Page 0x{0:X2}: ", Decoders.SCSI.EVPD.DecodeASCIIPage(inqBuf)).AppendLine(); - doWriteFile(options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page), String.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf); + doWriteFile(options.OutputPrefix, string.Format("_scsi_evpd_{0:X2}h.bin", page), string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf); } } else if(page == 0x80) @@ -243,7 +243,7 @@ namespace DiscImageChef.Commands scsi80 = true; scsiSerial = Decoders.SCSI.EVPD.DecodePage80(inqBuf); - doWriteFile(options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page), String.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf); + doWriteFile(options.OutputPrefix, string.Format("_scsi_evpd_{0:X2}h.bin", page), string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf); } } else @@ -255,7 +255,7 @@ namespace DiscImageChef.Commands sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); if(!sense) { - doWriteFile(options.OutputPrefix, String.Format("_scsi_evpd_{0:X2}h.bin", page), String.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf); + doWriteFile(options.OutputPrefix, string.Format("_scsi_evpd_{0:X2}h.bin", page), string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf); } } } @@ -275,7 +275,7 @@ namespace DiscImageChef.Commands byte[] modeBuf; double duration; Decoders.SCSI.Modes.DecodedMode? decMode = null; - Decoders.SCSI.PeripheralDeviceTypes devType = (DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes)inq.Value.PeripheralDeviceType; + Decoders.SCSI.PeripheralDeviceTypes devType = (Decoders.SCSI.PeripheralDeviceTypes)inq.Value.PeripheralDeviceType; sense = dev.ModeSense10(out modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5, out duration); if(sense || dev.Error) @@ -316,7 +316,7 @@ namespace DiscImageChef.Commands { case 0x00: { - if(devType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice && page.Subpage == 0) + if(devType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice && page.Subpage == 0) DicConsole.WriteLine(Decoders.SCSI.Modes.PrettifyModePage_00_SFF(page.PageResponse)); else { @@ -331,7 +331,7 @@ namespace DiscImageChef.Commands { if(page.Subpage == 0) { - if(devType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(devType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) DicConsole.WriteLine(Decoders.SCSI.Modes.PrettifyModePage_01_MMC(page.PageResponse)); else DicConsole.WriteLine(Decoders.SCSI.Modes.PrettifyModePage_01(page.PageResponse)); @@ -390,7 +390,7 @@ namespace DiscImageChef.Commands { if(page.Subpage == 0) { - if(devType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(devType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) DicConsole.WriteLine(Decoders.SCSI.Modes.PrettifyModePage_07_MMC(page.PageResponse)); else DicConsole.WriteLine(Decoders.SCSI.Modes.PrettifyModePage_07(page.PageResponse)); @@ -460,7 +460,7 @@ namespace DiscImageChef.Commands { if(page.Subpage == 0) { - if(devType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) + if(devType == Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) DicConsole.WriteLine(Decoders.SCSI.Modes.PrettifyModePage_10_SSC(page.PageResponse)); else DicConsole.WriteLine(Decoders.SCSI.Modes.PrettifyModePage_10(page.PageResponse)); @@ -494,7 +494,7 @@ namespace DiscImageChef.Commands { if(page.Subpage == 0) { - if(devType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(devType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) DicConsole.WriteLine(Decoders.SCSI.Modes.PrettifyModePage_1C_SFF(page.PageResponse)); else DicConsole.WriteLine(Decoders.SCSI.Modes.PrettifyModePage_1C(page.PageResponse)); @@ -537,7 +537,7 @@ namespace DiscImageChef.Commands } } - if(devType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(devType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { byte[] confBuf; @@ -824,7 +824,7 @@ namespace DiscImageChef.Commands } default: { - if(dev.Model.StartsWith("CD-R ")) + if(dev.Model.StartsWith("CD-R ", StringComparison.Ordinal)) { plxtSense = dev.PlextorReadEepromCDR(out plxtBuf, out senseBuf, dev.Timeout, out duration); } @@ -992,7 +992,7 @@ namespace DiscImageChef.Commands #endregion Plextor } - if(devType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) + if(devType == Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) { byte[] seqBuf; diff --git a/DiscImageChef/Commands/DeviceReport.cs b/DiscImageChef/Commands/DeviceReport.cs index f4d39120..7d83924b 100644 --- a/DiscImageChef/Commands/DeviceReport.cs +++ b/DiscImageChef/Commands/DeviceReport.cs @@ -47,16 +47,16 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Device-Report command", "--verbose={0}", options.Verbose); DicConsole.DebugWriteLine("Device-Report command", "--device={0}", options.DevicePath); - if(!System.IO.File.Exists(options.DevicePath)) + if(!File.Exists(options.DevicePath)) { DicConsole.ErrorWriteLine("Specified device does not exist."); return; } if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && - options.DevicePath[0] != '/' && Char.IsLetter(options.DevicePath[0])) + options.DevicePath[0] != '/' && char.IsLetter(options.DevicePath[0])) { - options.DevicePath = "\\\\.\\" + Char.ToUpper(options.DevicePath[0]) + ':'; + options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; } Device dev = new Device(options.DevicePath); @@ -94,7 +94,7 @@ namespace DiscImageChef.Commands static void doATADeviceReport(DeviceReportOptions options, Device dev) { - DiscImageChef.Decoders.ATA.AtaErrorRegistersCHS errorRegs; + Decoders.ATA.AtaErrorRegistersCHS errorRegs; byte[] buffer; double duration; uint timeout = 5; @@ -721,7 +721,9 @@ namespace DiscImageChef.Commands if((ataId.PhysLogSectorSize & 0x2000) == 0x2000) { +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created physicalsectorsize = logicalsectorsize * (uint)Math.Pow(2, (double)(ataId.PhysLogSectorSize & 0xF)); +#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created } else physicalsectorsize = logicalsectorsize; @@ -937,7 +939,9 @@ namespace DiscImageChef.Commands if((ataId.PhysLogSectorSize & 0x2000) == 0x2000) { +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created physicalsectorsize = logicalsectorsize * (uint)Math.Pow(2, (double)(ataId.PhysLogSectorSize & 0xF)); +#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created } else physicalsectorsize = logicalsectorsize; @@ -1178,7 +1182,7 @@ namespace DiscImageChef.Commands { DicConsole.WriteLine("Querying ATAPI IDENTIFY..."); - DiscImageChef.Decoders.ATA.AtaErrorRegistersCHS errorRegs; + Decoders.ATA.AtaErrorRegistersCHS errorRegs; dev.AtapiIdentify(out buffer, out errorRegs, timeout, out duration); if(Decoders.ATA.Identify.Decode(buffer).HasValue) @@ -1594,7 +1598,7 @@ namespace DiscImageChef.Commands { Decoders.SCSI.Inquiry.SCSIInquiry inq = Decoders.SCSI.Inquiry.Decode(buffer).Value; - List versionDescriptors = new List(); + List versionDescriptors = new List(); report.SCSI.Inquiry = new scsiInquiryType(); if(inq.DeviceTypeModifier != 0) @@ -1642,7 +1646,7 @@ namespace DiscImageChef.Commands } if(inq.VersionDescriptors != null) { - foreach(UInt16 descriptor in inq.VersionDescriptors) + foreach(ushort descriptor in inq.VersionDescriptors) { if(descriptor != 0) versionDescriptors.Add(descriptor); @@ -1716,12 +1720,12 @@ namespace DiscImageChef.Commands if(removable) { - if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { dev.AllowMediumRemoval(out senseBuffer, timeout, out duration); dev.EjectTray(out senseBuffer, timeout, out duration); } - else if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) + else if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) { dev.SpcAllowMediumRemoval(out senseBuffer, timeout, out duration); DicConsole.WriteLine("Asking drive to unload tape (can take a few minutes)..."); @@ -1772,8 +1776,7 @@ namespace DiscImageChef.Commands if(!sense && !dev.Error && !decMode.HasValue) decMode = Decoders.SCSI.Modes.DecodeMode6(buffer, devType); - if(!sense && !dev.Error) - report.SCSI.SupportsModeSense6 = true; + report.SCSI.SupportsModeSense6 |= (!sense && !dev.Error); Decoders.SCSI.Modes.ModePage_2A? cdromMode = null; @@ -1821,7 +1824,7 @@ namespace DiscImageChef.Commands List mediaTypes = new List(); #region MultiMediaDevice - if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { report.SCSI.MultiMediaDevice = new mmcType(); @@ -2129,7 +2132,6 @@ namespace DiscImageChef.Commands case 0x0031: { report.SCSI.MultiMediaDevice.Features.CanWriteDDCDR = true; - ; Decoders.SCSI.MMC.Feature_0031? ftr0031 = Decoders.SCSI.MMC.Features.Decode_0031(desc.Data); if(ftr0031.HasValue) report.SCSI.MultiMediaDevice.Features.CanTestWriteDDCDR = ftr0031.Value.TestWrite; @@ -2321,13 +2323,15 @@ namespace DiscImageChef.Commands try { - report.SCSI.MultiMediaDevice.Features.FirmwareDate = new DateTime(Int32.Parse(syear), Int32.Parse(smonth), - Int32.Parse(sday), Int32.Parse(shour), Int32.Parse(sminute), - Int32.Parse(ssecond), DateTimeKind.Utc); + report.SCSI.MultiMediaDevice.Features.FirmwareDate = new DateTime(int.Parse(syear), int.Parse(smonth), + int.Parse(sday), int.Parse(shour), int.Parse(sminute), + int.Parse(ssecond), DateTimeKind.Utc); report.SCSI.MultiMediaDevice.Features.FirmwareDateSpecified = true; } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { } } @@ -2627,7 +2631,7 @@ namespace DiscImageChef.Commands } } - if(mediaType.StartsWith("CD-") || mediaType == "Audio CD") + if(mediaType.StartsWith("CD-", StringComparison.Ordinal) || mediaType == "Audio CD") { mediaTest.CanReadTOCSpecified = true; mediaTest.CanReadFullTOCSpecified = true; @@ -2637,7 +2641,7 @@ namespace DiscImageChef.Commands mediaTest.CanReadFullTOC = !dev.ReadRawToc(out buffer, out senseBuffer, 1, timeout, out duration); } - if(mediaType.StartsWith("CD-R")) + if(mediaType.StartsWith("CD-R", StringComparison.Ordinal)) { mediaTest.CanReadATIPSpecified = true; mediaTest.CanReadPMASpecified = true; @@ -2647,7 +2651,7 @@ namespace DiscImageChef.Commands mediaTest.CanReadPMA = !dev.ReadPma(out buffer, out senseBuffer, timeout, out duration); } - if(mediaType.StartsWith("DVD-") || mediaType.StartsWith("HD DVD-")) + if(mediaType.StartsWith("DVD-", StringComparison.Ordinal) || mediaType.StartsWith("HD DVD-", StringComparison.Ordinal)) { mediaTest.CanReadPFISpecified = true; mediaTest.CanReadDMISpecified = true; @@ -2689,7 +2693,7 @@ namespace DiscImageChef.Commands mediaTest.CanReadSpareAreaInformation = !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.DVD, 0, 0, MmcDiscStructureFormat.DVDRAM_SpareAreaInformation, 0, timeout, out duration); } - if(mediaType.StartsWith("BD-R") && mediaType != "BD-ROM") + if(mediaType.StartsWith("BD-R", StringComparison.Ordinal) && mediaType != "BD-ROM") { mediaTest.CanReadDDSSpecified = true; mediaTest.CanReadSpareAreaInformationSpecified = true; @@ -2716,7 +2720,7 @@ namespace DiscImageChef.Commands mediaTest.CanReadRecordablePFI = !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.DVD, 0, 0, MmcDiscStructureFormat.DVDR_PhysicalInformation, 0, timeout, out duration); } - if(mediaType.StartsWith("DVD+R")) + if(mediaType.StartsWith("DVD+R", StringComparison.Ordinal)) { mediaTest.CanReadADIPSpecified = true; mediaTest.CanReadDCBSpecified = true; @@ -2733,14 +2737,14 @@ namespace DiscImageChef.Commands mediaTest.CanReadHDCMI = !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.DVD, 0, 0, MmcDiscStructureFormat.HDDVD_CopyrightInformation, 0, timeout, out duration); } - if(mediaType.EndsWith(" DL")) + if(mediaType.EndsWith(" DL", StringComparison.Ordinal)) { mediaTest.CanReadLayerCapacitySpecified = true; DicConsole.WriteLine("Querying DVD Layer Capacity..."); mediaTest.CanReadLayerCapacity = !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.DVD, 0, 0, MmcDiscStructureFormat.DVDR_LayerCapacity, 0, timeout, out duration); } - if(mediaType.StartsWith("BD-R")) + if(mediaType.StartsWith("BD-R", StringComparison.Ordinal)) { mediaTest.CanReadDiscInformationSpecified = true; mediaTest.CanReadPACSpecified = true; @@ -2780,7 +2784,7 @@ namespace DiscImageChef.Commands } } - if(mediaType.StartsWith("CD-") || mediaType == "Audio CD") + if(mediaType.StartsWith("CD-", StringComparison.Ordinal) || mediaType == "Audio CD") { mediaTest.CanReadC2PointersSpecified = true; mediaTest.CanReadCorrectedSubchannelSpecified = true; @@ -2976,7 +2980,7 @@ namespace DiscImageChef.Commands Decoders.SCSI.FixedSense? decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuffer); if(decSense.HasValue) { - if(decSense.Value.SenseKey == DiscImageChef.Decoders.SCSI.SenseKeys.IllegalRequest && + if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest && decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00) { mediaTest.SupportsReadLong = true; @@ -3034,7 +3038,7 @@ namespace DiscImageChef.Commands } else if(mediaTest.BlockSize == 2048) { - if(mediaType.StartsWith("DVD")) + if(mediaType.StartsWith("DVD", StringComparison.Ordinal)) { sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 37856, timeout, out duration); if(!sense && !dev.Error) @@ -3133,7 +3137,7 @@ namespace DiscImageChef.Commands } #endregion MultiMediaDevice #region SequentialAccessDevice - else if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) + else if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) { report.SCSI.SequentialDevice = new sscType(); DicConsole.WriteLine("Querying SCSI READ BLOCK LIMITS..."); @@ -3207,7 +3211,7 @@ namespace DiscImageChef.Commands { report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes = new int[mtsh.Value.descriptors[i].densityCodes.Length]; for(int j = 0; j < mtsh.Value.descriptors.Length; j++) - report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes[j] = (int)mtsh.Value.descriptors[i].densityCodes[j]; + report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes[j] = mtsh.Value.descriptors[i].densityCodes[j]; } } } @@ -3366,7 +3370,7 @@ namespace DiscImageChef.Commands { seqTest.SupportedMediaTypes[i].DensityCodes = new int[mtsh.Value.descriptors[i].densityCodes.Length]; for(int j = 0; j < mtsh.Value.descriptors.Length; j++) - seqTest.SupportedMediaTypes[i].DensityCodes[j] = (int)mtsh.Value.descriptors[i].densityCodes[j]; + seqTest.SupportedMediaTypes[i].DensityCodes[j] = mtsh.Value.descriptors[i].densityCodes[j]; } } } @@ -3544,7 +3548,7 @@ namespace DiscImageChef.Commands Decoders.SCSI.FixedSense? decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuffer); if(decSense.HasValue) { - if(decSense.Value.SenseKey == DiscImageChef.Decoders.SCSI.SenseKeys.IllegalRequest && + if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest && decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00) { mediaTest.SupportsReadLong = true; @@ -3745,7 +3749,7 @@ namespace DiscImageChef.Commands Decoders.SCSI.FixedSense? decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuffer); if(decSense.HasValue) { - if(decSense.Value.SenseKey == DiscImageChef.Decoders.SCSI.SenseKeys.IllegalRequest && + if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest && decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00) { report.SCSI.ReadCapabilities.SupportsReadLong = true; @@ -3832,7 +3836,7 @@ namespace DiscImageChef.Commands for(ushort i = (ushort)report.SCSI.ReadCapabilities.BlockSize; i < (ushort)report.SCSI.ReadCapabilities.BlockSize * 36; i++) { DicConsole.Write("\rTrying to READ LONG with a size of {0} bytes...", i); - sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, (ushort)i, timeout, out duration); + sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, i, timeout, out duration); if(!sense) { if(options.Debug) @@ -3859,7 +3863,7 @@ namespace DiscImageChef.Commands xmlSer.Serialize(xmlFs, report); xmlFs.Close(); - if(Settings.Settings.Current.SaveReportsGlobally && !String.IsNullOrEmpty(Settings.Settings.ReportsPath)) + if(Settings.Settings.Current.SaveReportsGlobally && !string.IsNullOrEmpty(Settings.Settings.ReportsPath)) { xmlFs = new FileStream(Path.Combine(Settings.Settings.ReportsPath, xmlFile), FileMode.Create); xmlSer.Serialize(xmlFs, report); diff --git a/DiscImageChef/Commands/DumpMedia.cs b/DiscImageChef/Commands/DumpMedia.cs index 48a28bcb..c11962bd 100644 --- a/DiscImageChef/Commands/DumpMedia.cs +++ b/DiscImageChef/Commands/DumpMedia.cs @@ -63,16 +63,16 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Dump-Media command", "--retry-passes={0}", options.RetryPasses); DicConsole.DebugWriteLine("Dump-Media command", "--persistent={0}", options.Persistent); - if(!System.IO.File.Exists(options.DevicePath)) + if(!File.Exists(options.DevicePath)) { DicConsole.ErrorWriteLine("Specified device does not exist."); return; } if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && - options.DevicePath[0] != '/' && Char.IsLetter(options.DevicePath[0])) + options.DevicePath[0] != '/' && char.IsLetter(options.DevicePath[0])) { - options.DevicePath = "\\\\.\\" + Char.ToUpper(options.DevicePath[0]) + ':'; + options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; } mhddLog = null; @@ -213,7 +213,9 @@ namespace DiscImageChef.Commands if((ataId.PhysLogSectorSize & 0x2000) == 0x2000) { +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created physicalsectorsize = blockSize * (uint)Math.Pow(2, (double)(ataId.PhysLogSectorSize & 0xF)); +#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created } else physicalsectorsize = blockSize; @@ -394,10 +396,12 @@ namespace DiscImageChef.Commands if((blocks - i) < blocksToRead) blocksToRead = (byte)(blocks - i); +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; if(currentSpeed < minSpeed && currentSpeed != 0) minSpeed = currentSpeed; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed); @@ -492,13 +496,17 @@ namespace DiscImageChef.Commands writeToDataFile(new byte[blockSize * blocksToRead]); } +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (cmdDuration / (double)1000); +#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created GC.Collect(); } end = DateTime.Now; DicConsole.WriteLine(); mhddLog.Close(); +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), options.DevicePath); +#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created #region Error handling if(unreadableSectors.Count > 0 && !aborted) @@ -605,10 +613,12 @@ namespace DiscImageChef.Commands double cmdDuration = 0; +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; if(currentSpeed < minSpeed && currentSpeed != 0) minSpeed = currentSpeed; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator DicConsole.Write("\rReading cylinder {0} head {1} sector {2} ({3:F3} MiB/sec.)", Cy, Hd, Sc, currentSpeed); @@ -691,7 +701,9 @@ namespace DiscImageChef.Commands writeToDataFile(new byte[blockSize]); } +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created currentSpeed = ((double)blockSize / (double)1048576) / (cmdDuration / (double)1000); +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created GC.Collect(); currentBlock++; @@ -701,7 +713,9 @@ namespace DiscImageChef.Commands end = DateTime.Now; DicConsole.WriteLine(); mhddLog.Close(); +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), options.DevicePath); +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created } dataChk = new Core.Checksum(); dataFs.Seek(0, SeekOrigin.Begin); @@ -790,7 +804,9 @@ namespace DiscImageChef.Commands Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type); } } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { //DicConsole.DebugWriteLine("Dump-media command", "Plugin {0} crashed", _plugin.Name); } @@ -821,7 +837,9 @@ namespace DiscImageChef.Commands Core.Statistics.AddFilesystem(_plugin.XmlFSType.Type); } } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { //DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name); } @@ -992,12 +1010,12 @@ namespace DiscImageChef.Commands } } - if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.DirectAccess || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.OCRWDevice || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.OpticalDevice || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.SimplifiedDevice || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.WriteOnceDevice) + if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.DirectAccess || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.OCRWDevice || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.OpticalDevice || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.SimplifiedDevice || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.WriteOnceDevice) { sense = dev.ReadCapacity(out cmdBuf, out senseBuf, dev.Timeout, out duration); if(!sense) @@ -1013,7 +1031,7 @@ namespace DiscImageChef.Commands if(sense && blocks == 0) { // Not all MMC devices support READ CAPACITY, as they have READ TOC - if(dev.SCSIType != DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(dev.SCSIType != Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { DicConsole.ErrorWriteLine("Unable to get media capacity"); DicConsole.ErrorWriteLine("{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); @@ -1042,7 +1060,7 @@ namespace DiscImageChef.Commands physicalBlockSize = blockSize; } - if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) + if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) { throw new NotImplementedException(); } @@ -1063,7 +1081,7 @@ namespace DiscImageChef.Commands CICMMetadataType sidecar = new CICMMetadataType(); #region MultiMediaDevice - if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { sidecar.OpticalDisc = new OpticalDiscType[1]; sidecar.OpticalDisc[0] = new OpticalDiscType(); @@ -1338,7 +1356,7 @@ namespace DiscImageChef.Commands Decoders.DVD.PFI.PhysicalFormatInformation? nintendoPfi = Decoders.DVD.PFI.Decode(cmdBuf); if(nintendoPfi != null) { - if(nintendoPfi.Value.DiskCategory == DiscImageChef.Decoders.DVD.DiskCategory.Nintendo && + if(nintendoPfi.Value.DiskCategory == Decoders.DVD.DiskCategory.Nintendo && nintendoPfi.Value.PartVersion == 15) { throw new NotImplementedException("Dumping Nintendo GameCube or Wii discs is not yet implemented."); @@ -1424,7 +1442,7 @@ namespace DiscImageChef.Commands dskType = MediaType.HDDVDRW; break; case Decoders.DVD.DiskCategory.Nintendo: - if(decPfi.DiscSize == DiscImageChef.Decoders.DVD.DVDSize.Eighty) + if(decPfi.DiscSize == Decoders.DVD.DVDSize.Eighty) dskType = MediaType.GOD; else dskType = MediaType.WOD; @@ -1473,7 +1491,7 @@ namespace DiscImageChef.Commands writeToFile(sidecar.OpticalDisc[0].CMI.Image, tmpBuf); Decoders.DVD.CSS_CPRM.LeadInCopyright cpy = Decoders.DVD.CSS_CPRM.DecodeLeadInCopyright(cmdBuf).Value; - if(cpy.CopyrightType != DiscImageChef.Decoders.DVD.CopyrightType.NoProtection) + if(cpy.CopyrightType != Decoders.DVD.CopyrightType.NoProtection) sidecar.OpticalDisc[0].CopyProtection = cpy.CopyrightType.ToString(); } } @@ -1732,7 +1750,7 @@ namespace DiscImageChef.Commands if(dev.Type == DeviceType.ATAPI) { - DiscImageChef.Decoders.ATA.AtaErrorRegistersCHS errorRegs; + Decoders.ATA.AtaErrorRegistersCHS errorRegs; sense = dev.AtapiIdentify(out cmdBuf, out errorRegs); if(!sense) { @@ -1769,7 +1787,7 @@ namespace DiscImageChef.Commands if(!sense) { EVPDType evpd = new EVPDType(); - evpd.Image = String.Format("{0}.evpd_{1:X2}h.bin", options.OutputPrefix, page); + evpd.Image = string.Format("{0}.evpd_{1:X2}h.bin", options.OutputPrefix, page); evpd.Checksums = Core.Checksum.GetChecksums(cmdBuf).ToArray(); evpd.Size = cmdBuf.Length; evpd.Checksums = Core.Checksum.GetChecksums(cmdBuf).ToArray(); @@ -1830,8 +1848,7 @@ namespace DiscImageChef.Commands scsiDensityCode = (byte)decMode.Value.Header.BlockDescriptors[0].Density; foreach(Decoders.SCSI.Modes.ModePage modePage in decMode.Value.Pages) - if(modePage.Page == 0x05) - containsFloppyPage = true; + containsFloppyPage |= modePage.Page == 0x05; } } } @@ -1898,7 +1915,7 @@ namespace DiscImageChef.Commands int leadInSectorsGood = 0, leadInSectorsTotal = 0; initDataFile(options.OutputPrefix + ".leadin.bin"); - dataChk = new DiscImageChef.Core.Checksum(); + dataChk = new Core.Checksum(); start = DateTime.UtcNow; @@ -1911,10 +1928,12 @@ namespace DiscImageChef.Commands double cmdDuration = 0; +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; if(currentSpeed < minSpeed && currentSpeed != 0) minSpeed = currentSpeed; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator DicConsole.Write("\rTrying to read lead-in sector {0} ({1:F3} MiB/sec.)", (int)leadInBlock, currentSpeed); @@ -1995,10 +2014,12 @@ namespace DiscImageChef.Commands if((blocks - i) < blocksToRead) blocksToRead = (uint)(blocks - i); +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; if(currentSpeed < minSpeed && currentSpeed != 0) minSpeed = currentSpeed; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed); @@ -2249,7 +2270,7 @@ namespace DiscImageChef.Commands bool testSense; Decoders.SCSI.FixedSense? decSense; - if(dev.SCSIType != DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(dev.SCSIType != Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { /*testSense = dev.ReadLong16(out readBuffer, out senseBuf, false, 0, 0xFFFF, dev.Timeout, out duration); if (testSense && !dev.Error) @@ -2276,7 +2297,7 @@ namespace DiscImageChef.Commands decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuf); if(decSense.HasValue) { - if(decSense.Value.SenseKey == DiscImageChef.Decoders.SCSI.SenseKeys.IllegalRequest && + if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest && decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00) { rawAble = true; @@ -2405,7 +2426,7 @@ namespace DiscImageChef.Commands decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuf); if(decSense.HasValue) { - if(decSense.Value.SenseKey == DiscImageChef.Decoders.SCSI.SenseKeys.IllegalRequest && + if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest && decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00) { rawAble = true; @@ -2413,7 +2434,6 @@ namespace DiscImageChef.Commands { longBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF); syqReadLong10 = !dev.SyQuestReadLong10(out readBuffer, out senseBuf, 0, longBlockSize, dev.Timeout, out duration); - ; } } else @@ -2424,7 +2444,7 @@ namespace DiscImageChef.Commands decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuf); if(decSense.HasValue) { - if(decSense.Value.SenseKey == DiscImageChef.Decoders.SCSI.SenseKeys.IllegalRequest && + if(decSense.Value.SenseKey == Decoders.SCSI.SenseKeys.IllegalRequest && decSense.Value.ASC == 0x24 && decSense.Value.ASCQ == 0x00) { rawAble = true; @@ -2432,7 +2452,6 @@ namespace DiscImageChef.Commands { longBlockSize = 0xFFFF - (decSense.Value.Information & 0xFFFF); syqReadLong6 = !dev.SyQuestReadLong6(out readBuffer, out senseBuf, 0, longBlockSize, dev.Timeout, out duration); - ; } } } @@ -2609,10 +2628,12 @@ namespace DiscImageChef.Commands if((blocks - i) < blocksToRead) blocksToRead = (uint)(blocks - i); +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; if(currentSpeed < minSpeed && currentSpeed != 0) minSpeed = currentSpeed; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed); @@ -2919,7 +2940,9 @@ namespace DiscImageChef.Commands double chkDuration = (chkEnd - chkStart).TotalMilliseconds; totalChkDuration += chkDuration; +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (chkDuration / (double)1000); +#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created } DicConsole.WriteLine(); closeDataFile(); @@ -2992,7 +3015,9 @@ namespace DiscImageChef.Commands dskType = MediaType.GOD; } } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { //DicConsole.DebugWriteLine("Dump-media command", "Plugin {0} crashed", _plugin.Name); } @@ -3032,7 +3057,9 @@ namespace DiscImageChef.Commands dskType = MediaType.GOD; } } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { //DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name); } @@ -3180,7 +3207,9 @@ namespace DiscImageChef.Commands DicConsole.WriteLine(); DicConsole.WriteLine("Took a total of {0:F3} seconds ({1:F3} processing commands, {2:F3} checksumming).", (end - start).TotalSeconds, totalDuration / 1000, totalChkDuration / 1000); +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created DicConsole.WriteLine("Avegare speed: {0:F3} MiB/sec.", (((double)blockSize * (double)(blocks + 1)) / 1048576) / (totalDuration / 1000)); +#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created DicConsole.WriteLine("Fastest speed burst: {0:F3} MiB/sec.", maxSpeed); DicConsole.WriteLine("Slowest speed burst: {0:F3} MiB/sec.", minSpeed); DicConsole.WriteLine("{0} sectors could not be read.", unreadableSectors.Count); diff --git a/DiscImageChef/Commands/Entropy.cs b/DiscImageChef/Commands/Entropy.cs index f2544d99..004bc05f 100644 --- a/DiscImageChef/Commands/Entropy.cs +++ b/DiscImageChef/Commands/Entropy.cs @@ -105,14 +105,18 @@ namespace DiscImageChef.Commands double entropy = 0; foreach(ulong l in entTable) { +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created double frequency = (double)l / (double)trackSize; +#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created entropy += -(frequency * Math.Log(frequency, 2)); } DicConsole.WriteLine("Entropy for track {0} is {1:F4}.", currentTrack.TrackSequence, entropy); +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created if(options.DuplicatedSectors) DicConsole.WriteLine("Track {0} has {1} unique sectors ({1:P3})", currentTrack.TrackSequence, uniqueSectorsPerTrack.Count, (double)uniqueSectorsPerTrack.Count / (double)sectors); +#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created DicConsole.WriteLine(); } @@ -162,7 +166,9 @@ namespace DiscImageChef.Commands double entropy = 0; foreach(ulong l in entTable) { +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created double frequency = (double)l / (double)diskSize; +#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created entropy += -(frequency * Math.Log(frequency, 2)); } @@ -171,7 +177,9 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Entropy for disk is {0:F4}.", entropy); if(options.DuplicatedSectors) +#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created DicConsole.WriteLine("Disk has {0} unique sectors ({1:P3})", uniqueSectors.Count, (double)uniqueSectors.Count / (double)sectors); +#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created Core.Statistics.AddCommand("entropy"); } diff --git a/DiscImageChef/Commands/ExtractFiles.cs b/DiscImageChef/Commands/ExtractFiles.cs index 28f60fd7..dc700014 100644 --- a/DiscImageChef/Commands/ExtractFiles.cs +++ b/DiscImageChef/Commands/ExtractFiles.cs @@ -40,7 +40,7 @@ using System.IO; namespace DiscImageChef.Commands { - public class ExtractFiles + public static class ExtractFiles { public static void doExtractFiles(ExtractFilesOptions options) { @@ -50,7 +50,7 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Extract-Files command", "--xattrs={0}", options.Xattrs); DicConsole.DebugWriteLine("Extract-Files command", "--output={0}", options.OutputDir); - if(!System.IO.File.Exists(options.InputFile)) + if(!File.Exists(options.InputFile)) { DicConsole.ErrorWriteLine("Specified file does not exist."); return; @@ -153,13 +153,13 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Filesystem not identified"); else if(id_plugins.Count > 1) { - DicConsole.WriteLine(String.Format("Identified by {0} plugins", id_plugins.Count)); + DicConsole.WriteLine(string.Format("Identified by {0} plugins", id_plugins.Count)); foreach(string plugin_name in id_plugins) { if(plugins.PluginsList.TryGetValue(plugin_name, out _plugin)) { - DicConsole.WriteLine(String.Format("As identified by {0}.", _plugin.Name)); + DicConsole.WriteLine(string.Format("As identified by {0}.", _plugin.Name)); Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(ulong), typeof(ulong) }).Invoke(new object[] { _imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors }); error = fs.Mount(options.Debug); @@ -185,7 +185,7 @@ namespace DiscImageChef.Commands else { plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin); - DicConsole.WriteLine(String.Format("Identified by {0}.", _plugin.Name)); + DicConsole.WriteLine(string.Format("Identified by {0}.", _plugin.Name)); Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(ulong), typeof(ulong) }).Invoke(new object[] { _imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors }); error = fs.Mount(options.Debug); if(error == Errno.NoError) @@ -213,14 +213,14 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Filesystem not identified"); else if(id_plugins.Count > 1) { - DicConsole.WriteLine(String.Format("Identified by {0} plugins", id_plugins.Count)); + DicConsole.WriteLine(string.Format("Identified by {0} plugins", id_plugins.Count)); foreach(string plugin_name in id_plugins) { if(plugins.PluginsList.TryGetValue(plugin_name, out _plugin)) { - DicConsole.WriteLine(String.Format("As identified by {0}.", _plugin.Name)); - Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(ulong), typeof(ulong) }).Invoke(new object[] { _imageFormat, (ulong)0, (ulong)(_imageFormat.GetSectors() - 1) }); + DicConsole.WriteLine(string.Format("As identified by {0}.", _plugin.Name)); + Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(ulong), typeof(ulong) }).Invoke(new object[] { _imageFormat, (ulong)0, _imageFormat.GetSectors() - 1 }); error = fs.Mount(options.Debug); if(error == Errno.NoError) { @@ -244,8 +244,8 @@ namespace DiscImageChef.Commands else { plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin); - DicConsole.WriteLine(String.Format("Identified by {0}.", _plugin.Name)); - Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(ulong), typeof(ulong) }).Invoke(new object[] { _imageFormat, (ulong)0, (ulong)(_imageFormat.GetSectors() - 1) }); + DicConsole.WriteLine(string.Format("Identified by {0}.", _plugin.Name)); + Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(ulong), typeof(ulong) }).Invoke(new object[] { _imageFormat, (ulong)0, _imageFormat.GetSectors() - 1 }); error = fs.Mount(options.Debug); if(error == Errno.NoError) { @@ -294,7 +294,7 @@ namespace DiscImageChef.Commands FileShare.None); outputFile.Write(xattrBuf, 0, xattrBuf.Length); outputFile.Close(); - System.IO.FileInfo fi = new System.IO.FileInfo(outputPath); + FileInfo fi = new FileInfo(outputPath); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { fi.CreationTimeUtc = stat.CreationTimeUtc; } catch { } try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; } catch { } @@ -333,7 +333,7 @@ namespace DiscImageChef.Commands FileShare.None); outputFile.Write(outBuf, 0, outBuf.Length); outputFile.Close(); - System.IO.FileInfo fi = new System.IO.FileInfo(outputPath); + FileInfo fi = new FileInfo(outputPath); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { fi.CreationTimeUtc = stat.CreationTimeUtc; } catch { } try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; } catch { } @@ -363,7 +363,7 @@ namespace DiscImageChef.Commands } catch(Exception ex) { - DicConsole.ErrorWriteLine(String.Format("Error reading file: {0}", ex.Message)); + DicConsole.ErrorWriteLine(string.Format("Error reading file: {0}", ex.Message)); DicConsole.DebugWriteLine("Extract-Files command", ex.StackTrace); } diff --git a/DiscImageChef/Commands/Formats.cs b/DiscImageChef/Commands/Formats.cs index ed4ad31d..0c61013c 100644 --- a/DiscImageChef/Commands/Formats.cs +++ b/DiscImageChef/Commands/Formats.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Collections.Generic; using DiscImageChef.ImagePlugins; using DiscImageChef.PartPlugins; diff --git a/DiscImageChef/Commands/Ls.cs b/DiscImageChef/Commands/Ls.cs index 495dd46b..8f182b24 100644 --- a/DiscImageChef/Commands/Ls.cs +++ b/DiscImageChef/Commands/Ls.cs @@ -39,7 +39,7 @@ using DiscImageChef.PartPlugins; namespace DiscImageChef.Commands { - public class Ls + public static class Ls { public static void doLs(LsOptions options) { @@ -142,13 +142,13 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Filesystem not identified"); else if(id_plugins.Count > 1) { - DicConsole.WriteLine(String.Format("Identified by {0} plugins", id_plugins.Count)); + DicConsole.WriteLine(string.Format("Identified by {0} plugins", id_plugins.Count)); foreach(string plugin_name in id_plugins) { if(plugins.PluginsList.TryGetValue(plugin_name, out _plugin)) { - DicConsole.WriteLine(String.Format("As identified by {0}.", _plugin.Name)); + DicConsole.WriteLine(string.Format("As identified by {0}.", _plugin.Name)); Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(ulong), typeof(ulong) }).Invoke(new object[] { _imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors }); error = fs.Mount(options.Debug); @@ -174,7 +174,7 @@ namespace DiscImageChef.Commands else { plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin); - DicConsole.WriteLine(String.Format("Identified by {0}.", _plugin.Name)); + DicConsole.WriteLine(string.Format("Identified by {0}.", _plugin.Name)); Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(ulong), typeof(ulong) }).Invoke(new object[] { _imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector + partitions[i].PartitionSectors }); error = fs.Mount(options.Debug); if(error == Errno.NoError) @@ -202,14 +202,14 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Filesystem not identified"); else if(id_plugins.Count > 1) { - DicConsole.WriteLine(String.Format("Identified by {0} plugins", id_plugins.Count)); + DicConsole.WriteLine(string.Format("Identified by {0} plugins", id_plugins.Count)); foreach(string plugin_name in id_plugins) { if(plugins.PluginsList.TryGetValue(plugin_name, out _plugin)) { - DicConsole.WriteLine(String.Format("As identified by {0}.", _plugin.Name)); - Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(ulong), typeof(ulong) }).Invoke(new object[] { _imageFormat, (ulong)0, (ulong)(_imageFormat.GetSectors() - 1) }); + DicConsole.WriteLine(string.Format("As identified by {0}.", _plugin.Name)); + Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(ulong), typeof(ulong) }).Invoke(new object[] { _imageFormat, (ulong)0, _imageFormat.GetSectors() - 1 }); error = fs.Mount(options.Debug); if(error == Errno.NoError) { @@ -233,8 +233,8 @@ namespace DiscImageChef.Commands else { plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin); - DicConsole.WriteLine(String.Format("Identified by {0}.", _plugin.Name)); - Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(ulong), typeof(ulong) }).Invoke(new object[] { _imageFormat, (ulong)0, (ulong)(_imageFormat.GetSectors() - 1) }); + DicConsole.WriteLine(string.Format("Identified by {0}.", _plugin.Name)); + Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(ulong), typeof(ulong) }).Invoke(new object[] { _imageFormat, (ulong)0, _imageFormat.GetSectors() - 1 }); error = fs.Mount(options.Debug); if(error == Errno.NoError) { @@ -291,7 +291,7 @@ namespace DiscImageChef.Commands } catch(Exception ex) { - DicConsole.ErrorWriteLine(String.Format("Error reading file: {0}", ex.Message)); + DicConsole.ErrorWriteLine(string.Format("Error reading file: {0}", ex.Message)); DicConsole.DebugWriteLine("Ls command", ex.StackTrace); } diff --git a/DiscImageChef/Commands/MediaInfo.cs b/DiscImageChef/Commands/MediaInfo.cs index 2f0996fd..d1cd2c0a 100644 --- a/DiscImageChef/Commands/MediaInfo.cs +++ b/DiscImageChef/Commands/MediaInfo.cs @@ -48,16 +48,16 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Media-Info command", "--device={0}", options.DevicePath); DicConsole.DebugWriteLine("Media-Info command", "--output-prefix={0}", options.OutputPrefix); - if(!System.IO.File.Exists(options.DevicePath)) + if(!File.Exists(options.DevicePath)) { DicConsole.ErrorWriteLine("Specified device does not exist."); return; } if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && - options.DevicePath[0] != '/' && Char.IsLetter(options.DevicePath[0])) + options.DevicePath[0] != '/' && char.IsLetter(options.DevicePath[0])) { - options.DevicePath = "\\\\.\\" + Char.ToUpper(options.DevicePath[0]) + ':'; + options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; } Device dev = new Device(options.DevicePath); @@ -221,16 +221,15 @@ namespace DiscImageChef.Commands scsiDensityCode = (byte)decMode.Value.Header.BlockDescriptors[0].Density; foreach(Decoders.SCSI.Modes.ModePage modePage in decMode.Value.Pages) - if(modePage.Page == 0x05) - containsFloppyPage = true; + containsFloppyPage |= modePage.Page == 0x05; } - if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.DirectAccess || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.OCRWDevice || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.OpticalDevice || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.SimplifiedDevice || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.WriteOnceDevice) + if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.DirectAccess || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.OCRWDevice || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.OpticalDevice || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.SimplifiedDevice || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.WriteOnceDevice) { sense = dev.ReadCapacity(out cmdBuf, out senseBuf, dev.Timeout, out duration); if(!sense) @@ -247,7 +246,7 @@ namespace DiscImageChef.Commands if(sense && blocks == 0) { // Not all MMC devices support READ CAPACITY, as they have READ TOC - if(dev.SCSIType != DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(dev.SCSIType != Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { DicConsole.ErrorWriteLine("Unable to get media capacity"); DicConsole.ErrorWriteLine("{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); @@ -270,11 +269,11 @@ namespace DiscImageChef.Commands { blocks++; DicConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2} bytes)", - blocks, blockSize, blocks * (ulong)blockSize); + blocks, blockSize, blocks * blockSize); } } - if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) + if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) { byte[] seqBuf; byte[] medBuf; @@ -326,7 +325,7 @@ namespace DiscImageChef.Commands */ } - if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { sense = dev.GetConfiguration(out cmdBuf, out senseBuf, 0, MmcGetConfigurationRt.Current, dev.Timeout, out duration); if(sense) @@ -522,7 +521,7 @@ namespace DiscImageChef.Commands dskType = MediaType.HDDVDRW; break; case Decoders.DVD.DiskCategory.Nintendo: - if(decPfi.Value.DiscSize == DiscImageChef.Decoders.DVD.DVDSize.Eighty) + if(decPfi.Value.DiscSize == Decoders.DVD.DVDSize.Eighty) dskType = MediaType.GOD; else dskType = MediaType.WOD; @@ -997,8 +996,7 @@ namespace DiscImageChef.Commands else hasAudioTrack = true; - if(track.ADR == 4) - hasVideoTrack = true; + hasVideoTrack |= track.ADR == 4; } } @@ -1055,12 +1053,12 @@ namespace DiscImageChef.Commands if(nintendoPfi != null) { DicConsole.WriteLine("PFI:\n{0}", Decoders.DVD.PFI.Prettify(cmdBuf)); - if(nintendoPfi.Value.DiskCategory == DiscImageChef.Decoders.DVD.DiskCategory.Nintendo && + if(nintendoPfi.Value.DiskCategory == Decoders.DVD.DiskCategory.Nintendo && nintendoPfi.Value.PartVersion == 15) { - if(nintendoPfi.Value.DiscSize == DiscImageChef.Decoders.DVD.DVDSize.Eighty) + if(nintendoPfi.Value.DiscSize == Decoders.DVD.DVDSize.Eighty) dskType = MediaType.GOD; - else if(nintendoPfi.Value.DiscSize == DiscImageChef.Decoders.DVD.DVDSize.OneTwenty) + else if(nintendoPfi.Value.DiscSize == Decoders.DVD.DVDSize.OneTwenty) dskType = MediaType.WOD; } } diff --git a/DiscImageChef/Commands/MediaScan.cs b/DiscImageChef/Commands/MediaScan.cs index eb07c7ff..b819b707 100644 --- a/DiscImageChef/Commands/MediaScan.cs +++ b/DiscImageChef/Commands/MediaScan.cs @@ -58,9 +58,9 @@ namespace DiscImageChef.Commands } if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && - options.DevicePath[0] != '/' && Char.IsLetter(options.DevicePath[0])) + options.DevicePath[0] != '/' && char.IsLetter(options.DevicePath[0])) { - options.DevicePath = "\\\\.\\" + Char.ToUpper(options.DevicePath[0]) + ':'; + options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; } mhddLog = null; @@ -323,9 +323,9 @@ namespace DiscImageChef.Commands Random rnd = new Random(); uint seekPos = (uint)rnd.Next((int)blocks); - ushort seekCy = (ushort)rnd.Next((int)cylinders); - byte seekHd = (byte)rnd.Next((int)heads); - byte seekSc = (byte)rnd.Next((int)sectors); + ushort seekCy = (ushort)rnd.Next(cylinders); + byte seekHd = (byte)rnd.Next(heads); + byte seekSc = (byte)rnd.Next(sectors); aborted = false; System.Console.CancelKeyPress += (sender, e) => @@ -351,10 +351,12 @@ namespace DiscImageChef.Commands if((blocks - i) < blocksToRead) blocksToRead = (byte)(blocks - i); +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; if(currentSpeed < minSpeed && currentSpeed != 0) minSpeed = currentSpeed; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed); @@ -447,13 +449,17 @@ namespace DiscImageChef.Commands ibgLog.Write(i, 0); } +#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (cmdDuration / (double)1000); +#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values GC.Collect(); } end = DateTime.UtcNow; DicConsole.WriteLine(); mhddLog.Close(); +#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), devicePath); +#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values if(SeekLba) { @@ -469,10 +475,12 @@ namespace DiscImageChef.Commands if(SeekLba) dev.Seek(out errorLba, seekPos, timeout, out seekCur); +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(seekCur > seekMax && seekCur != 0) seekMax = seekCur; if(seekCur < seekMin && seekCur != 0) seekMin = seekCur; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator seekTotal += seekCur; GC.Collect(); @@ -498,10 +506,12 @@ namespace DiscImageChef.Commands double cmdDuration = 0; +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; if(currentSpeed < minSpeed && currentSpeed != 0) minSpeed = currentSpeed; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator DicConsole.Write("\rReading cylinder {0} head {1} sector {2} ({3:F3} MiB/sec.)", Cy, Hd, Sc, currentSpeed); @@ -580,7 +590,9 @@ namespace DiscImageChef.Commands ibgLog.Write(currentBlock, 0); } +#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values currentSpeed = ((double)blockSize / (double)1048576) / (cmdDuration / (double)1000); +#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values GC.Collect(); currentBlock++; @@ -590,7 +602,9 @@ namespace DiscImageChef.Commands end = DateTime.UtcNow; DicConsole.WriteLine(); mhddLog.Close(); +#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), devicePath); +#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values if(Seek) { @@ -599,19 +613,21 @@ namespace DiscImageChef.Commands if(aborted) break; - seekCy = (ushort)rnd.Next((int)cylinders); - seekHd = (byte)rnd.Next((int)heads); - seekSc = (byte)rnd.Next((int)sectors); + seekCy = (ushort)rnd.Next(cylinders); + seekHd = (byte)rnd.Next(heads); + seekSc = (byte)rnd.Next(sectors); DicConsole.Write("\rSeeking to cylinder {0}, head {1}, sector {2}...\t\t", seekCy, seekHd, seekSc); if(Seek) dev.Seek(out errorChs, seekCy, seekHd, seekSc, timeout, out seekCur); +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(seekCur > seekMax && seekCur != 0) seekMax = seekCur; if(seekCur < seekMin && seekCur != 0) seekMin = seekCur; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator seekTotal += seekCur; GC.Collect(); @@ -622,7 +638,9 @@ namespace DiscImageChef.Commands DicConsole.WriteLine(); DicConsole.WriteLine("Took a total of {0} seconds ({1} processing commands).", (end - start).TotalSeconds, totalDuration / 1000); +#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values DicConsole.WriteLine("Avegare speed: {0:F3} MiB/sec.", (((double)blockSize * (double)(blocks + 1)) / 1048576) / (totalDuration / 1000)); +#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values DicConsole.WriteLine("Fastest speed burst: {0:F3} MiB/sec.", maxSpeed); DicConsole.WriteLine("Slowest speed burst: {0:F3} MiB/sec.", minSpeed); DicConsole.WriteLine("Summary:"); @@ -640,7 +658,9 @@ namespace DiscImageChef.Commands } DicConsole.WriteLine(); +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(seekTotal != 0 || seekMin != double.MaxValue || seekMax != double.MinValue) +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator DicConsole.WriteLine("Testing {0} seeks, longest seek took {1:F3} ms, fastest one took {2:F3} ms. ({3:F3} ms average)", seekTimes, seekMax, seekMin, seekTotal / 1000); @@ -732,12 +752,12 @@ namespace DiscImageChef.Commands } } - if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.DirectAccess || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.OCRWDevice || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.OpticalDevice || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.SimplifiedDevice || - dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.WriteOnceDevice) + if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.DirectAccess || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.OCRWDevice || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.OpticalDevice || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.SimplifiedDevice || + dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.WriteOnceDevice) { sense = dev.ReadCapacity(out cmdBuf, out senseBuf, dev.Timeout, out duration); if(!sense) @@ -753,7 +773,7 @@ namespace DiscImageChef.Commands if(sense && blocks == 0) { // Not all MMC devices support READ CAPACITY, as they have READ TOC - if(dev.SCSIType != DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(dev.SCSIType != Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { DicConsole.ErrorWriteLine("Unable to get media capacity"); DicConsole.ErrorWriteLine("{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); @@ -774,12 +794,14 @@ namespace DiscImageChef.Commands if(blocks != 0 && blockSize != 0) { blocks++; +#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values DicConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2} bytes)", blocks, blockSize, blocks * (ulong)blockSize); +#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values } } - if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) + if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) { DicConsole.WriteLine("Scanning will never be supported on SCSI Streaming Devices."); DicConsole.WriteLine("It has no sense to do it, and it will put too much strain on the tape."); @@ -795,7 +817,7 @@ namespace DiscImageChef.Commands bool compactDisc = true; Decoders.CD.FullTOC.CDFullTOC? toc = null; - if(dev.SCSIType == DiscImageChef.Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { sense = dev.GetConfiguration(out cmdBuf, out senseBuf, 0, MmcGetConfigurationRt.Current, dev.Timeout, out duration); if(!sense) @@ -910,10 +932,12 @@ namespace DiscImageChef.Commands if((blocks - i) < blocksToRead) blocksToRead = (uint)(blocks - i); +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; if(currentSpeed < minSpeed && currentSpeed != 0) minSpeed = currentSpeed; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed); @@ -991,13 +1015,17 @@ namespace DiscImageChef.Commands } } +#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (cmdDuration / (double)1000); +#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values GC.Collect(); } end = DateTime.UtcNow; DicConsole.WriteLine(); mhddLog.Close(); +#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), devicePath); +#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values } else { @@ -1021,9 +1049,9 @@ namespace DiscImageChef.Commands return; } - if(!read16 && blocks > ((long)0xFFFFFFFF + (long)1)) + if(!read16 && blocks > 0xFFFFFFFFL + 1L) { - DicConsole.ErrorWriteLine("Device only supports SCSI READ (10) but has more than {0} blocks ({1} blocks total)", (long)0xFFFFFFFF + (long)1, blocks); + DicConsole.ErrorWriteLine("Device only supports SCSI READ (10) but has more than {0} blocks ({1} blocks total)", 0xFFFFFFFFL + 1L, blocks); return; } @@ -1090,10 +1118,12 @@ namespace DiscImageChef.Commands if((blocks - i) < blocksToRead) blocksToRead = (uint)(blocks - i); +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed; if(currentSpeed < minSpeed && currentSpeed != 0) minSpeed = currentSpeed; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, blocks, currentSpeed); @@ -1149,12 +1179,17 @@ namespace DiscImageChef.Commands ibgLog.Write(i, 0); } +#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values currentSpeed = ((double)blockSize * blocksToRead / (double)1048576) / (cmdDuration / (double)1000); +#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values } + end = DateTime.UtcNow; DicConsole.WriteLine(); mhddLog.Close(); +#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalDuration / 1000), devicePath); +#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values } bool seek6, seek10; @@ -1221,7 +1256,7 @@ namespace DiscImageChef.Commands } else if(read10) { - dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, seekPos, blockSize, 0, (ushort)1, dev.Timeout, out seekCur); + dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, seekPos, blockSize, 0, 1, dev.Timeout, out seekCur); } else if(read6) { @@ -1229,10 +1264,12 @@ namespace DiscImageChef.Commands } } +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(seekCur > seekMax && seekCur != 0) seekMax = seekCur; if(seekCur < seekMin && seekCur != 0) seekMin = seekCur; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator seekTotal += seekCur; GC.Collect(); @@ -1241,7 +1278,9 @@ namespace DiscImageChef.Commands DicConsole.WriteLine(); DicConsole.WriteLine("Took a total of {0} seconds ({1} processing commands).", (end - start).TotalSeconds, totalDuration / 1000); +#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values DicConsole.WriteLine("Avegare speed: {0:F3} MiB/sec.", (((double)blockSize * (double)(blocks + 1)) / 1048576) / (totalDuration / 1000)); +#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values DicConsole.WriteLine("Fastest speed burst: {0:F3} MiB/sec.", maxSpeed); DicConsole.WriteLine("Slowest speed burst: {0:F3} MiB/sec.", minSpeed); DicConsole.WriteLine("Summary:"); @@ -1259,7 +1298,9 @@ namespace DiscImageChef.Commands } DicConsole.WriteLine(); +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator if(seekTotal != 0 || seekMin != double.MaxValue || seekMax != double.MinValue) +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator DicConsole.WriteLine("Testing {0} seeks, longest seek took {1:F3} ms, fastest one took {2:F3} ms. ({3:F3} ms average)", seekTimes, seekMax, seekMin, seekTotal / 1000); diff --git a/DiscImageChef/Commands/PrintHex.cs b/DiscImageChef/Commands/PrintHex.cs index 9e4a09da..7452608c 100644 --- a/DiscImageChef/Commands/PrintHex.cs +++ b/DiscImageChef/Commands/PrintHex.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using DiscImageChef.ImagePlugins; using DiscImageChef.Console; diff --git a/DiscImageChef/Commands/Statistics.cs b/DiscImageChef/Commands/Statistics.cs index 192529c2..8fdaae8a 100644 --- a/DiscImageChef/Commands/Statistics.cs +++ b/DiscImageChef/Commands/Statistics.cs @@ -30,7 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using DiscImageChef.Console; namespace DiscImageChef.Commands diff --git a/DiscImageChef/Commands/Verify.cs b/DiscImageChef/Commands/Verify.cs index a659c85b..237c0595 100644 --- a/DiscImageChef/Commands/Verify.cs +++ b/DiscImageChef/Commands/Verify.cs @@ -114,27 +114,27 @@ namespace DiscImageChef.Commands DateTime StartCheck; DateTime EndCheck; - List FailingLBAs = new List(); - List UnknownLBAs = new List(); + List FailingLBAs = new List(); + List UnknownLBAs = new List(); bool? checkStatus = null; if(formatHasTracks) { List inputTracks = inputFormat.GetTracks(); - UInt64 currentSectorAll = 0; + ulong currentSectorAll = 0; StartCheck = DateTime.UtcNow; foreach(Track currentTrack in inputTracks) { - UInt64 remainingSectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector; - UInt64 currentSector = 0; + ulong remainingSectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector; + ulong currentSector = 0; while(remainingSectors > 0) { DicConsole.Write("\rChecking sector {0} of {1}, on track {2}", currentSectorAll, inputFormat.GetSectors(), currentTrack.TrackSequence); - List tempFailingLBAs; - List tempUnknownLBAs; + List tempFailingLBAs; + List tempUnknownLBAs; bool? tempStatus; if(remainingSectors < 512) @@ -151,10 +151,10 @@ namespace DiscImageChef.Commands else checkStatus = null; - foreach(UInt64 failLBA in tempFailingLBAs) + foreach(ulong failLBA in tempFailingLBAs) FailingLBAs.Add(failLBA); - foreach(UInt64 unknownLBA in tempUnknownLBAs) + foreach(ulong unknownLBA in tempUnknownLBAs) UnknownLBAs.Add(unknownLBA); if(remainingSectors < 512) @@ -176,16 +176,16 @@ namespace DiscImageChef.Commands } else { - UInt64 remainingSectors = inputFormat.GetSectors(); - UInt64 currentSector = 0; + ulong remainingSectors = inputFormat.GetSectors(); + ulong currentSector = 0; StartCheck = DateTime.UtcNow; while(remainingSectors > 0) { DicConsole.Write("\rChecking sector {0} of {1}", currentSector, inputFormat.GetSectors()); - List tempFailingLBAs; - List tempUnknownLBAs; + List tempFailingLBAs; + List tempUnknownLBAs; bool? tempStatus; if(remainingSectors < 512) @@ -202,10 +202,10 @@ namespace DiscImageChef.Commands else checkStatus = null; - foreach(UInt64 failLBA in tempFailingLBAs) + foreach(ulong failLBA in tempFailingLBAs) FailingLBAs.Add(failLBA); - foreach(UInt64 unknownLBA in tempUnknownLBAs) + foreach(ulong unknownLBA in tempUnknownLBAs) UnknownLBAs.Add(unknownLBA); if(remainingSectors < 512) diff --git a/DiscImageChef/Core/Checksum.cs b/DiscImageChef/Core/Checksum.cs index cabb907f..284277c6 100644 --- a/DiscImageChef/Core/Checksum.cs +++ b/DiscImageChef/Core/Checksum.cs @@ -30,12 +30,10 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -using System; using System.Collections.Generic; using DiscImageChef.Checksums; using Schemas; using System.Threading; -using System.IO; namespace DiscImageChef.Core { @@ -188,64 +186,64 @@ namespace DiscImageChef.Core internal List End() { - List Checksums = new List(); + List chks = new List(); ChecksumType chk = new ChecksumType(); chk.type = ChecksumTypeType.adler32; chk.Value = adler32ctx.End(); - Checksums.Add(chk); + chks.Add(chk); chk = new ChecksumType(); chk.type = ChecksumTypeType.crc16; chk.Value = crc16ctx.End(); - Checksums.Add(chk); + chks.Add(chk); chk = new ChecksumType(); chk.type = ChecksumTypeType.crc32; chk.Value = crc32ctx.End(); - Checksums.Add(chk); + chks.Add(chk); chk = new ChecksumType(); chk.type = ChecksumTypeType.crc64; chk.Value = crc64ctx.End(); - Checksums.Add(chk); + chks.Add(chk); chk = new ChecksumType(); chk.type = ChecksumTypeType.md5; chk.Value = md5ctx.End(); - Checksums.Add(chk); + chks.Add(chk); chk = new ChecksumType(); chk.type = ChecksumTypeType.ripemd160; chk.Value = ripemd160ctx.End(); - Checksums.Add(chk); + chks.Add(chk); chk = new ChecksumType(); chk.type = ChecksumTypeType.sha1; chk.Value = sha1ctx.End(); - Checksums.Add(chk); + chks.Add(chk); chk = new ChecksumType(); chk.type = ChecksumTypeType.sha256; chk.Value = sha256ctx.End(); - Checksums.Add(chk); + chks.Add(chk); chk = new ChecksumType(); chk.type = ChecksumTypeType.sha384; chk.Value = sha384ctx.End(); - Checksums.Add(chk); + chks.Add(chk); chk = new ChecksumType(); chk.type = ChecksumTypeType.sha512; chk.Value = sha512ctx.End(); - Checksums.Add(chk); + chks.Add(chk); chk = new ChecksumType(); chk.type = ChecksumTypeType.spamsum; chk.Value = ssctx.End(); - Checksums.Add(chk); + chks.Add(chk); - return Checksums; + return chks; } internal static List GetChecksums(byte[] data) diff --git a/DiscImageChef/Core/IBGLog.cs b/DiscImageChef/Core/IBGLog.cs index 2c9c32a0..34255886 100644 --- a/DiscImageChef/Core/IBGLog.cs +++ b/DiscImageChef/Core/IBGLog.cs @@ -284,7 +284,7 @@ namespace DiscImageChef.Core ibgHeader.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n"); StreamWriter sr = new StreamWriter(ibgFs); - sr.Write(ibgHeader.ToString()); + sr.Write(ibgHeader); sr.Close(); ibgFs.Close(); } diff --git a/DiscImageChef/DetectImageFormat.cs b/DiscImageChef/DetectImageFormat.cs index 5cfa9290..1cb17e47 100644 --- a/DiscImageChef/DetectImageFormat.cs +++ b/DiscImageChef/DetectImageFormat.cs @@ -30,44 +30,6 @@ // Copyright © 2011-2016 Natalia Portillo // ****************************************************************************/ -// /*************************************************************************** -// The Disc Image Chef -// ---------------------------------------------------------------------------- -// -// Filename : DetectImageFormat.cs -// Version : 1.0 -// Author(s) : Natalia Portillo -// -// Component : Main -// -// Revision : $Revision$ -// Last change by : $Author$ -// Date : $Date$ -// -// --[ Description ] ---------------------------------------------------------- -// -// Detects disc image format -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright (C) 2011-2015 Claunia.com -// ****************************************************************************/ -// //$Id$ - using System; namespace DiscImageChef.ImagePlugins @@ -85,40 +47,44 @@ namespace DiscImageChef.ImagePlugins _imageFormat = null; // Check all but RAW plugin - foreach (ImagePlugin _imageplugin in plugins.ImagePluginsList.Values) + foreach(ImagePlugin _imageplugin in plugins.ImagePluginsList.Values) { - if (_imageplugin.PluginUUID != new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) + if(_imageplugin.PluginUUID != new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) { try { - if (_imageplugin.IdentifyImage(imagePath)) + if(_imageplugin.IdentifyImage(imagePath)) { _imageFormat = _imageplugin; break; } } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { } } } // Check only RAW plugin - if (_imageFormat == null) + if(_imageFormat == null) { - foreach (ImagePlugin _imageplugin in plugins.ImagePluginsList.Values) + foreach(ImagePlugin _imageplugin in plugins.ImagePluginsList.Values) { - if (_imageplugin.PluginUUID == new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) + if(_imageplugin.PluginUUID == new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) { try { - if (_imageplugin.IdentifyImage(imagePath)) + if(_imageplugin.IdentifyImage(imagePath)) { _imageFormat = _imageplugin; break; } } +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { } } @@ -126,7 +92,7 @@ namespace DiscImageChef.ImagePlugins } // Still not recognized - if (_imageFormat == null) + if(_imageFormat == null) { return null; } diff --git a/DiscImageChef/DiscImageChef.csproj b/DiscImageChef/DiscImageChef.csproj index 237299e8..544e6a59 100644 --- a/DiscImageChef/DiscImageChef.csproj +++ b/DiscImageChef/DiscImageChef.csproj @@ -140,6 +140,8 @@ + + diff --git a/DiscImageChef/Main.cs b/DiscImageChef/Main.cs index ebf0e9a8..4b09965b 100644 --- a/DiscImageChef/Main.cs +++ b/DiscImageChef/Main.cs @@ -33,7 +33,6 @@ using System; using System.Reflection; using DiscImageChef.Console; -using DiscImageChef.Settings; using CommandLine; namespace DiscImageChef diff --git a/DiscImageChef/Options.cs b/DiscImageChef/Options.cs index 859ed48c..409cf4af 100644 --- a/DiscImageChef/Options.cs +++ b/DiscImageChef/Options.cs @@ -256,10 +256,10 @@ namespace DiscImageChef [Verb("benchmark", HelpText = "Benchmarks hashing and entropy calculation.")] public class BenchmarkOptions : CommonOptions { - [Option('b', "block-size", Required = false, Default = (int)512, HelpText = "Block size.")] + [Option('b', "block-size", Required = false, Default = 512, HelpText = "Block size.")] public int BlockSize { get; set; } - [Option('s', "buffer-size", Required = false, Default = (int)128, HelpText = "Buffer size in mebibytes.")] + [Option('s', "buffer-size", Required = false, Default = 128, HelpText = "Buffer size in mebibytes.")] public int BufferSize { get; set; } } diff --git a/DiscImageChef/Plugins.cs b/DiscImageChef/Plugins.cs index 9e2e474b..5f7fbc3b 100644 --- a/DiscImageChef/Plugins.cs +++ b/DiscImageChef/Plugins.cs @@ -55,21 +55,21 @@ namespace DiscImageChef public void RegisterAllPlugins() { - Assembly assembly; + Assembly assembly; assembly = Assembly.GetAssembly(typeof(ImagePlugin)); - foreach (Type type in assembly.GetTypes()) + foreach(Type type in assembly.GetTypes()) { try { - if (type.IsSubclassOf(typeof(ImagePlugin))) + if(type.IsSubclassOf(typeof(ImagePlugin))) { ImagePlugin plugin = (ImagePlugin)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); RegisterImagePlugin(plugin); } } - catch (Exception exception) + catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); } @@ -77,17 +77,17 @@ namespace DiscImageChef assembly = Assembly.GetAssembly(typeof(PartPlugin)); - foreach (Type type in assembly.GetTypes()) + foreach(Type type in assembly.GetTypes()) { try { - if (type.IsSubclassOf(typeof(PartPlugin))) + if(type.IsSubclassOf(typeof(PartPlugin))) { PartPlugin plugin = (PartPlugin)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); RegisterPartPlugin(plugin); } } - catch (Exception exception) + catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); } @@ -95,17 +95,17 @@ namespace DiscImageChef assembly = Assembly.GetAssembly(typeof(Filesystem)); - foreach (Type type in assembly.GetTypes()) + foreach(Type type in assembly.GetTypes()) { try { - if (type.IsSubclassOf(typeof(Filesystem))) + if(type.IsSubclassOf(typeof(Filesystem))) { Filesystem plugin = (Filesystem)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); RegisterPlugin(plugin); } } - catch (Exception exception) + catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); } @@ -114,7 +114,7 @@ namespace DiscImageChef void RegisterImagePlugin(ImagePlugin plugin) { - if (!ImagePluginsList.ContainsKey(plugin.Name.ToLower())) + if(!ImagePluginsList.ContainsKey(plugin.Name.ToLower())) { ImagePluginsList.Add(plugin.Name.ToLower(), plugin); } @@ -122,7 +122,7 @@ namespace DiscImageChef void RegisterPlugin(Filesystem plugin) { - if (!PluginsList.ContainsKey(plugin.Name.ToLower())) + if(!PluginsList.ContainsKey(plugin.Name.ToLower())) { PluginsList.Add(plugin.Name.ToLower(), plugin); } @@ -130,7 +130,7 @@ namespace DiscImageChef void RegisterPartPlugin(PartPlugin partplugin) { - if (!PartPluginsList.ContainsKey(partplugin.Name.ToLower())) + if(!PartPluginsList.ContainsKey(partplugin.Name.ToLower())) { PartPluginsList.Add(partplugin.Name.ToLower(), partplugin); }