diff --git a/Aaru.Checksums b/Aaru.Checksums index 41d26c705..843291076 160000 --- a/Aaru.Checksums +++ b/Aaru.Checksums @@ -1 +1 @@ -Subproject commit 41d26c7057aa40afaf4d43fdd018d9403c2a29a7 +Subproject commit 843291076cd12156aaa09040ecc511eee64db4bd diff --git a/Aaru.CommonTypes b/Aaru.CommonTypes index 222d660d6..1fe6700b1 160000 --- a/Aaru.CommonTypes +++ b/Aaru.CommonTypes @@ -1 +1 @@ -Subproject commit 222d660d6b2da77b151e0a5a3dcf03c06a5f8343 +Subproject commit 1fe6700b1143a9054ea48903a6a1647060971674 diff --git a/Aaru.Compression/AppleRle.cs b/Aaru.Compression/AppleRle.cs index d577c8c53..2a39176f5 100644 --- a/Aaru.Compression/AppleRle.cs +++ b/Aaru.Compression/AppleRle.cs @@ -39,60 +39,60 @@ namespace Aaru.Compression { const uint DART_CHUNK = 20960; - readonly Stream inStream; - int count; - bool nextA; // true if A, false if B + readonly Stream _inStream; + int _count; + bool _nextA; // true if A, false if B - byte repeatedbyteA, repeatedbyteB; - bool repeatMode; // true if we're repeating, false if we're just copying + byte _repeatedByteA, _repeatedByteB; + bool _repeatMode; // true if we're repeating, false if we're just copying public AppleRle(Stream stream) { - inStream = stream; + _inStream = stream; Reset(); } void Reset() { - repeatedbyteA = repeatedbyteB = 0; - count = 0; - nextA = true; - repeatMode = false; + _repeatedByteA = _repeatedByteB = 0; + _count = 0; + _nextA = true; + _repeatMode = false; } public int ProduceByte() { - if(repeatMode && count > 0) + if(_repeatMode && _count > 0) { - count--; + _count--; - if(nextA) + if(_nextA) { - nextA = false; + _nextA = false; - return repeatedbyteA; + return _repeatedByteA; } - nextA = true; + _nextA = true; - return repeatedbyteB; + return _repeatedByteB; } - if(!repeatMode && - count > 0) + if(!_repeatMode && + _count > 0) { - count--; + _count--; - return inStream.ReadByte(); + return _inStream.ReadByte(); } - if(inStream.Position == inStream.Length) + if(_inStream.Position == _inStream.Length) return -1; while(true) { - byte b1 = (byte)inStream.ReadByte(); - byte b2 = (byte)inStream.ReadByte(); + byte b1 = (byte)_inStream.ReadByte(); + byte b2 = (byte)_inStream.ReadByte(); short s = (short)((b1 << 8) | b2); if(s == 0 || @@ -102,22 +102,22 @@ namespace Aaru.Compression if(s < 0) { - repeatMode = true; - repeatedbyteA = (byte)inStream.ReadByte(); - repeatedbyteB = (byte)inStream.ReadByte(); - count = (-s * 2) - 1; - nextA = false; + _repeatMode = true; + _repeatedByteA = (byte)_inStream.ReadByte(); + _repeatedByteB = (byte)_inStream.ReadByte(); + _count = (-s * 2) - 1; + _nextA = false; - return repeatedbyteA; + return _repeatedByteA; } if(s <= 0) continue; - repeatMode = false; - count = (s * 2) - 1; + _repeatMode = false; + _count = (s * 2) - 1; - return inStream.ReadByte(); + return _inStream.ReadByte(); } } } diff --git a/Aaru.Compression/TeleDiskLzh.cs b/Aaru.Compression/TeleDiskLzh.cs index 236b2129f..486ab8e0c 100644 --- a/Aaru.Compression/TeleDiskLzh.cs +++ b/Aaru.Compression/TeleDiskLzh.cs @@ -77,7 +77,7 @@ namespace Aaru.Compression */ /* decoder table */ - readonly byte[] d_code = + readonly byte[] _dCode = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, @@ -96,7 +96,7 @@ namespace Aaru.Compression 0x3C, 0x3D, 0x3E, 0x3F }; - readonly byte[] d_len = + readonly byte[] _dLen = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, @@ -114,40 +114,40 @@ namespace Aaru.Compression 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }; - readonly ushort[] freq = new ushort[T + 1]; /* cumulative freq table */ + readonly ushort[] _freq = new ushort[T + 1]; /* cumulative freq table */ - readonly Stream inStream; + readonly Stream _inStream; /* * pointing parent nodes. * area [T..(T + N_CHAR - 1)] are pointers for leaves */ - readonly short[] prnt = new short[T + N_CHAR]; + readonly short[] _prnt = new short[T + N_CHAR]; /* pointing children nodes (son[], son[] + 1)*/ - readonly short[] son = new short[T]; - readonly byte[] text_buf = new byte[(N + F) - 1]; + readonly short[] _son = new short[T]; + readonly byte[] _textBuf = new byte[(N + F) - 1]; - ushort getbuf; - byte getlen; + ushort _getbuf; + byte _getlen; - Tdlzhuf tdctl; + Tdlzhuf _tdctl; public TeleDiskLzh(Stream dataStream) { int i; - getbuf = 0; - getlen = 0; - tdctl = new Tdlzhuf(); - tdctl.Ibufcnt = tdctl.Ibufndx = 0; // input buffer is empty - tdctl.Bufcnt = 0; + _getbuf = 0; + _getlen = 0; + _tdctl = new Tdlzhuf(); + _tdctl.Ibufcnt = _tdctl.Ibufndx = 0; // input buffer is empty + _tdctl.Bufcnt = 0; StartHuff(); for(i = 0; i < N - F; i++) - text_buf[i] = 0x20; + _textBuf[i] = 0x20; - tdctl.R = N - F; - inStream = dataStream; + _tdctl.R = N - F; + _inStream = dataStream; } /* DeCompression @@ -163,16 +163,16 @@ namespace Aaru.Compression int count; // was an unsigned long, seems unnecessary for(count = 0; count < len;) - if(tdctl.Bufcnt == 0) + if(_tdctl.Bufcnt == 0) { if((c = DecodeChar()) < 0) return count; // fatal error if(c < 256) { - buf[count] = (byte)c; - text_buf[tdctl.R++] = (byte)c; - tdctl.R &= N - 1; + buf[count] = (byte)c; + _textBuf[_tdctl.R++] = (byte)c; + _tdctl.R &= N - 1; count++; } else @@ -182,28 +182,28 @@ namespace Aaru.Compression if((pos = DecodePosition()) < 0) return count; // fatal error - tdctl.Bufpos = (ushort)((tdctl.R - pos - 1) & (N - 1)); - tdctl.Bufcnt = (ushort)((c - 255) + THRESHOLD); - tdctl.Bufndx = 0; + _tdctl.Bufpos = (ushort)((_tdctl.R - pos - 1) & (N - 1)); + _tdctl.Bufcnt = (ushort)((c - 255) + THRESHOLD); + _tdctl.Bufndx = 0; } } else { // still chars from last string - while(tdctl.Bufndx < tdctl.Bufcnt && - count < len) + while(_tdctl.Bufndx < _tdctl.Bufcnt && + count < len) { - c = text_buf[(tdctl.Bufpos + tdctl.Bufndx) & (N - 1)]; + c = _textBuf[(_tdctl.Bufpos + _tdctl.Bufndx) & (N - 1)]; buf[count] = (byte)c; - tdctl.Bufndx++; - text_buf[tdctl.R++] = (byte)c; - tdctl.R &= N - 1; + _tdctl.Bufndx++; + _textBuf[_tdctl.R++] = (byte)c; + _tdctl.R &= N - 1; count++; } // reset bufcnt after copy string from text_buf[] - if(tdctl.Bufndx >= tdctl.Bufcnt) - tdctl.Bufndx = tdctl.Bufcnt = 0; + if(_tdctl.Bufndx >= _tdctl.Bufcnt) + _tdctl.Bufndx = _tdctl.Bufcnt = 0; } return count; // count == len, success @@ -211,31 +211,31 @@ namespace Aaru.Compression long DataRead(out byte[] buf, long size) { - if(size > inStream.Length - inStream.Position) - size = inStream.Length - inStream.Position; + if(size > _inStream.Length - _inStream.Position) + size = _inStream.Length - _inStream.Position; buf = new byte[size]; - inStream.Read(buf, 0, (int)size); + _inStream.Read(buf, 0, (int)size); return size; } int NextWord() { - if(tdctl.Ibufndx >= tdctl.Ibufcnt) + if(_tdctl.Ibufndx >= _tdctl.Ibufcnt) { - tdctl.Ibufndx = 0; - tdctl.Ibufcnt = (ushort)DataRead(out tdctl.Inbuf, BUFSZ); + _tdctl.Ibufndx = 0; + _tdctl.Ibufcnt = (ushort)DataRead(out _tdctl.Inbuf, BUFSZ); - if(tdctl.Ibufcnt <= 0) + if(_tdctl.Ibufcnt <= 0) return -1; } - while(getlen <= 8) + while(_getlen <= 8) { // typically reads a word at a time - getbuf |= (ushort)(tdctl.Inbuf[tdctl.Ibufndx++] << (8 - getlen)); - getlen += 8; + _getbuf |= (ushort)(_tdctl.Inbuf[_tdctl.Ibufndx++] << (8 - _getlen)); + _getlen += 8; } return 0; @@ -246,9 +246,9 @@ namespace Aaru.Compression if(NextWord() < 0) return -1; - short i = (short)getbuf; - getbuf <<= 1; - getlen--; + short i = (short)_getbuf; + _getbuf <<= 1; + _getlen--; return i < 0 ? 1 : 0; } @@ -258,10 +258,10 @@ namespace Aaru.Compression if(NextWord() != 0) return -1; - ushort i = getbuf; - getbuf <<= 8; - getlen -= 8; - i = (ushort)(i >> 8); + ushort i = _getbuf; + _getbuf <<= 8; + _getlen -= 8; + i = (ushort)(i >> 8); return i; } @@ -274,9 +274,9 @@ namespace Aaru.Compression for(i = 0; i < N_CHAR; i++) { - freq[i] = 1; - son[i] = (short)(i + T); - prnt[i + T] = (short)i; + _freq[i] = 1; + _son[i] = (short)(i + T); + _prnt[i + T] = (short)i; } i = 0; @@ -284,15 +284,15 @@ namespace Aaru.Compression while(j <= ROOT) { - freq[j] = (ushort)(freq[i] + freq[i + 1]); - son[j] = (short)i; - prnt[i] = prnt[i + 1] = (short)j; - i += 2; + _freq[j] = (ushort)(_freq[i] + _freq[i + 1]); + _son[j] = (short)i; + _prnt[i] = _prnt[i + 1] = (short)j; + i += 2; j++; } - freq[T] = 0xffff; - prnt[ROOT] = 0; + _freq[T] = 0xffff; + _prnt[ROOT] = 0; } /* reconstruct freq tree */ @@ -305,10 +305,10 @@ namespace Aaru.Compression short j = 0; for(i = 0; i < T; i++) - if(son[i] >= T) + if(_son[i] >= T) { - freq[j] = (ushort)((freq[i] + 1) / 2); - son[j] = son[i]; + _freq[j] = (ushort)((_freq[i] + 1) / 2); + _son[j] = _son[i]; j++; } @@ -316,75 +316,75 @@ namespace Aaru.Compression for(i = 0, j = N_CHAR; j < T; i += 2, j++) { k = (short)(i + 1); - ushort f = freq[j] = (ushort)(freq[i] + freq[k]); + ushort f = _freq[j] = (ushort)(_freq[i] + _freq[k]); - for(k = (short)(j - 1); f < freq[k]; k--) {} + for(k = (short)(j - 1); f < _freq[k]; k--) {} k++; ushort l = (ushort)((j - k) * 2); - Array.ConstrainedCopy(freq, k, freq, k + 1, l); - freq[k] = f; - Array.ConstrainedCopy(son, k, son, k + 1, l); - son[k] = i; + Array.ConstrainedCopy(_freq, k, _freq, k + 1, l); + _freq[k] = f; + Array.ConstrainedCopy(_son, k, _son, k + 1, l); + _son[k] = i; } /* connect parent nodes */ for(i = 0; i < T; i++) - if((k = son[i]) >= T) - prnt[k] = i; + if((k = _son[i]) >= T) + _prnt[k] = i; else - prnt[k] = prnt[k + 1] = i; + _prnt[k] = _prnt[k + 1] = i; } /* update freq tree */ void Update(int c) { - if(freq[ROOT] == MAX_FREQ) + if(_freq[ROOT] == MAX_FREQ) Reconst(); - c = prnt[c + T]; + c = _prnt[c + T]; do { - int k = ++freq[c]; + int k = ++_freq[c]; /* swap nodes to keep the tree freq-ordered */ int l; - if(k <= freq[l = c + 1]) + if(k <= _freq[l = c + 1]) continue; - while(k > freq[++l]) {} + while(k > _freq[++l]) {} l--; - freq[c] = freq[l]; - freq[l] = (ushort)k; + _freq[c] = _freq[l]; + _freq[l] = (ushort)k; - int i = son[c]; - prnt[i] = (short)l; + int i = _son[c]; + _prnt[i] = (short)l; if(i < T) - prnt[i + 1] = (short)l; + _prnt[i + 1] = (short)l; - int j = son[l]; - son[l] = (short)i; + int j = _son[l]; + _son[l] = (short)i; - prnt[j] = (short)c; + _prnt[j] = (short)c; if(j < T) - prnt[j + 1] = (short)c; + _prnt[j + 1] = (short)c; - son[c] = (short)j; + _son[c] = (short)j; c = l; - } while((c = prnt[c]) != 0); /* do it until reaching the root */ + } while((c = _prnt[c]) != 0); /* do it until reaching the root */ } short DecodeChar() { - ushort c = (ushort)son[ROOT]; + ushort c = (ushort)_son[ROOT]; /* * start searching tree from the root to leaves. @@ -399,7 +399,7 @@ namespace Aaru.Compression return -1; c += (ushort)ret; - c = (ushort)son[c]; + c = (ushort)_son[c]; } c -= T; @@ -417,8 +417,8 @@ namespace Aaru.Compression return -1; ushort i = (ushort)bit; - ushort c = (ushort)(d_code[i] << 6); - ushort j = d_len[i]; + ushort c = (ushort)(_dCode[i] << 6); + ushort j = _dLen[i]; /* input lower 6 bits directly */ j -= 2; diff --git a/Aaru.Core/Checksum.cs b/Aaru.Core/Checksum.cs index 2bc4c15f7..89ea07ed6 100644 --- a/Aaru.Core/Checksum.cs +++ b/Aaru.Core/Checksum.cs @@ -53,304 +53,304 @@ namespace Aaru.Core /// Checksums and hashes data, with different algorithms multithreaded public class Checksum { - readonly IChecksum adler32Ctx; - readonly IChecksum crc16Ctx; - readonly IChecksum crc32Ctx; - readonly IChecksum crc64Ctx; - readonly EnableChecksum enabled; - readonly IChecksum f16Ctx; - readonly IChecksum f32Ctx; - readonly IChecksum md5Ctx; - readonly IChecksum sha1Ctx; - readonly IChecksum sha256Ctx; - readonly IChecksum sha384Ctx; - readonly IChecksum sha512Ctx; - readonly IChecksum ssctx; - HashPacket adlerPkt; - Thread adlerThread; - HashPacket crc16Pkt; - Thread crc16Thread; - HashPacket crc32Pkt; - Thread crc32Thread; - HashPacket crc64Pkt; - Thread crc64Thread; - HashPacket f16Pkt; - Thread f16Thread; - HashPacket f32Pkt; - Thread f32Thread; - HashPacket md5Pkt; - Thread md5Thread; - HashPacket sha1Pkt; - Thread sha1Thread; - HashPacket sha256Pkt; - Thread sha256Thread; - HashPacket sha384Pkt; - Thread sha384Thread; - HashPacket sha512Pkt; - Thread sha512Thread; - HashPacket spamsumPkt; - Thread spamsumThread; + readonly IChecksum _adler32Ctx; + readonly IChecksum _crc16Ctx; + readonly IChecksum _crc32Ctx; + readonly IChecksum _crc64Ctx; + readonly EnableChecksum _enabled; + readonly IChecksum _f16Ctx; + readonly IChecksum _f32Ctx; + readonly IChecksum _md5Ctx; + readonly IChecksum _sha1Ctx; + readonly IChecksum _sha256Ctx; + readonly IChecksum _sha384Ctx; + readonly IChecksum _sha512Ctx; + readonly IChecksum _ssCtx; + HashPacket _adlerPkt; + Thread _adlerThread; + HashPacket _crc16Pkt; + Thread _crc16Thread; + HashPacket _crc32Pkt; + Thread _crc32Thread; + HashPacket _crc64Pkt; + Thread _crc64Thread; + HashPacket _f16Pkt; + Thread _f16Thread; + HashPacket _f32Pkt; + Thread _f32Thread; + HashPacket _md5Pkt; + Thread _md5Thread; + HashPacket _sha1Pkt; + Thread _sha1Thread; + HashPacket _sha256Pkt; + Thread _sha256Thread; + HashPacket _sha384Pkt; + Thread _sha384Thread; + HashPacket _sha512Pkt; + Thread _sha512Thread; + HashPacket _spamsumPkt; + Thread _spamsumThread; public Checksum(EnableChecksum enabled = EnableChecksum.All) { - this.enabled = enabled; + _enabled = enabled; if(enabled.HasFlag(EnableChecksum.Adler32)) { - adler32Ctx = new Adler32Context(); + _adler32Ctx = new Adler32Context(); - adlerPkt = new HashPacket + _adlerPkt = new HashPacket { - Context = adler32Ctx + Context = _adler32Ctx }; } if(enabled.HasFlag(EnableChecksum.Crc16)) { - crc16Ctx = new CRC16IBMContext(); + _crc16Ctx = new CRC16IBMContext(); - crc16Pkt = new HashPacket + _crc16Pkt = new HashPacket { - Context = crc16Ctx + Context = _crc16Ctx }; } if(enabled.HasFlag(EnableChecksum.Crc32)) { - crc32Ctx = new Crc32Context(); + _crc32Ctx = new Crc32Context(); - crc32Pkt = new HashPacket + _crc32Pkt = new HashPacket { - Context = crc32Ctx + Context = _crc32Ctx }; } if(enabled.HasFlag(EnableChecksum.Crc64)) { - crc64Ctx = new Crc64Context(); + _crc64Ctx = new Crc64Context(); - crc64Pkt = new HashPacket + _crc64Pkt = new HashPacket { - Context = crc64Ctx + Context = _crc64Ctx }; } if(enabled.HasFlag(EnableChecksum.Md5)) { - md5Ctx = new Md5Context(); + _md5Ctx = new Md5Context(); - md5Pkt = new HashPacket + _md5Pkt = new HashPacket { - Context = md5Ctx + Context = _md5Ctx }; } if(enabled.HasFlag(EnableChecksum.Sha1)) { - sha1Ctx = new Sha1Context(); + _sha1Ctx = new Sha1Context(); - sha1Pkt = new HashPacket + _sha1Pkt = new HashPacket { - Context = sha1Ctx + Context = _sha1Ctx }; } if(enabled.HasFlag(EnableChecksum.Sha256)) { - sha256Ctx = new Sha256Context(); + _sha256Ctx = new Sha256Context(); - sha256Pkt = new HashPacket + _sha256Pkt = new HashPacket { - Context = sha256Ctx + Context = _sha256Ctx }; } if(enabled.HasFlag(EnableChecksum.Sha384)) { - sha384Ctx = new Sha384Context(); + _sha384Ctx = new Sha384Context(); - sha384Pkt = new HashPacket + _sha384Pkt = new HashPacket { - Context = sha384Ctx + Context = _sha384Ctx }; } if(enabled.HasFlag(EnableChecksum.Sha512)) { - sha512Ctx = new Sha512Context(); + _sha512Ctx = new Sha512Context(); - sha512Pkt = new HashPacket + _sha512Pkt = new HashPacket { - Context = sha512Ctx + Context = _sha512Ctx }; } if(enabled.HasFlag(EnableChecksum.SpamSum)) { - ssctx = new SpamSumContext(); + _ssCtx = new SpamSumContext(); - spamsumPkt = new HashPacket + _spamsumPkt = new HashPacket { - Context = ssctx + Context = _ssCtx }; } if(enabled.HasFlag(EnableChecksum.Fletcher16)) { - f16Ctx = new Fletcher16Context(); + _f16Ctx = new Fletcher16Context(); - f16Pkt = new HashPacket + _f16Pkt = new HashPacket { - Context = f16Ctx + Context = _f16Ctx }; } if(enabled.HasFlag(EnableChecksum.Fletcher32)) { - f32Ctx = new Fletcher32Context(); + _f32Ctx = new Fletcher32Context(); - f32Pkt = new HashPacket + _f32Pkt = new HashPacket { - Context = f32Ctx + Context = _f32Ctx }; } - adlerThread = new Thread(UpdateHash); - crc16Thread = new Thread(UpdateHash); - crc32Thread = new Thread(UpdateHash); - crc64Thread = new Thread(UpdateHash); - md5Thread = new Thread(UpdateHash); - sha1Thread = new Thread(UpdateHash); - sha256Thread = new Thread(UpdateHash); - sha384Thread = new Thread(UpdateHash); - sha512Thread = new Thread(UpdateHash); - spamsumThread = new Thread(UpdateHash); - f16Thread = new Thread(UpdateHash); - f32Thread = new Thread(UpdateHash); + _adlerThread = new Thread(UpdateHash); + _crc16Thread = new Thread(UpdateHash); + _crc32Thread = new Thread(UpdateHash); + _crc64Thread = new Thread(UpdateHash); + _md5Thread = new Thread(UpdateHash); + _sha1Thread = new Thread(UpdateHash); + _sha256Thread = new Thread(UpdateHash); + _sha384Thread = new Thread(UpdateHash); + _sha512Thread = new Thread(UpdateHash); + _spamsumThread = new Thread(UpdateHash); + _f16Thread = new Thread(UpdateHash); + _f32Thread = new Thread(UpdateHash); } public void Update(byte[] data) { - if(enabled.HasFlag(EnableChecksum.Adler32)) + if(_enabled.HasFlag(EnableChecksum.Adler32)) { - adlerPkt.Data = data; - adlerThread.Start(adlerPkt); + _adlerPkt.Data = data; + _adlerThread.Start(_adlerPkt); } - if(enabled.HasFlag(EnableChecksum.Crc16)) + if(_enabled.HasFlag(EnableChecksum.Crc16)) { - crc16Pkt.Data = data; - crc16Thread.Start(crc16Pkt); + _crc16Pkt.Data = data; + _crc16Thread.Start(_crc16Pkt); } - if(enabled.HasFlag(EnableChecksum.Crc32)) + if(_enabled.HasFlag(EnableChecksum.Crc32)) { - crc32Pkt.Data = data; - crc32Thread.Start(crc32Pkt); + _crc32Pkt.Data = data; + _crc32Thread.Start(_crc32Pkt); } - if(enabled.HasFlag(EnableChecksum.Crc64)) + if(_enabled.HasFlag(EnableChecksum.Crc64)) { - crc64Pkt.Data = data; - crc64Thread.Start(crc64Pkt); + _crc64Pkt.Data = data; + _crc64Thread.Start(_crc64Pkt); } - if(enabled.HasFlag(EnableChecksum.Md5)) + if(_enabled.HasFlag(EnableChecksum.Md5)) { - md5Pkt.Data = data; - md5Thread.Start(md5Pkt); + _md5Pkt.Data = data; + _md5Thread.Start(_md5Pkt); } - if(enabled.HasFlag(EnableChecksum.Sha1)) + if(_enabled.HasFlag(EnableChecksum.Sha1)) { - sha1Pkt.Data = data; - sha1Thread.Start(sha1Pkt); + _sha1Pkt.Data = data; + _sha1Thread.Start(_sha1Pkt); } - if(enabled.HasFlag(EnableChecksum.Sha256)) + if(_enabled.HasFlag(EnableChecksum.Sha256)) { - sha256Pkt.Data = data; - sha256Thread.Start(sha256Pkt); + _sha256Pkt.Data = data; + _sha256Thread.Start(_sha256Pkt); } - if(enabled.HasFlag(EnableChecksum.Sha384)) + if(_enabled.HasFlag(EnableChecksum.Sha384)) { - sha384Pkt.Data = data; - sha384Thread.Start(sha384Pkt); + _sha384Pkt.Data = data; + _sha384Thread.Start(_sha384Pkt); } - if(enabled.HasFlag(EnableChecksum.Sha512)) + if(_enabled.HasFlag(EnableChecksum.Sha512)) { - sha512Pkt.Data = data; - sha512Thread.Start(sha512Pkt); + _sha512Pkt.Data = data; + _sha512Thread.Start(_sha512Pkt); } - if(enabled.HasFlag(EnableChecksum.SpamSum)) + if(_enabled.HasFlag(EnableChecksum.SpamSum)) { - spamsumPkt.Data = data; - spamsumThread.Start(spamsumPkt); + _spamsumPkt.Data = data; + _spamsumThread.Start(_spamsumPkt); } - if(enabled.HasFlag(EnableChecksum.Fletcher16)) + if(_enabled.HasFlag(EnableChecksum.Fletcher16)) { - f16Pkt.Data = data; - f16Thread.Start(f16Pkt); + _f16Pkt.Data = data; + _f16Thread.Start(_f16Pkt); } - if(enabled.HasFlag(EnableChecksum.Fletcher32)) + if(_enabled.HasFlag(EnableChecksum.Fletcher32)) { - f32Pkt.Data = data; - f32Thread.Start(f32Pkt); + _f32Pkt.Data = data; + _f32Thread.Start(_f32Pkt); } - while(adlerThread.IsAlive || - crc16Thread.IsAlive || - crc32Thread.IsAlive || - crc64Thread.IsAlive || - md5Thread.IsAlive || - sha1Thread.IsAlive || - sha256Thread.IsAlive || - sha384Thread.IsAlive || - sha512Thread.IsAlive || - spamsumThread.IsAlive || - f16Thread.IsAlive || - f32Thread.IsAlive) {} + while(_adlerThread.IsAlive || + _crc16Thread.IsAlive || + _crc32Thread.IsAlive || + _crc64Thread.IsAlive || + _md5Thread.IsAlive || + _sha1Thread.IsAlive || + _sha256Thread.IsAlive || + _sha384Thread.IsAlive || + _sha512Thread.IsAlive || + _spamsumThread.IsAlive || + _f16Thread.IsAlive || + _f32Thread.IsAlive) {} - if(enabled.HasFlag(EnableChecksum.Adler32)) - adlerThread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Adler32)) + _adlerThread = new Thread(UpdateHash); - if(enabled.HasFlag(EnableChecksum.Crc16)) - crc16Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Crc16)) + _crc16Thread = new Thread(UpdateHash); - if(enabled.HasFlag(EnableChecksum.Crc32)) - crc32Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Crc32)) + _crc32Thread = new Thread(UpdateHash); - if(enabled.HasFlag(EnableChecksum.Crc16)) - crc64Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Crc16)) + _crc64Thread = new Thread(UpdateHash); - if(enabled.HasFlag(EnableChecksum.Md5)) - md5Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Md5)) + _md5Thread = new Thread(UpdateHash); - if(enabled.HasFlag(EnableChecksum.Sha1)) - sha1Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Sha1)) + _sha1Thread = new Thread(UpdateHash); - if(enabled.HasFlag(EnableChecksum.Sha256)) - sha256Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Sha256)) + _sha256Thread = new Thread(UpdateHash); - if(enabled.HasFlag(EnableChecksum.Sha384)) - sha384Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Sha384)) + _sha384Thread = new Thread(UpdateHash); - if(enabled.HasFlag(EnableChecksum.Sha512)) - sha512Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Sha512)) + _sha512Thread = new Thread(UpdateHash); - if(enabled.HasFlag(EnableChecksum.SpamSum)) - spamsumThread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.SpamSum)) + _spamsumThread = new Thread(UpdateHash); - if(enabled.HasFlag(EnableChecksum.Fletcher16)) - f16Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Fletcher16)) + _f16Thread = new Thread(UpdateHash); - if(enabled.HasFlag(EnableChecksum.Fletcher32)) - f32Thread = new Thread(UpdateHash); + if(_enabled.HasFlag(EnableChecksum.Fletcher32)) + _f32Thread = new Thread(UpdateHash); } public List End() @@ -359,134 +359,134 @@ namespace Aaru.Core ChecksumType chk; - if(enabled.HasFlag(EnableChecksum.All)) + if(_enabled.HasFlag(EnableChecksum.All)) { chk = new ChecksumType { type = ChecksumTypeType.adler32, - Value = adler32Ctx.End() + Value = _adler32Ctx.End() }; chks.Add(chk); } - if(enabled.HasFlag(EnableChecksum.Crc16)) + if(_enabled.HasFlag(EnableChecksum.Crc16)) { chk = new ChecksumType { type = ChecksumTypeType.crc16, - Value = crc16Ctx.End() + Value = _crc16Ctx.End() }; chks.Add(chk); } - if(enabled.HasFlag(EnableChecksum.Crc32)) + if(_enabled.HasFlag(EnableChecksum.Crc32)) { chk = new ChecksumType { type = ChecksumTypeType.crc32, - Value = crc32Ctx.End() + Value = _crc32Ctx.End() }; chks.Add(chk); } - if(enabled.HasFlag(EnableChecksum.Crc64)) + if(_enabled.HasFlag(EnableChecksum.Crc64)) { chk = new ChecksumType { type = ChecksumTypeType.crc64, - Value = crc64Ctx.End() + Value = _crc64Ctx.End() }; chks.Add(chk); } - if(enabled.HasFlag(EnableChecksum.Md5)) + if(_enabled.HasFlag(EnableChecksum.Md5)) { chk = new ChecksumType { type = ChecksumTypeType.md5, - Value = md5Ctx.End() + Value = _md5Ctx.End() }; chks.Add(chk); } - if(enabled.HasFlag(EnableChecksum.Sha1)) + if(_enabled.HasFlag(EnableChecksum.Sha1)) { chk = new ChecksumType { type = ChecksumTypeType.sha1, - Value = sha1Ctx.End() + Value = _sha1Ctx.End() }; chks.Add(chk); } - if(enabled.HasFlag(EnableChecksum.Sha256)) + if(_enabled.HasFlag(EnableChecksum.Sha256)) { chk = new ChecksumType { type = ChecksumTypeType.sha256, - Value = sha256Ctx.End() + Value = _sha256Ctx.End() }; chks.Add(chk); } - if(enabled.HasFlag(EnableChecksum.Sha384)) + if(_enabled.HasFlag(EnableChecksum.Sha384)) { chk = new ChecksumType { type = ChecksumTypeType.sha384, - Value = sha384Ctx.End() + Value = _sha384Ctx.End() }; chks.Add(chk); } - if(enabled.HasFlag(EnableChecksum.Sha512)) + if(_enabled.HasFlag(EnableChecksum.Sha512)) { chk = new ChecksumType { type = ChecksumTypeType.sha512, - Value = sha512Ctx.End() + Value = _sha512Ctx.End() }; chks.Add(chk); } - if(enabled.HasFlag(EnableChecksum.SpamSum)) + if(_enabled.HasFlag(EnableChecksum.SpamSum)) { chk = new ChecksumType { type = ChecksumTypeType.spamsum, - Value = ssctx.End() + Value = _ssCtx.End() }; chks.Add(chk); } - if(enabled.HasFlag(EnableChecksum.Fletcher16)) + if(_enabled.HasFlag(EnableChecksum.Fletcher16)) { chk = new ChecksumType { type = ChecksumTypeType.fletcher16, - Value = f16Ctx.End() + Value = _f16Ctx.End() }; chks.Add(chk); } - if(!enabled.HasFlag(EnableChecksum.Fletcher32)) + if(!_enabled.HasFlag(EnableChecksum.Fletcher32)) return chks; chk = new ChecksumType { type = ChecksumTypeType.fletcher32, - Value = f32Ctx.End() + Value = _f32Ctx.End() }; chks.Add(chk); diff --git a/Aaru.Core/DataFile.cs b/Aaru.Core/DataFile.cs index 382797129..60763367b 100644 --- a/Aaru.Core/DataFile.cs +++ b/Aaru.Core/DataFile.cs @@ -40,40 +40,40 @@ namespace Aaru.Core [SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global")] public class DataFile { - readonly FileStream dataFs; + readonly FileStream _dataFs; /// Opens, or create, a new file /// File public DataFile(string outputFile) => - dataFs = new FileStream(outputFile, FileMode.OpenOrCreate, FileAccess.ReadWrite); + _dataFs = new FileStream(outputFile, FileMode.OpenOrCreate, FileAccess.ReadWrite); /// Closes the file - public void Close() => dataFs?.Close(); + public void Close() => _dataFs?.Close(); /// Reads bytes at current position /// Array to place read data within /// Offset of where data will be read /// How many bytes to read /// How many bytes were read - public int Read(byte[] array, int offset, int count) => dataFs.Read(array, offset, count); + public int Read(byte[] array, int offset, int count) => _dataFs.Read(array, offset, count); /// Seeks to the specified block /// Block to seek to /// Block size in bytes /// Position - public long Seek(ulong block, ulong blockSize) => dataFs.Seek((long)(block * blockSize), SeekOrigin.Begin); + public long Seek(ulong block, ulong blockSize) => _dataFs.Seek((long)(block * blockSize), SeekOrigin.Begin); /// Seeks to specified byte position /// Byte position /// Where to count for position /// Position - public long Seek(ulong offset, SeekOrigin origin) => dataFs.Seek((long)offset, origin); + public long Seek(ulong offset, SeekOrigin origin) => _dataFs.Seek((long)offset, origin); /// Seeks to specified byte position /// Byte position /// Where to count for position /// Position - public long Seek(long offset, SeekOrigin origin) => dataFs.Seek(offset, origin); + public long Seek(long offset, SeekOrigin origin) => _dataFs.Seek(offset, origin); /// Writes data at current position /// Data @@ -83,7 +83,7 @@ namespace Aaru.Core /// Data /// Offset of data from where to start taking data to write /// How many bytes to write - public void Write(byte[] data, int offset, int count) => dataFs.Write(data, offset, count); + public void Write(byte[] data, int offset, int count) => _dataFs.Write(data, offset, count); /// Writes data at specified block /// Data @@ -100,12 +100,12 @@ namespace Aaru.Core /// How many bytes to write public void WriteAt(byte[] data, ulong block, uint blockSize, int offset, int count) { - dataFs.Seek((long)(block * blockSize), SeekOrigin.Begin); - dataFs.Write(data, offset, count); + _dataFs.Seek((long)(block * blockSize), SeekOrigin.Begin); + _dataFs.Write(data, offset, count); } /// Current file position - public long Position => dataFs.Position; + public long Position => _dataFs.Position; /// Writes data to a newly created file /// Who asked the file to be written (class, plugin, etc.) diff --git a/Aaru.Core/Devices/Dumping/ATA.cs b/Aaru.Core/Devices/Dumping/ATA.cs index 0110d5515..84769e92b 100644 --- a/Aaru.Core/Devices/Dumping/ATA.cs +++ b/Aaru.Core/Devices/Dumping/ATA.cs @@ -68,8 +68,8 @@ namespace Aaru.Core.Devices.Dumping } } - const ushort ATA_PROFILE = 0x0001; - const uint TIMEOUT = 5; + const ushort ataProfile = 0x0001; + const uint timeout = 5; double imageWriteDuration = 0; MediaType mediaType = MediaType.Unknown; @@ -99,7 +99,7 @@ namespace Aaru.Core.Devices.Dumping // Initializate reader UpdateStatus?.Invoke("Initializing reader."); _dumpLog.WriteLine("Initializing reader."); - var ataReader = new Reader(_dev, TIMEOUT, ataIdentify, _errorLog); + var ataReader = new Reader(_dev, timeout, ataIdentify, _errorLog); // Fill reader blocks ulong blocks = ataReader.GetDeviceBlocks(); @@ -248,7 +248,7 @@ namespace Aaru.Core.Devices.Dumping mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private); - ibgLog = new IbgLog(_outputPrefix + ".ibg", ATA_PROFILE); + ibgLog = new IbgLog(_outputPrefix + ".ibg", ataProfile); if(_resume.NextBlock > 0) { @@ -469,7 +469,7 @@ namespace Aaru.Core.Devices.Dumping mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private); - ibgLog = new IbgLog(_outputPrefix + ".ibg", ATA_PROFILE); + ibgLog = new IbgLog(_outputPrefix + ".ibg", ataProfile); ulong currentBlock = 0; blocks = (ulong)(cylinders * heads * sectors); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs index d7bff321a..64b7ef395 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs @@ -179,7 +179,7 @@ namespace Aaru.Core.Devices.Dumping int trackRetries = 0; // First track of each session has at least 150 sectors of pregap and is not always readable - if(tracks.Where(t => t.TrackSession == track.TrackSession).OrderBy(t => t.TrackSequence). + if(tracks.Where(trk => trk.TrackSession == track.TrackSession).OrderBy(trk => trk.TrackSequence). FirstOrDefault().TrackSequence == track.TrackSequence) { AaruConsole.DebugWriteLine("Pregap calculator", "Skipping track {0}", track.TrackSequence); @@ -203,7 +203,7 @@ namespace Aaru.Core.Devices.Dumping int lba = (int)track.TrackStartSector - 1; bool pregapFound = false; - Track previousTrack = tracks.FirstOrDefault(t => t.TrackSequence == track.TrackSequence - 1); + Track previousTrack = tracks.FirstOrDefault(trk => trk.TrackSequence == track.TrackSequence - 1); bool goneBack = false; bool goFront = false; diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs index dedc44238..5a9282e2c 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs @@ -54,8 +54,8 @@ namespace Aaru.Core.Devices.Dumping { void DumpMs() { - const ushort SBC_PROFILE = 0x0001; - const uint BLOCK_SIZE = 512; + const ushort sbcProfile = 0x0001; + const uint blockSize = 512; double totalDuration = 0; double currentSpeed = 0; double maxSpeed = double.MinValue; @@ -81,23 +81,23 @@ namespace Aaru.Core.Devices.Dumping blocks++; - ulong totalSize = blocks * (ulong)BLOCK_SIZE; + ulong totalSize = blocks * (ulong)blockSize; if(totalSize > 1099511627776) UpdateStatus?. - Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)"); + Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)"); else if(totalSize > 1073741824) UpdateStatus?. - Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)"); + Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)"); else if(totalSize > 1048576) UpdateStatus?. - Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1048576d:F3} MiB)"); + Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1048576d:F3} MiB)"); else if(totalSize > 1024) UpdateStatus?. - Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1024d:F3} KiB)"); + Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1024d:F3} KiB)"); else UpdateStatus?. - Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize} bytes)"); + Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize} bytes)"); if(blocks == 0) { @@ -107,9 +107,9 @@ namespace Aaru.Core.Devices.Dumping return; } - UpdateStatus?.Invoke($"Device reports {blocks} blocks ({blocks * BLOCK_SIZE} bytes)."); + UpdateStatus?.Invoke($"Device reports {blocks} blocks ({blocks * blockSize} bytes)."); UpdateStatus?.Invoke($"Device can read {blocksToRead} blocks at a time."); - UpdateStatus?.Invoke($"Device reports {BLOCK_SIZE} bytes per logical block."); + UpdateStatus?.Invoke($"Device reports {blockSize} bytes per logical block."); UpdateStatus?.Invoke($"SCSI device type: {_dev.ScsiType}."); if(blocks > 262144) @@ -127,9 +127,9 @@ namespace Aaru.Core.Devices.Dumping bool ret; - var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, BLOCK_SIZE, blocksToRead, _private); - var ibgLog = new IbgLog(_outputPrefix + ".ibg", SBC_PROFILE); - ret = _outputPlugin.Create(_outputPath, dskType, _formatOptions, blocks, BLOCK_SIZE); + var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private); + var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile); + ret = _outputPlugin.Create(_outputPath, dskType, _formatOptions, blocks, blockSize); // Cannot create image if(!ret) @@ -196,7 +196,7 @@ namespace Aaru.Core.Devices.Dumping UpdateProgress?.Invoke($"Reading sector {i} of {blocks} ({currentSpeed:F3} MiB/sec.)", (long)i, blocks); - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)i, BLOCK_SIZE, 0, + sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0, blocksToRead, false, _dev.Timeout, out double cmdDuration); totalDuration += cmdDuration; @@ -224,7 +224,7 @@ namespace Aaru.Core.Devices.Dumping // Write empty data DateTime writeStart = DateTime.Now; - _outputPlugin.WriteSectors(new byte[BLOCK_SIZE * _skip], i, _skip); + _outputPlugin.WriteSectors(new byte[blockSize * _skip], i, _skip); imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; for(ulong b = i; b < i + _skip; b++) @@ -246,7 +246,7 @@ namespace Aaru.Core.Devices.Dumping if(elapsed < 1) continue; - currentSpeed = (sectorSpeedStart * BLOCK_SIZE) / (1048576 * elapsed); + currentSpeed = (sectorSpeedStart * blockSize) / (1048576 * elapsed); sectorSpeedStart = 0; timeSpeedStart = DateTime.UtcNow; } @@ -255,24 +255,24 @@ namespace Aaru.Core.Devices.Dumping EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, BLOCK_SIZE, (end - start).TotalSeconds, currentSpeed * 1024, - (BLOCK_SIZE * (double)(blocks + 1)) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, + (blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000), _devicePath); UpdateStatus?.Invoke($"Dump finished in {(end - start).TotalSeconds} seconds."); UpdateStatus?. - Invoke($"Average dump speed {((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / (totalDuration / 1000):F3} KiB/sec."); + Invoke($"Average dump speed {((double)blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000):F3} KiB/sec."); UpdateStatus?. - Invoke($"Average write speed {((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / imageWriteDuration:F3} KiB/sec."); + Invoke($"Average write speed {((double)blockSize * (double)(blocks + 1)) / 1024 / imageWriteDuration:F3} KiB/sec."); _dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); _dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", - ((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / (totalDuration / 1000)); + ((double)blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000)); _dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.", - ((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / imageWriteDuration); + ((double)blockSize * (double)(blocks + 1)) / 1024 / imageWriteDuration); #region Trimming if(_resume.BadBlocks.Count > 0 && @@ -301,7 +301,7 @@ namespace Aaru.Core.Devices.Dumping PulseProgress?.Invoke($"Trimming sector {badSector}"); sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)badSector, - BLOCK_SIZE, 0, 1, false, _dev.Timeout, out double _); + blockSize, 0, 1, false, _dev.Timeout, out double _); if(sense || _dev.Error) { @@ -458,7 +458,7 @@ namespace Aaru.Core.Devices.Dumping runningPersistent ? "recovering partial data, " : "")); sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)badSector, - BLOCK_SIZE, 0, 1, false, _dev.Timeout, out double cmdDuration); + blockSize, 0, 1, false, _dev.Timeout, out double cmdDuration); totalDuration += cmdDuration; @@ -585,12 +585,12 @@ namespace Aaru.Core.Devices.Dumping UpdateStatus?.Invoke($"Sidecar created in {(end - chkStart).TotalSeconds} seconds."); UpdateStatus?. - Invoke($"Average checksum speed {((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / (totalChkDuration / 1000):F3} KiB/sec."); + Invoke($"Average checksum speed {((double)blockSize * (double)(blocks + 1)) / 1024 / (totalChkDuration / 1000):F3} KiB/sec."); _dumpLog.WriteLine("Sidecar created in {0} seconds.", (end - chkStart).TotalSeconds); _dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", - ((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / (totalChkDuration / 1000)); + ((double)blockSize * (double)(blocks + 1)) / 1024 / (totalChkDuration / 1000)); if(_preSidecar != null) { @@ -622,15 +622,15 @@ namespace Aaru.Core.Devices.Dumping sidecar.BlockMedia[0].DiskSubType = xmlType.subType; sidecar.BlockMedia[0].Interface = "USB"; sidecar.BlockMedia[0].LogicalBlocks = blocks; - sidecar.BlockMedia[0].PhysicalBlockSize = (int)BLOCK_SIZE; - sidecar.BlockMedia[0].LogicalBlockSize = (int)BLOCK_SIZE; + sidecar.BlockMedia[0].PhysicalBlockSize = (int)blockSize; + sidecar.BlockMedia[0].LogicalBlockSize = (int)blockSize; sidecar.BlockMedia[0].Manufacturer = _dev.Manufacturer; sidecar.BlockMedia[0].Model = _dev.Model; if(!_private) sidecar.BlockMedia[0].Serial = _dev.Serial; - sidecar.BlockMedia[0].Size = blocks * BLOCK_SIZE; + sidecar.BlockMedia[0].Size = blocks * blockSize; if(_dev.IsRemovable) sidecar.BlockMedia[0].DumpHardwareArray = _resume.Tries.ToArray(); @@ -650,7 +650,7 @@ namespace Aaru.Core.Devices.Dumping Invoke($"Took a total of {(end - start).TotalSeconds:F3} seconds ({totalDuration / 1000:F3} processing commands, {totalChkDuration / 1000:F3} checksumming, {imageWriteDuration:F3} writing, {(closeEnd - closeStart).TotalSeconds:F3} closing)."); UpdateStatus?. - Invoke($"Average speed: {((double)BLOCK_SIZE * (double)(blocks + 1)) / 1048576 / (totalDuration / 1000):F3} MiB/sec."); + Invoke($"Average speed: {((double)blockSize * (double)(blocks + 1)) / 1048576 / (totalDuration / 1000):F3} MiB/sec."); if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs index 971508250..5ba8433bd 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs @@ -42,11 +42,11 @@ namespace Aaru.Core.Devices.Dumping { public partial class Dump { - static readonly byte[] FatSignature = + static readonly byte[] _fatSignature = { 0x46, 0x41, 0x54, 0x31, 0x36, 0x20, 0x20, 0x20 }; - static readonly byte[] IsoExtension = + static readonly byte[] _isoExtension = { 0x49, 0x53, 0x4F }; @@ -114,7 +114,7 @@ namespace Aaru.Core.Devices.Dumping Array.Copy(buffer, 0x36, tmp, 0, 8); // UMDs are stored inside a FAT16 volume - if(!tmp.SequenceEqual(FatSignature)) + if(!tmp.SequenceEqual(_fatSignature)) { DumpMs(); @@ -142,7 +142,7 @@ namespace Aaru.Core.Devices.Dumping tmp = new byte[3]; Array.Copy(buffer, 0x28, tmp, 0, 3); - if(!tmp.SequenceEqual(IsoExtension)) + if(!tmp.SequenceEqual(_isoExtension)) { DumpMs(); diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs index 7b75d2899..d07fa3ece 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs @@ -52,8 +52,8 @@ namespace Aaru.Core.Devices.Dumping { void DumpUmd() { - const uint BLOCK_SIZE = 2048; - const MediaType DSK_TYPE = MediaType.UMD; + const uint blockSize = 2048; + const MediaType dskType = MediaType.UMD; uint blocksToRead = 16; double totalDuration = 0; double currentSpeed = 0; @@ -95,47 +95,47 @@ namespace Aaru.Core.Devices.Dumping } uint umdSizeInBytes = BitConverter.ToUInt32(readBuffer, 0x3C); - ulong blocks = umdSizeInBytes / BLOCK_SIZE; + ulong blocks = umdSizeInBytes / blockSize; string mediaPartNumber = Encoding.ASCII.GetString(readBuffer, 0, 11).Trim(); - ulong totalSize = blocks * BLOCK_SIZE; + ulong totalSize = blocks * blockSize; if(totalSize > 1099511627776) UpdateStatus?. - Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)"); + Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)"); else if(totalSize > 1073741824) UpdateStatus?. - Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)"); + Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)"); else if(totalSize > 1048576) UpdateStatus?. - Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1048576d:F3} MiB)"); + Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1048576d:F3} MiB)"); else if(totalSize > 1024) UpdateStatus?. - Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize / 1024d:F3} KiB)"); + Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize / 1024d:F3} KiB)"); else UpdateStatus?. - Invoke($"Media has {blocks} blocks of {BLOCK_SIZE} bytes/each. (for a total of {totalSize} bytes)"); + Invoke($"Media has {blocks} blocks of {blockSize} bytes/each. (for a total of {totalSize} bytes)"); - UpdateStatus?.Invoke($"Device reports {blocks} blocks ({blocks * BLOCK_SIZE} bytes)."); + UpdateStatus?.Invoke($"Device reports {blocks} blocks ({blocks * blockSize} bytes)."); UpdateStatus?.Invoke($"Device can read {blocksToRead} blocks at a time."); - UpdateStatus?.Invoke($"Device reports {BLOCK_SIZE} bytes per logical block."); + UpdateStatus?.Invoke($"Device reports {blockSize} bytes per logical block."); UpdateStatus?.Invoke($"Device reports {2048} bytes per physical block."); UpdateStatus?.Invoke($"SCSI device type: {_dev.ScsiType}."); - UpdateStatus?.Invoke($"Media identified as {DSK_TYPE}."); + UpdateStatus?.Invoke($"Media identified as {dskType}."); UpdateStatus?.Invoke($"Media part number is {mediaPartNumber}."); - _dumpLog.WriteLine("Device reports {0} blocks ({1} bytes).", blocks, blocks * BLOCK_SIZE); + _dumpLog.WriteLine("Device reports {0} blocks ({1} bytes).", blocks, blocks * blockSize); _dumpLog.WriteLine("Device can read {0} blocks at a time.", blocksToRead); - _dumpLog.WriteLine("Device reports {0} bytes per logical block.", BLOCK_SIZE); + _dumpLog.WriteLine("Device reports {0} bytes per logical block.", blockSize); _dumpLog.WriteLine("Device reports {0} bytes per physical block.", 2048); _dumpLog.WriteLine("SCSI device type: {0}.", _dev.ScsiType); - _dumpLog.WriteLine("Media identified as {0}.", DSK_TYPE); + _dumpLog.WriteLine("Media identified as {0}.", dskType); _dumpLog.WriteLine("Media part number is {0}.", mediaPartNumber); bool ret; - var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, BLOCK_SIZE, blocksToRead, _private); + var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private); var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0010); - ret = _outputPlugin.Create(_outputPath, DSK_TYPE, _formatOptions, blocks, BLOCK_SIZE); + ret = _outputPlugin.Create(_outputPath, dskType, _formatOptions, blocks, blockSize); // Cannot create image if(!ret) @@ -156,10 +156,10 @@ namespace Aaru.Core.Devices.Dumping { new Track { - TrackBytesPerSector = (int)BLOCK_SIZE, + TrackBytesPerSector = (int)blockSize, TrackEndSector = blocks - 1, TrackSequence = 1, - TrackRawBytesPerSector = (int)BLOCK_SIZE, + TrackRawBytesPerSector = (int)blockSize, TrackSubchannelType = TrackSubchannelType.None, TrackSession = 1, TrackType = TrackType.Data @@ -246,7 +246,7 @@ namespace Aaru.Core.Devices.Dumping // Write empty data DateTime writeStart = DateTime.Now; - _outputPlugin.WriteSectors(new byte[BLOCK_SIZE * _skip], i, _skip); + _outputPlugin.WriteSectors(new byte[blockSize * _skip], i, _skip); imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; for(ulong b = i; b < i + _skip; b++) @@ -268,7 +268,7 @@ namespace Aaru.Core.Devices.Dumping if(elapsed < 1) continue; - currentSpeed = (sectorSpeedStart * BLOCK_SIZE) / (1048576 * elapsed); + currentSpeed = (sectorSpeedStart * blockSize) / (1048576 * elapsed); sectorSpeedStart = 0; timeSpeedStart = DateTime.UtcNow; } @@ -277,24 +277,24 @@ namespace Aaru.Core.Devices.Dumping EndProgress?.Invoke(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, BLOCK_SIZE, (end - start).TotalSeconds, currentSpeed * 1024, - (BLOCK_SIZE * (double)(blocks + 1)) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, + (blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000), _devicePath); UpdateStatus?.Invoke($"Dump finished in {(end - start).TotalSeconds} seconds."); UpdateStatus?. - Invoke($"Average dump speed {((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / (totalDuration / 1000):F3} KiB/sec."); + Invoke($"Average dump speed {((double)blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000):F3} KiB/sec."); UpdateStatus?. - Invoke($"Average write speed {((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / imageWriteDuration:F3} KiB/sec."); + Invoke($"Average write speed {((double)blockSize * (double)(blocks + 1)) / 1024 / imageWriteDuration:F3} KiB/sec."); _dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); _dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", - ((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / (totalDuration / 1000)); + ((double)blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000)); _dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.", - ((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / imageWriteDuration); + ((double)blockSize * (double)(blocks + 1)) / 1024 / imageWriteDuration); #region Trimming if(_resume.BadBlocks.Count > 0 && @@ -562,7 +562,7 @@ namespace Aaru.Core.Devices.Dumping double totalChkDuration = 0; if(_metadata) - WriteOpticalSidecar(BLOCK_SIZE, blocks, DSK_TYPE, null, null, 1, out totalChkDuration, null); + WriteOpticalSidecar(blockSize, blocks, dskType, null, null, 1, out totalChkDuration, null); UpdateStatus?.Invoke(""); @@ -570,7 +570,7 @@ namespace Aaru.Core.Devices.Dumping Invoke($"Took a total of {(end - start).TotalSeconds:F3} seconds ({totalDuration / 1000:F3} processing commands, {totalChkDuration / 1000:F3} checksumming, {imageWriteDuration:F3} writing, {(closeEnd - closeStart).TotalSeconds:F3} closing)."); UpdateStatus?. - Invoke($"Average speed: {((double)BLOCK_SIZE * (double)(blocks + 1)) / 1048576 / (totalDuration / 1000):F3} MiB/sec."); + Invoke($"Average speed: {((double)blockSize * (double)(blocks + 1)) / 1048576 / (totalDuration / 1000):F3} MiB/sec."); if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); @@ -582,7 +582,7 @@ namespace Aaru.Core.Devices.Dumping UpdateStatus?.Invoke($"{_resume.BadBlocks.Count} sectors could not be read."); UpdateStatus?.Invoke(""); - Statistics.AddMedia(DSK_TYPE, true); + Statistics.AddMedia(dskType, true); } } } \ No newline at end of file diff --git a/Aaru.Core/Devices/Dumping/SBC.cs b/Aaru.Core/Devices/Dumping/SBC.cs index 8e39b248d..943d59645 100644 --- a/Aaru.Core/Devices/Dumping/SBC.cs +++ b/Aaru.Core/Devices/Dumping/SBC.cs @@ -69,7 +69,7 @@ namespace Aaru.Core.Devices.Dumping byte scsiMediumType = 0; byte scsiDensityCode = 0; bool containsFloppyPage = false; - const ushort SBC_PROFILE = 0x0001; + const ushort sbcProfile = 0x0001; DateTime start; DateTime end; double totalDuration = 0; @@ -338,7 +338,7 @@ namespace Aaru.Core.Devices.Dumping _dumpLog.WriteLine("Reading {0} sectors at a time.", blocksToRead); var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private); - var ibgLog = new IbgLog(_outputPrefix + ".ibg", SBC_PROFILE); + var ibgLog = new IbgLog(_outputPrefix + ".ibg", sbcProfile); ret = _outputPlugin.Create(_outputPath, dskType, _formatOptions, blocks, blockSize); // Cannot create image diff --git a/Aaru.Core/Devices/Dumping/SecureDigital.cs b/Aaru.Core/Devices/Dumping/SecureDigital.cs index 6a1309ced..e5c00d010 100644 --- a/Aaru.Core/Devices/Dumping/SecureDigital.cs +++ b/Aaru.Core/Devices/Dumping/SecureDigital.cs @@ -69,8 +69,8 @@ namespace Aaru.Core.Devices.Dumping } bool sense; - const ushort SD_PROFILE = 0x0001; - const uint TIMEOUT = 5; + const ushort sdProfile = 0x0001; + const uint timeout = 5; double duration; uint blocksToRead = 1; @@ -92,7 +92,7 @@ namespace Aaru.Core.Devices.Dumping { UpdateStatus?.Invoke("Reading Extended CSD"); _dumpLog.WriteLine("Reading Extended CSD"); - sense = _dev.ReadExtendedCsd(out ecsd, out response, TIMEOUT, out duration); + sense = _dev.ReadExtendedCsd(out ecsd, out response, timeout, out duration); if(!sense) { @@ -118,7 +118,7 @@ namespace Aaru.Core.Devices.Dumping UpdateStatus?.Invoke("Reading CSD"); _dumpLog.WriteLine("Reading CSD"); - sense = _dev.ReadCsd(out csd, out response, TIMEOUT, out duration); + sense = _dev.ReadCsd(out csd, out response, timeout, out duration); if(!sense) { @@ -139,7 +139,7 @@ namespace Aaru.Core.Devices.Dumping UpdateStatus?.Invoke("Reading OCR"); _dumpLog.WriteLine("Reading OCR"); - sense = _dev.ReadOcr(out ocr, out response, TIMEOUT, out duration); + sense = _dev.ReadOcr(out ocr, out response, timeout, out duration); if(sense) { @@ -156,7 +156,7 @@ namespace Aaru.Core.Devices.Dumping { UpdateStatus?.Invoke("Reading CSD"); _dumpLog.WriteLine("Reading CSD"); - sense = _dev.ReadCsd(out csd, out response, TIMEOUT, out duration); + sense = _dev.ReadCsd(out csd, out response, timeout, out duration); if(!sense) { @@ -180,7 +180,7 @@ namespace Aaru.Core.Devices.Dumping UpdateStatus?.Invoke("Reading OCR"); _dumpLog.WriteLine("Reading OCR"); - sense = _dev.ReadSdocr(out ocr, out response, TIMEOUT, out duration); + sense = _dev.ReadSdocr(out ocr, out response, timeout, out duration); if(sense) { @@ -192,7 +192,7 @@ namespace Aaru.Core.Devices.Dumping UpdateStatus?.Invoke("Reading SCR"); _dumpLog.WriteLine("Reading SCR"); - sense = _dev.ReadScr(out scr, out response, TIMEOUT, out duration); + sense = _dev.ReadScr(out scr, out response, timeout, out duration); if(sense) { @@ -208,7 +208,7 @@ namespace Aaru.Core.Devices.Dumping UpdateStatus?.Invoke("Reading CID"); _dumpLog.WriteLine("Reading CID"); - sense = _dev.ReadCid(out byte[] cid, out response, TIMEOUT, out duration); + sense = _dev.ReadCid(out byte[] cid, out response, timeout, out duration); if(sense) { @@ -241,7 +241,7 @@ namespace Aaru.Core.Devices.Dumping while(true) { - error = _dev.Read(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, TIMEOUT, out duration); + error = _dev.Read(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, timeout, out duration); if(error) blocksToRead /= 2; @@ -308,7 +308,7 @@ namespace Aaru.Core.Devices.Dumping } var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private); - var ibgLog = new IbgLog(_outputPrefix + ".ibg", SD_PROFILE); + var ibgLog = new IbgLog(_outputPrefix + ".ibg", sdProfile); ret = _outputPlugin.Create(_outputPath, _dev.Type == DeviceType.SecureDigital ? MediaType.SecureDigital : MediaType.MMC, @@ -367,7 +367,7 @@ namespace Aaru.Core.Devices.Dumping UpdateProgress?.Invoke($"Reading sector {i} of {blocks} ({currentSpeed:F3} MiB/sec.)", (long)i, (long)blocks); - error = _dev.Read(out cmdBuf, out response, (uint)i, blockSize, blocksToRead, byteAddressed, TIMEOUT, + error = _dev.Read(out cmdBuf, out response, (uint)i, blockSize, blocksToRead, byteAddressed, timeout, out duration); if(!error) @@ -462,7 +462,7 @@ namespace Aaru.Core.Devices.Dumping PulseProgress?.Invoke($"Trimming sector {badSector}"); - error = _dev.Read(out cmdBuf, out response, (uint)badSector, blockSize, 1, byteAddressed, TIMEOUT, + error = _dev.Read(out cmdBuf, out response, (uint)badSector, blockSize, 1, byteAddressed, timeout, out duration); totalDuration += duration; @@ -514,7 +514,7 @@ namespace Aaru.Core.Devices.Dumping forward ? "forward" : "reverse", runningPersistent ? "recovering partial data, " : "")); - error = _dev.Read(out cmdBuf, out response, (uint)badSector, blockSize, 1, byteAddressed, TIMEOUT, + error = _dev.Read(out cmdBuf, out response, (uint)badSector, blockSize, 1, byteAddressed, timeout, out duration); totalDuration += duration; diff --git a/Aaru.Core/Devices/Dumping/XGD.cs b/Aaru.Core/Devices/Dumping/XGD.cs index 813b8f4b6..a23486d18 100644 --- a/Aaru.Core/Devices/Dumping/XGD.cs +++ b/Aaru.Core/Devices/Dumping/XGD.cs @@ -62,7 +62,7 @@ namespace Aaru.Core.Devices.Dumping internal void Xgd(Dictionary mediaTags, MediaType dskType) { bool sense; - const uint BLOCK_SIZE = 2048; + const uint blockSize = 2048; uint blocksToRead = 64; DateTime start; DateTime end; @@ -371,7 +371,7 @@ namespace Aaru.Core.Devices.Dumping _dumpLog.WriteLine("Total 0 size: {0} sectors", totalSize); _dumpLog.WriteLine("Real layer break: {0}", layerBreak); - bool read12 = !_dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, BLOCK_SIZE, 0, 1, + bool read12 = !_dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, 0, blockSize, 0, 1, false, _dev.Timeout, out _); if(!read12) @@ -404,7 +404,7 @@ namespace Aaru.Core.Devices.Dumping { if(read12) { - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, 0, BLOCK_SIZE, 0, + sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, 0, blockSize, 0, blocksToRead, false, _dev.Timeout, out _); if(sense || _dev.Error) @@ -458,9 +458,9 @@ namespace Aaru.Core.Devices.Dumping _dumpLog.WriteLine("Reading {0} sectors at a time.", blocksToRead); UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time."); - var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, BLOCK_SIZE, blocksToRead, _private); + var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, blocksToRead, _private); var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0010); - ret = _outputPlugin.Create(_outputPath, dskType, _formatOptions, blocks, BLOCK_SIZE); + ret = _outputPlugin.Create(_outputPath, dskType, _formatOptions, blocks, blockSize); // Cannot create image if(!ret) @@ -493,10 +493,10 @@ namespace Aaru.Core.Devices.Dumping { new Track { - TrackBytesPerSector = (int)BLOCK_SIZE, + TrackBytesPerSector = (int)blockSize, TrackEndSector = blocks - 1, TrackSequence = 1, - TrackRawBytesPerSector = (int)BLOCK_SIZE, + TrackRawBytesPerSector = (int)blockSize, TrackSubchannelType = TrackSubchannelType.None, TrackSession = 1, TrackType = TrackType.Data @@ -591,8 +591,8 @@ namespace Aaru.Core.Devices.Dumping UpdateProgress?.Invoke($"Reading sector {i} of {totalSize} ({currentSpeed:F3} MiB/sec.)", (long)i, (long)totalSize); - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)i, - BLOCK_SIZE, 0, blocksToRead, false, _dev.Timeout, out cmdDuration); + sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)i, blockSize, + 0, blocksToRead, false, _dev.Timeout, out cmdDuration); totalDuration += cmdDuration; @@ -619,7 +619,7 @@ namespace Aaru.Core.Devices.Dumping // Write empty data DateTime writeStart = DateTime.Now; - _outputPlugin.WriteSectors(new byte[BLOCK_SIZE * _skip], i, _skip); + _outputPlugin.WriteSectors(new byte[blockSize * _skip], i, _skip); imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; for(ulong b = i; b < i + _skip; b++) @@ -654,7 +654,7 @@ namespace Aaru.Core.Devices.Dumping if(elapsed < 1) continue; - currentSpeed = (sectorSpeedStart * BLOCK_SIZE) / (1048576 * elapsed); + currentSpeed = (sectorSpeedStart * blockSize) / (1048576 * elapsed); sectorSpeedStart = 0; timeSpeedStart = DateTime.UtcNow; } @@ -680,7 +680,7 @@ namespace Aaru.Core.Devices.Dumping // Write empty data DateTime writeStart = DateTime.Now; - _outputPlugin.WriteSectors(new byte[BLOCK_SIZE * blocksToRead], i, blocksToRead); + _outputPlugin.WriteSectors(new byte[blockSize * blocksToRead], i, blocksToRead); imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; blocksToRead = saveBlocksToRead; extents.Add(i, blocksToRead, true); @@ -722,8 +722,8 @@ namespace Aaru.Core.Devices.Dumping // Write empty data DateTime writeStart = DateTime.Now; - _outputPlugin.WriteSectors(new byte[BLOCK_SIZE * blocksToRead], middle + currentSector, blocksToRead); - imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; + _outputPlugin.WriteSectors(new byte[blockSize * blocksToRead], middle + currentSector, blocksToRead); + imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; extents.Add(currentSector, blocksToRead, true); currentSector += blocksToRead; @@ -787,8 +787,8 @@ namespace Aaru.Core.Devices.Dumping UpdateProgress?.Invoke($"Reading sector {currentSector} of {totalSize} ({currentSpeed:F3} MiB/sec.)", (long)currentSector, (long)totalSize); - sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)l1, BLOCK_SIZE, - 0, blocksToRead, false, _dev.Timeout, out cmdDuration); + sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)l1, blockSize, 0, + blocksToRead, false, _dev.Timeout, out cmdDuration); totalDuration += cmdDuration; @@ -812,7 +812,7 @@ namespace Aaru.Core.Devices.Dumping // Write empty data DateTime writeStart = DateTime.Now; - _outputPlugin.WriteSectors(new byte[BLOCK_SIZE * _skip], currentSector, _skip); + _outputPlugin.WriteSectors(new byte[blockSize * _skip], currentSector, _skip); imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; // TODO: Handle errors in video partition @@ -843,7 +843,7 @@ namespace Aaru.Core.Devices.Dumping if(elapsed < 1) continue; - currentSpeed = (sectorSpeedStart * BLOCK_SIZE) / (1048576 * elapsed); + currentSpeed = (sectorSpeedStart * blockSize) / (1048576 * elapsed); sectorSpeedStart = 0; timeSpeedStart = DateTime.UtcNow; } @@ -876,24 +876,24 @@ namespace Aaru.Core.Devices.Dumping AaruConsole.WriteLine(); mhddLog.Close(); - ibgLog.Close(_dev, blocks, BLOCK_SIZE, (end - start).TotalSeconds, currentSpeed * 1024, - (BLOCK_SIZE * (double)(blocks + 1)) / 1024 / (totalDuration / 1000), _devicePath); + ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, + (blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000), _devicePath); UpdateStatus?.Invoke($"Dump finished in {(end - start).TotalSeconds} seconds."); UpdateStatus?. - Invoke($"Average dump speed {((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / (totalDuration / 1000):F3} KiB/sec."); + Invoke($"Average dump speed {((double)blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000):F3} KiB/sec."); UpdateStatus?. - Invoke($"Average write speed {((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / imageWriteDuration:F3} KiB/sec."); + Invoke($"Average write speed {((double)blockSize * (double)(blocks + 1)) / 1024 / imageWriteDuration:F3} KiB/sec."); _dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); _dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", - ((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / (totalDuration / 1000)); + ((double)blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000)); _dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.", - ((double)BLOCK_SIZE * (double)(blocks + 1)) / 1024 / imageWriteDuration); + ((double)blockSize * (double)(blocks + 1)) / 1024 / imageWriteDuration); #region Trimming if(_resume.BadBlocks.Count > 0 && @@ -921,7 +921,7 @@ namespace Aaru.Core.Devices.Dumping PulseProgress?.Invoke($"Trimming sector {badSector}"); sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)badSector, - BLOCK_SIZE, 0, 1, false, _dev.Timeout, out cmdDuration); + blockSize, 0, 1, false, _dev.Timeout, out cmdDuration); totalDuration += cmdDuration; @@ -1084,7 +1084,7 @@ namespace Aaru.Core.Devices.Dumping runningPersistent ? "recovering partial data, " : "")); sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)badSector, - BLOCK_SIZE, 0, 1, false, _dev.Timeout, out cmdDuration); + blockSize, 0, 1, false, _dev.Timeout, out cmdDuration); totalDuration += cmdDuration; @@ -1224,7 +1224,7 @@ namespace Aaru.Core.Devices.Dumping Value = layerBreak }; - WriteOpticalSidecar(BLOCK_SIZE, blocks, dskType, layers, mediaTags, 1, out totalChkDuration, null); + WriteOpticalSidecar(blockSize, blocks, dskType, layers, mediaTags, 1, out totalChkDuration, null); } UpdateStatus?.Invoke(""); @@ -1233,7 +1233,7 @@ namespace Aaru.Core.Devices.Dumping Invoke($"Took a total of {(end - start).TotalSeconds:F3} seconds ({totalDuration / 1000:F3} processing commands, {totalChkDuration / 1000:F3} checksumming, {imageWriteDuration:F3} writing, {(closeEnd - closeStart).TotalSeconds:F3} closing)."); UpdateStatus?. - Invoke($"Average speed: {((double)BLOCK_SIZE * (double)(blocks + 1)) / 1048576 / (totalDuration / 1000):F3} MiB/sec."); + Invoke($"Average speed: {((double)blockSize * (double)(blocks + 1)) / 1048576 / (totalDuration / 1000):F3} MiB/sec."); if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); diff --git a/Aaru.Core/Devices/Scanning/ATA.cs b/Aaru.Core/Devices/Scanning/ATA.cs index 0fdcba477..82c7f96c5 100644 --- a/Aaru.Core/Devices/Scanning/ATA.cs +++ b/Aaru.Core/Devices/Scanning/ATA.cs @@ -47,8 +47,8 @@ namespace Aaru.Core.Devices.Scanning var results = new ScanResults(); bool sense; results.Blocks = 0; - const ushort ATA_PROFILE = 0x0001; - const uint TIMEOUT = 5; + const ushort ataProfile = 0x0001; + const uint timeout = 5; sense = _dev.AtaIdentify(out byte[] cmdBuf, out _); @@ -56,7 +56,7 @@ namespace Aaru.Core.Devices.Scanning Identify.Decode(cmdBuf).HasValue) { // Initializate reader - var ataReader = new Reader(_dev, TIMEOUT, cmdBuf, null); + var ataReader = new Reader(_dev, timeout, cmdBuf, null); // Fill reader blocks results.Blocks = ataReader.GetDeviceBlocks(); @@ -122,9 +122,9 @@ namespace Aaru.Core.Devices.Scanning { UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time."); - InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, ATA_PROFILE); + InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, ataProfile); mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, blocksToRead, false); - ibgLog = new IbgLog(_ibgLogPath, ATA_PROFILE); + ibgLog = new IbgLog(_ibgLogPath, ataProfile); start = DateTime.UtcNow; DateTime timeSpeedStart = DateTime.UtcNow; @@ -239,9 +239,9 @@ namespace Aaru.Core.Devices.Scanning } else { - InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, ATA_PROFILE); + InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, ataProfile); mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, blocksToRead, false); - ibgLog = new IbgLog(_ibgLogPath, ATA_PROFILE); + ibgLog = new IbgLog(_ibgLogPath, ataProfile); ulong currentBlock = 0; results.Blocks = (ulong)(cylinders * heads * sectors); diff --git a/Aaru.Core/Devices/Scanning/SecureDigital.cs b/Aaru.Core/Devices/Scanning/SecureDigital.cs index 583aaa333..851d8b169 100644 --- a/Aaru.Core/Devices/Scanning/SecureDigital.cs +++ b/Aaru.Core/Devices/Scanning/SecureDigital.cs @@ -47,9 +47,9 @@ namespace Aaru.Core.Devices.Scanning byte[] cmdBuf; bool sense; results.Blocks = 0; - const uint TIMEOUT = 5; + const uint timeout = 5; double duration; - const ushort SD_PROFILE = 0x0001; + const ushort sdProfile = 0x0001; uint blocksToRead = 128; uint blockSize = 512; bool byteAddressed = true; @@ -58,7 +58,7 @@ namespace Aaru.Core.Devices.Scanning { case DeviceType.MMC: { - sense = _dev.ReadExtendedCsd(out cmdBuf, out _, TIMEOUT, out _); + sense = _dev.ReadExtendedCsd(out cmdBuf, out _, timeout, out _); if(!sense) { @@ -73,7 +73,7 @@ namespace Aaru.Core.Devices.Scanning if(sense || results.Blocks == 0) { - sense = _dev.ReadCsd(out cmdBuf, out _, TIMEOUT, out _); + sense = _dev.ReadCsd(out cmdBuf, out _, timeout, out _); if(!sense) { @@ -88,7 +88,7 @@ namespace Aaru.Core.Devices.Scanning case DeviceType.SecureDigital: { - sense = _dev.ReadCsd(out cmdBuf, out _, TIMEOUT, out _); + sense = _dev.ReadCsd(out cmdBuf, out _, timeout, out _); if(!sense) { @@ -117,7 +117,7 @@ namespace Aaru.Core.Devices.Scanning while(true) { - sense = _dev.Read(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, TIMEOUT, out duration); + sense = _dev.Read(out cmdBuf, out _, 0, blockSize, blocksToRead, byteAddressed, timeout, out duration); if(sense) blocksToRead /= 2; @@ -157,9 +157,9 @@ namespace Aaru.Core.Devices.Scanning UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time."); - InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, SD_PROFILE); + InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, sdProfile); var mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, blocksToRead, false); - var ibgLog = new IbgLog(_ibgLogPath, SD_PROFILE); + var ibgLog = new IbgLog(_ibgLogPath, sdProfile); start = DateTime.UtcNow; DateTime timeSpeedStart = DateTime.UtcNow; @@ -187,7 +187,7 @@ namespace Aaru.Core.Devices.Scanning UpdateProgress?.Invoke($"Reading sector {i} of {results.Blocks} ({currentSpeed:F3} MiB/sec.)", (long)i, (long)results.Blocks); - bool error = _dev.Read(out cmdBuf, out _, (uint)i, blockSize, blocksToRead, byteAddressed, TIMEOUT, + bool error = _dev.Read(out cmdBuf, out _, (uint)i, blockSize, blocksToRead, byteAddressed, timeout, out duration); if(!error) @@ -254,7 +254,7 @@ namespace Aaru.Core.Devices.Scanning PulseProgress?.Invoke($"Seeking to sector {seekPos}...\t\t"); - _dev.Read(out cmdBuf, out _, seekPos, blockSize, blocksToRead, byteAddressed, TIMEOUT, + _dev.Read(out cmdBuf, out _, seekPos, blockSize, blocksToRead, byteAddressed, timeout, out double seekCur); #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator diff --git a/Aaru.Core/Entropy.cs b/Aaru.Core/Entropy.cs index 666d8ff8d..7e2b76304 100644 --- a/Aaru.Core/Entropy.cs +++ b/Aaru.Core/Entropy.cs @@ -42,13 +42,13 @@ namespace Aaru.Core { public class Entropy { - readonly bool debug; - readonly IMediaImage inputFormat; + readonly bool _debug; + readonly IMediaImage _inputFormat; public Entropy(bool debug, IMediaImage inputFormat) { - this.debug = debug; - this.inputFormat = inputFormat; + _debug = debug; + _inputFormat = inputFormat; } public event InitProgressHandler InitProgressEvent; @@ -62,7 +62,7 @@ namespace Aaru.Core { List entropyResultses = new List(); - if(!(inputFormat is IOpticalMediaImage opticalMediaImage)) + if(!(_inputFormat is IOpticalMediaImage opticalMediaImage)) { AaruConsole.ErrorWriteLine("The selected image does not support tracks."); @@ -134,7 +134,7 @@ namespace Aaru.Core } catch(Exception ex) { - if(debug) + if(_debug) AaruConsole.DebugWriteLine("Could not get tracks because {0}", ex.Message); else AaruConsole.ErrorWriteLine("Unable to get separate tracks, not calculating their entropy"); @@ -154,14 +154,14 @@ namespace Aaru.Core ulong diskSize = 0; List uniqueSectors = new List(); - entropy.Sectors = inputFormat.Info.Sectors; + entropy.Sectors = _inputFormat.Info.Sectors; AaruConsole.WriteLine("Sectors {0}", entropy.Sectors); InitProgressEvent?.Invoke(); for(ulong i = 0; i < entropy.Sectors; i++) { UpdateProgressEvent?.Invoke($"Entropying sector {i + 1}", (long)(i + 1), (long)entropy.Sectors); - byte[] sector = inputFormat.ReadSector(i); + byte[] sector = _inputFormat.ReadSector(i); if(duplicatedSectors) { diff --git a/Aaru.Core/Logging/DumpLog.cs b/Aaru.Core/Logging/DumpLog.cs index b5ab0c79d..0a1a91010 100644 --- a/Aaru.Core/Logging/DumpLog.cs +++ b/Aaru.Core/Logging/DumpLog.cs @@ -44,7 +44,7 @@ namespace Aaru.Core.Logging /// Creates a dump log public class DumpLog { - readonly StreamWriter logSw; + readonly StreamWriter _logSw; /// Initializes the dump log /// Output log file @@ -55,9 +55,9 @@ namespace Aaru.Core.Logging if(string.IsNullOrEmpty(outputFile)) return; - logSw = new StreamWriter(outputFile, true); + _logSw = new StreamWriter(outputFile, true); - logSw.WriteLine("Start logging at {0}", DateTime.Now); + _logSw.WriteLine("Start logging at {0}", DateTime.Now); PlatformID platId = DetectOS.GetRealPlatformID(); string platVer = DetectOS.GetVersion(); @@ -66,25 +66,25 @@ namespace Aaru.Core.Logging Attribute.GetCustomAttribute(typeof(DumpLog).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; - logSw.WriteLine("################# System information #################"); + _logSw.WriteLine("################# System information #################"); - logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer, - Environment.Is64BitOperatingSystem ? 64 : 32); + _logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer, + Environment.Is64BitOperatingSystem ? 64 : 32); if(DetectOS.IsMono) - logSw.WriteLine("Mono {0}", Version.GetMonoVersion()); + _logSw.WriteLine("Mono {0}", Version.GetMonoVersion()); else if(DetectOS.IsNetCore) - logSw.WriteLine(".NET Core {0}", Version.GetNetCoreVersion()); + _logSw.WriteLine(".NET Core {0}", Version.GetNetCoreVersion()); else - logSw.WriteLine(RuntimeInformation.FrameworkDescription); + _logSw.WriteLine(RuntimeInformation.FrameworkDescription); - logSw.WriteLine(); + _logSw.WriteLine(); - logSw.WriteLine("################# Program information ################"); - logSw.WriteLine("Aaru {0}", assemblyVersion?.InformationalVersion); - logSw.WriteLine("Running in {0}-bit", Environment.Is64BitProcess ? 64 : 32); + _logSw.WriteLine("################# Program information ################"); + _logSw.WriteLine("Aaru {0}", assemblyVersion?.InformationalVersion); + _logSw.WriteLine("Running in {0}-bit", Environment.Is64BitProcess ? 64 : 32); #if DEBUG - logSw.WriteLine("DEBUG version"); + _logSw.WriteLine("DEBUG version"); #endif if(@private) { @@ -106,72 +106,72 @@ namespace Aaru.Core.Logging } } - logSw.WriteLine("Command line: {0}", string.Join(" ", args)); + _logSw.WriteLine("Command line: {0}", string.Join(" ", args)); } else - logSw.WriteLine("Command line: {0}", Environment.CommandLine); + _logSw.WriteLine("Command line: {0}", Environment.CommandLine); - logSw.WriteLine(); + _logSw.WriteLine(); if(dev.IsRemote) { - logSw.WriteLine("################# Remote information #################"); - logSw.WriteLine("Server: {0}", dev.RemoteApplication); - logSw.WriteLine("Version: {0}", dev.RemoteVersion); + _logSw.WriteLine("################# Remote information #################"); + _logSw.WriteLine("Server: {0}", dev.RemoteApplication); + _logSw.WriteLine("Version: {0}", dev.RemoteVersion); - logSw.WriteLine("Operating system: {0} {1}", dev.RemoteOperatingSystem, - dev.RemoteOperatingSystemVersion); + _logSw.WriteLine("Operating system: {0} {1}", dev.RemoteOperatingSystem, + dev.RemoteOperatingSystemVersion); - logSw.WriteLine("Architecture: {0}", dev.RemoteArchitecture); - logSw.WriteLine("Protocol version: {0}", dev.RemoteProtocolVersion); - logSw.WriteLine("######################################################"); + _logSw.WriteLine("Architecture: {0}", dev.RemoteArchitecture); + _logSw.WriteLine("Protocol version: {0}", dev.RemoteProtocolVersion); + _logSw.WriteLine("######################################################"); } - logSw.WriteLine("################# Device information #################"); - logSw.WriteLine("Manufacturer: {0}", dev.Manufacturer); - logSw.WriteLine("Model: {0}", dev.Model); - logSw.WriteLine("Firmware revision: {0}", dev.FirmwareRevision); + _logSw.WriteLine("################# Device information #################"); + _logSw.WriteLine("Manufacturer: {0}", dev.Manufacturer); + _logSw.WriteLine("Model: {0}", dev.Model); + _logSw.WriteLine("Firmware revision: {0}", dev.FirmwareRevision); if(!@private) - logSw.WriteLine("Serial number: {0}", dev.Serial); + _logSw.WriteLine("Serial number: {0}", dev.Serial); - logSw.WriteLine("Removable device: {0}", dev.IsRemovable); - logSw.WriteLine("Device type: {0}", dev.Type); - logSw.WriteLine("CompactFlash device: {0}", dev.IsCompactFlash); - logSw.WriteLine("PCMCIA device: {0}", dev.IsPcmcia); - logSw.WriteLine("USB device: {0}", dev.IsUsb); + _logSw.WriteLine("Removable device: {0}", dev.IsRemovable); + _logSw.WriteLine("Device type: {0}", dev.Type); + _logSw.WriteLine("CompactFlash device: {0}", dev.IsCompactFlash); + _logSw.WriteLine("PCMCIA device: {0}", dev.IsPcmcia); + _logSw.WriteLine("USB device: {0}", dev.IsUsb); if(dev.IsUsb) { - logSw.WriteLine("USB manufacturer: {0}", dev.UsbManufacturerString); - logSw.WriteLine("USB product: {0}", dev.UsbProductString); + _logSw.WriteLine("USB manufacturer: {0}", dev.UsbManufacturerString); + _logSw.WriteLine("USB product: {0}", dev.UsbProductString); if(!@private) - logSw.WriteLine("USB serial: {0}", dev.UsbSerialString); + _logSw.WriteLine("USB serial: {0}", dev.UsbSerialString); - logSw.WriteLine("USB vendor ID: {0:X4}h", dev.UsbVendorId); - logSw.WriteLine("USB product ID: {0:X4}h", dev.UsbProductId); + _logSw.WriteLine("USB vendor ID: {0:X4}h", dev.UsbVendorId); + _logSw.WriteLine("USB product ID: {0:X4}h", dev.UsbProductId); } - logSw.WriteLine("FireWire device: {0}", dev.IsFireWire); + _logSw.WriteLine("FireWire device: {0}", dev.IsFireWire); if(dev.IsFireWire) { - logSw.WriteLine("FireWire vendor: {0}", dev.FireWireVendorName); - logSw.WriteLine("FireWire model: {0}", dev.FireWireModelName); + _logSw.WriteLine("FireWire vendor: {0}", dev.FireWireVendorName); + _logSw.WriteLine("FireWire model: {0}", dev.FireWireModelName); if(!@private) - logSw.WriteLine("FireWire GUID: 0x{0:X16}", dev.FireWireGuid); + _logSw.WriteLine("FireWire GUID: 0x{0:X16}", dev.FireWireGuid); - logSw.WriteLine("FireWire vendor ID: 0x{0:X8}", dev.FireWireVendor); - logSw.WriteLine("FireWire product ID: 0x{0:X8}", dev.FireWireModel); + _logSw.WriteLine("FireWire vendor ID: 0x{0:X8}", dev.FireWireVendor); + _logSw.WriteLine("FireWire product ID: 0x{0:X8}", dev.FireWireModel); } - logSw.WriteLine("######################################################"); + _logSw.WriteLine("######################################################"); - logSw.WriteLine(); - logSw.WriteLine("################ Dumping progress log ################"); - logSw.Flush(); + _logSw.WriteLine(); + _logSw.WriteLine("################ Dumping progress log ################"); + _logSw.Flush(); } /// Adds a new line to the dump log @@ -179,20 +179,20 @@ namespace Aaru.Core.Logging /// Arguments public void WriteLine(string format, params object[] args) { - if(logSw == null) + if(_logSw == null) return; string text = string.Format(format, args); - logSw.WriteLine("{0:s} {1}", DateTime.Now, text); - logSw.Flush(); + _logSw.WriteLine("{0:s} {1}", DateTime.Now, text); + _logSw.Flush(); } /// Finishes and closes the dump log public void Close() { - logSw?.WriteLine("######################################################"); - logSw?.WriteLine("End logging at {0}", DateTime.Now); - logSw?.Close(); + _logSw?.WriteLine("######################################################"); + _logSw?.WriteLine("End logging at {0}", DateTime.Now); + _logSw?.Close(); } } } \ No newline at end of file diff --git a/Aaru.Core/Logging/IBGLog.cs b/Aaru.Core/Logging/IBGLog.cs index 9b64384c3..6efd7000a 100644 --- a/Aaru.Core/Logging/IBGLog.cs +++ b/Aaru.Core/Logging/IBGLog.cs @@ -41,19 +41,19 @@ namespace Aaru.Core.Logging /// Implements a log in the format used by IMGBurn internal class IbgLog { - readonly CultureInfo ibgCulture; - readonly double ibgDivider; - readonly string ibgMediaType; - readonly StringBuilder ibgSb; - readonly string logFile; - DateTime ibgDatePoint; - ulong ibgIntSector; - double ibgIntSpeed; - double ibgMaxSpeed; - int ibgSampleRate; - int ibgSnaps; - bool ibgStartSet; - double ibgStartSpeed; + readonly CultureInfo _ibgCulture; + readonly double _ibgDivider; + readonly string _ibgMediaType; + readonly StringBuilder _ibgSb; + readonly string _logFile; + DateTime _ibgDatePoint; + ulong _ibgIntSector; + double _ibgIntSpeed; + double _ibgMaxSpeed; + int _ibgSampleRate; + int _ibgSnaps; + bool _ibgStartSet; + double _ibgStartSpeed; /// Initializes the IMGBurn log /// Log file @@ -63,169 +63,169 @@ namespace Aaru.Core.Logging if(string.IsNullOrEmpty(outputFile)) return; - logFile = outputFile; - ibgSb = new StringBuilder(); - ibgDatePoint = DateTime.Now; - ibgCulture = new CultureInfo("en-US"); - ibgStartSet = false; - ibgMaxSpeed = 0; - ibgIntSpeed = 0; - ibgSnaps = 0; - ibgIntSector = 0; + _logFile = outputFile; + _ibgSb = new StringBuilder(); + _ibgDatePoint = DateTime.Now; + _ibgCulture = new CultureInfo("en-US"); + _ibgStartSet = false; + _ibgMaxSpeed = 0; + _ibgIntSpeed = 0; + _ibgSnaps = 0; + _ibgIntSector = 0; switch(currentProfile) { case 0x0001: - ibgMediaType = "HDD"; - ibgDivider = 1353; + _ibgMediaType = "HDD"; + _ibgDivider = 1353; break; case 0x0002: - ibgMediaType = "PD-650"; - ibgDivider = 150; + _ibgMediaType = "PD-650"; + _ibgDivider = 150; break; case 0x0005: - ibgMediaType = "CD-MO"; - ibgDivider = 150; + _ibgMediaType = "CD-MO"; + _ibgDivider = 150; break; case 0x0008: - ibgMediaType = "CD-ROM"; - ibgDivider = 150; + _ibgMediaType = "CD-ROM"; + _ibgDivider = 150; break; case 0x0009: - ibgMediaType = "CD-R"; - ibgDivider = 150; + _ibgMediaType = "CD-R"; + _ibgDivider = 150; break; case 0x000A: - ibgMediaType = "CD-RW"; - ibgDivider = 150; + _ibgMediaType = "CD-RW"; + _ibgDivider = 150; break; case 0x0010: - ibgMediaType = "DVD-ROM"; - ibgDivider = 1353; + _ibgMediaType = "DVD-ROM"; + _ibgDivider = 1353; break; case 0x0011: - ibgMediaType = "DVD-R"; - ibgDivider = 1353; + _ibgMediaType = "DVD-R"; + _ibgDivider = 1353; break; case 0x0012: - ibgMediaType = "DVD-RAM"; - ibgDivider = 1353; + _ibgMediaType = "DVD-RAM"; + _ibgDivider = 1353; break; case 0x0013: case 0x0014: - ibgMediaType = "DVD-RW"; - ibgDivider = 1353; + _ibgMediaType = "DVD-RW"; + _ibgDivider = 1353; break; case 0x0015: case 0x0016: - ibgMediaType = "DVD-R DL"; - ibgDivider = 1353; + _ibgMediaType = "DVD-R DL"; + _ibgDivider = 1353; break; case 0x0017: - ibgMediaType = "DVD-RW DL"; - ibgDivider = 1353; + _ibgMediaType = "DVD-RW DL"; + _ibgDivider = 1353; break; case 0x0018: - ibgMediaType = "DVD-Download"; - ibgDivider = 1353; + _ibgMediaType = "DVD-Download"; + _ibgDivider = 1353; break; case 0x001A: - ibgMediaType = "DVD+RW"; - ibgDivider = 1353; + _ibgMediaType = "DVD+RW"; + _ibgDivider = 1353; break; case 0x001B: - ibgMediaType = "DVD+R"; - ibgDivider = 1353; + _ibgMediaType = "DVD+R"; + _ibgDivider = 1353; break; case 0x0020: - ibgMediaType = "DDCD-ROM"; - ibgDivider = 150; + _ibgMediaType = "DDCD-ROM"; + _ibgDivider = 150; break; case 0x0021: - ibgMediaType = "DDCD-R"; - ibgDivider = 150; + _ibgMediaType = "DDCD-R"; + _ibgDivider = 150; break; case 0x0022: - ibgMediaType = "DDCD-RW"; - ibgDivider = 150; + _ibgMediaType = "DDCD-RW"; + _ibgDivider = 150; break; case 0x002A: - ibgMediaType = "DVD+RW DL"; - ibgDivider = 1353; + _ibgMediaType = "DVD+RW DL"; + _ibgDivider = 1353; break; case 0x002B: - ibgMediaType = "DVD+R DL"; - ibgDivider = 1353; + _ibgMediaType = "DVD+R DL"; + _ibgDivider = 1353; break; case 0x0040: - ibgMediaType = "BD-ROM"; - ibgDivider = 4500; + _ibgMediaType = "BD-ROM"; + _ibgDivider = 4500; break; case 0x0041: case 0x0042: - ibgMediaType = "BD-R"; - ibgDivider = 4500; + _ibgMediaType = "BD-R"; + _ibgDivider = 4500; break; case 0x0043: - ibgMediaType = "BD-RE"; - ibgDivider = 4500; + _ibgMediaType = "BD-RE"; + _ibgDivider = 4500; break; case 0x0050: - ibgMediaType = "HD DVD-ROM"; - ibgDivider = 4500; + _ibgMediaType = "HD DVD-ROM"; + _ibgDivider = 4500; break; case 0x0051: - ibgMediaType = "HD DVD-R"; - ibgDivider = 4500; + _ibgMediaType = "HD DVD-R"; + _ibgDivider = 4500; break; case 0x0052: - ibgMediaType = "HD DVD-RAM"; - ibgDivider = 4500; + _ibgMediaType = "HD DVD-RAM"; + _ibgDivider = 4500; break; case 0x0053: - ibgMediaType = "HD DVD-RW"; - ibgDivider = 4500; + _ibgMediaType = "HD DVD-RW"; + _ibgDivider = 4500; break; case 0x0058: - ibgMediaType = "HD DVD-R DL"; - ibgDivider = 4500; + _ibgMediaType = "HD DVD-R DL"; + _ibgDivider = 4500; break; case 0x005A: - ibgMediaType = "HD DVD-RW DL"; - ibgDivider = 4500; + _ibgMediaType = "HD DVD-RW DL"; + _ibgDivider = 4500; break; default: - ibgMediaType = "Unknown"; - ibgDivider = 1353; + _ibgMediaType = "Unknown"; + _ibgDivider = 1353; break; } @@ -236,34 +236,34 @@ namespace Aaru.Core.Logging /// Current speed at the snapshot internal void Write(ulong sector, double currentSpeed) { - if(logFile == null) + if(_logFile == null) return; - ibgIntSpeed += currentSpeed; - ibgSampleRate += (int)Math.Floor((DateTime.Now - ibgDatePoint).TotalMilliseconds); - ibgSnaps++; + _ibgIntSpeed += currentSpeed; + _ibgSampleRate += (int)Math.Floor((DateTime.Now - _ibgDatePoint).TotalMilliseconds); + _ibgSnaps++; - if(ibgSampleRate < 100) + if(_ibgSampleRate < 100) return; - if(ibgIntSpeed > 0 && - !ibgStartSet) + if(_ibgIntSpeed > 0 && + !_ibgStartSet) { - ibgStartSpeed = ibgIntSpeed / ibgSnaps / ibgDivider; - ibgStartSet = true; + _ibgStartSpeed = _ibgIntSpeed / _ibgSnaps / _ibgDivider; + _ibgStartSet = true; } - ibgSb.AppendFormat("{0:0.00},{1},{2:0},0", ibgIntSpeed / ibgSnaps / ibgDivider, ibgIntSector, - ibgSampleRate).AppendLine(); + _ibgSb.AppendFormat("{0:0.00},{1},{2:0},0", _ibgIntSpeed / _ibgSnaps / _ibgDivider, _ibgIntSector, + _ibgSampleRate).AppendLine(); - if(ibgIntSpeed / ibgSnaps / ibgDivider > ibgMaxSpeed) - ibgMaxSpeed = ibgIntSpeed / ibgDivider; + if(_ibgIntSpeed / _ibgSnaps / _ibgDivider > _ibgMaxSpeed) + _ibgMaxSpeed = _ibgIntSpeed / _ibgDivider; - ibgDatePoint = DateTime.Now; - ibgIntSpeed = 0; - ibgSampleRate = 0; - ibgSnaps = 0; - ibgIntSector = sector; + _ibgDatePoint = DateTime.Now; + _ibgIntSpeed = 0; + _ibgSampleRate = 0; + _ibgSnaps = 0; + _ibgIntSector = sector; } /// Closes the IMGBurn log @@ -277,10 +277,10 @@ namespace Aaru.Core.Logging internal void Close(Device dev, ulong blocks, ulong blockSize, double totalSeconds, double currentSpeed, double averageSpeed, string devicePath) { - if(logFile == null) + if(_logFile == null) return; - var ibgFs = new FileStream(logFile, FileMode.Create); + var ibgFs = new FileStream(_logFile, FileMode.Create); var ibgHeader = new StringBuilder(); string ibgBusType; @@ -312,7 +312,7 @@ namespace Aaru.Core.Logging ibgHeader.AppendFormat("DEVICE_BUSTYPE={0}", ibgBusType).AppendLine(); ibgHeader.AppendLine(); - ibgHeader.AppendFormat("MEDIA_TYPE={0}", ibgMediaType).AppendLine(); + ibgHeader.AppendFormat("MEDIA_TYPE={0}", _ibgMediaType).AppendLine(); ibgHeader.AppendLine("MEDIA_BOOKTYPE=Unknown"); ibgHeader.AppendLine("MEDIA_ID=N/A"); ibgHeader.AppendLine("MEDIA_TRACKPATH=PTP"); @@ -325,17 +325,20 @@ namespace Aaru.Core.Logging ibgHeader.AppendFormat("DATA_TYPE=MODE1/{0}", blockSize).AppendLine(); ibgHeader.AppendLine("DATA_VOLUMEIDENTIFIER="); ibgHeader.AppendLine(); - ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_START={0:0.00}", ibgStartSpeed).AppendLine(); - ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_END={0:0.00}", currentSpeed / ibgDivider).AppendLine(); - ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_AVERAGE={0:0.00}", averageSpeed / ibgDivider).AppendLine(); - ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_MAX={0:0.00}", ibgMaxSpeed).AppendLine(); - ibgHeader.AppendFormat(ibgCulture, "VERIFY_TIME_TAKEN={0:0}", Math.Floor(totalSeconds)).AppendLine(); + ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_START={0:0.00}", _ibgStartSpeed).AppendLine(); + ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_END={0:0.00}", currentSpeed / _ibgDivider).AppendLine(); + + ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_AVERAGE={0:0.00}", averageSpeed / _ibgDivider). + AppendLine(); + + ibgHeader.AppendFormat(_ibgCulture, "VERIFY_SPEED_MAX={0:0.00}", _ibgMaxSpeed).AppendLine(); + ibgHeader.AppendFormat(_ibgCulture, "VERIFY_TIME_TAKEN={0:0}", Math.Floor(totalSeconds)).AppendLine(); ibgHeader.AppendLine("[END_CONFIGURATION]"); ibgHeader.AppendLine(); ibgHeader.AppendLine("HRPC=True"); ibgHeader.AppendLine(); ibgHeader.AppendLine("[START_VERIFY_GRAPH_VALUES]"); - ibgHeader.Append(ibgSb); + ibgHeader.Append(_ibgSb); ibgHeader.AppendLine("[END_VERIFY_GRAPH_VALUES]"); ibgHeader.AppendLine(); ibgHeader.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n"); diff --git a/Aaru.Core/Logging/MHDDLog.cs b/Aaru.Core/Logging/MHDDLog.cs index 406b9a5f3..61f55dcea 100644 --- a/Aaru.Core/Logging/MHDDLog.cs +++ b/Aaru.Core/Logging/MHDDLog.cs @@ -42,8 +42,9 @@ namespace Aaru.Core.Logging /// Implements a log in the format used by MHDD internal class MhddLog { - readonly string logFile; - readonly MemoryStream mhddFs; + const string MHDD_VER = "VER:2 "; + readonly string _logFile; + readonly MemoryStream _mhddFs; /// Initializes the MHDD log /// Log file @@ -59,8 +60,8 @@ namespace Aaru.Core.Logging string.IsNullOrEmpty(outputFile)) return; - mhddFs = new MemoryStream(); - logFile = outputFile; + _mhddFs = new MemoryStream(); + _logFile = outputFile; string mode; @@ -102,8 +103,6 @@ namespace Aaru.Core.Logging string scanblocksize = string.Format(new CultureInfo("en-US"), "SCAN BLOCK SIZE: {0:n0} sectors", blocksToRead); - const string MHDD_VER = "VER:2 "; - byte[] deviceBytes = Encoding.ASCII.GetBytes(device); byte[] modeBytes = Encoding.ASCII.GetBytes(mode); byte[] fwBytes = Encoding.ASCII.GetBytes(fw); @@ -122,24 +121,24 @@ namespace Aaru.Core.Logging newLine[0] = 0x0D; newLine[1] = 0x0A; - mhddFs.Write(BitConverter.GetBytes(pointer), 0, 4); - mhddFs.Write(newLine, 0, 2); - mhddFs.Write(verBytes, 0, verBytes.Length); - mhddFs.Write(newLine, 0, 2); - mhddFs.Write(modeBytes, 0, modeBytes.Length); - mhddFs.Write(newLine, 0, 2); - mhddFs.Write(deviceBytes, 0, deviceBytes.Length); - mhddFs.Write(newLine, 0, 2); - mhddFs.Write(fwBytes, 0, fwBytes.Length); - mhddFs.Write(newLine, 0, 2); - mhddFs.Write(snBytes, 0, snBytes.Length); - mhddFs.Write(newLine, 0, 2); - mhddFs.Write(sectorsBytes, 0, sectorsBytes.Length); - mhddFs.Write(newLine, 0, 2); - mhddFs.Write(sectorsizeBytes, 0, sectorsizeBytes.Length); - mhddFs.Write(newLine, 0, 2); - mhddFs.Write(scanblocksizeBytes, 0, scanblocksizeBytes.Length); - mhddFs.Write(newLine, 0, 2); + _mhddFs.Write(BitConverter.GetBytes(pointer), 0, 4); + _mhddFs.Write(newLine, 0, 2); + _mhddFs.Write(verBytes, 0, verBytes.Length); + _mhddFs.Write(newLine, 0, 2); + _mhddFs.Write(modeBytes, 0, modeBytes.Length); + _mhddFs.Write(newLine, 0, 2); + _mhddFs.Write(deviceBytes, 0, deviceBytes.Length); + _mhddFs.Write(newLine, 0, 2); + _mhddFs.Write(fwBytes, 0, fwBytes.Length); + _mhddFs.Write(newLine, 0, 2); + _mhddFs.Write(snBytes, 0, snBytes.Length); + _mhddFs.Write(newLine, 0, 2); + _mhddFs.Write(sectorsBytes, 0, sectorsBytes.Length); + _mhddFs.Write(newLine, 0, 2); + _mhddFs.Write(sectorsizeBytes, 0, sectorsizeBytes.Length); + _mhddFs.Write(newLine, 0, 2); + _mhddFs.Write(scanblocksizeBytes, 0, scanblocksizeBytes.Length); + _mhddFs.Write(newLine, 0, 2); } /// Logs a new read @@ -147,25 +146,25 @@ namespace Aaru.Core.Logging /// Duration in milliseconds internal void Write(ulong sector, double duration) { - if(logFile == null) + if(_logFile == null) return; byte[] sectorBytes = BitConverter.GetBytes(sector); byte[] durationBytes = BitConverter.GetBytes((ulong)(duration * 1000)); - mhddFs.Write(sectorBytes, 0, 8); - mhddFs.Write(durationBytes, 0, 8); + _mhddFs.Write(sectorBytes, 0, 8); + _mhddFs.Write(durationBytes, 0, 8); } /// Closes and writes to file the MHDD log internal void Close() { - if(logFile == null) + if(_logFile == null) return; - var fs = new FileStream(logFile, FileMode.Create); - mhddFs.WriteTo(fs); - mhddFs.Close(); + var fs = new FileStream(_logFile, FileMode.Create); + _mhddFs.WriteTo(fs); + _mhddFs.Close(); fs.Close(); } } diff --git a/Aaru.Core/Partitions.cs b/Aaru.Core/Partitions.cs index 89d86e523..050af9ac6 100644 --- a/Aaru.Core/Partitions.cs +++ b/Aaru.Core/Partitions.cs @@ -36,7 +36,6 @@ using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Console; -using Aaru.Partitions; namespace Aaru.Core { diff --git a/Aaru.Core/Sidecar/BlockMedia.cs b/Aaru.Core/Sidecar/BlockMedia.cs index 0f223f101..f59b0230e 100644 --- a/Aaru.Core/Sidecar/BlockMedia.cs +++ b/Aaru.Core/Sidecar/BlockMedia.cs @@ -64,7 +64,7 @@ namespace Aaru.Core void BlockMedia(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins, List imgChecksums, ref CICMMetadataType sidecar, Encoding encoding) { - if(aborted) + if(_aborted) return; sidecar.BlockMedia = new[] @@ -103,7 +103,7 @@ namespace Aaru.Core foreach(MediaTagType tagType in image.Info.ReadableMediaTags) { - if(aborted) + if(_aborted) return; switch(tagType) @@ -344,7 +344,7 @@ namespace Aaru.Core while(doneSectors < sectors) { - if(aborted) + if(_aborted) { EndProgress2(); @@ -413,7 +413,7 @@ namespace Aaru.Core { UpdateStatus($"Hashing partition {tapePartition.Number}..."); - if(aborted) + if(_aborted) return; var tapePartitionChk = new Checksum(); @@ -429,7 +429,7 @@ namespace Aaru.Core while(doneSectors < sectors) { - if(aborted) + if(_aborted) { EndProgress2(); @@ -491,7 +491,7 @@ namespace Aaru.Core { UpdateStatus($"Hashing file {tapeFile.File}..."); - if(aborted) + if(_aborted) return; var tapeFileChk = new Checksum(); @@ -507,7 +507,7 @@ namespace Aaru.Core while(doneSectors < sectors) { - if(aborted) + if(_aborted) { EndProgress2(); @@ -561,7 +561,7 @@ namespace Aaru.Core UpdateStatus("Checking filesystems..."); - if(aborted) + if(_aborted) return; List partitions = Partitions.GetAll(image); @@ -575,7 +575,7 @@ namespace Aaru.Core for(int i = 0; i < partitions.Count; i++) { - if(aborted) + if(_aborted) return; sidecar.BlockMedia[0].FileSystemInformation[i] = new PartitionType @@ -593,7 +593,7 @@ namespace Aaru.Core foreach(IFilesystem plugin in plugins.PluginsList.Values) try { - if(aborted) + if(_aborted) return; if(!plugin.Identify(image, partitions[i])) @@ -627,7 +627,7 @@ namespace Aaru.Core } else { - if(aborted) + if(_aborted) return; sidecar.BlockMedia[0].FileSystemInformation[0] = new PartitionType @@ -648,7 +648,7 @@ namespace Aaru.Core foreach(IFilesystem plugin in plugins.PluginsList.Values) try { - if(aborted) + if(_aborted) return; if(!plugin.Identify(image, wholePart)) @@ -857,7 +857,7 @@ namespace Aaru.Core string scpFilePath = Path.Combine(Path.GetDirectoryName(imagePath), Path.GetFileNameWithoutExtension(imagePath) + ".scp"); - if(aborted) + if(_aborted) return; if(File.Exists(scpFilePath)) @@ -886,7 +886,7 @@ namespace Aaru.Core for(byte t = scpImage.Header.start; t <= scpImage.Header.end; t++) { - if(aborted) + if(_aborted) return; var scpBlockTrackType = new BlockTrackType @@ -950,7 +950,7 @@ namespace Aaru.Core bool kfDir = false; - if(aborted) + if(_aborted) return; if(Directory.Exists(basename)) @@ -994,7 +994,7 @@ namespace Aaru.Core foreach(KeyValuePair kvp in kfImage.tracks) { - if(aborted) + if(_aborted) return; var kfBlockTrackType = new BlockTrackType @@ -1051,7 +1051,7 @@ namespace Aaru.Core string dfiFilePath = Path.Combine(Path.GetDirectoryName(imagePath), Path.GetFileNameWithoutExtension(imagePath) + ".dfi"); - if(aborted) + if(_aborted) return; if(!File.Exists(dfiFilePath)) @@ -1081,7 +1081,7 @@ namespace Aaru.Core foreach(int t in dfiImage.TrackOffsets.Keys) { - if(aborted) + if(_aborted) return; var dfiBlockTrackType = new BlockTrackType diff --git a/Aaru.Core/Sidecar/BlockTape.cs b/Aaru.Core/Sidecar/BlockTape.cs index 61c28deb7..b08df3d80 100644 --- a/Aaru.Core/Sidecar/BlockTape.cs +++ b/Aaru.Core/Sidecar/BlockTape.cs @@ -44,7 +44,7 @@ namespace Aaru.Core /// Expected block size in bytes public CICMMetadataType BlockTape(string folderName, List files, uint blockSize) { - sidecar = new CICMMetadataType + _sidecar = new CICMMetadataType { BlockMedia = new[] { @@ -80,8 +80,8 @@ namespace Aaru.Core } }; - if(aborted) - return sidecar; + if(_aborted) + return _sidecar; ulong currentBlock = 0; ulong totalSize = 0; @@ -92,10 +92,10 @@ namespace Aaru.Core for(int i = 0; i < files.Count; i++) { - if(aborted) - return sidecar; + if(_aborted) + return _sidecar; - fs = new FileStream(files[i], FileMode.Open, FileAccess.Read); + _fs = new FileStream(files[i], FileMode.Open, FileAccess.Read); var fileWorker = new Checksum(); var tapeFile = new TapeFileType @@ -106,25 +106,25 @@ namespace Aaru.Core offset = 0, Value = Path.GetFileName(files[i]) }, - Size = (ulong)fs.Length, + Size = (ulong)_fs.Length, BlockSize = blockSize, StartBlock = currentBlock, Sequence = (ulong)i }; const uint SECTORS_TO_READ = 512; - ulong sectors = (ulong)fs.Length / blockSize; + ulong sectors = (ulong)_fs.Length / blockSize; ulong doneSectors = 0; InitProgress2(); while(doneSectors < sectors) { - if(aborted) + if(_aborted) { EndProgress2(); - return sidecar; + return _sidecar; } byte[] sector; @@ -132,7 +132,7 @@ namespace Aaru.Core if(sectors - doneSectors >= SECTORS_TO_READ) { sector = new byte[SECTORS_TO_READ * blockSize]; - fs.Read(sector, 0, sector.Length); + _fs.Read(sector, 0, sector.Length); UpdateProgress2($"Hashing block {doneSectors} of {sectors} on file {i + 1} of {files.Count}", (long)doneSectors, (long)sectors); @@ -142,7 +142,7 @@ namespace Aaru.Core else { sector = new byte[(uint)(sectors - doneSectors) * blockSize]; - fs.Read(sector, 0, sector.Length); + _fs.Read(sector, 0, sector.Length); UpdateProgress2($"Hashing block {doneSectors} of {sectors} on file {i + 1} of {files.Count}", (long)doneSectors, (long)sectors); @@ -156,7 +156,7 @@ namespace Aaru.Core tapeFile.EndBlock = (tapeFile.StartBlock + sectors) - 1; currentBlock += sectors; - totalSize += (ulong)fs.Length; + totalSize += (ulong)_fs.Length; tapeFile.Checksums = fileWorker.End().ToArray(); tapeFiles.Add(tapeFile); @@ -164,59 +164,59 @@ namespace Aaru.Core } UpdateStatus("Setting metadata..."); - sidecar.BlockMedia[0].Checksums = tapeWorker.End().ToArray(); - sidecar.BlockMedia[0].ContentChecksums = sidecar.BlockMedia[0].Checksums; - sidecar.BlockMedia[0].Size = totalSize; - sidecar.BlockMedia[0].LogicalBlocks = currentBlock; - sidecar.BlockMedia[0].TapeInformation[0].EndBlock = currentBlock - 1; - sidecar.BlockMedia[0].TapeInformation[0].Size = totalSize; - sidecar.BlockMedia[0].TapeInformation[0].Checksums = sidecar.BlockMedia[0].Checksums; - sidecar.BlockMedia[0].TapeInformation[0].File = tapeFiles.ToArray(); + _sidecar.BlockMedia[0].Checksums = tapeWorker.End().ToArray(); + _sidecar.BlockMedia[0].ContentChecksums = _sidecar.BlockMedia[0].Checksums; + _sidecar.BlockMedia[0].Size = totalSize; + _sidecar.BlockMedia[0].LogicalBlocks = currentBlock; + _sidecar.BlockMedia[0].TapeInformation[0].EndBlock = currentBlock - 1; + _sidecar.BlockMedia[0].TapeInformation[0].Size = totalSize; + _sidecar.BlockMedia[0].TapeInformation[0].Checksums = _sidecar.BlockMedia[0].Checksums; + _sidecar.BlockMedia[0].TapeInformation[0].File = tapeFiles.ToArray(); // This is purely for convenience, as typically these kind of data represents QIC tapes if(blockSize == 512) { - sidecar.BlockMedia[0].DiskType = "Quarter-inch cartridge"; + _sidecar.BlockMedia[0].DiskType = "Quarter-inch cartridge"; if(totalSize <= 20 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-11"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-11"; else if(totalSize <= 40 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-40"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-40"; else if(totalSize <= 60 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-24"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-24"; else if(totalSize <= 80 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-80"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-80"; else if(totalSize <= 120 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-120"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-120"; else if(totalSize <= 150 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-150"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-150"; else if(totalSize <= 320 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-320"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-320"; else if(totalSize <= 340 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-3010"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-3010"; else if(totalSize <= 525 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-525"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-525"; else if(totalSize <= 670 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-3020"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-3020"; else if(totalSize <= 1200 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-3080"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-3080"; else if(totalSize <= 1350 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-1350"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-1350"; else if(totalSize <= (long)4000 * 1048576) - sidecar.BlockMedia[0].DiskSubType = "QIC-3095"; + _sidecar.BlockMedia[0].DiskSubType = "QIC-3095"; else { - sidecar.BlockMedia[0].DiskType = "Unknown tape"; - sidecar.BlockMedia[0].DiskSubType = "Unknown tape"; + _sidecar.BlockMedia[0].DiskType = "Unknown tape"; + _sidecar.BlockMedia[0].DiskSubType = "Unknown tape"; } } else { - sidecar.BlockMedia[0].DiskType = "Unknown tape"; - sidecar.BlockMedia[0].DiskSubType = "Unknown tape"; + _sidecar.BlockMedia[0].DiskType = "Unknown tape"; + _sidecar.BlockMedia[0].DiskSubType = "Unknown tape"; } - return sidecar; + return _sidecar; } } } \ No newline at end of file diff --git a/Aaru.Core/Sidecar/Files.cs b/Aaru.Core/Sidecar/Files.cs index e2dbf91df..c814fa72d 100644 --- a/Aaru.Core/Sidecar/Files.cs +++ b/Aaru.Core/Sidecar/Files.cs @@ -264,7 +264,7 @@ namespace Aaru.Core while(position < stat.Length - 1048576) { - if(aborted) + if(_aborted) return file; data = new byte[1048576]; @@ -289,7 +289,7 @@ namespace Aaru.Core file.Checksums = fileChkWorker.End().ToArray(); } else - file.Checksums = emptyChecksums; + file.Checksums = _emptyChecksums; Errno ret = filesystem.ListXAttr(path + "/" + filename, out List xattrs); diff --git a/Aaru.Core/Sidecar/OpticalDisc.cs b/Aaru.Core/Sidecar/OpticalDisc.cs index fab038e2c..aee979938 100644 --- a/Aaru.Core/Sidecar/OpticalDisc.cs +++ b/Aaru.Core/Sidecar/OpticalDisc.cs @@ -63,7 +63,7 @@ namespace Aaru.Core void OpticalDisc(IOpticalMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins, List imgChecksums, ref CICMMetadataType sidecar, Encoding encoding) { - if(aborted) + if(_aborted) return; sidecar.OpticalDisc = new[] @@ -104,7 +104,7 @@ namespace Aaru.Core foreach(MediaTagType tagType in image.Info.ReadableMediaTags) { - if(aborted) + if(_aborted) return; switch(tagType) @@ -443,7 +443,7 @@ namespace Aaru.Core image.Info.MediaType != MediaType.Unknown) sidecar.OpticalDisc[0].Dimensions = Dimensions.DimensionsFromMediaType(image.Info.MediaType); - if(aborted) + if(_aborted) return; InitProgress(); @@ -456,7 +456,7 @@ namespace Aaru.Core foreach(Track trk in tracks) { - if(aborted) + if(_aborted) { EndProgress(); @@ -587,7 +587,7 @@ namespace Aaru.Core while(doneSectors < sectors) { - if(aborted) + if(_aborted) { EndProgress(); EndProgress2(); @@ -674,7 +674,7 @@ namespace Aaru.Core while(doneSectors < sectors) { - if(aborted) + if(_aborted) { EndProgress(); EndProgress2(); @@ -746,7 +746,7 @@ namespace Aaru.Core foreach(IFilesystem plugin in plugins.PluginsList.Values) try { - if(aborted) + if(_aborted) { EndProgress(); @@ -813,7 +813,7 @@ namespace Aaru.Core foreach(IFilesystem plugin in plugins.PluginsList.Values) try { - if(aborted) + if(_aborted) { EndProgress(); diff --git a/Aaru.Core/Sidecar/Sidecar.cs b/Aaru.Core/Sidecar/Sidecar.cs index a8a7191d0..15cce665f 100644 --- a/Aaru.Core/Sidecar/Sidecar.cs +++ b/Aaru.Core/Sidecar/Sidecar.cs @@ -44,27 +44,27 @@ namespace Aaru.Core { public partial class Sidecar { - readonly ChecksumType[] emptyChecksums; - readonly Encoding encoding; - readonly FileInfo fi; - readonly Guid filterId; - readonly IMediaImage image; - readonly string imagePath; - readonly Checksum imgChkWorker; - readonly PluginBase plugins; - bool aborted; - FileStream fs; - CICMMetadataType sidecar; + readonly ChecksumType[] _emptyChecksums; + readonly Encoding _encoding; + readonly FileInfo _fi; + readonly Guid _filterId; + readonly IMediaImage _image; + readonly string _imagePath; + readonly Checksum _imgChkWorker; + readonly PluginBase _plugins; + bool _aborted; + FileStream _fs; + CICMMetadataType _sidecar; public Sidecar() { - plugins = GetPluginBase.Instance; - imgChkWorker = new Checksum(); - aborted = false; + _plugins = GetPluginBase.Instance; + _imgChkWorker = new Checksum(); + _aborted = false; var emptyChkWorker = new Checksum(); emptyChkWorker.Update(new byte[0]); - emptyChecksums = emptyChkWorker.End().ToArray(); + _emptyChecksums = emptyChkWorker.End().ToArray(); } /// Image @@ -73,19 +73,16 @@ namespace Aaru.Core /// Encoding for analysis public Sidecar(IMediaImage image, string imagePath, Guid filterId, Encoding encoding) { - this.image = image; - this.imagePath = imagePath; - this.filterId = filterId; - this.encoding = encoding; - - sidecar = image.CicmMetadata ?? new CICMMetadataType(); - plugins = GetPluginBase.Instance; - - fi = new FileInfo(imagePath); - fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read); - - imgChkWorker = new Checksum(); - aborted = false; + _image = image; + _imagePath = imagePath; + _filterId = filterId; + _encoding = encoding; + _sidecar = image.CicmMetadata ?? new CICMMetadataType(); + _plugins = GetPluginBase.Instance; + _fi = new FileInfo(imagePath); + _fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read); + _imgChkWorker = new Checksum(); + _aborted = false; } /// Implements creating a metadata sidecar @@ -100,50 +97,50 @@ namespace Aaru.Core UpdateStatus("Hashing image file..."); InitProgress(); - while(position < fi.Length - 1048576) + while(position < _fi.Length - 1048576) { - if(aborted) - return sidecar; + if(_aborted) + return _sidecar; data = new byte[1048576]; - fs.Read(data, 0, 1048576); + _fs.Read(data, 0, 1048576); - UpdateProgress("Hashing image file byte {0} of {1}", position, fi.Length); + UpdateProgress("Hashing image file byte {0} of {1}", position, _fi.Length); - imgChkWorker.Update(data); + _imgChkWorker.Update(data); position += 1048576; } - data = new byte[fi.Length - position]; - fs.Read(data, 0, (int)(fi.Length - position)); + data = new byte[_fi.Length - position]; + _fs.Read(data, 0, (int)(_fi.Length - position)); - UpdateProgress("Hashing image file byte {0} of {1}", position, fi.Length); + UpdateProgress("Hashing image file byte {0} of {1}", position, _fi.Length); - imgChkWorker.Update(data); + _imgChkWorker.Update(data); // For fast debugging, skip checksum //skipImageChecksum: EndProgress(); - fs.Close(); + _fs.Close(); - List imgChecksums = imgChkWorker.End(); + List imgChecksums = _imgChkWorker.End(); - sidecar.OpticalDisc = null; - sidecar.BlockMedia = null; - sidecar.AudioMedia = null; - sidecar.LinearMedia = null; + _sidecar.OpticalDisc = null; + _sidecar.BlockMedia = null; + _sidecar.AudioMedia = null; + _sidecar.LinearMedia = null; - if(aborted) - return sidecar; + if(_aborted) + return _sidecar; - switch(image.Info.XmlMediaType) + switch(_image.Info.XmlMediaType) { case XmlMediaType.OpticalDisc: - if(image is IOpticalMediaImage opticalImage) - OpticalDisc(opticalImage, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, - encoding); + if(_image is IOpticalMediaImage opticalImage) + OpticalDisc(opticalImage, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, + _encoding); else { AaruConsole. @@ -154,26 +151,26 @@ namespace Aaru.Core break; case XmlMediaType.BlockMedia: - BlockMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, encoding); + BlockMedia(_image, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, _encoding); break; case XmlMediaType.LinearMedia: - LinearMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, encoding); + LinearMedia(_image, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, _encoding); break; case XmlMediaType.AudioMedia: - AudioMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, encoding); + AudioMedia(_image, _filterId, _imagePath, _fi, _plugins, imgChecksums, ref _sidecar, _encoding); break; } - return sidecar; + return _sidecar; } public void Abort() { UpdateStatus("Aborting..."); - aborted = true; + _aborted = true; } } } \ No newline at end of file diff --git a/Aaru.Devices/Device/Commands.cs b/Aaru.Devices/Device/Commands.cs index 7e40a1006..721a51612 100644 --- a/Aaru.Devices/Device/Commands.cs +++ b/Aaru.Devices/Device/Commands.cs @@ -163,11 +163,11 @@ namespace Aaru.Devices { switch(command) { - case MmcCommands.SendCid when cachedCid != null: + case MmcCommands.SendCid when _cachedCid != null: { DateTime start = DateTime.Now; - buffer = new byte[cachedCid.Length]; - Array.Copy(cachedCid, buffer, buffer.Length); + buffer = new byte[_cachedCid.Length]; + Array.Copy(_cachedCid, buffer, buffer.Length); response = new uint[4]; sense = false; DateTime end = DateTime.Now; @@ -175,11 +175,11 @@ namespace Aaru.Devices return 0; } - case MmcCommands.SendCsd when cachedCid != null: + case MmcCommands.SendCsd when _cachedCid != null: { DateTime start = DateTime.Now; - buffer = new byte[cachedCsd.Length]; - Array.Copy(cachedCsd, buffer, buffer.Length); + buffer = new byte[_cachedCsd.Length]; + Array.Copy(_cachedCsd, buffer, buffer.Length); response = new uint[4]; sense = false; DateTime end = DateTime.Now; @@ -187,11 +187,11 @@ namespace Aaru.Devices return 0; } - case (MmcCommands)SecureDigitalCommands.SendScr when cachedScr != null: + case (MmcCommands)SecureDigitalCommands.SendScr when _cachedScr != null: { DateTime start = DateTime.Now; - buffer = new byte[cachedScr.Length]; - Array.Copy(cachedScr, buffer, buffer.Length); + buffer = new byte[_cachedScr.Length]; + Array.Copy(_cachedScr, buffer, buffer.Length); response = new uint[4]; sense = false; DateTime end = DateTime.Now; @@ -199,12 +199,12 @@ namespace Aaru.Devices return 0; } - case (MmcCommands)SecureDigitalCommands.SendOperatingCondition when cachedOcr != null: - case MmcCommands.SendOpCond when cachedOcr != null: + case (MmcCommands)SecureDigitalCommands.SendOperatingCondition when _cachedOcr != null: + case MmcCommands.SendOpCond when _cachedOcr != null: { DateTime start = DateTime.Now; - buffer = new byte[cachedOcr.Length]; - Array.Copy(cachedOcr, buffer, buffer.Length); + buffer = new byte[_cachedOcr.Length]; + Array.Copy(_cachedOcr, buffer, buffer.Length); response = new uint[4]; sense = false; DateTime end = DateTime.Now; diff --git a/Aaru.Devices/Device/Constructor.cs b/Aaru.Devices/Device/Constructor.cs index 67ee9a915..91fc87ad9 100644 --- a/Aaru.Devices/Device/Constructor.cs +++ b/Aaru.Devices/Device/Constructor.cs @@ -307,8 +307,8 @@ namespace Aaru.Devices if(!sense) { - cachedCsd = new byte[16]; - Array.Copy(sdBuffer, 0, cachedCsd, 0, 16); + _cachedCsd = new byte[16]; + Array.Copy(sdBuffer, 0, _cachedCsd, 0, 16); } sdBuffer = new byte[16]; @@ -321,8 +321,8 @@ namespace Aaru.Devices if(!sense) { - cachedCid = new byte[16]; - Array.Copy(sdBuffer, 0, cachedCid, 0, 16); + _cachedCid = new byte[16]; + Array.Copy(sdBuffer, 0, _cachedCid, 0, 16); } sdBuffer = new byte[8]; @@ -336,14 +336,14 @@ namespace Aaru.Devices if(!sense) { - cachedScr = new byte[8]; - Array.Copy(sdBuffer, 0, cachedScr, 0, 8); + _cachedScr = new byte[8]; + Array.Copy(sdBuffer, 0, _cachedScr, 0, 8); } sdBuffer = new byte[4]; LastError = Windows.Command.SendMmcCommand((SafeFileHandle)FileHandle, - cachedScr != null + _cachedScr != null ? (MmcCommands)SecureDigitalCommands. SendOperatingCondition : MmcCommands.SendOpCond, false, true, @@ -353,8 +353,8 @@ namespace Aaru.Devices if(!sense) { - cachedScr = new byte[4]; - Array.Copy(sdBuffer, 0, cachedScr, 0, 4); + _cachedScr = new byte[4]; + Array.Copy(sdBuffer, 0, _cachedScr, 0, 4); } } @@ -375,34 +375,34 @@ namespace Aaru.Devices if(File.Exists("/sys/block/" + devPath + "/device/csd")) { - int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/csd", out cachedCsd); + int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/csd", out _cachedCsd); if(len == 0) - cachedCsd = null; + _cachedCsd = null; } if(File.Exists("/sys/block/" + devPath + "/device/cid")) { - int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/cid", out cachedCid); + int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/cid", out _cachedCid); if(len == 0) - cachedCid = null; + _cachedCid = null; } if(File.Exists("/sys/block/" + devPath + "/device/scr")) { - int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/scr", out cachedScr); + int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/scr", out _cachedScr); if(len == 0) - cachedScr = null; + _cachedScr = null; } if(File.Exists("/sys/block/" + devPath + "/device/ocr")) { - int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/ocr", out cachedOcr); + int len = ConvertFromHexAscii("/sys/block/" + devPath + "/device/ocr", out _cachedOcr); if(len == 0) - cachedOcr = null; + _cachedOcr = null; } } @@ -426,7 +426,7 @@ namespace Aaru.Devices break; case DeviceType.SecureDigital: case DeviceType.MMC: - if(!_remote.GetSdhciRegisters(out cachedCsd, out cachedCid, out cachedOcr, out cachedScr)) + if(!_remote.GetSdhciRegisters(out _cachedCsd, out _cachedCid, out _cachedOcr, out _cachedScr)) { Type = DeviceType.SCSI; ScsiType = PeripheralDeviceTypes.DirectAccess; @@ -437,15 +437,15 @@ namespace Aaru.Devices } #region SecureDigital / MultiMediaCard - if(cachedCid != null) + if(_cachedCid != null) { ScsiType = PeripheralDeviceTypes.DirectAccess; IsRemovable = false; - if(cachedScr != null) + if(_cachedScr != null) { Type = DeviceType.SecureDigital; - CID decoded = Decoders.SecureDigital.Decoders.DecodeCID(cachedCid); + CID decoded = Decoders.SecureDigital.Decoders.DecodeCID(_cachedCid); Manufacturer = VendorString.Prettify(decoded.Manufacturer); Model = decoded.ProductName; @@ -457,7 +457,7 @@ namespace Aaru.Devices else { Type = DeviceType.MMC; - Decoders.MMC.CID decoded = Decoders.MMC.Decoders.DecodeCID(cachedCid); + Decoders.MMC.CID decoded = Decoders.MMC.Decoders.DecodeCID(_cachedCid); Manufacturer = Decoders.MMC.VendorString.Prettify(decoded.Manufacturer); Model = decoded.ProductName; @@ -513,7 +513,7 @@ namespace Aaru.Devices string usbTemp = usbSr.ReadToEnd(); ushort.TryParse(usbTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, - out usbProduct); + out _usbProduct); usbSr.Close(); @@ -521,7 +521,7 @@ namespace Aaru.Devices usbTemp = usbSr.ReadToEnd(); ushort.TryParse(usbTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, - out usbVendor); + out _usbVendor); usbSr.Close(); @@ -574,8 +574,8 @@ namespace Aaru.Devices if(usbDevice != null) { UsbDescriptors = usbDevice.BinaryDescriptors; - usbVendor = (ushort)usbDevice.DeviceDescriptor.idVendor; - usbProduct = (ushort)usbDevice.DeviceDescriptor.idProduct; + _usbVendor = (ushort)usbDevice.DeviceDescriptor.idVendor; + _usbProduct = (ushort)usbDevice.DeviceDescriptor.idProduct; UsbManufacturerString = usbDevice.Manufacturer; UsbProductString = usbDevice.Product; @@ -599,8 +599,8 @@ namespace Aaru.Devices { IsUsb = true; UsbDescriptors = remoteUsbDescriptors; - usbVendor = remoteUsbVendor; - usbProduct = remoteUsbProduct; + _usbVendor = remoteUsbVendor; + _usbProduct = remoteUsbProduct; UsbManufacturerString = remoteUsbManufacturer; UsbProductString = remoteUsbProductString; UsbSerialString = remoteUsbSerial; @@ -611,7 +611,7 @@ namespace Aaru.Devices #region FireWire if(!(_remote is null)) { - if(_remote.GetFireWireData(out firewireVendor, out firewireModel, out firewireGuid, + if(_remote.GetFireWireData(out _firewireVendor, out _firewireModel, out _firewireGuid, out string remoteFireWireVendorName, out string remoteFireWireModelName)) { IsFireWire = true; @@ -648,7 +648,7 @@ namespace Aaru.Devices string fwTemp = fwSr.ReadToEnd(); uint.TryParse(fwTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, - out firewireModel); + out _firewireModel); fwSr.Close(); @@ -656,7 +656,7 @@ namespace Aaru.Devices fwTemp = fwSr.ReadToEnd(); uint.TryParse(fwTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, - out firewireVendor); + out _firewireVendor); fwSr.Close(); @@ -664,7 +664,7 @@ namespace Aaru.Devices fwTemp = fwSr.ReadToEnd(); ulong.TryParse(fwTemp, NumberStyles.HexNumber, CultureInfo.InvariantCulture, - out firewireGuid); + out _firewireGuid); fwSr.Close(); @@ -886,7 +886,7 @@ namespace Aaru.Devices Model = FireWireModelName; if(string.IsNullOrEmpty(Serial)) - Serial = $"{firewireGuid:X16}"; + Serial = $"{_firewireGuid:X16}"; else foreach(char c in Serial.Where(c => !char.IsControl(c))) Serial = $"{(uint)c:X2}"; diff --git a/Aaru.Devices/Device/Variables.cs b/Aaru.Devices/Device/Variables.cs index 47a30cb8a..c1e3082bf 100644 --- a/Aaru.Devices/Device/Variables.cs +++ b/Aaru.Devices/Device/Variables.cs @@ -38,18 +38,18 @@ namespace Aaru.Devices { public partial class Device { - readonly ushort usbVendor; - readonly ushort usbProduct; - readonly ulong firewireGuid; - readonly uint firewireModel; - readonly uint firewireVendor; + readonly ushort _usbVendor; + readonly ushort _usbProduct; + readonly ulong _firewireGuid; + readonly uint _firewireModel; + readonly uint _firewireVendor; // MMC and SecureDigital, values that need to be get with card idle, something that may // not be possible to do but usually is already done by the SDHCI driver. - readonly byte[] cachedCsd; - readonly byte[] cachedCid; - readonly byte[] cachedScr; - readonly byte[] cachedOcr; + readonly byte[] _cachedCsd; + readonly byte[] _cachedCid; + readonly byte[] _cachedScr; + readonly byte[] _cachedOcr; /// Gets the Platform ID for this device /// The Platform ID @@ -105,11 +105,11 @@ namespace Aaru.Devices /// Gets the USB vendor ID. /// The USB vendor ID. - public ushort UsbVendorId => usbVendor; + public ushort UsbVendorId => _usbVendor; /// Gets the USB product ID. /// The USB product ID. - public ushort UsbProductId => usbProduct; + public ushort UsbProductId => _usbProduct; /// Gets the USB descriptors. /// The USB descriptors. @@ -133,11 +133,11 @@ namespace Aaru.Devices /// Gets the FireWire GUID /// The FireWire GUID. - public ulong FireWireGuid => firewireGuid; + public ulong FireWireGuid => _firewireGuid; /// Gets the FireWire model number /// The FireWire model. - public uint FireWireModel => firewireModel; + public uint FireWireModel => _firewireModel; /// Gets the FireWire model name. /// The FireWire model name. @@ -145,7 +145,7 @@ namespace Aaru.Devices /// Gets the FireWire vendor number. /// The FireWire vendor number. - public uint FireWireVendor => firewireVendor; + public uint FireWireVendor => _firewireVendor; /// Gets the FireWire vendor name. /// The FireWire vendor name. diff --git a/Aaru.Devices/Remote/Consts.cs b/Aaru.Devices/Remote/Consts.cs index 483f7a5d8..2680d0dd6 100644 --- a/Aaru.Devices/Remote/Consts.cs +++ b/Aaru.Devices/Remote/Consts.cs @@ -34,9 +34,9 @@ namespace Aaru.Devices.Remote { public class Consts { - public const uint RemoteId = 0x52434944; // "DICR" - public const uint PacketId = 0x544B4350; // "PCKT" - public const int PacketVersion = 1; - public const int MaxProtocol = 1; + public const uint REMOTE_ID = 0x52434944; // "DICR" + public const uint PACKET_ID = 0x544B4350; // "PCKT" + public const int PACKET_VERSION = 1; + public const int MAX_PROTOCOL = 1; } } \ No newline at end of file diff --git a/Aaru.Devices/Remote/Remote.cs b/Aaru.Devices/Remote/Remote.cs index f8ba98ed5..8485f012f 100644 --- a/Aaru.Devices/Remote/Remote.cs +++ b/Aaru.Devices/Remote/Remote.cs @@ -86,8 +86,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -122,7 +122,7 @@ namespace Aaru.Devices.Remote throw new ArgumentException(); } - if(hdr.version != Consts.PacketVersion) + if(hdr.version != Consts.PACKET_VERSION) { AaruConsole.ErrorWriteLine("Unrecognized packet version..."); @@ -152,16 +152,16 @@ namespace Aaru.Devices.Remote { application = "Aaru", version = Version.GetVersion(), - maxProtocol = Consts.MaxProtocol, + maxProtocol = Consts.MAX_PROTOCOL, sysname = DetectOS.GetPlatformName(DetectOS.GetRealPlatformID(), DetectOS.GetVersion()), release = DetectOS.GetVersion(), machine = RuntimeInformation.ProcessArchitecture.ToString(), hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, len = (uint)Marshal.SizeOf(), - version = Consts.PacketVersion, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.Hello } }; @@ -193,10 +193,10 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, len = (uint)Marshal.SizeOf(), - version = Consts.PacketVersion, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandAmIRoot } }; @@ -225,8 +225,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -271,10 +271,10 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, len = (uint)Marshal.SizeOf(), - version = Consts.PacketVersion, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandListDevices } }; @@ -303,8 +303,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -338,7 +338,7 @@ namespace Aaru.Devices.Remote return new DeviceInfo[0]; } - if(hdr.version != Consts.PacketVersion) + if(hdr.version != Consts.PACKET_VERSION) { AaruConsole.ErrorWriteLine("Unrecognized packet version..."); @@ -381,10 +381,10 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, len = (uint)Marshal.SizeOf(), - version = Consts.PacketVersion, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandOpen }, device_path = devicePath @@ -416,8 +416,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); lastError = -1; @@ -471,9 +471,9 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, - version = Consts.PacketVersion, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandScsi }, direction = (int)direction, @@ -521,8 +521,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -570,9 +570,9 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, - version = Consts.PacketVersion, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandAtaChs }, registers = registers, @@ -617,8 +617,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -665,9 +665,9 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, - version = Consts.PacketVersion, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandAtaLba28 }, registers = registers, @@ -712,8 +712,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -761,9 +761,9 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, - version = Consts.PacketVersion, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandAtaLba48 }, registers = registers, @@ -808,8 +808,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -857,9 +857,9 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, - version = Consts.PacketVersion, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandAtaLba48 }, command = command, @@ -907,8 +907,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -953,10 +953,10 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, len = (uint)Marshal.SizeOf(), - version = Consts.PacketVersion, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandGetType } }; @@ -985,8 +985,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -1027,10 +1027,10 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, len = (uint)Marshal.SizeOf(), - version = Consts.PacketVersion, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandGetSdhciRegisters } }; @@ -1059,8 +1059,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -1145,10 +1145,10 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, len = (uint)Marshal.SizeOf(), - version = Consts.PacketVersion, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandGetUsbData } }; @@ -1177,8 +1177,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -1231,10 +1231,10 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, len = (uint)Marshal.SizeOf(), - version = Consts.PacketVersion, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandGetFireWireData } }; @@ -1263,8 +1263,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -1312,10 +1312,10 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, len = (uint)Marshal.SizeOf(), - version = Consts.PacketVersion, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandGetPcmciaData } }; @@ -1344,8 +1344,8 @@ namespace Aaru.Devices.Remote AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrBuf); - if(hdr.remote_id != Consts.RemoteId || - hdr.packet_id != Consts.PacketId) + if(hdr.remote_id != Consts.REMOTE_ID || + hdr.packet_id != Consts.PACKET_ID) { AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet..."); @@ -1405,10 +1405,10 @@ namespace Aaru.Devices.Remote { hdr = new AaruPacketHeader { - remote_id = Consts.RemoteId, - packet_id = Consts.PacketId, + remote_id = Consts.REMOTE_ID, + packet_id = Consts.PACKET_ID, len = (uint)Marshal.SizeOf(), - version = Consts.PacketVersion, + version = Consts.PACKET_VERSION, packetType = AaruPacketType.CommandCloseDevice } }; diff --git a/Aaru.Filesystems/AODOS.cs b/Aaru.Filesystems/AODOS.cs index c50032e7d..76e33425c 100644 --- a/Aaru.Filesystems/AODOS.cs +++ b/Aaru.Filesystems/AODOS.cs @@ -46,7 +46,7 @@ namespace Aaru.Filesystems // This may be missing fields, or not, I don't know russian so any help is appreciated public class AODOS : IFilesystem { - readonly byte[] AODOSIdentifier = + readonly byte[] _identifier = { 0x20, 0x41, 0x4F, 0x2D, 0x44, 0x4F, 0x53, 0x20 }; @@ -71,18 +71,18 @@ namespace Aaru.Filesystems imagePlugin.Info.Sectors != 1600) return false; - byte[] sector = imagePlugin.ReadSector(0); - AODOS_BootBlock bb = Marshal.ByteArrayToStructureLittleEndian(sector); + byte[] sector = imagePlugin.ReadSector(0); + BootBlock bb = Marshal.ByteArrayToStructureLittleEndian(sector); - return bb.identifier.SequenceEqual(AODOSIdentifier); + return bb.identifier.SequenceEqual(_identifier); } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = Encoding.GetEncoding("koi8-r"); - byte[] sector = imagePlugin.ReadSector(0); - AODOS_BootBlock bb = Marshal.ByteArrayToStructureLittleEndian(sector); + byte[] sector = imagePlugin.ReadSector(0); + BootBlock bb = Marshal.ByteArrayToStructureLittleEndian(sector); var sbInformation = new StringBuilder(); @@ -111,7 +111,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AODOS_BootBlock + struct BootBlock { /// A NOP opcode public readonly byte nop; diff --git a/Aaru.Filesystems/APFS.cs b/Aaru.Filesystems/APFS.cs index 858aa03f9..5afd96954 100644 --- a/Aaru.Filesystems/APFS.cs +++ b/Aaru.Filesystems/APFS.cs @@ -58,12 +58,12 @@ namespace Aaru.Filesystems if(partition.Start >= partition.End) return false; - byte[] sector = imagePlugin.ReadSector(partition.Start); - ApfsContainerSuperBlock nxSb; + byte[] sector = imagePlugin.ReadSector(partition.Start); + ContainerSuperBlock nxSb; try { - nxSb = Marshal.ByteArrayToStructureLittleEndian(sector); + nxSb = Marshal.ByteArrayToStructureLittleEndian(sector); } catch { @@ -84,12 +84,12 @@ namespace Aaru.Filesystems if(partition.Start >= partition.End) return; - byte[] sector = imagePlugin.ReadSector(partition.Start); - ApfsContainerSuperBlock nxSb; + byte[] sector = imagePlugin.ReadSector(partition.Start); + ContainerSuperBlock nxSb; try { - nxSb = Marshal.ByteArrayToStructureLittleEndian(sector); + nxSb = Marshal.ByteArrayToStructureLittleEndian(sector); } catch { @@ -118,7 +118,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ApfsContainerSuperBlock + struct ContainerSuperBlock { public readonly ulong unknown1; // Varies between copies of the superblock public readonly ulong unknown2; diff --git a/Aaru.Filesystems/AppleCommon/Enums.cs b/Aaru.Filesystems/AppleCommon/Enums.cs index f529ddf74..16db9a252 100644 --- a/Aaru.Filesystems/AppleCommon/Enums.cs +++ b/Aaru.Filesystems/AppleCommon/Enums.cs @@ -32,6 +32,8 @@ using System; +// ReSharper disable InconsistentNaming + namespace Aaru.Filesystems { // Information from Inside Macintosh diff --git a/Aaru.Filesystems/AppleCommon/Info.cs b/Aaru.Filesystems/AppleCommon/Info.cs index 29b9cf4d5..fcf76eb88 100644 --- a/Aaru.Filesystems/AppleCommon/Info.cs +++ b/Aaru.Filesystems/AppleCommon/Info.cs @@ -39,7 +39,7 @@ namespace Aaru.Filesystems // https://developer.apple.com/legacy/library/documentation/mac/pdf/Files/File_Manager.pdf internal static partial class AppleCommon { - internal static string GetBootBlockInformation(byte[] bbSector, Encoding Encoding) + internal static string GetBootBlockInformation(byte[] bbSector, Encoding encoding) { if(bbSector is null || bbSector.Length < 0x100) @@ -75,24 +75,24 @@ namespace Aaru.Filesystems else if(bb.bbPageFlags < 0) sb.AppendLine("Allocate secondary sound and video buffers at boot."); - sb.AppendFormat("System filename: {0}", StringHandlers.PascalToString(bb.bbSysName, Encoding)).AppendLine(); + sb.AppendFormat("System filename: {0}", StringHandlers.PascalToString(bb.bbSysName, encoding)).AppendLine(); - sb.AppendFormat("Finder filename: {0}", StringHandlers.PascalToString(bb.bbShellName, Encoding)). + sb.AppendFormat("Finder filename: {0}", StringHandlers.PascalToString(bb.bbShellName, encoding)). AppendLine(); - sb.AppendFormat("Debugger filename: {0}", StringHandlers.PascalToString(bb.bbDbg1Name, Encoding)). + sb.AppendFormat("Debugger filename: {0}", StringHandlers.PascalToString(bb.bbDbg1Name, encoding)). AppendLine(); - sb.AppendFormat("Disassembler filename: {0}", StringHandlers.PascalToString(bb.bbDbg2Name, Encoding)). + sb.AppendFormat("Disassembler filename: {0}", StringHandlers.PascalToString(bb.bbDbg2Name, encoding)). AppendLine(); - sb.AppendFormat("Startup screen filename: {0}", StringHandlers.PascalToString(bb.bbScreenName, Encoding)). + sb.AppendFormat("Startup screen filename: {0}", StringHandlers.PascalToString(bb.bbScreenName, encoding)). AppendLine(); sb.AppendFormat("First program to execute at boot: {0}", - StringHandlers.PascalToString(bb.bbHelloName, Encoding)).AppendLine(); + StringHandlers.PascalToString(bb.bbHelloName, encoding)).AppendLine(); - sb.AppendFormat("Clipboard filename: {0}", StringHandlers.PascalToString(bb.bbScrapName, Encoding)). + sb.AppendFormat("Clipboard filename: {0}", StringHandlers.PascalToString(bb.bbScrapName, encoding)). AppendLine(); sb.AppendFormat("Maximum opened files: {0}", bb.bbCntFCBs * 4).AppendLine(); diff --git a/Aaru.Filesystems/AppleCommon/Structs.cs b/Aaru.Filesystems/AppleCommon/Structs.cs index 051447f80..dc741c20b 100644 --- a/Aaru.Filesystems/AppleCommon/Structs.cs +++ b/Aaru.Filesystems/AppleCommon/Structs.cs @@ -32,6 +32,8 @@ using System.Runtime.InteropServices; +// ReSharper disable InconsistentNaming + namespace Aaru.Filesystems { // Information from Inside Macintosh diff --git a/Aaru.Filesystems/AppleDOS/AppleDOS.cs b/Aaru.Filesystems/AppleDOS/AppleDOS.cs index 0a1ee76d6..88013fa94 100644 --- a/Aaru.Filesystems/AppleDOS/AppleDOS.cs +++ b/Aaru.Filesystems/AppleDOS/AppleDOS.cs @@ -40,17 +40,16 @@ namespace Aaru.Filesystems { public partial class AppleDOS : IReadOnlyFilesystem { - bool debug; - IMediaImage device; - bool mounted; - int sectorsPerTrack; - ulong start; - ulong totalFileEntries; - bool track1UsedByFiles; - bool track2UsedByFiles; - uint usedSectors; - - Vtoc vtoc; + bool _debug; + IMediaImage _device; + bool _mounted; + int _sectorsPerTrack; + ulong _start; + ulong _totalFileEntries; + bool _track1UsedByFiles; + bool _track2UsedByFiles; + uint _usedSectors; + Vtoc _vtoc; public FileSystemType XmlFsType { get; private set; } public Encoding Encoding { get; private set; } @@ -73,23 +72,23 @@ namespace Aaru.Filesystems #region Caches /// Caches track/sector lists - Dictionary extentCache; + Dictionary _extentCache; /// Caches files - Dictionary fileCache; + Dictionary _fileCache; /// Caches catalog - Dictionary catalogCache; + Dictionary _catalogCache; /// Caches file size - Dictionary fileSizeCache; + Dictionary _fileSizeCache; /// Caches VTOC - byte[] vtocBlocks; + byte[] _vtocBlocks; /// Caches catalog - byte[] catalogBlocks; + byte[] _catalogBlocks; /// Caches boot code - byte[] bootBlocks; + byte[] _bootBlocks; /// Caches file type - Dictionary fileTypeCache; + Dictionary _fileTypeCache; /// Caches locked files - List lockedFiles; + List _lockedFiles; #endregion Caches } } \ No newline at end of file diff --git a/Aaru.Filesystems/AppleDOS/Dir.cs b/Aaru.Filesystems/AppleDOS/Dir.cs index 700a74f92..2bd41be58 100644 --- a/Aaru.Filesystems/AppleDOS/Dir.cs +++ b/Aaru.Filesystems/AppleDOS/Dir.cs @@ -49,7 +49,7 @@ namespace Aaru.Filesystems { dest = null; - return !mounted ? Errno.AccessDenied : Errno.NotSupported; + return !_mounted ? Errno.AccessDenied : Errno.NotSupported; } /// @@ -60,16 +60,16 @@ namespace Aaru.Filesystems { contents = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) return Errno.NotSupported; - contents = catalogCache.Keys.ToList(); + contents = _catalogCache.Keys.ToList(); - if(debug) + if(_debug) { contents.Add("$"); contents.Add("$Boot"); @@ -84,24 +84,24 @@ namespace Aaru.Filesystems Errno ReadCatalog() { var catalogMs = new MemoryStream(); - ulong lba = (ulong)((vtoc.catalogTrack * sectorsPerTrack) + vtoc.catalogSector); - totalFileEntries = 0; - catalogCache = new Dictionary(); - fileTypeCache = new Dictionary(); - fileSizeCache = new Dictionary(); - lockedFiles = new List(); + ulong lba = (ulong)((_vtoc.catalogTrack * _sectorsPerTrack) + _vtoc.catalogSector); + _totalFileEntries = 0; + _catalogCache = new Dictionary(); + _fileTypeCache = new Dictionary(); + _fileSizeCache = new Dictionary(); + _lockedFiles = new List(); if(lba == 0 || - lba > device.Info.Sectors) + lba > _device.Info.Sectors) return Errno.InvalidArgument; while(lba != 0) { - usedSectors++; - byte[] catSectorB = device.ReadSector(lba); - totalFileEntries += 7; + _usedSectors++; + byte[] catSectorB = _device.ReadSector(lba); + _totalFileEntries += 7; - if(debug) + if(_debug) catalogMs.Write(catSectorB, 0, catSectorB.Length); // Read the catalog sector @@ -109,8 +109,8 @@ namespace Aaru.Filesystems foreach(FileEntry entry in catSector.entries.Where(entry => entry.extentTrack > 0)) { - track1UsedByFiles |= entry.extentTrack == 1; - track2UsedByFiles |= entry.extentTrack == 2; + _track1UsedByFiles |= entry.extentTrack == 1; + _track2UsedByFiles |= entry.extentTrack == 2; byte[] filenameB = new byte[30]; ushort ts = (ushort)((entry.extentTrack << 8) | entry.extentSector); @@ -121,28 +121,28 @@ namespace Aaru.Filesystems string filename = StringHandlers.SpacePaddedToString(filenameB, Encoding); - if(!catalogCache.ContainsKey(filename)) - catalogCache.Add(filename, ts); + if(!_catalogCache.ContainsKey(filename)) + _catalogCache.Add(filename, ts); - if(!fileTypeCache.ContainsKey(filename)) - fileTypeCache.Add(filename, (byte)(entry.typeAndFlags & 0x7F)); + if(!_fileTypeCache.ContainsKey(filename)) + _fileTypeCache.Add(filename, (byte)(entry.typeAndFlags & 0x7F)); - if(!fileSizeCache.ContainsKey(filename)) - fileSizeCache.Add(filename, entry.length * vtoc.bytesPerSector); + if(!_fileSizeCache.ContainsKey(filename)) + _fileSizeCache.Add(filename, entry.length * _vtoc.bytesPerSector); if((entry.typeAndFlags & 0x80) == 0x80 && - !lockedFiles.Contains(filename)) - lockedFiles.Add(filename); + !_lockedFiles.Contains(filename)) + _lockedFiles.Add(filename); } - lba = (ulong)((catSector.trackOfNext * sectorsPerTrack) + catSector.sectorOfNext); + lba = (ulong)((catSector.trackOfNext * _sectorsPerTrack) + catSector.sectorOfNext); - if(lba > device.Info.Sectors) + if(lba > _device.Info.Sectors) break; } - if(debug) - catalogBlocks = catalogMs.ToArray(); + if(_debug) + _catalogBlocks = catalogMs.ToArray(); return Errno.NoError; } diff --git a/Aaru.Filesystems/AppleDOS/File.cs b/Aaru.Filesystems/AppleDOS/File.cs index 243841d24..b8c76de0d 100644 --- a/Aaru.Filesystems/AppleDOS/File.cs +++ b/Aaru.Filesystems/AppleDOS/File.cs @@ -46,7 +46,7 @@ namespace Aaru.Filesystems { attributes = new FileAttributes(); - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -59,18 +59,18 @@ namespace Aaru.Filesystems string filename = pathElements[0].ToUpperInvariant(); - if(!fileCache.ContainsKey(filename)) + if(!_fileCache.ContainsKey(filename)) return Errno.NoSuchFile; attributes = FileAttributes.Extents; attributes |= FileAttributes.File; - if(lockedFiles.Contains(filename)) + if(_lockedFiles.Contains(filename)) attributes |= FileAttributes.ReadOnly; - if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) + if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || + string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || + string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) attributes |= FileAttributes.System; return Errno.NoError; @@ -78,7 +78,7 @@ namespace Aaru.Filesystems public Errno Read(string path, long offset, long size, ref byte[] buf) { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -95,25 +95,25 @@ namespace Aaru.Filesystems if(filename.Length > 30) return Errno.NameTooLong; - if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) + if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || + string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || + string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0) - file = catalogBlocks; + file = _catalogBlocks; else if(string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0) - file = vtocBlocks; + file = _vtocBlocks; else - file = bootBlocks; + file = _bootBlocks; else { - if(!fileCache.TryGetValue(filename, out file)) + if(!_fileCache.TryGetValue(filename, out file)) { Errno error = CacheFile(filename); if(error != Errno.NoError) return error; - if(!fileCache.TryGetValue(filename, out file)) + if(!_fileCache.TryGetValue(filename, out file)) return Errno.InvalidArgument; } } @@ -135,7 +135,7 @@ namespace Aaru.Filesystems { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -151,35 +151,35 @@ namespace Aaru.Filesystems if(filename.Length > 30) return Errno.NameTooLong; - if(!fileCache.ContainsKey(filename)) + if(!_fileCache.ContainsKey(filename)) return Errno.NoSuchFile; stat = new FileEntryInfo(); - fileSizeCache.TryGetValue(filename, out int filesize); + _fileSizeCache.TryGetValue(filename, out int filesize); GetAttributes(path, out FileAttributes attrs); - if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) + if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || + string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || + string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) { if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0) - stat.Length = catalogBlocks.Length; + stat.Length = _catalogBlocks.Length; else if(string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0) - stat.Length = bootBlocks.Length; + stat.Length = _bootBlocks.Length; else if(string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0) - stat.Length = vtocBlocks.Length; + stat.Length = _vtocBlocks.Length; - stat.Blocks = stat.Length / vtoc.bytesPerSector; + stat.Blocks = stat.Length / _vtoc.bytesPerSector; } else { stat.Length = filesize; - stat.Blocks = stat.Length / vtoc.bytesPerSector; + stat.Blocks = stat.Length / _vtoc.bytesPerSector; } stat.Attributes = attrs; - stat.BlockSize = vtoc.bytesPerSector; + stat.BlockSize = _vtoc.bytesPerSector; stat.Links = 1; return Errno.NoError; @@ -190,7 +190,7 @@ namespace Aaru.Filesystems deviceBlock = 0; // TODO: Not really important. - return !mounted ? Errno.AccessDenied : Errno.NotImplemented; + return !_mounted ? Errno.AccessDenied : Errno.NotImplemented; } Errno CacheFile(string path) @@ -208,20 +208,20 @@ namespace Aaru.Filesystems if(filename.Length > 30) return Errno.NameTooLong; - if(!catalogCache.TryGetValue(filename, out ushort ts)) + if(!_catalogCache.TryGetValue(filename, out ushort ts)) return Errno.NoSuchFile; - ulong lba = (ulong)((((ts & 0xFF00) >> 8) * sectorsPerTrack) + (ts & 0xFF)); + ulong lba = (ulong)((((ts & 0xFF00) >> 8) * _sectorsPerTrack) + (ts & 0xFF)); var fileMs = new MemoryStream(); var tsListMs = new MemoryStream(); ushort expectedBlock = 0; while(lba != 0) { - usedSectors++; - byte[] tsSectorB = device.ReadSector(lba); + _usedSectors++; + byte[] tsSectorB = _device.ReadSector(lba); - if(debug) + if(_debug) tsListMs.Write(tsSectorB, 0, tsSectorB.Length); // Read the track/sector list sector @@ -229,60 +229,60 @@ namespace Aaru.Filesystems if(tsSector.sectorOffset > expectedBlock) { - byte[] hole = new byte[(tsSector.sectorOffset - expectedBlock) * vtoc.bytesPerSector]; + byte[] hole = new byte[(tsSector.sectorOffset - expectedBlock) * _vtoc.bytesPerSector]; fileMs.Write(hole, 0, hole.Length); expectedBlock = tsSector.sectorOffset; } foreach(TrackSectorListEntry entry in tsSector.entries) { - track1UsedByFiles |= entry.track == 1; - track2UsedByFiles |= entry.track == 2; - usedSectors++; + _track1UsedByFiles |= entry.track == 1; + _track2UsedByFiles |= entry.track == 2; + _usedSectors++; - ulong blockLba = (ulong)((entry.track * sectorsPerTrack) + entry.sector); + ulong blockLba = (ulong)((entry.track * _sectorsPerTrack) + entry.sector); if(blockLba == 0) break; - byte[] fileBlock = device.ReadSector(blockLba); + byte[] fileBlock = _device.ReadSector(blockLba); fileMs.Write(fileBlock, 0, fileBlock.Length); expectedBlock++; } - lba = (ulong)((tsSector.nextListTrack * sectorsPerTrack) + tsSector.nextListSector); + lba = (ulong)((tsSector.nextListTrack * _sectorsPerTrack) + tsSector.nextListSector); } - if(fileCache.ContainsKey(filename)) - fileCache.Remove(filename); + if(_fileCache.ContainsKey(filename)) + _fileCache.Remove(filename); - if(extentCache.ContainsKey(filename)) - extentCache.Remove(filename); + if(_extentCache.ContainsKey(filename)) + _extentCache.Remove(filename); - fileCache.Add(filename, fileMs.ToArray()); - extentCache.Add(filename, tsListMs.ToArray()); + _fileCache.Add(filename, fileMs.ToArray()); + _extentCache.Add(filename, tsListMs.ToArray()); return Errno.NoError; } Errno CacheAllFiles() { - fileCache = new Dictionary(); - extentCache = new Dictionary(); + _fileCache = new Dictionary(); + _extentCache = new Dictionary(); - foreach(Errno error in catalogCache.Keys.Select(CacheFile).Where(error => error != Errno.NoError)) + foreach(Errno error in _catalogCache.Keys.Select(CacheFile).Where(error => error != Errno.NoError)) return error; uint tracksOnBoot = 1; - if(!track1UsedByFiles) + if(!_track1UsedByFiles) tracksOnBoot++; - if(!track2UsedByFiles) + if(!_track2UsedByFiles) tracksOnBoot++; - bootBlocks = device.ReadSectors(0, (uint)(tracksOnBoot * sectorsPerTrack)); - usedSectors += (uint)(bootBlocks.Length / vtoc.bytesPerSector); + _bootBlocks = _device.ReadSectors(0, (uint)(tracksOnBoot * _sectorsPerTrack)); + _usedSectors += (uint)(_bootBlocks.Length / _vtoc.bytesPerSector); return Errno.NoError; } diff --git a/Aaru.Filesystems/AppleDOS/Info.cs b/Aaru.Filesystems/AppleDOS/Info.cs index 0268e6735..fb22206da 100644 --- a/Aaru.Filesystems/AppleDOS/Info.cs +++ b/Aaru.Filesystems/AppleDOS/Info.cs @@ -55,10 +55,10 @@ namespace Aaru.Filesystems int spt = imagePlugin.Info.Sectors == 455 ? 13 : 16; byte[] vtocB = imagePlugin.ReadSector((ulong)(17 * spt)); - vtoc = Marshal.ByteArrayToStructureLittleEndian(vtocB); + _vtoc = Marshal.ByteArrayToStructureLittleEndian(vtocB); - return vtoc.catalogSector < spt && vtoc.maxTrackSectorPairsPerSector <= 122 && - vtoc.sectorsPerTrack == spt && vtoc.bytesPerSector == 256; + return _vtoc.catalogSector < spt && _vtoc.maxTrackSectorPairsPerSector <= 122 && + _vtoc.sectorsPerTrack == spt && _vtoc.bytesPerSector == 256; } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, @@ -72,22 +72,22 @@ namespace Aaru.Filesystems spt = imagePlugin.Info.Sectors == 455 ? 13 : 16; byte[] vtocB = imagePlugin.ReadSector((ulong)(17 * spt)); - vtoc = Marshal.ByteArrayToStructureLittleEndian(vtocB); + _vtoc = Marshal.ByteArrayToStructureLittleEndian(vtocB); sb.AppendLine("Apple DOS File System"); sb.AppendLine(); - sb.AppendFormat("Catalog starts at sector {0} of track {1}", vtoc.catalogSector, vtoc.catalogTrack). + sb.AppendFormat("Catalog starts at sector {0} of track {1}", _vtoc.catalogSector, _vtoc.catalogTrack). AppendLine(); - sb.AppendFormat("File system initialized by DOS release {0}", vtoc.dosRelease).AppendLine(); - sb.AppendFormat("Disk volume number {0}", vtoc.volumeNumber).AppendLine(); - sb.AppendFormat("Sectors allocated at most in track {0}", vtoc.lastAllocatedSector).AppendLine(); - sb.AppendFormat("{0} tracks in volume", vtoc.tracks).AppendLine(); - sb.AppendFormat("{0} sectors per track", vtoc.sectorsPerTrack).AppendLine(); - sb.AppendFormat("{0} bytes per sector", vtoc.bytesPerSector).AppendLine(); + sb.AppendFormat("File system initialized by DOS release {0}", _vtoc.dosRelease).AppendLine(); + sb.AppendFormat("Disk volume number {0}", _vtoc.volumeNumber).AppendLine(); + sb.AppendFormat("Sectors allocated at most in track {0}", _vtoc.lastAllocatedSector).AppendLine(); + sb.AppendFormat("{0} tracks in volume", _vtoc.tracks).AppendLine(); + sb.AppendFormat("{0} sectors per track", _vtoc.sectorsPerTrack).AppendLine(); + sb.AppendFormat("{0} bytes per sector", _vtoc.bytesPerSector).AppendLine(); - sb.AppendFormat("Track allocation is {0}", vtoc.allocationDirection > 0 ? "forward" : "reverse"). + sb.AppendFormat("Track allocation is {0}", _vtoc.allocationDirection > 0 ? "forward" : "reverse"). AppendLine(); information = sb.ToString(); diff --git a/Aaru.Filesystems/AppleDOS/Super.cs b/Aaru.Filesystems/AppleDOS/Super.cs index 2f23bf431..28b48be12 100644 --- a/Aaru.Filesystems/AppleDOS/Super.cs +++ b/Aaru.Filesystems/AppleDOS/Super.cs @@ -49,41 +49,41 @@ namespace Aaru.Filesystems public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, Dictionary options, string @namespace) { - device = imagePlugin; - start = partition.Start; + _device = imagePlugin; + _start = partition.Start; Encoding = encoding ?? new Apple2(); - if(device.Info.Sectors != 455 && - device.Info.Sectors != 560) + if(_device.Info.Sectors != 455 && + _device.Info.Sectors != 560) { AaruConsole.DebugWriteLine("Apple DOS plugin", "Incorrect device size."); return Errno.InOutError; } - if(start > 0) + if(_start > 0) { AaruConsole.DebugWriteLine("Apple DOS plugin", "Partitions are not supported."); return Errno.InOutError; } - if(device.Info.SectorSize != 256) + if(_device.Info.SectorSize != 256) { AaruConsole.DebugWriteLine("Apple DOS plugin", "Incorrect sector size."); return Errno.InOutError; } - sectorsPerTrack = device.Info.Sectors == 455 ? 13 : 16; + _sectorsPerTrack = _device.Info.Sectors == 455 ? 13 : 16; // Read the VTOC - vtocBlocks = device.ReadSector((ulong)(17 * sectorsPerTrack)); - vtoc = Marshal.ByteArrayToStructureLittleEndian(vtocBlocks); + _vtocBlocks = _device.ReadSector((ulong)(17 * _sectorsPerTrack)); + _vtoc = Marshal.ByteArrayToStructureLittleEndian(_vtocBlocks); - track1UsedByFiles = false; - track2UsedByFiles = false; - usedSectors = 1; + _track1UsedByFiles = false; + _track2UsedByFiles = false; + _usedSectors = 1; Errno error = ReadCatalog(); @@ -107,23 +107,23 @@ namespace Aaru.Filesystems XmlFsType = new FileSystemType { Bootable = true, - Clusters = device.Info.Sectors, - ClusterSize = vtoc.bytesPerSector, - Files = (ulong)catalogCache.Count, + Clusters = _device.Info.Sectors, + ClusterSize = _vtoc.bytesPerSector, + Files = (ulong)_catalogCache.Count, FilesSpecified = true, FreeClustersSpecified = true, Type = "Apple DOS" }; - XmlFsType.FreeClusters = XmlFsType.Clusters - usedSectors; + XmlFsType.FreeClusters = XmlFsType.Clusters - _usedSectors; if(options == null) options = GetDefaultOptions(); if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out debug); + bool.TryParse(debugString, out _debug); - mounted = true; + _mounted = true; return Errno.NoError; } @@ -132,11 +132,11 @@ namespace Aaru.Filesystems /// Umounts this DOS filesystem public Errno Unmount() { - mounted = false; - extentCache = null; - fileCache = null; - catalogCache = null; - fileSizeCache = null; + _mounted = false; + _extentCache = null; + _fileCache = null; + _catalogCache = null; + _fileSizeCache = null; return Errno.NoError; } @@ -148,15 +148,15 @@ namespace Aaru.Filesystems { stat = new FileSystemInfo { - Blocks = device.Info.Sectors, + Blocks = _device.Info.Sectors, FilenameLength = 30, - Files = (ulong)catalogCache.Count, + Files = (ulong)_catalogCache.Count, PluginId = Id, Type = "Apple DOS" }; - stat.FreeFiles = totalFileEntries - stat.Files; - stat.FreeBlocks = stat.Blocks - usedSectors; + stat.FreeFiles = _totalFileEntries - stat.Files; + stat.FreeBlocks = stat.Blocks - _usedSectors; return Errno.NoError; } diff --git a/Aaru.Filesystems/AppleDOS/Xattr.cs b/Aaru.Filesystems/AppleDOS/Xattr.cs index e076c6c47..333af5c40 100644 --- a/Aaru.Filesystems/AppleDOS/Xattr.cs +++ b/Aaru.Filesystems/AppleDOS/Xattr.cs @@ -47,7 +47,7 @@ namespace Aaru.Filesystems { xattrs = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -65,17 +65,17 @@ namespace Aaru.Filesystems xattrs = new List(); - if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) {} + if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || + string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || + string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) {} else { - if(!catalogCache.ContainsKey(filename)) + if(!_catalogCache.ContainsKey(filename)) return Errno.NoSuchFile; xattrs.Add("com.apple.dos.type"); - if(debug) + if(_debug) xattrs.Add("com.apple.dos.tracksectorlist"); } @@ -90,7 +90,7 @@ namespace Aaru.Filesystems /// Buffer. public Errno GetXattr(string path, string xattr, ref byte[] buf) { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -106,17 +106,17 @@ namespace Aaru.Filesystems if(filename.Length > 30) return Errno.NameTooLong; - if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) + if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || + string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || + string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) return Errno.NoSuchExtendedAttribute; - if(!catalogCache.ContainsKey(filename)) + if(!_catalogCache.ContainsKey(filename)) return Errno.NoSuchFile; if(string.Compare(xattr, "com.apple.dos.type", StringComparison.InvariantCulture) == 0) { - if(!fileTypeCache.TryGetValue(filename, out byte type)) + if(!_fileTypeCache.TryGetValue(filename, out byte type)) return Errno.InvalidArgument; buf = new byte[1]; @@ -126,10 +126,10 @@ namespace Aaru.Filesystems } if(string.Compare(xattr, "com.apple.dos.tracksectorlist", StringComparison.InvariantCulture) != 0 || - !debug) + !_debug) return Errno.NoSuchExtendedAttribute; - if(!extentCache.TryGetValue(filename, out byte[] ts)) + if(!_extentCache.TryGetValue(filename, out byte[] ts)) return Errno.InvalidArgument; buf = new byte[ts.Length]; diff --git a/Aaru.Filesystems/AppleHFS/Consts.cs b/Aaru.Filesystems/AppleHFS/Consts.cs index 0bdbfc23c..a68c2a057 100644 --- a/Aaru.Filesystems/AppleHFS/Consts.cs +++ b/Aaru.Filesystems/AppleHFS/Consts.cs @@ -32,6 +32,8 @@ using System.Diagnostics.CodeAnalysis; +// ReSharper disable InconsistentNaming + namespace Aaru.Filesystems { // Information from Inside Macintosh diff --git a/Aaru.Filesystems/AppleHFS/Enums.cs b/Aaru.Filesystems/AppleHFS/Enums.cs index eaa693e5d..6fd32edc9 100644 --- a/Aaru.Filesystems/AppleHFS/Enums.cs +++ b/Aaru.Filesystems/AppleHFS/Enums.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2020 Natalia Portillo // ****************************************************************************/ +// ReSharper disable InconsistentNaming + namespace Aaru.Filesystems { public partial class AppleHFS diff --git a/Aaru.Filesystems/AppleMFS/AppleMFS.cs b/Aaru.Filesystems/AppleMFS/AppleMFS.cs index 96ba482d5..76d4ae83c 100644 --- a/Aaru.Filesystems/AppleMFS/AppleMFS.cs +++ b/Aaru.Filesystems/AppleMFS/AppleMFS.cs @@ -41,24 +41,24 @@ namespace Aaru.Filesystems // Information from Inside Macintosh Volume II public partial class AppleMFS : IReadOnlyFilesystem { - bool mounted; - bool debug; - IMediaImage device; - ulong partitionStart; - Dictionary idToFilename; - Dictionary idToEntry; - Dictionary filenameToId; - MasterDirectoryBlock volMDB; - byte[] bootBlocks; - byte[] mdbBlocks; - byte[] directoryBlocks; - byte[] blockMapBytes; - uint[] blockMap; - int sectorsPerBlock; - byte[] bootTags; - byte[] mdbTags; - byte[] directoryTags; - byte[] bitmapTags; + bool _mounted; + bool _debug; + IMediaImage _device; + ulong _partitionStart; + Dictionary _idToFilename; + Dictionary _idToEntry; + Dictionary _filenameToId; + MasterDirectoryBlock _volMdb; + byte[] _bootBlocks; + byte[] _mdbBlocks; + byte[] _directoryBlocks; + byte[] _blockMapBytes; + uint[] _blockMap; + int _sectorsPerBlock; + byte[] _bootTags; + byte[] _mdbTags; + byte[] _directoryTags; + byte[] _bitmapTags; public FileSystemType XmlFsType { get; private set; } public string Name => "Apple Macintosh File System"; diff --git a/Aaru.Filesystems/AppleMFS/Dir.cs b/Aaru.Filesystems/AppleMFS/Dir.cs index 652ffbfc3..09140cd5b 100644 --- a/Aaru.Filesystems/AppleMFS/Dir.cs +++ b/Aaru.Filesystems/AppleMFS/Dir.cs @@ -46,22 +46,22 @@ namespace Aaru.Filesystems { contents = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) return Errno.NotSupported; - contents = idToFilename.Select(kvp => kvp.Value).ToList(); + contents = _idToFilename.Select(kvp => kvp.Value).ToList(); - if(debug) + if(_debug) { contents.Add("$"); contents.Add("$Bitmap"); contents.Add("$MDB"); - if(bootBlocks != null) + if(_bootBlocks != null) contents.Add("$Boot"); } @@ -72,54 +72,54 @@ namespace Aaru.Filesystems bool FillDirectory() { - idToFilename = new Dictionary(); - idToEntry = new Dictionary(); - filenameToId = new Dictionary(); + _idToFilename = new Dictionary(); + _idToEntry = new Dictionary(); + _filenameToId = new Dictionary(); int offset = 0; - while(offset + 51 < directoryBlocks.Length) + while(offset + 51 < _directoryBlocks.Length) { var entry = new FileEntry { - flFlags = (FileFlags)directoryBlocks[offset + 0] + flFlags = (FileFlags)_directoryBlocks[offset + 0] }; if(!entry.flFlags.HasFlag(FileFlags.Used)) break; - entry.flTyp = directoryBlocks[offset + 1]; + entry.flTyp = _directoryBlocks[offset + 1]; entry.flUsrWds = - Marshal.ByteArrayToStructureBigEndian(directoryBlocks, offset + 2, 16); + Marshal.ByteArrayToStructureBigEndian(_directoryBlocks, offset + 2, 16); - entry.flFlNum = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 18); - entry.flStBlk = BigEndianBitConverter.ToUInt16(directoryBlocks, offset + 22); - entry.flLgLen = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 24); - entry.flPyLen = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 28); - entry.flRStBlk = BigEndianBitConverter.ToUInt16(directoryBlocks, offset + 32); - entry.flRLgLen = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 34); - entry.flRPyLen = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 38); - entry.flCrDat = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 42); - entry.flMdDat = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 46); - entry.flNam = new byte[directoryBlocks[offset + 50] + 1]; - Array.Copy(directoryBlocks, offset + 50, entry.flNam, 0, entry.flNam.Length); + entry.flFlNum = BigEndianBitConverter.ToUInt32(_directoryBlocks, offset + 18); + entry.flStBlk = BigEndianBitConverter.ToUInt16(_directoryBlocks, offset + 22); + entry.flLgLen = BigEndianBitConverter.ToUInt32(_directoryBlocks, offset + 24); + entry.flPyLen = BigEndianBitConverter.ToUInt32(_directoryBlocks, offset + 28); + entry.flRStBlk = BigEndianBitConverter.ToUInt16(_directoryBlocks, offset + 32); + entry.flRLgLen = BigEndianBitConverter.ToUInt32(_directoryBlocks, offset + 34); + entry.flRPyLen = BigEndianBitConverter.ToUInt32(_directoryBlocks, offset + 38); + entry.flCrDat = BigEndianBitConverter.ToUInt32(_directoryBlocks, offset + 42); + entry.flMdDat = BigEndianBitConverter.ToUInt32(_directoryBlocks, offset + 46); + entry.flNam = new byte[_directoryBlocks[offset + 50] + 1]; + Array.Copy(_directoryBlocks, offset + 50, entry.flNam, 0, entry.flNam.Length); string lowerFilename = StringHandlers. PascalToString(entry.flNam, Encoding).ToLowerInvariant().Replace('/', ':'); - if(entry.flFlags.HasFlag(FileFlags.Used) && - !idToFilename.ContainsKey(entry.flFlNum) && - !idToEntry.ContainsKey(entry.flFlNum) && - !filenameToId.ContainsKey(lowerFilename) && + if(entry.flFlags.HasFlag(FileFlags.Used) && + !_idToFilename.ContainsKey(entry.flFlNum) && + !_idToEntry.ContainsKey(entry.flFlNum) && + !_filenameToId.ContainsKey(lowerFilename) && entry.flFlNum > 0) { - idToEntry.Add(entry.flFlNum, entry); + _idToEntry.Add(entry.flFlNum, entry); - idToFilename.Add(entry.flFlNum, - StringHandlers.PascalToString(entry.flNam, Encoding).Replace('/', ':')); + _idToFilename.Add(entry.flFlNum, + StringHandlers.PascalToString(entry.flNam, Encoding).Replace('/', ':')); - filenameToId.Add(lowerFilename, entry.flFlNum); + _filenameToId.Add(lowerFilename, entry.flFlNum); AaruConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flFlags = {0}", entry.flFlags); AaruConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flTyp = {0}", entry.flTyp); diff --git a/Aaru.Filesystems/AppleMFS/File.cs b/Aaru.Filesystems/AppleMFS/File.cs index cd0df1e64..84a0d59af 100644 --- a/Aaru.Filesystems/AppleMFS/File.cs +++ b/Aaru.Filesystems/AppleMFS/File.cs @@ -47,7 +47,7 @@ namespace Aaru.Filesystems { deviceBlock = new long(); - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -60,13 +60,13 @@ namespace Aaru.Filesystems path = pathElements[0]; - if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) + if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return Errno.NoSuchFile; - if(!idToEntry.TryGetValue(fileId, out FileEntry entry)) + if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return Errno.NoSuchFile; - if(fileBlock > entry.flPyLen / volMDB.drAlBlkSiz) + if(fileBlock > entry.flPyLen / _volMdb.drAlBlkSiz) return Errno.InvalidArgument; uint nextBlock = entry.flStBlk; @@ -76,16 +76,16 @@ namespace Aaru.Filesystems { if(relBlock == fileBlock) { - deviceBlock = ((nextBlock - 2) * sectorsPerBlock) + volMDB.drAlBlSt + (long)partitionStart; + deviceBlock = ((nextBlock - 2) * _sectorsPerBlock) + _volMdb.drAlBlSt + (long)_partitionStart; return Errno.NoError; } - if(blockMap[nextBlock] == BMAP_FREE || - blockMap[nextBlock] == BMAP_LAST) + if(_blockMap[nextBlock] == BMAP_FREE || + _blockMap[nextBlock] == BMAP_LAST) break; - nextBlock = blockMap[nextBlock]; + nextBlock = _blockMap[nextBlock]; relBlock++; } @@ -96,7 +96,7 @@ namespace Aaru.Filesystems { attributes = new FileAttributes(); - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -109,10 +109,10 @@ namespace Aaru.Filesystems path = pathElements[0]; - if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) + if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return Errno.NoSuchFile; - if(!idToEntry.TryGetValue(fileId, out FileEntry entry)) + if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return Errno.NoSuchFile; if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsAlias)) @@ -157,22 +157,22 @@ namespace Aaru.Filesystems public Errno Read(string path, long offset, long size, ref byte[] buf) { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; byte[] file; Errno error = Errno.NoError; - if(debug && string.Compare(path, "$", StringComparison.InvariantCulture) == 0) - file = directoryBlocks; - else if(debug && + if(_debug && string.Compare(path, "$", StringComparison.InvariantCulture) == 0) + file = _directoryBlocks; + else if(_debug && string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 && - bootBlocks != null) - file = bootBlocks; - else if(debug && string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0) - file = blockMapBytes; - else if(debug && string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0) - file = mdbBlocks; + _bootBlocks != null) + file = _bootBlocks; + else if(_debug && string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0) + file = _blockMapBytes; + else if(_debug && string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0) + file = _mdbBlocks; else error = ReadFile(path, out file, false, false); @@ -203,7 +203,7 @@ namespace Aaru.Filesystems { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -216,7 +216,7 @@ namespace Aaru.Filesystems path = pathElements[0]; - if(debug) + if(_debug) if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0 || @@ -224,7 +224,7 @@ namespace Aaru.Filesystems { stat = new FileEntryInfo { - BlockSize = device.Info.SectorSize, + BlockSize = _device.Info.SectorSize, Inode = 0, Links = 1, Attributes = FileAttributes.System @@ -232,26 +232,28 @@ namespace Aaru.Filesystems if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0) { - stat.Blocks = (directoryBlocks.Length / stat.BlockSize) + - (directoryBlocks.Length % stat.BlockSize); + stat.Blocks = (_directoryBlocks.Length / stat.BlockSize) + + (_directoryBlocks.Length % stat.BlockSize); - stat.Length = directoryBlocks.Length; + stat.Length = _directoryBlocks.Length; } else if(string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0) { - stat.Blocks = (blockMapBytes.Length / stat.BlockSize) + (blockMapBytes.Length % stat.BlockSize); - stat.Length = blockMapBytes.Length; + stat.Blocks = (_blockMapBytes.Length / stat.BlockSize) + + (_blockMapBytes.Length % stat.BlockSize); + + stat.Length = _blockMapBytes.Length; } else if(string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 && - bootBlocks != null) + _bootBlocks != null) { - stat.Blocks = (bootBlocks.Length / stat.BlockSize) + (bootBlocks.Length % stat.BlockSize); - stat.Length = bootBlocks.Length; + stat.Blocks = (_bootBlocks.Length / stat.BlockSize) + (_bootBlocks.Length % stat.BlockSize); + stat.Length = _bootBlocks.Length; } else if(string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0) { - stat.Blocks = (mdbBlocks.Length / stat.BlockSize) + (mdbBlocks.Length % stat.BlockSize); - stat.Length = mdbBlocks.Length; + stat.Blocks = (_mdbBlocks.Length / stat.BlockSize) + (_mdbBlocks.Length % stat.BlockSize); + stat.Length = _mdbBlocks.Length; } else return Errno.InvalidArgument; @@ -259,10 +261,10 @@ namespace Aaru.Filesystems return Errno.NoError; } - if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) + if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return Errno.NoSuchFile; - if(!idToEntry.TryGetValue(fileId, out FileEntry entry)) + if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return Errno.NoSuchFile; Errno error = GetAttributes(path, out FileAttributes attr); @@ -273,8 +275,8 @@ namespace Aaru.Filesystems stat = new FileEntryInfo { Attributes = attr, - Blocks = entry.flLgLen / volMDB.drAlBlkSiz, - BlockSize = volMDB.drAlBlkSiz, + Blocks = entry.flLgLen / _volMdb.drAlBlkSiz, + BlockSize = _volMdb.drAlBlkSiz, CreationTime = DateHandlers.MacToDateTime(entry.flCrDat), Inode = entry.flFlNum, LastWriteTime = DateHandlers.MacToDateTime(entry.flMdDat), @@ -296,7 +298,7 @@ namespace Aaru.Filesystems { buf = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -309,10 +311,10 @@ namespace Aaru.Filesystems path = pathElements[0]; - if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) + if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return Errno.NoSuchFile; - if(!idToEntry.TryGetValue(fileId, out FileEntry entry)) + if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return Errno.NoSuchFile; uint nextBlock; @@ -348,23 +350,25 @@ namespace Aaru.Filesystems if(tags) sectors = - device.ReadSectorsTag((ulong)((nextBlock - 2) * sectorsPerBlock) + volMDB.drAlBlSt + partitionStart, - (uint)sectorsPerBlock, SectorTagType.AppleSectorTag); + _device. + ReadSectorsTag((ulong)((nextBlock - 2) * _sectorsPerBlock) + _volMdb.drAlBlSt + _partitionStart, + (uint)_sectorsPerBlock, SectorTagType.AppleSectorTag); else sectors = - device.ReadSectors((ulong)((nextBlock - 2) * sectorsPerBlock) + volMDB.drAlBlSt + partitionStart, - (uint)sectorsPerBlock); + _device. + ReadSectors((ulong)((nextBlock - 2) * _sectorsPerBlock) + _volMdb.drAlBlSt + _partitionStart, + (uint)_sectorsPerBlock); ms.Write(sectors, 0, sectors.Length); - if(blockMap[nextBlock] == BMAP_FREE) + if(_blockMap[nextBlock] == BMAP_FREE) { AaruConsole.ErrorWriteLine("File truncated at block {0}", nextBlock); break; } - nextBlock = blockMap[nextBlock]; + nextBlock = _blockMap[nextBlock]; } while(nextBlock > BMAP_LAST); if(tags) diff --git a/Aaru.Filesystems/AppleMFS/Super.cs b/Aaru.Filesystems/AppleMFS/Super.cs index 6927fb959..7b38ea27f 100644 --- a/Aaru.Filesystems/AppleMFS/Super.cs +++ b/Aaru.Filesystems/AppleMFS/Super.cs @@ -45,162 +45,163 @@ namespace Aaru.Filesystems // Information from Inside Macintosh Volume II public partial class AppleMFS { + const int BYTES_BEFORE_BLOCK_MAP = 64; + public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, Dictionary options, string @namespace) { - device = imagePlugin; - partitionStart = partition.Start; - Encoding = encoding ?? Encoding.GetEncoding("macintosh"); + _device = imagePlugin; + _partitionStart = partition.Start; + Encoding = encoding ?? Encoding.GetEncoding("macintosh"); if(options == null) options = GetDefaultOptions(); if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out debug); + bool.TryParse(debugString, out _debug); - volMDB = new MasterDirectoryBlock(); + _volMdb = new MasterDirectoryBlock(); - mdbBlocks = device.ReadSector(2 + partitionStart); - bootBlocks = device.ReadSector(0 + partitionStart); + _mdbBlocks = _device.ReadSector(2 + _partitionStart); + _bootBlocks = _device.ReadSector(0 + _partitionStart); - volMDB.drSigWord = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x000); + _volMdb.drSigWord = BigEndianBitConverter.ToUInt16(_mdbBlocks, 0x000); - if(volMDB.drSigWord != MFS_MAGIC) + if(_volMdb.drSigWord != MFS_MAGIC) return Errno.InvalidArgument; - volMDB.drCrDate = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x002); - volMDB.drLsBkUp = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x006); - volMDB.drAtrb = (AppleCommon.VolumeAttributes)BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00A); - volMDB.drNmFls = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00C); - volMDB.drDirSt = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x00E); - volMDB.drBlLen = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x010); - volMDB.drNmAlBlks = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x012); - volMDB.drAlBlkSiz = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x014); - volMDB.drClpSiz = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x018); - volMDB.drAlBlSt = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x01C); - volMDB.drNxtFNum = BigEndianBitConverter.ToUInt32(mdbBlocks, 0x01E); - volMDB.drFreeBks = BigEndianBitConverter.ToUInt16(mdbBlocks, 0x022); - volMDB.drVNSiz = mdbBlocks[0x024]; - byte[] variableSize = new byte[volMDB.drVNSiz + 1]; - Array.Copy(mdbBlocks, 0x024, variableSize, 0, volMDB.drVNSiz + 1); - volMDB.drVN = StringHandlers.PascalToString(variableSize, Encoding); + _volMdb.drCrDate = BigEndianBitConverter.ToUInt32(_mdbBlocks, 0x002); + _volMdb.drLsBkUp = BigEndianBitConverter.ToUInt32(_mdbBlocks, 0x006); + _volMdb.drAtrb = (AppleCommon.VolumeAttributes)BigEndianBitConverter.ToUInt16(_mdbBlocks, 0x00A); + _volMdb.drNmFls = BigEndianBitConverter.ToUInt16(_mdbBlocks, 0x00C); + _volMdb.drDirSt = BigEndianBitConverter.ToUInt16(_mdbBlocks, 0x00E); + _volMdb.drBlLen = BigEndianBitConverter.ToUInt16(_mdbBlocks, 0x010); + _volMdb.drNmAlBlks = BigEndianBitConverter.ToUInt16(_mdbBlocks, 0x012); + _volMdb.drAlBlkSiz = BigEndianBitConverter.ToUInt32(_mdbBlocks, 0x014); + _volMdb.drClpSiz = BigEndianBitConverter.ToUInt32(_mdbBlocks, 0x018); + _volMdb.drAlBlSt = BigEndianBitConverter.ToUInt16(_mdbBlocks, 0x01C); + _volMdb.drNxtFNum = BigEndianBitConverter.ToUInt32(_mdbBlocks, 0x01E); + _volMdb.drFreeBks = BigEndianBitConverter.ToUInt16(_mdbBlocks, 0x022); + _volMdb.drVNSiz = _mdbBlocks[0x024]; + byte[] variableSize = new byte[_volMdb.drVNSiz + 1]; + Array.Copy(_mdbBlocks, 0x024, variableSize, 0, _volMdb.drVNSiz + 1); + _volMdb.drVN = StringHandlers.PascalToString(variableSize, Encoding); - directoryBlocks = device.ReadSectors(volMDB.drDirSt + partitionStart, volMDB.drBlLen); - int bytesInBlockMap = ((volMDB.drNmAlBlks * 12) / 8) + ((volMDB.drNmAlBlks * 12) % 8); - const int BYTES_BEFORE_BLOCK_MAP = 64; - int bytesInWholeMdb = bytesInBlockMap + BYTES_BEFORE_BLOCK_MAP; + _directoryBlocks = _device.ReadSectors(_volMdb.drDirSt + _partitionStart, _volMdb.drBlLen); + int bytesInBlockMap = ((_volMdb.drNmAlBlks * 12) / 8) + ((_volMdb.drNmAlBlks * 12) % 8); + int bytesInWholeMdb = bytesInBlockMap + BYTES_BEFORE_BLOCK_MAP; - int sectorsInWholeMdb = (bytesInWholeMdb / (int)device.Info.SectorSize) + - (bytesInWholeMdb % (int)device.Info.SectorSize); + int sectorsInWholeMdb = (bytesInWholeMdb / (int)_device.Info.SectorSize) + + (bytesInWholeMdb % (int)_device.Info.SectorSize); - byte[] wholeMdb = device.ReadSectors(partitionStart + 2, (uint)sectorsInWholeMdb); - blockMapBytes = new byte[bytesInBlockMap]; - Array.Copy(wholeMdb, BYTES_BEFORE_BLOCK_MAP, blockMapBytes, 0, blockMapBytes.Length); + byte[] wholeMdb = _device.ReadSectors(_partitionStart + 2, (uint)sectorsInWholeMdb); + _blockMapBytes = new byte[bytesInBlockMap]; + Array.Copy(wholeMdb, BYTES_BEFORE_BLOCK_MAP, _blockMapBytes, 0, _blockMapBytes.Length); int offset = 0; - blockMap = new uint[volMDB.drNmAlBlks + 2 + 1]; + _blockMap = new uint[_volMdb.drNmAlBlks + 2 + 1]; - for(int i = 2; i < volMDB.drNmAlBlks + 2; i += 8) + for(int i = 2; i < _volMdb.drNmAlBlks + 2; i += 8) { uint tmp1 = 0; uint tmp2 = 0; uint tmp3 = 0; - if(offset + 4 <= blockMapBytes.Length) - tmp1 = BigEndianBitConverter.ToUInt32(blockMapBytes, offset); + if(offset + 4 <= _blockMapBytes.Length) + tmp1 = BigEndianBitConverter.ToUInt32(_blockMapBytes, offset); - if(offset + 4 + 4 <= blockMapBytes.Length) - tmp2 = BigEndianBitConverter.ToUInt32(blockMapBytes, offset + 4); + if(offset + 4 + 4 <= _blockMapBytes.Length) + tmp2 = BigEndianBitConverter.ToUInt32(_blockMapBytes, offset + 4); - if(offset + 8 + 4 <= blockMapBytes.Length) - tmp3 = BigEndianBitConverter.ToUInt32(blockMapBytes, offset + 8); + if(offset + 8 + 4 <= _blockMapBytes.Length) + tmp3 = BigEndianBitConverter.ToUInt32(_blockMapBytes, offset + 8); - if(i < blockMap.Length) - blockMap[i] = (tmp1 & 0xFFF00000) >> 20; + if(i < _blockMap.Length) + _blockMap[i] = (tmp1 & 0xFFF00000) >> 20; - if(i + 2 < blockMap.Length) - blockMap[i + 1] = (tmp1 & 0xFFF00) >> 8; + if(i + 2 < _blockMap.Length) + _blockMap[i + 1] = (tmp1 & 0xFFF00) >> 8; - if(i + 3 < blockMap.Length) - blockMap[i + 2] = ((tmp1 & 0xFF) << 4) + ((tmp2 & 0xF0000000) >> 28); + if(i + 3 < _blockMap.Length) + _blockMap[i + 2] = ((tmp1 & 0xFF) << 4) + ((tmp2 & 0xF0000000) >> 28); - if(i + 4 < blockMap.Length) - blockMap[i + 3] = (tmp2 & 0xFFF0000) >> 16; + if(i + 4 < _blockMap.Length) + _blockMap[i + 3] = (tmp2 & 0xFFF0000) >> 16; - if(i + 5 < blockMap.Length) - blockMap[i + 4] = (tmp2 & 0xFFF0) >> 4; + if(i + 5 < _blockMap.Length) + _blockMap[i + 4] = (tmp2 & 0xFFF0) >> 4; - if(i + 6 < blockMap.Length) - blockMap[i + 5] = ((tmp2 & 0xF) << 8) + ((tmp3 & 0xFF000000) >> 24); + if(i + 6 < _blockMap.Length) + _blockMap[i + 5] = ((tmp2 & 0xF) << 8) + ((tmp3 & 0xFF000000) >> 24); - if(i + 7 < blockMap.Length) - blockMap[i + 6] = (tmp3 & 0xFFF000) >> 12; + if(i + 7 < _blockMap.Length) + _blockMap[i + 6] = (tmp3 & 0xFFF000) >> 12; - if(i + 8 < blockMap.Length) - blockMap[i + 7] = tmp3 & 0xFFF; + if(i + 8 < _blockMap.Length) + _blockMap[i + 7] = tmp3 & 0xFFF; offset += 12; } - if(device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) + if(_device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) { - mdbTags = device.ReadSectorTag(2 + partitionStart, SectorTagType.AppleSectorTag); - bootTags = device.ReadSectorTag(0 + partitionStart, SectorTagType.AppleSectorTag); + _mdbTags = _device.ReadSectorTag(2 + _partitionStart, SectorTagType.AppleSectorTag); + _bootTags = _device.ReadSectorTag(0 + _partitionStart, SectorTagType.AppleSectorTag); - directoryTags = device.ReadSectorsTag(volMDB.drDirSt + partitionStart, volMDB.drBlLen, - SectorTagType.AppleSectorTag); + _directoryTags = _device.ReadSectorsTag(_volMdb.drDirSt + _partitionStart, _volMdb.drBlLen, + SectorTagType.AppleSectorTag); - bitmapTags = device.ReadSectorsTag(partitionStart + 2, (uint)sectorsInWholeMdb, - SectorTagType.AppleSectorTag); + _bitmapTags = _device.ReadSectorsTag(_partitionStart + 2, (uint)sectorsInWholeMdb, + SectorTagType.AppleSectorTag); } - sectorsPerBlock = (int)(volMDB.drAlBlkSiz / device.Info.SectorSize); + _sectorsPerBlock = (int)(_volMdb.drAlBlkSiz / _device.Info.SectorSize); if(!FillDirectory()) return Errno.InvalidArgument; - mounted = true; + _mounted = true; - ushort bbSig = BigEndianBitConverter.ToUInt16(bootBlocks, 0x000); + ushort bbSig = BigEndianBitConverter.ToUInt16(_bootBlocks, 0x000); if(bbSig != AppleCommon.BB_MAGIC) - bootBlocks = null; + _bootBlocks = null; XmlFsType = new FileSystemType(); - if(volMDB.drLsBkUp > 0) + if(_volMdb.drLsBkUp > 0) { - XmlFsType.BackupDate = DateHandlers.MacToDateTime(volMDB.drLsBkUp); + XmlFsType.BackupDate = DateHandlers.MacToDateTime(_volMdb.drLsBkUp); XmlFsType.BackupDateSpecified = true; } XmlFsType.Bootable = bbSig == AppleCommon.BB_MAGIC; - XmlFsType.Clusters = volMDB.drNmAlBlks; - XmlFsType.ClusterSize = volMDB.drAlBlkSiz; + XmlFsType.Clusters = _volMdb.drNmAlBlks; + XmlFsType.ClusterSize = _volMdb.drAlBlkSiz; - if(volMDB.drCrDate > 0) + if(_volMdb.drCrDate > 0) { - XmlFsType.CreationDate = DateHandlers.MacToDateTime(volMDB.drCrDate); + XmlFsType.CreationDate = DateHandlers.MacToDateTime(_volMdb.drCrDate); XmlFsType.CreationDateSpecified = true; } - XmlFsType.Files = volMDB.drNmFls; + XmlFsType.Files = _volMdb.drNmFls; XmlFsType.FilesSpecified = true; - XmlFsType.FreeClusters = volMDB.drFreeBks; + XmlFsType.FreeClusters = _volMdb.drFreeBks; XmlFsType.FreeClustersSpecified = true; XmlFsType.Type = "MFS"; - XmlFsType.VolumeName = volMDB.drVN; + XmlFsType.VolumeName = _volMdb.drVN; return Errno.NoError; } public Errno Unmount() { - mounted = false; - idToFilename = null; - idToEntry = null; - filenameToId = null; - bootBlocks = null; + _mounted = false; + _idToFilename = null; + _idToEntry = null; + _filenameToId = null; + _bootBlocks = null; return Errno.NoError; } @@ -209,10 +210,10 @@ namespace Aaru.Filesystems { stat = new FileSystemInfo { - Blocks = volMDB.drNmAlBlks, + Blocks = _volMdb.drNmAlBlks, FilenameLength = 255, - Files = volMDB.drNmFls, - FreeBlocks = volMDB.drFreeBks, + Files = _volMdb.drNmFls, + FreeBlocks = _volMdb.drFreeBks, PluginId = Id, Type = "Apple MFS" }; diff --git a/Aaru.Filesystems/AppleMFS/Xattr.cs b/Aaru.Filesystems/AppleMFS/Xattr.cs index cd2cbd0aa..c55b998b6 100644 --- a/Aaru.Filesystems/AppleMFS/Xattr.cs +++ b/Aaru.Filesystems/AppleMFS/Xattr.cs @@ -46,7 +46,7 @@ namespace Aaru.Filesystems { xattrs = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -61,36 +61,36 @@ namespace Aaru.Filesystems xattrs = new List(); - if(debug) + if(_debug) if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0) { - if(device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) + if(_device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) xattrs.Add("com.apple.macintosh.tags"); return Errno.NoError; } - if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) + if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return Errno.NoSuchFile; - if(!idToEntry.TryGetValue(fileId, out FileEntry entry)) + if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return Errno.NoSuchFile; if(entry.flRLgLen > 0) { xattrs.Add("com.apple.ResourceFork"); - if(debug && device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) + if(_debug && _device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) xattrs.Add("com.apple.ResourceFork.tags"); } xattrs.Add("com.apple.FinderInfo"); - if(debug && - device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) && + if(_debug && + _device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) && entry.flLgLen > 0) xattrs.Add("com.apple.macintosh.tags"); @@ -101,7 +101,7 @@ namespace Aaru.Filesystems public Errno GetXattr(string path, string xattr, ref byte[] buf) { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -114,42 +114,42 @@ namespace Aaru.Filesystems path = pathElements[0]; - if(debug) + if(_debug) if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0) - if(device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) && + if(_device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) && string.Compare(xattr, "com.apple.macintosh.tags", StringComparison.InvariantCulture) == 0) { if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0) { - buf = new byte[directoryTags.Length]; - Array.Copy(directoryTags, 0, buf, 0, buf.Length); + buf = new byte[_directoryTags.Length]; + Array.Copy(_directoryTags, 0, buf, 0, buf.Length); return Errno.NoError; } if(string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0) { - buf = new byte[bitmapTags.Length]; - Array.Copy(bitmapTags, 0, buf, 0, buf.Length); + buf = new byte[_bitmapTags.Length]; + Array.Copy(_bitmapTags, 0, buf, 0, buf.Length); return Errno.NoError; } if(string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0) { - buf = new byte[bootTags.Length]; - Array.Copy(bootTags, 0, buf, 0, buf.Length); + buf = new byte[_bootTags.Length]; + Array.Copy(_bootTags, 0, buf, 0, buf.Length); return Errno.NoError; } if(string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0) { - buf = new byte[mdbTags.Length]; - Array.Copy(mdbTags, 0, buf, 0, buf.Length); + buf = new byte[_mdbTags.Length]; + Array.Copy(_mdbTags, 0, buf, 0, buf.Length); return Errno.NoError; } @@ -159,10 +159,10 @@ namespace Aaru.Filesystems Errno error; - if(!filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) + if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) return Errno.NoSuchFile; - if(!idToEntry.TryGetValue(fileId, out FileEntry entry)) + if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) return Errno.NoSuchFile; if(entry.flRLgLen > 0 && @@ -188,8 +188,8 @@ namespace Aaru.Filesystems return Errno.NoError; } - if(!debug || - !device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) || + if(!_debug || + !_device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) || string.Compare(xattr, "com.apple.macintosh.tags", StringComparison.InvariantCulture) != 0) return Errno.NoSuchExtendedAttribute; diff --git a/Aaru.Filesystems/AtheOS.cs b/Aaru.Filesystems/AtheOS.cs index 476acaab7..ed4c3777b 100644 --- a/Aaru.Filesystems/AtheOS.cs +++ b/Aaru.Filesystems/AtheOS.cs @@ -104,7 +104,7 @@ namespace Aaru.Filesystems byte[] sbSector = new byte[AFS_SUPERBLOCK_SIZE]; Array.Copy(tmp, offset, sbSector, 0, AFS_SUPERBLOCK_SIZE); - AtheosSuperBlock afsSb = Marshal.ByteArrayToStructureLittleEndian(sbSector); + SuperBlock afsSb = Marshal.ByteArrayToStructureLittleEndian(sbSector); sb.AppendLine("Atheos filesystem"); @@ -168,7 +168,7 @@ namespace Aaru.Filesystems /// Be superblock [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AtheosSuperBlock + struct SuperBlock { /// 0x000, Volume name, 32 bytes [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] diff --git a/Aaru.Filesystems/BFS.cs b/Aaru.Filesystems/BFS.cs index 33f17e518..f73b497e4 100644 --- a/Aaru.Filesystems/BFS.cs +++ b/Aaru.Filesystems/BFS.cs @@ -106,7 +106,7 @@ namespace Aaru.Filesystems var sb = new StringBuilder(); - var besb = new BeSuperBlock(); + var besb = new SuperBlock(); byte[] sbSector = imagePlugin.ReadSector(0 + partition.Start); @@ -145,9 +145,9 @@ namespace Aaru.Filesystems } if(littleEndian) - besb = Marshal.ByteArrayToStructureLittleEndian(sbSector); + besb = Marshal.ByteArrayToStructureLittleEndian(sbSector); else - besb = Marshal.ByteArrayToStructureBigEndian(sbSector); + besb = Marshal.ByteArrayToStructureBigEndian(sbSector); sb.AppendLine(littleEndian ? "Little-endian BeFS" : "Big-endian BeFS"); @@ -239,7 +239,7 @@ namespace Aaru.Filesystems /// Be superblock [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BeSuperBlock + struct SuperBlock { /// 0x000, Volume name, 32 bytes [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] diff --git a/Aaru.Filesystems/CBM.cs b/Aaru.Filesystems/CBM.cs index d20271b8c..9081a9764 100644 --- a/Aaru.Filesystems/CBM.cs +++ b/Aaru.Filesystems/CBM.cs @@ -70,7 +70,7 @@ namespace Aaru.Filesystems if(imagePlugin.Info.Sectors == 3200) { sector = imagePlugin.ReadSector(1560); - CommodoreHeader cbmHdr = Marshal.ByteArrayToStructureLittleEndian(sector); + Header cbmHdr = Marshal.ByteArrayToStructureLittleEndian
(sector); if(cbmHdr.diskDosVersion == 0x44 && cbmHdr.dosVersion == 0x33 && @@ -80,7 +80,7 @@ namespace Aaru.Filesystems else { sector = imagePlugin.ReadSector(357); - CommodoreBam cbmBam = Marshal.ByteArrayToStructureLittleEndian(sector); + BAM cbmBam = Marshal.ByteArrayToStructureLittleEndian(sector); if(cbmBam.dosVersion == 0x41 && (cbmBam.doubleSided == 0x00 || cbmBam.doubleSided == 0x80) && @@ -112,7 +112,7 @@ namespace Aaru.Filesystems if(imagePlugin.Info.Sectors == 3200) { sector = imagePlugin.ReadSector(1560); - CommodoreHeader cbmHdr = Marshal.ByteArrayToStructureLittleEndian(sector); + Header cbmHdr = Marshal.ByteArrayToStructureLittleEndian
(sector); sbInformation.AppendFormat("Directory starts at track {0} sector {1}", cbmHdr.directoryTrack, cbmHdr.directorySector).AppendLine(); @@ -143,7 +143,7 @@ namespace Aaru.Filesystems else { sector = imagePlugin.ReadSector(357); - CommodoreBam cbmBam = Marshal.ByteArrayToStructureLittleEndian(sector); + BAM cbmBam = Marshal.ByteArrayToStructureLittleEndian(sector); sbInformation.AppendFormat("Directory starts at track {0} sector {1}", cbmBam.directoryTrack, cbmBam.directorySector).AppendLine(); @@ -170,7 +170,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CommodoreBam + struct BAM { /// Track where directory starts public readonly byte directoryTrack; @@ -213,7 +213,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CommodoreHeader + struct Header { /// Track where directory starts public readonly byte directoryTrack; diff --git a/Aaru.Filesystems/CPM/CPM.cs b/Aaru.Filesystems/CPM/CPM.cs index 76fcb2e27..9fb59226b 100644 --- a/Aaru.Filesystems/CPM/CPM.cs +++ b/Aaru.Filesystems/CPM/CPM.cs @@ -42,42 +42,42 @@ namespace Aaru.Filesystems internal partial class CPM : IReadOnlyFilesystem { /// True if thinks this is a CP/M filesystem - bool cpmFound; + bool _cpmFound; /// Cached - FileSystemInfo cpmStat; + FileSystemInfo _cpmStat; /// Cached file passwords, decoded - Dictionary decodedPasswordCache; + Dictionary _decodedPasswordCache; /// Stores all known CP/M disk definitions - CpmDefinitions definitions; - IMediaImage device; + CpmDefinitions _definitions; + IMediaImage _device; /// Cached directory listing - List dirList; + List _dirList; /// CP/M disc parameter block (on-memory) - DiscParameterBlock dpb; + DiscParameterBlock _dpb; /// Cached file data - Dictionary fileCache; + Dictionary _fileCache; /// The volume label, if the CP/M filesystem contains one - string label; + string _label; /// Timestamp in volume label for creation - byte[] labelCreationDate; + byte[] _labelCreationDate; /// Timestamp in volume label for update - byte[] labelUpdateDate; - bool mounted; + byte[] _labelUpdateDate; + bool _mounted; /// Cached file passwords - Dictionary passwordCache; + Dictionary _passwordCache; /// Sector deinterleaving mask - int[] sectorMask; + int[] _sectorMask; /// True if there are CP/M 3 timestamps - bool standardTimestamps; + bool _standardTimestamps; /// Cached file - Dictionary statCache; + Dictionary _statCache; /// True if there are timestamps in Z80DOS or DOS+ format - bool thirdPartyTimestamps; + bool _thirdPartyTimestamps; /// If thinks this is a CP/M filesystem, this is the definition for it - CpmDefinition workingDefinition; + CpmDefinition _workingDefinition; public FileSystemType XmlFsType { get; private set; } public Encoding Encoding { get; private set; } diff --git a/Aaru.Filesystems/CPM/Consts.cs b/Aaru.Filesystems/CPM/Consts.cs index ec5ad6450..f8a60b893 100644 --- a/Aaru.Filesystems/CPM/Consts.cs +++ b/Aaru.Filesystems/CPM/Consts.cs @@ -30,6 +30,8 @@ // Copyright © 2011-2020 Natalia Portillo // ****************************************************************************/ +// ReSharper disable InconsistentNaming + namespace Aaru.Filesystems { internal partial class CPM diff --git a/Aaru.Filesystems/CPM/Definitions.cs b/Aaru.Filesystems/CPM/Definitions.cs index a5d4176ca..72a41fc12 100644 --- a/Aaru.Filesystems/CPM/Definitions.cs +++ b/Aaru.Filesystems/CPM/Definitions.cs @@ -52,10 +52,10 @@ namespace Aaru.Filesystems throw new InvalidOperationException()); var defsSerializer = new XmlSerializer(typeof(CpmDefinitions)); - definitions = (CpmDefinitions)defsSerializer.Deserialize(defsReader); + _definitions = (CpmDefinitions)defsSerializer.Deserialize(defsReader); // Patch definitions - foreach(CpmDefinition def in definitions.definitions) + foreach(CpmDefinition def in _definitions.definitions) { if(def.side1 == null) { diff --git a/Aaru.Filesystems/CPM/Dir.cs b/Aaru.Filesystems/CPM/Dir.cs index 6536536ca..0b8949707 100644 --- a/Aaru.Filesystems/CPM/Dir.cs +++ b/Aaru.Filesystems/CPM/Dir.cs @@ -44,14 +44,14 @@ namespace Aaru.Filesystems { contents = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) return Errno.NotSupported; - contents = new List(dirList); + contents = new List(_dirList); return Errno.NoError; } @@ -103,17 +103,17 @@ namespace Aaru.Filesystems entry.extension[e] != 0x00) return false; - label = Encoding.ASCII.GetString(directory, off + 1, 11).Trim(); - labelCreationDate = new byte[4]; - labelUpdateDate = new byte[4]; - Array.Copy(directory, off + 24, labelCreationDate, 0, 4); - Array.Copy(directory, off + 28, labelUpdateDate, 0, 4); + _label = Encoding.ASCII.GetString(directory, off + 1, 11).Trim(); + _labelCreationDate = new byte[4]; + _labelUpdateDate = new byte[4]; + Array.Copy(directory, off + 24, _labelCreationDate, 0, 4); + Array.Copy(directory, off + 28, _labelUpdateDate, 0, 4); } else if(entry.statusUser == 0x21) if(directory[off + 1] == 0x00) - thirdPartyTimestamps = true; + _thirdPartyTimestamps = true; else - standardTimestamps |= directory[off + 21] == 0x00 && directory[off + 31] == 0x00; + _standardTimestamps |= directory[off + 21] == 0x00 && directory[off + 31] == 0x00; } return fileCount > 0; diff --git a/Aaru.Filesystems/CPM/File.cs b/Aaru.Filesystems/CPM/File.cs index b2b07952b..763fd0426 100644 --- a/Aaru.Filesystems/CPM/File.cs +++ b/Aaru.Filesystems/CPM/File.cs @@ -42,7 +42,7 @@ namespace Aaru.Filesystems { attributes = new FileAttributes(); - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -62,7 +62,7 @@ namespace Aaru.Filesystems return Errno.NoError; } - if(!statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out FileEntryInfo fInfo)) + if(!_statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out FileEntryInfo fInfo)) return Errno.NoSuchFile; attributes = fInfo.Attributes; @@ -75,12 +75,12 @@ namespace Aaru.Filesystems { deviceBlock = 0; - return !mounted ? Errno.AccessDenied : Errno.NotImplemented; + return !_mounted ? Errno.AccessDenied : Errno.NotImplemented; } public Errno Read(string path, long offset, long size, ref byte[] buf) { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; if(size == 0) @@ -101,7 +101,7 @@ namespace Aaru.Filesystems if(pathElements.Length != 1) return Errno.NotSupported; - if(!fileCache.TryGetValue(pathElements[0].ToUpperInvariant(), out byte[] file)) + if(!_fileCache.TryGetValue(pathElements[0].ToUpperInvariant(), out byte[] file)) return Errno.NoSuchFile; if(offset >= file.Length) @@ -120,14 +120,14 @@ namespace Aaru.Filesystems { dest = null; - return !mounted ? Errno.AccessDenied : Errno.NotSupported; + return !_mounted ? Errno.AccessDenied : Errno.NotSupported; } public Errno Stat(string path, out FileEntryInfo stat) { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -140,7 +140,7 @@ namespace Aaru.Filesystems if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) - return statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out stat) ? Errno.NoError + return _statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out stat) ? Errno.NoError : Errno.NoSuchFile; stat = new FileEntryInfo @@ -149,11 +149,11 @@ namespace Aaru.Filesystems BlockSize = XmlFsType.ClusterSize }; - if(labelCreationDate != null) - stat.CreationTime = DateHandlers.CpmToDateTime(labelCreationDate); + if(_labelCreationDate != null) + stat.CreationTime = DateHandlers.CpmToDateTime(_labelCreationDate); - if(labelUpdateDate != null) - stat.StatusChangeTime = DateHandlers.CpmToDateTime(labelUpdateDate); + if(_labelUpdateDate != null) + stat.StatusChangeTime = DateHandlers.CpmToDateTime(_labelUpdateDate); return Errno.NoError; } diff --git a/Aaru.Filesystems/CPM/Info.cs b/Aaru.Filesystems/CPM/Info.cs index 36fc5f6bb..42c0de303 100644 --- a/Aaru.Filesystems/CPM/Info.cs +++ b/Aaru.Filesystems/CPM/Info.cs @@ -162,11 +162,11 @@ namespace Aaru.Filesystems ulong sectorSize; ulong firstDirectorySector; byte[] directory = null; - workingDefinition = null; - label = null; + _workingDefinition = null; + _label = null; // Try Amstrad superblock - if(!cpmFound) + if(!_cpmFound) { // Read CHS = {0,0,1} sector = imagePlugin.ReadSector(0 + partition.Start); @@ -200,63 +200,63 @@ namespace Aaru.Filesystems if(sectorSize == imagePlugin.Info.SectorSize && sectorCount == imagePlugin.Info.Sectors) { - cpmFound = true; + _cpmFound = true; firstDirectorySector = (ulong)(amsSb.off * amsSb.spt); // Build a DiscParameterBlock - dpb = new DiscParameterBlock + _dpb = new DiscParameterBlock { al0 = sectorCount == 1440 ? (byte)0xF0 : (byte)0xC0, spt = amsSb.spt, bsh = amsSb.bsh }; - for(int i = 0; i < dpb.bsh; i++) - dpb.blm += (byte)Math.Pow(2, i); + for(int i = 0; i < _dpb.bsh; i++) + _dpb.blm += (byte)Math.Pow(2, i); if(sectorCount >= 1440) { - dpb.cks = 0x40; - dpb.drm = 0xFF; + _dpb.cks = 0x40; + _dpb.drm = 0xFF; } else { - dpb.cks = 0x10; - dpb.drm = 0x3F; + _dpb.cks = 0x10; + _dpb.drm = 0x3F; } - dpb.dsm = 0; // I don't care - dpb.exm = sectorCount == 2880 ? (byte)1 : (byte)0; - dpb.off = amsSb.off; - dpb.psh = amsSb.psh; + _dpb.dsm = 0; // I don't care + _dpb.exm = sectorCount == 2880 ? (byte)1 : (byte)0; + _dpb.off = amsSb.off; + _dpb.psh = amsSb.psh; - for(int i = 0; i < dpb.psh; i++) - dpb.phm += (byte)Math.Pow(2, i); + for(int i = 0; i < _dpb.psh; i++) + _dpb.phm += (byte)Math.Pow(2, i); - dpb.spt = (ushort)(amsSb.spt * (sectorSize / 128)); - uint directoryLength = (uint)((((ulong)dpb.drm + 1) * 32) / sectorSize); + _dpb.spt = (ushort)(amsSb.spt * (sectorSize / 128)); + uint directoryLength = (uint)((((ulong)_dpb.drm + 1) * 32) / sectorSize); directory = imagePlugin.ReadSectors(firstDirectorySector + partition.Start, directoryLength); // Build a CP/M disk definition - workingDefinition = new CpmDefinition + _workingDefinition = new CpmDefinition { - al0 = dpb.al0, - al1 = dpb.al1, + al0 = _dpb.al0, + al1 = _dpb.al1, bitrate = "LOW", - blm = dpb.blm, - bsh = dpb.bsh, + blm = _dpb.blm, + bsh = _dpb.bsh, bytesPerSector = 512, cylinders = amsSb.tps, - drm = dpb.drm, - dsm = dpb.dsm, + drm = _dpb.drm, + dsm = _dpb.dsm, encoding = "MFM", evenOdd = false, - exm = dpb.exm, + exm = _dpb.exm, label = null, comment = "Amstrad PCW superblock", - ofs = dpb.off, + ofs = _dpb.off, sectorsPerTrack = amsSb.spt, side1 = new Side { @@ -266,40 +266,40 @@ namespace Aaru.Filesystems }; for(int si = 0; si < amsSb.spt; si++) - workingDefinition.side1.sectorIds[si] = si + 1; + _workingDefinition.side1.sectorIds[si] = si + 1; if(amsSb.format == 2) { switch(amsSb.sidedness & 0x02) { case 1: - workingDefinition.order = "SIDES"; + _workingDefinition.order = "SIDES"; break; case 2: - workingDefinition.order = "CYLINDERS"; + _workingDefinition.order = "CYLINDERS"; break; default: - workingDefinition.order = null; + _workingDefinition.order = null; break; } - workingDefinition.side2 = new Side + _workingDefinition.side2 = new Side { sideId = 1, sectorIds = new int[amsSb.spt] }; for(int si = 0; si < amsSb.spt; si++) - workingDefinition.side2.sectorIds[si] = si + 1; + _workingDefinition.side2.sectorIds[si] = si + 1; } else - workingDefinition.order = null; + _workingDefinition.order = null; - workingDefinition.skew = 2; - workingDefinition.sofs = 0; + _workingDefinition.skew = 2; + _workingDefinition.sofs = 0; AaruConsole.DebugWriteLine("CP/M Plugin", "Found Amstrad superblock."); } @@ -307,7 +307,7 @@ namespace Aaru.Filesystems } // Try CP/M-86 superblock for hard disks - if(!cpmFound) + if(!_cpmFound) { // Read CHS = {0,0,4} sector = imagePlugin.ReadSector(3 + partition.Start); @@ -336,11 +336,11 @@ namespace Aaru.Filesystems startingSector == partition.Start && sectorsInPartition + partition.Start <= partition.End) { - cpmFound = true; + _cpmFound = true; firstDirectorySector = (ulong)(hddSb.off * hddSb.sectorsPerTrack); // Build a DiscParameterBlock - dpb = new DiscParameterBlock + _dpb = new DiscParameterBlock { al0 = (byte)hddSb.al0, al1 = (byte)hddSb.al1, @@ -360,7 +360,7 @@ namespace Aaru.Filesystems spt = hddSb.spt }; - uint directoryLength = (uint)((((ulong)dpb.drm + 1) * 32) / sectorSize); + uint directoryLength = (uint)((((ulong)_dpb.drm + 1) * 32) / sectorSize); directory = imagePlugin.ReadSectors(firstDirectorySector + partition.Start, directoryLength); @@ -368,23 +368,23 @@ namespace Aaru.Filesystems AaruConsole.DebugWriteLine("CP/M Plugin", "Found CP/M-86 hard disk superblock."); // Build a CP/M disk definition - workingDefinition = new CpmDefinition + _workingDefinition = new CpmDefinition { - al0 = dpb.al0, - al1 = dpb.al1, + al0 = _dpb.al0, + al1 = _dpb.al1, bitrate = "HIGH", - blm = dpb.blm, - bsh = dpb.bsh, + blm = _dpb.blm, + bsh = _dpb.bsh, bytesPerSector = 512, cylinders = hddSb.cylinders, - drm = dpb.drm, - dsm = dpb.dsm, + drm = _dpb.drm, + dsm = _dpb.dsm, encoding = "MFM", evenOdd = false, - exm = dpb.exm, + exm = _dpb.exm, label = null, comment = "CP/M-86 hard disk superblock", - ofs = dpb.off, + ofs = _dpb.off, sectorsPerTrack = hddSb.sectorsPerTrack, side1 = new Side { @@ -402,16 +402,16 @@ namespace Aaru.Filesystems }; for(int si = 0; si < hddSb.sectorsPerTrack; si++) - workingDefinition.side1.sectorIds[si] = si + 1; + _workingDefinition.side1.sectorIds[si] = si + 1; for(int si = 0; si < hddSb.spt; si++) - workingDefinition.side2.sectorIds[si] = si + 1; + _workingDefinition.side2.sectorIds[si] = si + 1; } } } // Try CP/M-86 format ID for floppies - if(!cpmFound) + if(!_cpmFound) { // Read CHS = {0,0,1} sector = imagePlugin.ReadSector(0 + partition.Start); @@ -441,10 +441,10 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize == 512 && imagePlugin.Info.Sectors == 320) { - cpmFound = true; + _cpmFound = true; firstDirectorySector86 = 8; - dpb = new DiscParameterBlock + _dpb = new DiscParameterBlock { al0 = 0xC0, al1 = 0, @@ -460,23 +460,23 @@ namespace Aaru.Filesystems spt = 8 * 4 }; - workingDefinition = new CpmDefinition + _workingDefinition = new CpmDefinition { - al0 = dpb.al0, - al1 = dpb.al1, + al0 = _dpb.al0, + al1 = _dpb.al1, bitrate = "LOW", - blm = dpb.blm, - bsh = dpb.bsh, + blm = _dpb.blm, + bsh = _dpb.bsh, bytesPerSector = 512, cylinders = 40, - drm = dpb.drm, - dsm = dpb.dsm, + drm = _dpb.drm, + dsm = _dpb.dsm, encoding = "MFM", evenOdd = false, - exm = dpb.exm, + exm = _dpb.exm, label = null, comment = "CP/M-86 floppy identifier", - ofs = dpb.off, + ofs = _dpb.off, sectorsPerTrack = 8, side1 = new Side { @@ -488,7 +488,7 @@ namespace Aaru.Filesystems }; for(int si = 0; si < 8; si++) - workingDefinition.side1.sectorIds[si] = si + 1; + _workingDefinition.side1.sectorIds[si] = si + 1; } break; @@ -496,10 +496,10 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize == 512 && imagePlugin.Info.Sectors == 640) { - cpmFound = true; + _cpmFound = true; firstDirectorySector86 = 16; - dpb = new DiscParameterBlock + _dpb = new DiscParameterBlock { al0 = 0x80, al1 = 0, @@ -515,23 +515,23 @@ namespace Aaru.Filesystems spt = 8 * 4 }; - workingDefinition = new CpmDefinition + _workingDefinition = new CpmDefinition { - al0 = dpb.al0, - al1 = dpb.al1, + al0 = _dpb.al0, + al1 = _dpb.al1, bitrate = "LOW", - blm = dpb.blm, - bsh = dpb.bsh, + blm = _dpb.blm, + bsh = _dpb.bsh, bytesPerSector = 512, cylinders = 40, - drm = dpb.drm, - dsm = dpb.dsm, + drm = _dpb.drm, + dsm = _dpb.dsm, encoding = "MFM", evenOdd = false, - exm = dpb.exm, + exm = _dpb.exm, label = null, comment = "CP/M-86 floppy identifier", - ofs = dpb.off, + ofs = _dpb.off, sectorsPerTrack = 8, side1 = new Side { @@ -549,10 +549,10 @@ namespace Aaru.Filesystems }; for(int si = 0; si < 8; si++) - workingDefinition.side1.sectorIds[si] = si + 1; + _workingDefinition.side1.sectorIds[si] = si + 1; for(int si = 0; si < 8; si++) - workingDefinition.side2.sectorIds[si] = si + 1; + _workingDefinition.side2.sectorIds[si] = si + 1; } break; @@ -562,10 +562,10 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize == 512 && imagePlugin.Info.Sectors == 720) { - cpmFound = true; + _cpmFound = true; firstDirectorySector86 = 36; - dpb = new DiscParameterBlock + _dpb = new DiscParameterBlock { al0 = 0x80, al1 = 0, @@ -581,23 +581,23 @@ namespace Aaru.Filesystems spt = 9 * 4 }; - workingDefinition = new CpmDefinition + _workingDefinition = new CpmDefinition { - al0 = dpb.al0, - al1 = dpb.al1, + al0 = _dpb.al0, + al1 = _dpb.al1, bitrate = "LOW", - blm = dpb.blm, - bsh = dpb.bsh, + blm = _dpb.blm, + bsh = _dpb.bsh, bytesPerSector = 512, cylinders = 40, - drm = dpb.drm, - dsm = dpb.dsm, + drm = _dpb.drm, + dsm = _dpb.dsm, encoding = "MFM", evenOdd = false, - exm = dpb.exm, + exm = _dpb.exm, label = null, comment = "CP/M-86 floppy identifier", - ofs = dpb.off, + ofs = _dpb.off, sectorsPerTrack = 9, side1 = new Side { @@ -615,10 +615,10 @@ namespace Aaru.Filesystems }; for(int si = 0; si < 9; si++) - workingDefinition.side1.sectorIds[si] = si + 1; + _workingDefinition.side1.sectorIds[si] = si + 1; for(int si = 0; si < 9; si++) - workingDefinition.side2.sectorIds[si] = si + 1; + _workingDefinition.side2.sectorIds[si] = si + 1; } break; @@ -627,10 +627,10 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize == 512 && imagePlugin.Info.Sectors == 1440) { - cpmFound = true; + _cpmFound = true; firstDirectorySector86 = 36; - dpb = new DiscParameterBlock + _dpb = new DiscParameterBlock { al0 = 0xF0, al1 = 0, @@ -646,23 +646,23 @@ namespace Aaru.Filesystems spt = 9 * 4 }; - workingDefinition = new CpmDefinition + _workingDefinition = new CpmDefinition { - al0 = dpb.al0, - al1 = dpb.al1, + al0 = _dpb.al0, + al1 = _dpb.al1, bitrate = "LOW", - blm = dpb.blm, - bsh = dpb.bsh, + blm = _dpb.blm, + bsh = _dpb.bsh, bytesPerSector = 512, cylinders = 80, - drm = dpb.drm, - dsm = dpb.dsm, + drm = _dpb.drm, + dsm = _dpb.dsm, encoding = "MFM", evenOdd = false, - exm = dpb.exm, + exm = _dpb.exm, label = null, comment = "CP/M-86 floppy identifier", - ofs = dpb.off, + ofs = _dpb.off, sectorsPerTrack = 9, side1 = new Side { @@ -680,10 +680,10 @@ namespace Aaru.Filesystems }; for(int si = 0; si < 9; si++) - workingDefinition.side1.sectorIds[si] = si + 1; + _workingDefinition.side1.sectorIds[si] = si + 1; for(int si = 0; si < 9; si++) - workingDefinition.side2.sectorIds[si] = si + 1; + _workingDefinition.side2.sectorIds[si] = si + 1; } break; @@ -691,10 +691,10 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize == 512 && imagePlugin.Info.Sectors == 1440) { - cpmFound = true; + _cpmFound = true; firstDirectorySector86 = 18; - dpb = new DiscParameterBlock + _dpb = new DiscParameterBlock { al0 = 0xF0, al1 = 0, @@ -710,23 +710,23 @@ namespace Aaru.Filesystems spt = 9 * 4 }; - workingDefinition = new CpmDefinition + _workingDefinition = new CpmDefinition { - al0 = dpb.al0, - al1 = dpb.al1, + al0 = _dpb.al0, + al1 = _dpb.al1, bitrate = "LOW", - blm = dpb.blm, - bsh = dpb.bsh, + blm = _dpb.blm, + bsh = _dpb.bsh, bytesPerSector = 512, cylinders = 80, - drm = dpb.drm, - dsm = dpb.dsm, + drm = _dpb.drm, + dsm = _dpb.dsm, encoding = "MFM", evenOdd = false, - exm = dpb.exm, + exm = _dpb.exm, label = null, comment = "CP/M-86 floppy identifier", - ofs = dpb.off, + ofs = _dpb.off, sectorsPerTrack = 9, side1 = new Side { @@ -744,10 +744,10 @@ namespace Aaru.Filesystems }; for(int si = 0; si < 9; si++) - workingDefinition.side1.sectorIds[si] = si + 1; + _workingDefinition.side1.sectorIds[si] = si + 1; for(int si = 0; si < 9; si++) - workingDefinition.side2.sectorIds[si] = si + 1; + _workingDefinition.side2.sectorIds[si] = si + 1; } break; @@ -755,10 +755,10 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize == 512 && imagePlugin.Info.Sectors == 2400) { - cpmFound = true; + _cpmFound = true; firstDirectorySector86 = 30; - dpb = new DiscParameterBlock + _dpb = new DiscParameterBlock { al0 = 0xC0, al1 = 0, @@ -774,23 +774,23 @@ namespace Aaru.Filesystems spt = 15 * 4 }; - workingDefinition = new CpmDefinition + _workingDefinition = new CpmDefinition { - al0 = dpb.al0, - al1 = dpb.al1, + al0 = _dpb.al0, + al1 = _dpb.al1, bitrate = "HIGH", - blm = dpb.blm, - bsh = dpb.bsh, + blm = _dpb.blm, + bsh = _dpb.bsh, bytesPerSector = 512, cylinders = 80, - drm = dpb.drm, - dsm = dpb.dsm, + drm = _dpb.drm, + dsm = _dpb.dsm, encoding = "MFM", evenOdd = false, - exm = dpb.exm, + exm = _dpb.exm, label = null, comment = "CP/M-86 floppy identifier", - ofs = dpb.off, + ofs = _dpb.off, sectorsPerTrack = 15, side1 = new Side { @@ -808,10 +808,10 @@ namespace Aaru.Filesystems }; for(int si = 0; si < 15; si++) - workingDefinition.side1.sectorIds[si] = si + 1; + _workingDefinition.side1.sectorIds[si] = si + 1; for(int si = 0; si < 15; si++) - workingDefinition.side2.sectorIds[si] = si + 1; + _workingDefinition.side2.sectorIds[si] = si + 1; } break; @@ -819,10 +819,10 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize == 512 && imagePlugin.Info.Sectors == 2880) { - cpmFound = true; + _cpmFound = true; firstDirectorySector86 = 36; - dpb = new DiscParameterBlock + _dpb = new DiscParameterBlock { al0 = 0xC0, al1 = 0, @@ -838,23 +838,23 @@ namespace Aaru.Filesystems spt = 18 * 4 }; - workingDefinition = new CpmDefinition + _workingDefinition = new CpmDefinition { - al0 = dpb.al0, - al1 = dpb.al1, + al0 = _dpb.al0, + al1 = _dpb.al1, bitrate = "LOW", - blm = dpb.blm, - bsh = dpb.bsh, + blm = _dpb.blm, + bsh = _dpb.bsh, bytesPerSector = 512, cylinders = 80, - drm = dpb.drm, - dsm = dpb.dsm, + drm = _dpb.drm, + dsm = _dpb.dsm, encoding = "MFM", evenOdd = false, - exm = dpb.exm, + exm = _dpb.exm, label = null, comment = "CP/M-86 floppy identifier", - ofs = dpb.off, + ofs = _dpb.off, sectorsPerTrack = 18, side1 = new Side { @@ -872,25 +872,25 @@ namespace Aaru.Filesystems }; for(int si = 0; si < 18; si++) - workingDefinition.side1.sectorIds[si] = si + 1; + _workingDefinition.side1.sectorIds[si] = si + 1; for(int si = 0; si < 18; si++) - workingDefinition.side2.sectorIds[si] = si + 1; + _workingDefinition.side2.sectorIds[si] = si + 1; } break; } - if(cpmFound) + if(_cpmFound) { - uint directoryLength = (uint)((((ulong)dpb.drm + 1) * 32) / imagePlugin.Info.SectorSize); + uint directoryLength = (uint)((((ulong)_dpb.drm + 1) * 32) / imagePlugin.Info.SectorSize); directory = imagePlugin.ReadSectors(firstDirectorySector86 + partition.Start, directoryLength); AaruConsole.DebugWriteLine("CP/M Plugin", "Found CP/M-86 floppy identifier."); } } // One of the few CP/M filesystem marks has been found, try for correcteness checking the whole directory - if(cpmFound) + if(_cpmFound) { if(CheckDir(directory)) { @@ -899,22 +899,22 @@ namespace Aaru.Filesystems return true; } - cpmFound = false; + _cpmFound = false; } // Try all definitions - if(!cpmFound) + if(!_cpmFound) { // Load all definitions AaruConsole.DebugWriteLine("CP/M Plugin", "Trying to load definitions."); - if(LoadDefinitions() && - definitions?.definitions != null && - definitions.definitions.Count > 0) + if(LoadDefinitions() && + _definitions?.definitions != null && + _definitions.definitions.Count > 0) { AaruConsole.DebugWriteLine("CP/M Plugin", "Trying all known definitions."); - foreach(CpmDefinition def in from def in definitions.definitions let sectors = + foreach(CpmDefinition def in from def in _definitions.definitions let sectors = (ulong)(def.cylinders * def.sides * def.sectorsPerTrack) where sectors == imagePlugin.Info.Sectors && def.bytesPerSector == imagePlugin.Info.SectorSize select def) @@ -932,24 +932,24 @@ namespace Aaru.Filesystems if(def.sides == 1) { - sectorMask = new int[def.side1.sectorIds.Length]; + _sectorMask = new int[def.side1.sectorIds.Length]; - for(int m = 0; m < sectorMask.Length; m++) - sectorMask[m] = def.side1.sectorIds[m] - def.side1.sectorIds[0]; + for(int m = 0; m < _sectorMask.Length; m++) + _sectorMask[m] = def.side1.sectorIds[m] - def.side1.sectorIds[0]; } else { // Head changes after every track if(string.Compare(def.order, "SIDES", StringComparison.InvariantCultureIgnoreCase) == 0) { - sectorMask = new int[def.side1.sectorIds.Length + def.side2.sectorIds.Length]; + _sectorMask = new int[def.side1.sectorIds.Length + def.side2.sectorIds.Length]; for(int m = 0; m < def.side1.sectorIds.Length; m++) - sectorMask[m] = def.side1.sectorIds[m] - def.side1.sectorIds[0]; + _sectorMask[m] = def.side1.sectorIds[m] - def.side1.sectorIds[0]; // Skip first track (first side) for(int m = 0; m < def.side2.sectorIds.Length; m++) - sectorMask[m + def.side1.sectorIds.Length] = + _sectorMask[m + def.side1.sectorIds.Length] = (def.side2.sectorIds[m] - def.side2.sectorIds[0]) + def.side1.sectorIds.Length; } @@ -959,11 +959,11 @@ namespace Aaru.Filesystems StringComparison.InvariantCultureIgnoreCase) == 0) { for(int m = 0; m < def.side1.sectorIds.Length; m++) - sectorMask[m] = def.side1.sectorIds[m] - def.side1.sectorIds[0]; + _sectorMask[m] = def.side1.sectorIds[m] - def.side1.sectorIds[0]; // Skip first track (first side) and first track (second side) for(int m = 0; m < def.side1.sectorIds.Length; m++) - sectorMask[m + def.side1.sectorIds.Length] = + _sectorMask[m + def.side1.sectorIds.Length] = (def.side1.sectorIds[m] - def.side1.sectorIds[0]) + def.side1.sectorIds.Length + def.side2.sectorIds.Length; } @@ -1004,8 +1004,8 @@ namespace Aaru.Filesystems { byte[] dirSector = imagePlugin.ReadSector((ulong)((int)offset + (int)partition.Start + - ((p / sectorMask.Length) * sectorMask.Length) + - sectorMask[p % sectorMask.Length])); + ((p / _sectorMask.Length) * _sectorMask.Length) + + _sectorMask[p % _sectorMask.Length])); ms.Write(dirSector, 0, dirSector.Length); } @@ -1028,9 +1028,9 @@ namespace Aaru.Filesystems def.comment); // Build a Disc Parameter Block - workingDefinition = def; + _workingDefinition = def; - dpb = new DiscParameterBlock + _dpb = new DiscParameterBlock { al0 = (byte)def.al0, al1 = (byte)def.al1, @@ -1049,72 +1049,72 @@ namespace Aaru.Filesystems switch(def.bytesPerSector) { case 128: - dpb.psh = 0; - dpb.phm = 0; + _dpb.psh = 0; + _dpb.phm = 0; break; case 256: - dpb.psh = 1; - dpb.phm = 1; + _dpb.psh = 1; + _dpb.phm = 1; break; case 512: - dpb.psh = 2; - dpb.phm = 3; + _dpb.psh = 2; + _dpb.phm = 3; break; case 1024: - dpb.psh = 3; - dpb.phm = 7; + _dpb.psh = 3; + _dpb.phm = 7; break; case 2048: - dpb.psh = 4; - dpb.phm = 15; + _dpb.psh = 4; + _dpb.phm = 15; break; case 4096: - dpb.psh = 5; - dpb.phm = 31; + _dpb.psh = 5; + _dpb.phm = 31; break; case 8192: - dpb.psh = 6; - dpb.phm = 63; + _dpb.psh = 6; + _dpb.phm = 63; break; case 16384: - dpb.psh = 7; - dpb.phm = 127; + _dpb.psh = 7; + _dpb.phm = 127; break; case 32768: - dpb.psh = 8; - dpb.phm = 255; + _dpb.psh = 8; + _dpb.phm = 255; break; } - cpmFound = true; - workingDefinition = def; + _cpmFound = true; + _workingDefinition = def; return true; } - label = null; - labelCreationDate = null; - labelUpdateDate = null; + _label = null; + _labelCreationDate = null; + _labelUpdateDate = null; } } } // Clear class variables - cpmFound = false; - workingDefinition = null; - dpb = null; - label = null; - standardTimestamps = false; - thirdPartyTimestamps = false; + _cpmFound = false; + _workingDefinition = null; + _dpb = null; + _label = null; + _standardTimestamps = false; + _thirdPartyTimestamps = false; return false; } @@ -1133,51 +1133,51 @@ namespace Aaru.Filesystems // As the identification is so complex, just call Identify() and relay on its findings if(!Identify(imagePlugin, partition) || - !cpmFound || - workingDefinition == null || - dpb == null) + !_cpmFound || + _workingDefinition == null || + _dpb == null) return; var sb = new StringBuilder(); sb.AppendLine("CP/M filesystem"); - if(!string.IsNullOrEmpty(workingDefinition.comment)) - sb.AppendFormat("Identified as {0}", workingDefinition.comment).AppendLine(); + if(!string.IsNullOrEmpty(_workingDefinition.comment)) + sb.AppendFormat("Identified as {0}", _workingDefinition.comment).AppendLine(); - sb.AppendFormat("Volume block is {0} bytes", 128 << dpb.bsh).AppendLine(); + sb.AppendFormat("Volume block is {0} bytes", 128 << _dpb.bsh).AppendLine(); - if(dpb.dsm > 0) - sb.AppendFormat("Volume contains {0} blocks ({1} bytes)", dpb.dsm, dpb.dsm * (128 << dpb.bsh)). + if(_dpb.dsm > 0) + sb.AppendFormat("Volume contains {0} blocks ({1} bytes)", _dpb.dsm, _dpb.dsm * (128 << _dpb.bsh)). AppendLine(); - sb.AppendFormat("Volume contains {0} directory entries", dpb.drm + 1).AppendLine(); + sb.AppendFormat("Volume contains {0} directory entries", _dpb.drm + 1).AppendLine(); - if(workingDefinition.sofs > 0) - sb.AppendFormat("Volume reserves {0} sectors for system", workingDefinition.sofs).AppendLine(); + if(_workingDefinition.sofs > 0) + sb.AppendFormat("Volume reserves {0} sectors for system", _workingDefinition.sofs).AppendLine(); else sb.AppendFormat("Volume reserves {1} tracks ({0} sectors) for system", - workingDefinition.ofs * workingDefinition.sectorsPerTrack, workingDefinition.ofs). + _workingDefinition.ofs * _workingDefinition.sectorsPerTrack, _workingDefinition.ofs). AppendLine(); - if(workingDefinition.side1.sectorIds.Length >= 2) + if(_workingDefinition.side1.sectorIds.Length >= 2) { - int interleaveSide1 = workingDefinition.side1.sectorIds[1] - workingDefinition.side1.sectorIds[0]; + int interleaveSide1 = _workingDefinition.side1.sectorIds[1] - _workingDefinition.side1.sectorIds[0]; if(interleaveSide1 > 1) sb.AppendFormat("Side 0 uses {0}:1 software interleaving", interleaveSide1).AppendLine(); } - if(workingDefinition.sides == 2) + if(_workingDefinition.sides == 2) { - if(workingDefinition.side2.sectorIds.Length >= 2) + if(_workingDefinition.side2.sectorIds.Length >= 2) { - int interleaveSide2 = workingDefinition.side2.sectorIds[1] - workingDefinition.side2.sectorIds[0]; + int interleaveSide2 = _workingDefinition.side2.sectorIds[1] - _workingDefinition.side2.sectorIds[0]; if(interleaveSide2 > 1) sb.AppendFormat("Side 1 uses {0}:1 software interleaving", interleaveSide2).AppendLine(); } - switch(workingDefinition.order) + switch(_workingDefinition.order) { case "SIDES": sb.AppendLine("Head changes after each whole track"); @@ -1188,62 +1188,62 @@ namespace Aaru.Filesystems break; default: - sb.AppendFormat("Unknown how {0} side ordering works", workingDefinition.order).AppendLine(); + sb.AppendFormat("Unknown how {0} side ordering works", _workingDefinition.order).AppendLine(); break; } } - if(workingDefinition.skew > 0) - sb.AppendFormat("Device uses {0}:1 hardware interleaving", workingDefinition.skew).AppendLine(); + if(_workingDefinition.skew > 0) + sb.AppendFormat("Device uses {0}:1 hardware interleaving", _workingDefinition.skew).AppendLine(); - if(workingDefinition.sofs > 0) - sb.AppendFormat("BSH {0} BLM {1} EXM {2} DSM {3} DRM {4} AL0 {5:X2}H AL1 {6:X2}H SOFS {7}", dpb.bsh, - dpb.blm, dpb.exm, dpb.dsm, dpb.drm, dpb.al0, dpb.al1, workingDefinition.sofs). + if(_workingDefinition.sofs > 0) + sb.AppendFormat("BSH {0} BLM {1} EXM {2} DSM {3} DRM {4} AL0 {5:X2}H AL1 {6:X2}H SOFS {7}", _dpb.bsh, + _dpb.blm, _dpb.exm, _dpb.dsm, _dpb.drm, _dpb.al0, _dpb.al1, _workingDefinition.sofs). AppendLine(); else - sb.AppendFormat("BSH {0} BLM {1} EXM {2} DSM {3} DRM {4} AL0 {5:X2}H AL1 {6:X2}H OFS {7}", dpb.bsh, - dpb.blm, dpb.exm, dpb.dsm, dpb.drm, dpb.al0, dpb.al1, workingDefinition.ofs). + sb.AppendFormat("BSH {0} BLM {1} EXM {2} DSM {3} DRM {4} AL0 {5:X2}H AL1 {6:X2}H OFS {7}", _dpb.bsh, + _dpb.blm, _dpb.exm, _dpb.dsm, _dpb.drm, _dpb.al0, _dpb.al1, _workingDefinition.ofs). AppendLine(); - if(label != null) - sb.AppendFormat("Volume label {0}", label).AppendLine(); + if(_label != null) + sb.AppendFormat("Volume label {0}", _label).AppendLine(); - if(standardTimestamps) + if(_standardTimestamps) sb.AppendLine("Volume uses standard CP/M timestamps"); - if(thirdPartyTimestamps) + if(_thirdPartyTimestamps) sb.AppendLine("Volume uses third party timestamps"); - if(labelCreationDate != null) - sb.AppendFormat("Volume created on {0}", DateHandlers.CpmToDateTime(labelCreationDate)).AppendLine(); + if(_labelCreationDate != null) + sb.AppendFormat("Volume created on {0}", DateHandlers.CpmToDateTime(_labelCreationDate)).AppendLine(); - if(labelUpdateDate != null) - sb.AppendFormat("Volume updated on {0}", DateHandlers.CpmToDateTime(labelUpdateDate)).AppendLine(); + if(_labelUpdateDate != null) + sb.AppendFormat("Volume updated on {0}", DateHandlers.CpmToDateTime(_labelUpdateDate)).AppendLine(); XmlFsType = new FileSystemType(); - XmlFsType.Bootable |= workingDefinition.sofs > 0 || workingDefinition.ofs > 0; - XmlFsType.ClusterSize = (uint)(128 << dpb.bsh); + XmlFsType.Bootable |= _workingDefinition.sofs > 0 || _workingDefinition.ofs > 0; + XmlFsType.ClusterSize = (uint)(128 << _dpb.bsh); - if(dpb.dsm > 0) - XmlFsType.Clusters = dpb.dsm; + if(_dpb.dsm > 0) + XmlFsType.Clusters = _dpb.dsm; else XmlFsType.Clusters = partition.End - partition.Start; - if(labelCreationDate != null) + if(_labelCreationDate != null) { - XmlFsType.CreationDate = DateHandlers.CpmToDateTime(labelCreationDate); + XmlFsType.CreationDate = DateHandlers.CpmToDateTime(_labelCreationDate); XmlFsType.CreationDateSpecified = true; } - if(labelUpdateDate != null) + if(_labelUpdateDate != null) { - XmlFsType.ModificationDate = DateHandlers.CpmToDateTime(labelUpdateDate); + XmlFsType.ModificationDate = DateHandlers.CpmToDateTime(_labelUpdateDate); XmlFsType.ModificationDateSpecified = true; } XmlFsType.Type = "CP/M"; - XmlFsType.VolumeName = label; + XmlFsType.VolumeName = _label; information = sb.ToString(); } diff --git a/Aaru.Filesystems/CPM/Super.cs b/Aaru.Filesystems/CPM/Super.cs index 514ae0756..f5c3bd6c4 100644 --- a/Aaru.Filesystems/CPM/Super.cs +++ b/Aaru.Filesystems/CPM/Super.cs @@ -53,54 +53,54 @@ namespace Aaru.Filesystems public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, Dictionary options, string @namespace) { - device = imagePlugin; + _device = imagePlugin; Encoding = encoding ?? Encoding.GetEncoding("IBM437"); // As the identification is so complex, just call Identify() and relay on its findings - if(!Identify(device, partition) || - !cpmFound || - workingDefinition == null || - dpb == null) + if(!Identify(_device, partition) || + !_cpmFound || + _workingDefinition == null || + _dpb == null) return Errno.InvalidArgument; // Build the software interleaving sector mask - if(workingDefinition.sides == 1) + if(_workingDefinition.sides == 1) { - sectorMask = new int[workingDefinition.side1.sectorIds.Length]; + _sectorMask = new int[_workingDefinition.side1.sectorIds.Length]; - for(int m = 0; m < sectorMask.Length; m++) - sectorMask[m] = workingDefinition.side1.sectorIds[m] - workingDefinition.side1.sectorIds[0]; + for(int m = 0; m < _sectorMask.Length; m++) + _sectorMask[m] = _workingDefinition.side1.sectorIds[m] - _workingDefinition.side1.sectorIds[0]; } else { // Head changes after every track - if(string.Compare(workingDefinition.order, "SIDES", StringComparison.InvariantCultureIgnoreCase) == 0) + if(string.Compare(_workingDefinition.order, "SIDES", StringComparison.InvariantCultureIgnoreCase) == 0) { - sectorMask = new int[workingDefinition.side1.sectorIds.Length + - workingDefinition.side2.sectorIds.Length]; + _sectorMask = new int[_workingDefinition.side1.sectorIds.Length + + _workingDefinition.side2.sectorIds.Length]; - for(int m = 0; m < workingDefinition.side1.sectorIds.Length; m++) - sectorMask[m] = workingDefinition.side1.sectorIds[m] - workingDefinition.side1.sectorIds[0]; + for(int m = 0; m < _workingDefinition.side1.sectorIds.Length; m++) + _sectorMask[m] = _workingDefinition.side1.sectorIds[m] - _workingDefinition.side1.sectorIds[0]; // Skip first track (first side) - for(int m = 0; m < workingDefinition.side2.sectorIds.Length; m++) - sectorMask[m + workingDefinition.side1.sectorIds.Length] = - (workingDefinition.side2.sectorIds[m] - workingDefinition.side2.sectorIds[0]) + - workingDefinition.side1.sectorIds.Length; + for(int m = 0; m < _workingDefinition.side2.sectorIds.Length; m++) + _sectorMask[m + _workingDefinition.side1.sectorIds.Length] = + (_workingDefinition.side2.sectorIds[m] - _workingDefinition.side2.sectorIds[0]) + + _workingDefinition.side1.sectorIds.Length; } // Head changes after whole side - else if(string.Compare(workingDefinition.order, "CYLINDERS", + else if(string.Compare(_workingDefinition.order, "CYLINDERS", StringComparison.InvariantCultureIgnoreCase) == 0) { - for(int m = 0; m < workingDefinition.side1.sectorIds.Length; m++) - sectorMask[m] = workingDefinition.side1.sectorIds[m] - workingDefinition.side1.sectorIds[0]; + for(int m = 0; m < _workingDefinition.side1.sectorIds.Length; m++) + _sectorMask[m] = _workingDefinition.side1.sectorIds[m] - _workingDefinition.side1.sectorIds[0]; // Skip first track (first side) and first track (second side) - for(int m = 0; m < workingDefinition.side1.sectorIds.Length; m++) - sectorMask[m + workingDefinition.side1.sectorIds.Length] = - (workingDefinition.side1.sectorIds[m] - workingDefinition.side1.sectorIds[0]) + - workingDefinition.side1.sectorIds.Length + workingDefinition.side2.sectorIds.Length; + for(int m = 0; m < _workingDefinition.side1.sectorIds.Length; m++) + _sectorMask[m + _workingDefinition.side1.sectorIds.Length] = + (_workingDefinition.side1.sectorIds[m] - _workingDefinition.side1.sectorIds[0]) + + _workingDefinition.side1.sectorIds.Length + _workingDefinition.side2.sectorIds.Length; // TODO: Implement CYLINDERS ordering AaruConsole.DebugWriteLine("CP/M Plugin", "CYLINDERS ordering not yet implemented."); @@ -109,7 +109,7 @@ namespace Aaru.Filesystems } // TODO: Implement COLUMBIA ordering - else if(string.Compare(workingDefinition.order, "COLUMBIA", + else if(string.Compare(_workingDefinition.order, "COLUMBIA", StringComparison.InvariantCultureIgnoreCase) == 0) { AaruConsole.DebugWriteLine("CP/M Plugin", @@ -119,8 +119,8 @@ namespace Aaru.Filesystems } // TODO: Implement EAGLE ordering - else if(string.Compare(workingDefinition.order, "EAGLE", StringComparison.InvariantCultureIgnoreCase) == - 0) + else if(string.Compare(_workingDefinition.order, "EAGLE", + StringComparison.InvariantCultureIgnoreCase) == 0) { AaruConsole.DebugWriteLine("CP/M Plugin", "Don't know how to handle EAGLE ordering, not proceeding with this definition."); @@ -131,7 +131,7 @@ namespace Aaru.Filesystems { AaruConsole.DebugWriteLine("CP/M Plugin", "Unknown order type \"{0}\", not proceeding with this definition.", - workingDefinition.order); + _workingDefinition.order); return Errno.NotSupported; } @@ -140,18 +140,19 @@ namespace Aaru.Filesystems // Deinterleave whole volume Dictionary deinterleavedSectors = new Dictionary(); - if(workingDefinition.sides == 1 || - string.Compare(workingDefinition.order, "SIDES", StringComparison.InvariantCultureIgnoreCase) == 0) + if(_workingDefinition.sides == 1 || + string.Compare(_workingDefinition.order, "SIDES", StringComparison.InvariantCultureIgnoreCase) == 0) { AaruConsole.DebugWriteLine("CP/M Plugin", "Deinterleaving whole volume."); for(int p = 0; p <= (int)(partition.End - partition.Start); p++) { byte[] readSector = - device.ReadSector((ulong)((int)partition.Start + ((p / sectorMask.Length) * sectorMask.Length) + - sectorMask[p % sectorMask.Length])); + _device.ReadSector((ulong)((int)partition.Start + + ((p / _sectorMask.Length) * _sectorMask.Length) + + _sectorMask[p % _sectorMask.Length])); - if(workingDefinition.complement) + if(_workingDefinition.complement) for(int b = 0; b < readSector.Length; b++) readSector[b] = (byte)(~readSector[b] & 0xFF); @@ -159,7 +160,7 @@ namespace Aaru.Filesystems } } - int blockSize = 128 << dpb.bsh; + int blockSize = 128 << _dpb.bsh; var blockMs = new MemoryStream(); ulong blockNo = 0; int sectorsPerBlock = 0; @@ -203,12 +204,12 @@ namespace Aaru.Filesystems AaruConsole.DebugWriteLine("CP/M Plugin", "Reading directory."); int dirOff; - int dirSectors = ((dpb.drm + 1) * 32) / workingDefinition.bytesPerSector; + int dirSectors = ((_dpb.drm + 1) * 32) / _workingDefinition.bytesPerSector; - if(workingDefinition.sofs > 0) - dirOff = workingDefinition.sofs; + if(_workingDefinition.sofs > 0) + dirOff = _workingDefinition.sofs; else - dirOff = workingDefinition.ofs * workingDefinition.sectorsPerTrack; + dirOff = _workingDefinition.ofs * _workingDefinition.sectorsPerTrack; // Read the whole directory blocks var dirMs = new MemoryStream(); @@ -232,13 +233,13 @@ namespace Aaru.Filesystems Dictionary>> fileExtents = new Dictionary>>(); - statCache = new Dictionary(); - cpmStat = new FileSystemInfo(); + _statCache = new Dictionary(); + _cpmStat = new FileSystemInfo(); bool atime = false; - dirList = new List(); - labelCreationDate = null; - labelUpdateDate = null; - passwordCache = new Dictionary(); + _dirList = new List(); + _labelCreationDate = null; + _labelUpdateDate = null; + _passwordCache = new Dictionary(); AaruConsole.DebugWriteLine("CP/M Plugin", "Traversing directory."); @@ -286,11 +287,11 @@ namespace Aaru.Filesystems if(!string.IsNullOrEmpty(extension)) filename = filename + "." + extension; - int entryNo = ((32 * entry.extentCounter) + entry.extentCounterHigh) / (dpb.exm + 1); + int entryNo = ((32 * entry.extentCounter) + entry.extentCounterHigh) / (_dpb.exm + 1); // Do we have a stat for the file already? - if(statCache.TryGetValue(filename, out FileEntryInfo fInfo)) - statCache.Remove(filename); + if(_statCache.TryGetValue(filename, out FileEntryInfo fInfo)) + _statCache.Remove(filename); else fInfo = new FileEntryInfo { @@ -331,11 +332,11 @@ namespace Aaru.Filesystems fInfo.UID = (ulong)user; extentBlocks.Add(entryNo, blocks); fileExtents.Add(filename, extentBlocks); - statCache.Add(filename, fInfo); + _statCache.Add(filename, fInfo); // Add the file to the directory listing - if(!dirList.Contains(filename)) - dirList.Add(filename); + if(!_dirList.Contains(filename)) + _dirList.Add(filename); // Count entries 3 by 3 for timestamps switch(dirCnt % 3) @@ -395,11 +396,11 @@ namespace Aaru.Filesystems if(!string.IsNullOrEmpty(extension)) filename = filename + "." + extension; - int entryNo = ((32 * entry.extentCounterHigh) + entry.extentCounter) / (dpb.exm + 1); + int entryNo = ((32 * entry.extentCounterHigh) + entry.extentCounter) / (_dpb.exm + 1); // Do we have a stat for the file already? - if(statCache.TryGetValue(filename, out FileEntryInfo fInfo)) - statCache.Remove(filename); + if(_statCache.TryGetValue(filename, out FileEntryInfo fInfo)) + _statCache.Remove(filename); else fInfo = new FileEntryInfo { @@ -440,11 +441,11 @@ namespace Aaru.Filesystems fInfo.UID = (ulong)user; extentBlocks.Add(entryNo, blocks); fileExtents.Add(filename, extentBlocks); - statCache.Add(filename, fInfo); + _statCache.Add(filename, fInfo); // Add the file to the directory listing - if(!dirList.Contains(filename)) - dirList.Add(filename); + if(!_dirList.Contains(filename)) + _dirList.Add(filename); // Count entries 3 by 3 for timestamps switch(dirCnt % 3) @@ -491,13 +492,13 @@ namespace Aaru.Filesystems filename = filename + "." + extension; // Do not repeat passwords - if(passwordCache.ContainsKey(filename)) - passwordCache.Remove(filename); + if(_passwordCache.ContainsKey(filename)) + _passwordCache.Remove(filename); // Copy whole password entry byte[] tmp = new byte[32]; Array.Copy(directory, dOff, tmp, 0, 32); - passwordCache.Add(filename, tmp); + _passwordCache.Add(filename, tmp); // Count entries 3 by 3 for timestamps switch(dirCnt % 3) @@ -531,11 +532,11 @@ namespace Aaru.Filesystems // access time atime |= (labelEntry.flags & 0x40) == 0x40; - label = Encoding.ASCII.GetString(directory, dOff + 1, 11).Trim(); - labelCreationDate = new byte[4]; - labelUpdateDate = new byte[4]; - Array.Copy(directory, dOff + 24, labelCreationDate, 0, 4); - Array.Copy(directory, dOff + 28, labelUpdateDate, 0, 4); + _label = Encoding.ASCII.GetString(directory, dOff + 1, 11).Trim(); + _labelCreationDate = new byte[4]; + _labelUpdateDate = new byte[4]; + Array.Copy(directory, dOff + 24, _labelCreationDate, 0, 4); + Array.Copy(directory, dOff + 28, _labelUpdateDate, 0, 4); // Count entries 3 by 3 for timestamps switch(dirCnt % 3) @@ -571,8 +572,8 @@ namespace Aaru.Filesystems // Entry contains timestamps for last 3 entries, whatever the kind they are. if(!string.IsNullOrEmpty(file1)) { - if(statCache.TryGetValue(file1, out fInfo)) - statCache.Remove(file1); + if(_statCache.TryGetValue(file1, out fInfo)) + _statCache.Remove(file1); else fInfo = new FileEntryInfo(); @@ -583,13 +584,13 @@ namespace Aaru.Filesystems fInfo.LastWriteTime = DateHandlers.CpmToDateTime(dateEntry.date2); - statCache.Add(file1, fInfo); + _statCache.Add(file1, fInfo); } if(!string.IsNullOrEmpty(file2)) { - if(statCache.TryGetValue(file2, out fInfo)) - statCache.Remove(file2); + if(_statCache.TryGetValue(file2, out fInfo)) + _statCache.Remove(file2); else fInfo = new FileEntryInfo(); @@ -600,13 +601,13 @@ namespace Aaru.Filesystems fInfo.LastWriteTime = DateHandlers.CpmToDateTime(dateEntry.date4); - statCache.Add(file2, fInfo); + _statCache.Add(file2, fInfo); } if(!string.IsNullOrEmpty(file3)) { - if(statCache.TryGetValue(file3, out fInfo)) - statCache.Remove(file3); + if(_statCache.TryGetValue(file3, out fInfo)) + _statCache.Remove(file3); else fInfo = new FileEntryInfo(); @@ -617,7 +618,7 @@ namespace Aaru.Filesystems fInfo.LastWriteTime = DateHandlers.CpmToDateTime(dateEntry.date6); - statCache.Add(file3, fInfo); + _statCache.Add(file3, fInfo); } file1 = null; @@ -637,8 +638,8 @@ namespace Aaru.Filesystems // Entry contains timestamps for last 3 entries, whatever the kind they are. if(!string.IsNullOrEmpty(file1)) { - if(statCache.TryGetValue(file1, out fInfo)) - statCache.Remove(file1); + if(_statCache.TryGetValue(file1, out fInfo)) + _statCache.Remove(file1); else fInfo = new FileEntryInfo(); @@ -650,13 +651,13 @@ namespace Aaru.Filesystems fInfo.CreationTime = DateHandlers.CpmToDateTime(ctime); fInfo.LastWriteTime = DateHandlers.CpmToDateTime(trdPartyDateEntry.modify1); - statCache.Add(file1, fInfo); + _statCache.Add(file1, fInfo); } if(!string.IsNullOrEmpty(file2)) { - if(statCache.TryGetValue(file2, out fInfo)) - statCache.Remove(file2); + if(_statCache.TryGetValue(file2, out fInfo)) + _statCache.Remove(file2); else fInfo = new FileEntryInfo(); @@ -668,13 +669,13 @@ namespace Aaru.Filesystems fInfo.CreationTime = DateHandlers.CpmToDateTime(ctime); fInfo.LastWriteTime = DateHandlers.CpmToDateTime(trdPartyDateEntry.modify2); - statCache.Add(file2, fInfo); + _statCache.Add(file2, fInfo); } if(!string.IsNullOrEmpty(file3)) { - if(statCache.TryGetValue(file1, out fInfo)) - statCache.Remove(file3); + if(_statCache.TryGetValue(file1, out fInfo)) + _statCache.Remove(file3); else fInfo = new FileEntryInfo(); @@ -686,7 +687,7 @@ namespace Aaru.Filesystems fInfo.CreationTime = DateHandlers.CpmToDateTime(ctime); fInfo.LastWriteTime = DateHandlers.CpmToDateTime(trdPartyDateEntry.modify3); - statCache.Add(file3, fInfo); + _statCache.Add(file3, fInfo); } file1 = null; @@ -702,14 +703,14 @@ namespace Aaru.Filesystems // this should not be a problem AaruConsole.DebugWriteLine("CP/M Plugin", "Reading files."); long usedBlocks = 0; - fileCache = new Dictionary(); + _fileCache = new Dictionary(); - foreach(string filename in dirList) + foreach(string filename in _dirList) { var fileMs = new MemoryStream(); - if(statCache.TryGetValue(filename, out FileEntryInfo fInfo)) - statCache.Remove(filename); + if(_statCache.TryGetValue(filename, out FileEntryInfo fInfo)) + _statCache.Remove(filename); fInfo.Blocks = 0; @@ -731,18 +732,18 @@ namespace Aaru.Filesystems fInfo.Attributes |= FileAttributes.Extents; fInfo.BlockSize = blockSize; fInfo.Length = fileMs.Length; - cpmStat.Files++; + _cpmStat.Files++; usedBlocks += fInfo.Blocks; - statCache.Add(filename, fInfo); - fileCache.Add(filename, fileMs.ToArray()); + _statCache.Add(filename, fInfo); + _fileCache.Add(filename, fileMs.ToArray()); } - decodedPasswordCache = new Dictionary(); + _decodedPasswordCache = new Dictionary(); // For each stored password, store a decoded version of it - if(passwordCache.Count > 0) - foreach(KeyValuePair kvp in passwordCache) + if(_passwordCache.Count > 0) + foreach(KeyValuePair kvp in _passwordCache) { byte[] tmp = new byte[8]; Array.Copy(kvp.Value, 16, tmp, 0, 8); @@ -750,45 +751,45 @@ namespace Aaru.Filesystems for(int t = 0; t < 8; t++) tmp[t] ^= kvp.Value[13]; - decodedPasswordCache.Add(kvp.Key, tmp); + _decodedPasswordCache.Add(kvp.Key, tmp); } // Generate statfs. - cpmStat.Blocks = (ulong)(dpb.dsm + 1); - cpmStat.FilenameLength = 11; - cpmStat.Files = (ulong)fileCache.Count; - cpmStat.FreeBlocks = cpmStat.Blocks - (ulong)usedBlocks; - cpmStat.PluginId = Id; - cpmStat.Type = "CP/M filesystem"; + _cpmStat.Blocks = (ulong)(_dpb.dsm + 1); + _cpmStat.FilenameLength = 11; + _cpmStat.Files = (ulong)_fileCache.Count; + _cpmStat.FreeBlocks = _cpmStat.Blocks - (ulong)usedBlocks; + _cpmStat.PluginId = Id; + _cpmStat.Type = "CP/M filesystem"; // Generate XML info XmlFsType = new FileSystemType { - Clusters = cpmStat.Blocks, + Clusters = _cpmStat.Blocks, ClusterSize = (uint)blockSize, - Files = (ulong)fileCache.Count, + Files = (ulong)_fileCache.Count, FilesSpecified = true, - FreeClusters = cpmStat.FreeBlocks, + FreeClusters = _cpmStat.FreeBlocks, FreeClustersSpecified = true, Type = "CP/M filesystem" }; - if(labelCreationDate != null) + if(_labelCreationDate != null) { - XmlFsType.CreationDate = DateHandlers.CpmToDateTime(labelCreationDate); + XmlFsType.CreationDate = DateHandlers.CpmToDateTime(_labelCreationDate); XmlFsType.CreationDateSpecified = true; } - if(labelUpdateDate != null) + if(_labelUpdateDate != null) { - XmlFsType.ModificationDate = DateHandlers.CpmToDateTime(labelUpdateDate); + XmlFsType.ModificationDate = DateHandlers.CpmToDateTime(_labelUpdateDate); XmlFsType.ModificationDateSpecified = true; } - if(!string.IsNullOrEmpty(label)) - XmlFsType.VolumeName = label; + if(!string.IsNullOrEmpty(_label)) + XmlFsType.VolumeName = _label; - mounted = true; + _mounted = true; return Errno.NoError; } @@ -800,27 +801,27 @@ namespace Aaru.Filesystems { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; - stat = cpmStat; + stat = _cpmStat; return Errno.NoError; } public Errno Unmount() { - mounted = false; - definitions = null; - cpmFound = false; - workingDefinition = null; - dpb = null; - sectorMask = null; - label = null; - thirdPartyTimestamps = false; - standardTimestamps = false; - labelCreationDate = null; - labelUpdateDate = null; + _mounted = false; + _definitions = null; + _cpmFound = false; + _workingDefinition = null; + _dpb = null; + _sectorMask = null; + _label = null; + _thirdPartyTimestamps = false; + _standardTimestamps = false; + _labelCreationDate = null; + _labelUpdateDate = null; return Errno.NoError; } diff --git a/Aaru.Filesystems/CPM/Xattr.cs b/Aaru.Filesystems/CPM/Xattr.cs index fe2a97064..f2e8d3907 100644 --- a/Aaru.Filesystems/CPM/Xattr.cs +++ b/Aaru.Filesystems/CPM/Xattr.cs @@ -46,7 +46,7 @@ namespace Aaru.Filesystems /// Buffer. public Errno GetXattr(string path, string xattr, ref byte[] buf) { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -57,17 +57,17 @@ namespace Aaru.Filesystems if(pathElements.Length != 1) return Errno.NotSupported; - if(!fileCache.ContainsKey(pathElements[0].ToUpperInvariant())) + if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant())) return Errno.NoSuchFile; if(string.Compare(xattr, "com.caldera.cpm.password", StringComparison.InvariantCulture) == 0) - if(!passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf)) + if(!_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf)) return Errno.NoError; if(string.Compare(xattr, "com.caldera.cpm.password.text", StringComparison.InvariantCulture) != 0) return Errno.NoSuchExtendedAttribute; - return !passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf) ? Errno.NoError + return !_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf) ? Errno.NoError : Errno.NoSuchExtendedAttribute; } @@ -80,7 +80,7 @@ namespace Aaru.Filesystems { xattrs = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -91,15 +91,15 @@ namespace Aaru.Filesystems if(pathElements.Length != 1) return Errno.NotSupported; - if(!fileCache.ContainsKey(pathElements[0].ToUpperInvariant())) + if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant())) return Errno.NoSuchFile; xattrs = new List(); - if(passwordCache.ContainsKey(pathElements[0].ToUpperInvariant())) + if(_passwordCache.ContainsKey(pathElements[0].ToUpperInvariant())) xattrs.Add("com.caldera.cpm.password"); - if(decodedPasswordCache.ContainsKey(pathElements[0].ToUpperInvariant())) + if(_decodedPasswordCache.ContainsKey(pathElements[0].ToUpperInvariant())) xattrs.Add("com.caldera.cpm.password.text"); return Errno.NoError; diff --git a/Aaru.Filesystems/Cram.cs b/Aaru.Filesystems/Cram.cs index a32b44016..2547746a3 100644 --- a/Aaru.Filesystems/Cram.cs +++ b/Aaru.Filesystems/Cram.cs @@ -76,17 +76,17 @@ namespace Aaru.Filesystems byte[] sector = imagePlugin.ReadSector(partition.Start); uint magic = BitConverter.ToUInt32(sector, 0x00); - var crSb = new CramSuperBlock(); + var crSb = new SuperBlock(); bool littleEndian = true; switch(magic) { case CRAM_MAGIC: - crSb = Marshal.ByteArrayToStructureLittleEndian(sector); + crSb = Marshal.ByteArrayToStructureLittleEndian(sector); break; case CRAM_CIGAM: - crSb = Marshal.ByteArrayToStructureBigEndian(sector); + crSb = Marshal.ByteArrayToStructureBigEndian(sector); littleEndian = false; break; @@ -123,7 +123,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct CramSuperBlock + struct SuperBlock { public readonly uint magic; public readonly uint size; diff --git a/Aaru.Filesystems/ECMA67.cs b/Aaru.Filesystems/ECMA67.cs index 850d1c81a..9e2242314 100644 --- a/Aaru.Filesystems/ECMA67.cs +++ b/Aaru.Filesystems/ECMA67.cs @@ -43,7 +43,7 @@ namespace Aaru.Filesystems { public class ECMA67 : IFilesystem { - readonly byte[] ecma67_magic = + readonly byte[] _magic = { 0x56, 0x4F, 0x4C }; @@ -69,7 +69,7 @@ namespace Aaru.Filesystems VolumeLabel vol = Marshal.ByteArrayToStructureLittleEndian(sector); - return ecma67_magic.SequenceEqual(vol.labelIdentifier) && vol.labelNumber == 1 && vol.recordLength == 0x31; + return _magic.SequenceEqual(vol.labelIdentifier) && vol.labelNumber == 1 && vol.recordLength == 0x31; } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, diff --git a/Aaru.Filesystems/EFS.cs b/Aaru.Filesystems/EFS.cs index c658cb832..2c7093f49 100644 --- a/Aaru.Filesystems/EFS.cs +++ b/Aaru.Filesystems/EFS.cs @@ -63,48 +63,48 @@ namespace Aaru.Filesystems // Misaligned if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc) { - uint sbSize = (uint)((Marshal.SizeOf() + 0x200) / imagePlugin.Info.SectorSize); + uint sbSize = (uint)((Marshal.SizeOf() + 0x200) / imagePlugin.Info.SectorSize); - if((Marshal.SizeOf() + 0x200) % imagePlugin.Info.SectorSize != 0) + if((Marshal.SizeOf() + 0x200) % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return false; - byte[] sbpiece = new byte[Marshal.SizeOf()]; + byte[] sbpiece = new byte[Marshal.SizeOf()]; - Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf()); + Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf()); - EFS_Superblock efsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); + Superblock sb = Marshal.ByteArrayToStructureBigEndian(sbpiece); AaruConsole.DebugWriteLine("EFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})", - 0x200, efsSb.sb_magic, EFS_MAGIC, EFS_MAGIC_NEW); + 0x200, sb.sb_magic, EFS_MAGIC, EFS_MAGIC_NEW); - if(efsSb.sb_magic == EFS_MAGIC || - efsSb.sb_magic == EFS_MAGIC_NEW) + if(sb.sb_magic == EFS_MAGIC || + sb.sb_magic == EFS_MAGIC_NEW) return true; } else { - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start + 1, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return false; - EFS_Superblock efsSb = Marshal.ByteArrayToStructureBigEndian(sector); + Superblock sb = Marshal.ByteArrayToStructureBigEndian(sector); AaruConsole.DebugWriteLine("EFS plugin", "magic at {0} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})", 1, - efsSb.sb_magic, EFS_MAGIC, EFS_MAGIC_NEW); + sb.sb_magic, EFS_MAGIC, EFS_MAGIC_NEW); - if(efsSb.sb_magic == EFS_MAGIC || - efsSb.sb_magic == EFS_MAGIC_NEW) + if(sb.sb_magic == EFS_MAGIC || + sb.sb_magic == EFS_MAGIC_NEW) return true; } @@ -120,43 +120,43 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize < 512) return; - var efsSb = new EFS_Superblock(); + var efsSb = new Superblock(); // Misaligned if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc) { - uint sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); + uint sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); - if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) + if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return; - byte[] sbpiece = new byte[Marshal.SizeOf()]; + byte[] sbpiece = new byte[Marshal.SizeOf()]; - Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf()); + Array.Copy(sector, 0x200, sbpiece, 0, Marshal.SizeOf()); - efsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); + efsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); AaruConsole.DebugWriteLine("EFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})", 0x200, efsSb.sb_magic, EFS_MAGIC, EFS_MAGIC_NEW); } else { - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start + 1, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return; - efsSb = Marshal.ByteArrayToStructureBigEndian(sector); + efsSb = Marshal.ByteArrayToStructureBigEndian(sector); AaruConsole.DebugWriteLine("EFS plugin", "magic at {0} = 0x{1:X8} (expected 0x{2:X8} or 0x{3:X8})", 1, efsSb.sb_magic, EFS_MAGIC, EFS_MAGIC_NEW); @@ -219,7 +219,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] - struct EFS_Superblock + struct Superblock { /* 0: fs size incl. bb 0 (in bb) */ public readonly int sb_size; diff --git a/Aaru.Filesystems/F2FS.cs b/Aaru.Filesystems/F2FS.cs index 96d1b32d0..4044f7c94 100644 --- a/Aaru.Filesystems/F2FS.cs +++ b/Aaru.Filesystems/F2FS.cs @@ -68,9 +68,9 @@ namespace Aaru.Filesystems if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; if(partition.Start + sbAddr >= partition.End) @@ -78,12 +78,12 @@ namespace Aaru.Filesystems byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return false; - F2FS_Superblock f2fsSb = Marshal.ByteArrayToStructureLittleEndian(sector); + Superblock sb = Marshal.ByteArrayToStructureLittleEndian(sector); - return f2fsSb.magic == F2FS_MAGIC; + return sb.magic == F2FS_MAGIC; } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, @@ -101,17 +101,17 @@ namespace Aaru.Filesystems if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return; - F2FS_Superblock f2fsSb = Marshal.ByteArrayToStructureLittleEndian(sector); + Superblock f2fsSb = Marshal.ByteArrayToStructureLittleEndian(sector); if(f2fsSb.magic != F2FS_MAGIC) return; @@ -158,7 +158,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] - struct F2FS_Superblock + struct Superblock { public readonly uint magic; public readonly ushort major_ver; diff --git a/Aaru.Filesystems/FAT/Consts.cs b/Aaru.Filesystems/FAT/Consts.cs index 2a110d299..b6c44371d 100644 --- a/Aaru.Filesystems/FAT/Consts.cs +++ b/Aaru.Filesystems/FAT/Consts.cs @@ -78,7 +78,7 @@ namespace Aaru.Filesystems const ushort EAT_ASN1 = 0xFFDD; const string FAT32_EA_TAIL = " EA. SF"; - readonly (string hash, string name)[] knownBootHashes = + readonly (string hash, string name)[] _knownBootHashes = { ("b639b4d5b25f63560e3b34a3a0feb732aa65486f", "Amstrad MS-DOS 3.20 (8-sector floppy)"), ("9311151f13f7611b1431593da05ddd3153370574", "Amstrad MS-DOS 3.20 (Spanish)"), diff --git a/Aaru.Filesystems/FAT/Dir.cs b/Aaru.Filesystems/FAT/Dir.cs index b83c122fb..03b4f29fa 100644 --- a/Aaru.Filesystems/FAT/Dir.cs +++ b/Aaru.Filesystems/FAT/Dir.cs @@ -61,21 +61,21 @@ namespace Aaru.Filesystems { contents = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; if(string.IsNullOrWhiteSpace(path) || path == "/") { - contents = rootDirectoryCache.Keys.ToList(); + contents = _rootDirectoryCache.Keys.ToList(); return Errno.NoError; } - string cutPath = path.StartsWith("/", StringComparison.Ordinal) ? path.Substring(1).ToLower(cultureInfo) - : path.ToLower(cultureInfo); + string cutPath = path.StartsWith("/", StringComparison.Ordinal) ? path.Substring(1).ToLower(_cultureInfo) + : path.ToLower(_cultureInfo); - if(directoryCache.TryGetValue(cutPath, out Dictionary currentDirectory)) + if(_directoryCache.TryGetValue(cutPath, out Dictionary currentDirectory)) { contents = currentDirectory.Keys.ToList(); @@ -88,7 +88,7 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); KeyValuePair entry = - rootDirectoryCache.FirstOrDefault(t => t.Key.ToLower(cultureInfo) == pieces[0]); + _rootDirectoryCache.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[0]); if(string.IsNullOrEmpty(entry.Key)) return Errno.NoSuchFile; @@ -98,11 +98,11 @@ namespace Aaru.Filesystems string currentPath = pieces[0]; - currentDirectory = rootDirectoryCache; + currentDirectory = _rootDirectoryCache; for(int p = 0; p < pieces.Length; p++) { - entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(cultureInfo) == pieces[p]); + entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[p]); if(string.IsNullOrEmpty(entry.Key)) return Errno.NoSuchFile; @@ -113,10 +113,10 @@ namespace Aaru.Filesystems currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}"; uint currentCluster = entry.Value.Dirent.start_cluster; - if(fat32) + if(_fat32) currentCluster += (uint)(entry.Value.Dirent.ea_handle << 16); - if(directoryCache.TryGetValue(currentPath, out currentDirectory)) + if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) continue; uint[] clusters = GetClusters(currentCluster); @@ -124,14 +124,14 @@ namespace Aaru.Filesystems if(clusters is null) return Errno.InvalidArgument; - byte[] directoryBuffer = new byte[bytesPerCluster * clusters.Length]; + byte[] directoryBuffer = new byte[_bytesPerCluster * clusters.Length]; for(int i = 0; i < clusters.Length; i++) { - byte[] buffer = image.ReadSectors(firstClusterSector + (clusters[i] * sectorsPerCluster), - sectorsPerCluster); + byte[] buffer = _image.ReadSectors(_firstClusterSector + (clusters[i] * _sectorsPerCluster), + _sectorsPerCluster); - Array.Copy(buffer, 0, directoryBuffer, i * bytesPerCluster, bytesPerCluster); + Array.Copy(buffer, 0, directoryBuffer, i * _bytesPerCluster, _bytesPerCluster); } currentDirectory = new Dictionary(); @@ -149,8 +149,8 @@ namespace Aaru.Filesystems if(dirent.attributes.HasFlag(FatAttributes.LFN)) { - if(@namespace != Namespace.Lfn && - @namespace != Namespace.Ecs) + if(_namespace != Namespace.Lfn && + _namespace != Namespace.Ecs) continue; LfnEntry lfnEntry = @@ -210,7 +210,7 @@ namespace Aaru.Filesystems Dirent = dirent }; - if((@namespace == Namespace.Lfn || @namespace == Namespace.Ecs) && + if((_namespace == Namespace.Lfn || _namespace == Namespace.Ecs) && lastLfnName != null) { byte calculatedLfnChecksum = LfnChecksum(dirent.filename, dirent.extension); @@ -231,7 +231,7 @@ namespace Aaru.Filesystems string name = Encoding.GetString(dirent.filename).TrimEnd(); string extension = Encoding.GetString(dirent.extension).TrimEnd(); - if(@namespace == Namespace.Nt) + if(_namespace == Namespace.Nt) { if(dirent.caseinfo.HasFlag(CaseInfo.LowerCaseExtension)) extension = extension.ToLower(CultureInfo.CurrentCulture); @@ -245,7 +245,7 @@ namespace Aaru.Filesystems else filename = name; - if(@namespace == Namespace.Human) + if(_namespace == Namespace.Human) { HumanDirectoryEntry humanEntry = Marshal.ByteArrayToStructureLittleEndian(directoryBuffer, pos, @@ -275,9 +275,9 @@ namespace Aaru.Filesystems } // Check OS/2 .LONGNAME - if(eaCache != null && - (@namespace == Namespace.Os2 || @namespace == Namespace.Ecs) && - !fat32) + if(_eaCache != null && + (_namespace == Namespace.Os2 || _namespace == Namespace.Ecs) && + !_fat32) { List> filesWithEas = currentDirectory.Where(t => t.Value.Dirent.ea_handle != 0).ToList(); @@ -319,14 +319,14 @@ namespace Aaru.Filesystems } // Check FAT32.IFS EAs - if(fat32 || debug) + if(_fat32 || _debug) { List> fat32EaSidecars = currentDirectory. Where(t => t.Key. EndsWith(FAT32_EA_TAIL, true, - cultureInfo)). + _cultureInfo)). ToList(); foreach(KeyValuePair sidecar in fat32EaSidecars) @@ -338,7 +338,7 @@ namespace Aaru.Filesystems continue; // If not in debug mode we will consider the lack of EA bitflags to mean the EAs are corrupted or not real - if(!debug) + if(!_debug) if(!fileWithEa.Dirent.caseinfo.HasFlag(CaseInfo.NormalEaOld) && !fileWithEa.Dirent.caseinfo.HasFlag(CaseInfo.CriticalEa) && !fileWithEa.Dirent.caseinfo.HasFlag(CaseInfo.NormalEa) && @@ -347,12 +347,12 @@ namespace Aaru.Filesystems fileWithEa.Fat32Ea = sidecar.Value.Dirent; - if(!debug) + if(!_debug) currentDirectory.Remove(sidecar.Key); } } - directoryCache.Add(currentPath, currentDirectory); + _directoryCache.Add(currentPath, currentDirectory); } contents = currentDirectory?.Keys.ToList(); diff --git a/Aaru.Filesystems/FAT/FAT.cs b/Aaru.Filesystems/FAT/FAT.cs index 2ce9522df..1fdc4cacd 100644 --- a/Aaru.Filesystems/FAT/FAT.cs +++ b/Aaru.Filesystems/FAT/FAT.cs @@ -44,26 +44,26 @@ namespace Aaru.Filesystems // X68K uses cdate/adate from direntry for extending filename public partial class FAT : IReadOnlyFilesystem { - uint bytesPerCluster; - byte[] cachedEaData; - CultureInfo cultureInfo; - bool debug; - Dictionary> directoryCache; - DirectoryEntry eaDirEntry; - bool fat12; - bool fat16; - bool fat32; - ushort[] fatEntries; - ulong fatFirstSector; - ulong firstClusterSector; - bool mounted; - Namespace @namespace; - uint reservedSectors; - Dictionary rootDirectoryCache; - uint sectorsPerCluster; - uint sectorsPerFat; - FileSystemInfo statfs; - bool useFirstFat; + uint _bytesPerCluster; + byte[] _cachedEaData; + CultureInfo _cultureInfo; + bool _debug; + Dictionary> _directoryCache; + DirectoryEntry _eaDirEntry; + bool _fat12; + bool _fat16; + bool _fat32; + ushort[] _fatEntries; + ulong _fatFirstSector; + ulong _firstClusterSector; + bool _mounted; + Namespace _namespace; + uint _reservedSectors; + Dictionary _rootDirectoryCache; + uint _sectorsPerCluster; + uint _sectorsPerFat; + FileSystemInfo _statfs; + bool _useFirstFat; public FileSystemType XmlFsType { get; private set; } diff --git a/Aaru.Filesystems/FAT/File.cs b/Aaru.Filesystems/FAT/File.cs index f5b84787b..01dd59bfe 100644 --- a/Aaru.Filesystems/FAT/File.cs +++ b/Aaru.Filesystems/FAT/File.cs @@ -46,7 +46,7 @@ namespace Aaru.Filesystems { deviceBlock = 0; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = Stat(path, out FileEntryInfo stat); @@ -55,7 +55,7 @@ namespace Aaru.Filesystems return err; if(stat.Attributes.HasFlag(FileAttributes.Directory) && - !debug) + !_debug) return Errno.IsDirectory; uint[] clusters = GetClusters((uint)stat.Inode); @@ -63,7 +63,7 @@ namespace Aaru.Filesystems if(fileBlock >= clusters.Length) return Errno.InvalidArgument; - deviceBlock = (long)(firstClusterSector + (clusters[fileBlock] * sectorsPerCluster)); + deviceBlock = (long)(_firstClusterSector + (clusters[fileBlock] * _sectorsPerCluster)); return Errno.NoError; } @@ -72,7 +72,7 @@ namespace Aaru.Filesystems { attributes = new FileAttributes(); - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = Stat(path, out FileEntryInfo stat); @@ -87,7 +87,7 @@ namespace Aaru.Filesystems public Errno Read(string path, long offset, long size, ref byte[] buf) { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = Stat(path, out FileEntryInfo stat); @@ -96,7 +96,7 @@ namespace Aaru.Filesystems return err; if(stat.Attributes.HasFlag(FileAttributes.Directory) && - !debug) + !_debug) return Errno.IsDirectory; if(offset >= stat.Length) @@ -107,11 +107,11 @@ namespace Aaru.Filesystems uint[] clusters = GetClusters((uint)stat.Inode); - long firstCluster = offset / bytesPerCluster; - long offsetInCluster = offset % bytesPerCluster; - long sizeInClusters = (size + offsetInCluster) / bytesPerCluster; + long firstCluster = offset / _bytesPerCluster; + long offsetInCluster = offset % _bytesPerCluster; + long sizeInClusters = (size + offsetInCluster) / _bytesPerCluster; - if((size + offsetInCluster) % bytesPerCluster > 0) + if((size + offsetInCluster) % _bytesPerCluster > 0) sizeInClusters++; var ms = new MemoryStream(); @@ -121,8 +121,9 @@ namespace Aaru.Filesystems if(i + firstCluster >= clusters.Length) return Errno.InvalidArgument; - byte[] buffer = image.ReadSectors(firstClusterSector + (clusters[i + firstCluster] * sectorsPerCluster), - sectorsPerCluster); + byte[] buffer = + _image.ReadSectors(_firstClusterSector + (clusters[i + firstCluster] * _sectorsPerCluster), + _sectorsPerCluster); ms.Write(buffer, 0, buffer.Length); } @@ -138,7 +139,7 @@ namespace Aaru.Filesystems { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = GetFileEntry(path, out CompleteDirectoryEntry completeEntry); @@ -151,28 +152,28 @@ namespace Aaru.Filesystems stat = new FileEntryInfo { Attributes = new FileAttributes(), - Blocks = entry.size / bytesPerCluster, - BlockSize = bytesPerCluster, + Blocks = entry.size / _bytesPerCluster, + BlockSize = _bytesPerCluster, Length = entry.size, - Inode = (ulong)(fat32 ? (entry.ea_handle << 16) + entry.start_cluster : entry.start_cluster), + Inode = (ulong)(_fat32 ? (entry.ea_handle << 16) + entry.start_cluster : entry.start_cluster), Links = 1, CreationTime = DateHandlers.DosToDateTime(entry.cdate, entry.ctime) }; - if(@namespace != Namespace.Human) + if(_namespace != Namespace.Human) { stat.LastWriteTime = DateHandlers.DosToDateTime(entry.mdate, entry.mtime); stat.CreationTime = stat.CreationTime?.AddMilliseconds(entry.ctime_ms * 10); } - if(entry.size % bytesPerCluster > 0) + if(entry.size % _bytesPerCluster > 0) stat.Blocks++; if(entry.attributes.HasFlag(FatAttributes.Subdirectory)) { stat.Attributes |= FileAttributes.Directory; - stat.Blocks = fat32 ? GetClusters((uint)((entry.ea_handle << 16) + entry.start_cluster)).Length + stat.Blocks = _fat32 ? GetClusters((uint)((entry.ea_handle << 16) + entry.start_cluster)).Length : GetClusters(entry.start_cluster).Length; stat.Length = stat.Blocks * stat.BlockSize; @@ -208,13 +209,15 @@ namespace Aaru.Filesystems uint nextCluster = startCluster; - ulong nextSector = (nextCluster / fatEntriesPerSector) + fatFirstSector + (useFirstFat ? 0 : sectorsPerFat); - int nextEntry = (int)(nextCluster % fatEntriesPerSector); + ulong nextSector = (nextCluster / _fatEntriesPerSector) + _fatFirstSector + + (_useFirstFat ? 0 : _sectorsPerFat); + + int nextEntry = (int)(nextCluster % _fatEntriesPerSector); ulong currentSector = nextSector; - byte[] fatData = image.ReadSector(currentSector); + byte[] fatData = _image.ReadSector(currentSector); - if(fat32) + if(_fat32) while((nextCluster & FAT32_MASK) > 0 && (nextCluster & FAT32_MASK) <= FAT32_FORMATTED) { @@ -222,30 +225,30 @@ namespace Aaru.Filesystems if(currentSector != nextSector) { - fatData = image.ReadSector(nextSector); + fatData = _image.ReadSector(nextSector); currentSector = nextSector; } nextCluster = BitConverter.ToUInt32(fatData, nextEntry * 4); - nextSector = (nextCluster / fatEntriesPerSector) + fatFirstSector + - (useFirstFat ? 0 : sectorsPerFat); + nextSector = (nextCluster / _fatEntriesPerSector) + _fatFirstSector + + (_useFirstFat ? 0 : _sectorsPerFat); - nextEntry = (int)(nextCluster % fatEntriesPerSector); + nextEntry = (int)(nextCluster % _fatEntriesPerSector); } - else if(fat16) + else if(_fat16) while(nextCluster > 0 && nextCluster <= FAT16_FORMATTED) { clusters.Add(nextCluster); - nextCluster = fatEntries[nextCluster]; + nextCluster = _fatEntries[nextCluster]; } else while(nextCluster > 0 && nextCluster <= FAT12_FORMATTED) { clusters.Add(nextCluster); - nextCluster = fatEntries[nextCluster]; + nextCluster = _fatEntries[nextCluster]; } return clusters.ToArray(); @@ -255,7 +258,8 @@ namespace Aaru.Filesystems { entry = null; - string cutPath = path.StartsWith("/") ? path.Substring(1).ToLower(cultureInfo) : path.ToLower(cultureInfo); + string cutPath = path.StartsWith("/") ? path.Substring(1).ToLower(_cultureInfo) + : path.ToLower(_cultureInfo); string[] pieces = cutPath.Split(new[] { @@ -267,7 +271,7 @@ namespace Aaru.Filesystems string parentPath = string.Join("/", pieces, 0, pieces.Length - 1); - if(!directoryCache.TryGetValue(parentPath, out _)) + if(!_directoryCache.TryGetValue(parentPath, out _)) { Errno err = ReadDir(parentPath, out _); @@ -278,12 +282,12 @@ namespace Aaru.Filesystems Dictionary parent; if(pieces.Length == 1) - parent = rootDirectoryCache; - else if(!directoryCache.TryGetValue(parentPath, out parent)) + parent = _rootDirectoryCache; + else if(!_directoryCache.TryGetValue(parentPath, out parent)) return Errno.InvalidArgument; KeyValuePair dirent = - parent.FirstOrDefault(t => t.Key.ToLower(cultureInfo) == pieces[^1]); + parent.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[^1]); if(string.IsNullOrEmpty(dirent.Key)) return Errno.NoSuchFile; diff --git a/Aaru.Filesystems/FAT/Info.cs b/Aaru.Filesystems/FAT/Info.cs index c6a1563e0..ce9fecf8f 100644 --- a/Aaru.Filesystems/FAT/Info.cs +++ b/Aaru.Filesystems/FAT/Info.cs @@ -1006,7 +1006,7 @@ namespace Aaru.Filesystems sb.AppendLine("Volume is bootable"); sb.AppendFormat("Boot code's SHA1: {0}", bootChk).AppendLine(); - string bootName = knownBootHashes.FirstOrDefault(t => t.hash == bootChk).name; + string bootName = _knownBootHashes.FirstOrDefault(t => t.hash == bootChk).name; if(string.IsNullOrWhiteSpace(bootName)) sb.AppendLine("Unknown boot code."); diff --git a/Aaru.Filesystems/FAT/Structs.cs b/Aaru.Filesystems/FAT/Structs.cs index 4666686bc..d91f00255 100644 --- a/Aaru.Filesystems/FAT/Structs.cs +++ b/Aaru.Filesystems/FAT/Structs.cs @@ -949,6 +949,7 @@ namespace Aaru.Filesystems public readonly byte[] name; } + [SuppressMessage("ReSharper", "InconsistentNaming")] enum UmsdosFlags : byte { /// Never show this entry in directory search diff --git a/Aaru.Filesystems/FAT/Super.cs b/Aaru.Filesystems/FAT/Super.cs index e6e00686a..52e66052f 100644 --- a/Aaru.Filesystems/FAT/Super.cs +++ b/Aaru.Filesystems/FAT/Super.cs @@ -51,9 +51,8 @@ namespace Aaru.Filesystems { public partial class FAT { - uint fatEntriesPerSector; - - IMediaImage image; + uint _fatEntriesPerSector; + IMediaImage _image; /// public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, @@ -65,7 +64,7 @@ namespace Aaru.Filesystems options = GetDefaultOptions(); if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out debug); + bool.TryParse(debugString, out _debug); // Default namespace if(@namespace is null) @@ -74,27 +73,27 @@ namespace Aaru.Filesystems switch(@namespace.ToLowerInvariant()) { case "dos": - this.@namespace = Namespace.Dos; + _namespace = Namespace.Dos; break; case "nt": - this.@namespace = Namespace.Nt; + _namespace = Namespace.Nt; break; case "os2": - this.@namespace = Namespace.Os2; + _namespace = Namespace.Os2; break; case "ecs": - this.@namespace = Namespace.Ecs; + _namespace = Namespace.Ecs; break; case "lfn": - this.@namespace = Namespace.Lfn; + _namespace = Namespace.Lfn; break; case "human": - this.@namespace = Namespace.Human; + _namespace = Namespace.Human; break; default: return Errno.InvalidArgument; @@ -110,13 +109,13 @@ namespace Aaru.Filesystems out HumanParameterBlock humanBpb, out AtariParameterBlock atariBpb, out byte minBootNearJump, out bool andosOemCorrect, out bool bootable); - fat12 = false; - fat16 = false; - fat32 = false; - useFirstFat = true; + _fat12 = false; + _fat16 = false; + _fat32 = false; + _useFirstFat = true; XmlFsType.Bootable = bootable; - statfs = new FileSystemInfo + _statfs = new FileSystemInfo { Blocks = XmlFsType.Clusters, FilenameLength = 11, @@ -139,13 +138,13 @@ namespace Aaru.Filesystems case BpbKind.Hardcoded: case BpbKind.Msx: case BpbKind.Apricot: - fat12 = true; + _fat12 = true; break; case BpbKind.ShortFat32: case BpbKind.LongFat32: { - fat32 = true; + _fat32 = true; Fat32ParameterBlock fat32Bpb = Marshal.ByteArrayToStructureLittleEndian(bpbSector); @@ -171,9 +170,9 @@ namespace Aaru.Filesystems (fat32Bpb.oem_name[5] != 0x49 || fat32Bpb.oem_name[6] != 0x48 || fat32Bpb.oem_name[7] != 0x43)) XmlFsType.SystemIdentifier = StringHandlers.CToString(fat32Bpb.oem_name); - sectorsPerCluster = fat32Bpb.spc; + _sectorsPerCluster = fat32Bpb.spc; XmlFsType.ClusterSize = (uint)(fat32Bpb.bps * fat32Bpb.spc); - reservedSectors = fat32Bpb.rsectors; + _reservedSectors = fat32Bpb.rsectors; if(fat32Bpb.big_sectors == 0 && fat32Bpb.signature == 0x28) @@ -181,10 +180,10 @@ namespace Aaru.Filesystems else XmlFsType.Clusters = fat32Bpb.big_sectors / fat32Bpb.spc; - sectorsPerFat = fat32Bpb.big_spfat; + _sectorsPerFat = fat32Bpb.big_spfat; XmlFsType.VolumeSerial = $"{fat32Bpb.serial_no:X8}"; - statfs.Id = new FileSystemId + _statfs.Id = new FileSystemId { IsInt = true, Serial32 = fat32Bpb.serial_no @@ -195,7 +194,7 @@ namespace Aaru.Filesystems XmlFsType.Dirty = true; if((fat32Bpb.mirror_flags & 0x80) == 0x80) - useFirstFat = (fat32Bpb.mirror_flags & 0xF) != 1; + _useFirstFat = (fat32Bpb.mirror_flags & 0xF) != 1; if(fat32Bpb.signature == 0x29) XmlFsType.VolumeName = Encoding.ASCII.GetString(fat32Bpb.volume_label); @@ -209,12 +208,12 @@ namespace Aaru.Filesystems BitConverter.ToUInt16(fat32Bpb.jump, 1) <= 0x1FC); sectorsPerRealSector = fat32Bpb.bps / imagePlugin.Info.SectorSize; - sectorsPerCluster *= sectorsPerRealSector; + _sectorsPerCluster *= sectorsPerRealSector; // First root directory sector - firstClusterSector = + _firstClusterSector = ((ulong)((fat32Bpb.big_spfat * fat32Bpb.fats_no) + fat32Bpb.rsectors) * sectorsPerRealSector) - - (2 * sectorsPerCluster); + (2 * _sectorsPerCluster); if(fat32Bpb.fsinfo_sector + partition.Start <= partition.End) { @@ -252,10 +251,10 @@ namespace Aaru.Filesystems case BpbKind.Human: // If not debug set Human68k namespace and ShiftJIS codepage as defaults - if(!debug) + if(!_debug) { - this.@namespace = Namespace.Human; - encoding = Encoding.GetEncoding("shift_jis"); + _namespace = Namespace.Human; + encoding = Encoding.GetEncoding("shift_jis"); } XmlFsType.Bootable = true; @@ -268,7 +267,7 @@ namespace Aaru.Filesystems ulong firstRootSector = 0; - if(!fat32) + if(!_fat32) { // This is to support FAT partitions on hybrid ISO/USB images if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc) @@ -288,8 +287,8 @@ namespace Aaru.Filesystems // However nothing prevents this to happen // If first file on disk uses only one cluster there is absolutely no way to differentiate between FAT12 and FAT16, // so let's hope implementations use common sense? - if(!fat12 && - !fat16) + if(!_fat12 && + !_fat16) { ulong clusters; @@ -299,14 +298,14 @@ namespace Aaru.Filesystems clusters = fakeBpb.spc == 0 ? fakeBpb.sectors : (ulong)fakeBpb.sectors / fakeBpb.spc; if(clusters < 4089) - fat12 = true; + _fat12 = true; else - fat16 = true; + _fat16 = true; } - if(fat12) + if(_fat12) XmlFsType.Type = "FAT12"; - else if(fat16) + else if(_fat16) XmlFsType.Type = "FAT16"; if(bpbKind == BpbKind.Atari) @@ -318,7 +317,7 @@ namespace Aaru.Filesystems XmlFsType.VolumeSerial = $"{atariBpb.serial_no[0]:X2}{atariBpb.serial_no[1]:X2}{atariBpb.serial_no[2]:X2}"; - statfs.Id = new FileSystemId + _statfs.Id = new FileSystemId { IsInt = true, Serial32 = (uint)((atariBpb.serial_no[0] << 16) + (atariBpb.serial_no[1] << 8) + @@ -379,7 +378,7 @@ namespace Aaru.Filesystems { XmlFsType.VolumeSerial = $"{fakeBpb.serial_no:X8}"; - statfs.Id = new FileSystemId + _statfs.Id = new FileSystemId { IsInt = true, Serial32 = fakeBpb.serial_no @@ -396,10 +395,10 @@ namespace Aaru.Filesystems else XmlFsType.Clusters = humanBpb.clusters == 0 ? humanBpb.big_clusters : humanBpb.clusters; - sectorsPerCluster = fakeBpb.spc; + _sectorsPerCluster = fakeBpb.spc; XmlFsType.ClusterSize = (uint)(fakeBpb.bps * fakeBpb.spc); - reservedSectors = fakeBpb.rsectors; - sectorsPerFat = fakeBpb.spfat; + _reservedSectors = fakeBpb.rsectors; + _sectorsPerFat = fakeBpb.spfat; if(fakeBpb.signature == 0x28 || fakeBpb.signature == 0x29 || @@ -435,29 +434,29 @@ namespace Aaru.Filesystems sectorsForRootDirectory = (uint)((fakeBpb.root_ent * 32) / imagePlugin.Info.SectorSize); sectorsPerRealSector = fakeBpb.bps / imagePlugin.Info.SectorSize; - sectorsPerCluster *= sectorsPerRealSector; + _sectorsPerCluster *= sectorsPerRealSector; } - firstClusterSector += partition.Start; + _firstClusterSector += partition.Start; - image = imagePlugin; + _image = imagePlugin; - if(fat32) - fatEntriesPerSector = imagePlugin.Info.SectorSize / 4; - else if(fat16) - fatEntriesPerSector = imagePlugin.Info.SectorSize / 2; + if(_fat32) + _fatEntriesPerSector = imagePlugin.Info.SectorSize / 4; + else if(_fat16) + _fatEntriesPerSector = imagePlugin.Info.SectorSize / 2; else - fatEntriesPerSector = (imagePlugin.Info.SectorSize * 2) / 3; + _fatEntriesPerSector = (imagePlugin.Info.SectorSize * 2) / 3; - fatFirstSector = partition.Start + (reservedSectors * sectorsPerRealSector); + _fatFirstSector = partition.Start + (_reservedSectors * sectorsPerRealSector); - rootDirectoryCache = new Dictionary(); + _rootDirectoryCache = new Dictionary(); byte[] rootDirectory = null; - if(!fat32) + if(!_fat32) { - firstClusterSector = (firstRootSector + sectorsForRootDirectory) - (sectorsPerCluster * 2); - rootDirectory = imagePlugin.ReadSectors(firstRootSector, sectorsForRootDirectory); + _firstClusterSector = (firstRootSector + sectorsForRootDirectory) - (_sectorsPerCluster * 2); + rootDirectory = imagePlugin.ReadSectors(firstRootSector, sectorsForRootDirectory); if(bpbKind == BpbKind.DecRainbow) { @@ -483,7 +482,8 @@ namespace Aaru.Filesystems foreach(uint cluster in rootDirectoryClusters) { byte[] buffer = - imagePlugin.ReadSectors(firstClusterSector + (cluster * sectorsPerCluster), sectorsPerCluster); + imagePlugin.ReadSectors(_firstClusterSector + (cluster * _sectorsPerCluster), + _sectorsPerCluster); rootMs.Write(buffer, 0, buffer.Length); } @@ -491,8 +491,8 @@ namespace Aaru.Filesystems rootDirectory = rootMs.ToArray(); // OS/2 FAT32.IFS uses LFN instead of .LONGNAME - if(this.@namespace == Namespace.Os2) - this.@namespace = Namespace.Os2; + if(_namespace == Namespace.Os2) + _namespace = Namespace.Os2; } if(rootDirectory is null) @@ -512,8 +512,8 @@ namespace Aaru.Filesystems if(entry.attributes.HasFlag(FatAttributes.LFN)) { - if(this.@namespace != Namespace.Lfn && - this.@namespace != Namespace.Ecs) + if(_namespace != Namespace.Lfn && + _namespace != Namespace.Ecs) continue; LfnEntry lfnEntry = @@ -574,7 +574,7 @@ namespace Aaru.Filesystems if(!string.IsNullOrEmpty(volname)) XmlFsType.VolumeName = - entry.caseinfo.HasFlag(CaseInfo.AllLowerCase) && this.@namespace == Namespace.Nt + entry.caseinfo.HasFlag(CaseInfo.AllLowerCase) && _namespace == Namespace.Nt ? volname.ToLower() : volname; if(entry.ctime > 0 && @@ -603,7 +603,7 @@ namespace Aaru.Filesystems Dirent = entry }; - if((this.@namespace == Namespace.Lfn || this.@namespace == Namespace.Ecs) && + if((_namespace == Namespace.Lfn || _namespace == Namespace.Ecs) && lastLfnName != null) { byte calculatedLfnChecksum = LfnChecksum(entry.filename, entry.extension); @@ -624,7 +624,7 @@ namespace Aaru.Filesystems string name = Encoding.GetString(entry.filename).TrimEnd(); string extension = Encoding.GetString(entry.extension).TrimEnd(); - if(this.@namespace == Namespace.Nt) + if(_namespace == Namespace.Nt) { if(entry.caseinfo.HasFlag(CaseInfo.LowerCaseExtension)) extension = extension.ToLower(CultureInfo.CurrentCulture); @@ -640,7 +640,7 @@ namespace Aaru.Filesystems completeEntry.Shortname = filename; - if(this.@namespace == Namespace.Human) + if(_namespace == Namespace.Human) { HumanDirectoryEntry humanEntry = Marshal.ByteArrayToStructureLittleEndian(rootDirectory, i, @@ -662,39 +662,39 @@ namespace Aaru.Filesystems completeEntry.HumanName = filename; } - if(!fat32 && + if(!_fat32 && filename == "EA DATA. SF") { - eaDirEntry = entry; + _eaDirEntry = entry; lastLfnName = null; lastLfnChecksum = 0; - if(debug) - rootDirectoryCache[completeEntry.ToString()] = completeEntry; + if(_debug) + _rootDirectoryCache[completeEntry.ToString()] = completeEntry; continue; } - rootDirectoryCache[completeEntry.ToString()] = completeEntry; - lastLfnName = null; - lastLfnChecksum = 0; + _rootDirectoryCache[completeEntry.ToString()] = completeEntry; + lastLfnName = null; + lastLfnChecksum = 0; } XmlFsType.VolumeName = XmlFsType.VolumeName?.Trim(); - statfs.Blocks = XmlFsType.Clusters; + _statfs.Blocks = XmlFsType.Clusters; switch(bpbKind) { case BpbKind.Hardcoded: - statfs.Type = $"Microsoft FAT{(fat16 ? "16" : "12")}"; + _statfs.Type = $"Microsoft FAT{(_fat16 ? "16" : "12")}"; break; case BpbKind.Atari: - statfs.Type = $"Atari FAT{(fat16 ? "16" : "12")}"; + _statfs.Type = $"Atari FAT{(_fat16 ? "16" : "12")}"; break; case BpbKind.Msx: - statfs.Type = $"MSX FAT{(fat16 ? "16" : "12")}"; + _statfs.Type = $"MSX FAT{(_fat16 ? "16" : "12")}"; break; case BpbKind.Dos2: @@ -703,89 +703,89 @@ namespace Aaru.Filesystems case BpbKind.Dos33: case BpbKind.ShortExtended: case BpbKind.Extended: - statfs.Type = $"Microsoft FAT{(fat16 ? "16" : "12")}"; + _statfs.Type = $"Microsoft FAT{(_fat16 ? "16" : "12")}"; break; case BpbKind.ShortFat32: case BpbKind.LongFat32: - statfs.Type = XmlFsType.Type == "FAT+" ? "FAT+" : "Microsoft FAT32"; + _statfs.Type = XmlFsType.Type == "FAT+" ? "FAT+" : "Microsoft FAT32"; break; case BpbKind.Andos: - statfs.Type = $"ANDOS FAT{(fat16 ? "16" : "12")}"; + _statfs.Type = $"ANDOS FAT{(_fat16 ? "16" : "12")}"; break; case BpbKind.Apricot: - statfs.Type = $"Apricot FAT{(fat16 ? "16" : "12")}"; + _statfs.Type = $"Apricot FAT{(_fat16 ? "16" : "12")}"; break; case BpbKind.DecRainbow: - statfs.Type = $"DEC FAT{(fat16 ? "16" : "12")}"; + _statfs.Type = $"DEC FAT{(_fat16 ? "16" : "12")}"; break; case BpbKind.Human: - statfs.Type = $"Human68k FAT{(fat16 ? "16" : "12")}"; + _statfs.Type = $"Human68k FAT{(_fat16 ? "16" : "12")}"; break; default: throw new ArgumentOutOfRangeException(); } - bytesPerCluster = sectorsPerCluster * imagePlugin.Info.SectorSize; + _bytesPerCluster = _sectorsPerCluster * imagePlugin.Info.SectorSize; - if(fat12) + if(_fat12) { byte[] fatBytes = - imagePlugin.ReadSectors(fatFirstSector + (useFirstFat ? 0 : sectorsPerFat), sectorsPerFat); + imagePlugin.ReadSectors(_fatFirstSector + (_useFirstFat ? 0 : _sectorsPerFat), _sectorsPerFat); - fatEntries = new ushort[statfs.Blocks]; + _fatEntries = new ushort[_statfs.Blocks]; int pos = 0; - for(int i = 0; i + 3 < fatBytes.Length && pos < fatEntries.Length; i += 3) + for(int i = 0; i + 3 < fatBytes.Length && pos < _fatEntries.Length; i += 3) { - fatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]); - fatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF0) >> 4) + (fatBytes[i + 2] << 4)); + _fatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF) << 8) + fatBytes[i + 0]); + _fatEntries[pos++] = (ushort)(((fatBytes[i + 1] & 0xF0) >> 4) + (fatBytes[i + 2] << 4)); } } - else if(fat16) + else if(_fat16) { AaruConsole.DebugWriteLine("FAT plugin", "Reading FAT16"); byte[] fatBytes = - imagePlugin.ReadSectors(fatFirstSector + (useFirstFat ? 0 : sectorsPerFat), sectorsPerFat); + imagePlugin.ReadSectors(_fatFirstSector + (_useFirstFat ? 0 : _sectorsPerFat), _sectorsPerFat); AaruConsole.DebugWriteLine("FAT plugin", "Casting FAT"); - fatEntries = MemoryMarshal.Cast(fatBytes).ToArray(); + _fatEntries = MemoryMarshal.Cast(fatBytes).ToArray(); } // TODO: Check how this affects international filenames - cultureInfo = new CultureInfo("en-US", false); - directoryCache = new Dictionary>(); + _cultureInfo = new CultureInfo("en-US", false); + _directoryCache = new Dictionary>(); // Check it is really an OS/2 EA file - if(eaDirEntry.start_cluster != 0) + if(_eaDirEntry.start_cluster != 0) { CacheEaData(); - ushort eamagic = BitConverter.ToUInt16(cachedEaData, 0); + ushort eamagic = BitConverter.ToUInt16(_cachedEaData, 0); if(eamagic != EADATA_MAGIC) { - eaDirEntry = new DirectoryEntry(); - cachedEaData = null; + _eaDirEntry = new DirectoryEntry(); + _cachedEaData = null; } else - eaCache = new Dictionary>(); + _eaCache = new Dictionary>(); } - else if(fat32) - eaCache = new Dictionary>(); + else if(_fat32) + _eaCache = new Dictionary>(); // Check OS/2 .LONGNAME - if(eaCache != null && - (this.@namespace == Namespace.Os2 || this.@namespace == Namespace.Ecs) && - !fat32) + if(_eaCache != null && + (_namespace == Namespace.Os2 || _namespace == Namespace.Ecs) && + !_fat32) { List> rootFilesWithEas = - rootDirectoryCache.Where(t => t.Value.Dirent.ea_handle != 0).ToList(); + _rootDirectoryCache.Where(t => t.Value.Dirent.ea_handle != 0).ToList(); foreach(KeyValuePair fileWithEa in rootFilesWithEas) { @@ -818,32 +818,32 @@ namespace Aaru.Filesystems longname = longname.Replace('/', '\u2215'); fileWithEa.Value.Longname = longname; - rootDirectoryCache.Remove(fileWithEa.Key); - rootDirectoryCache[fileWithEa.Value.ToString()] = fileWithEa.Value; + _rootDirectoryCache.Remove(fileWithEa.Key); + _rootDirectoryCache[fileWithEa.Value.ToString()] = fileWithEa.Value; } } // Check FAT32.IFS EAs - if(fat32 || debug) + if(_fat32 || _debug) { - List> fat32EaSidecars = rootDirectoryCache. + List> fat32EaSidecars = _rootDirectoryCache. Where(t => t.Key. EndsWith(FAT32_EA_TAIL, true, - cultureInfo)). + _cultureInfo)). ToList(); foreach(KeyValuePair sidecar in fat32EaSidecars) { // No real file this sidecar accompanies - if(!rootDirectoryCache. + if(!_rootDirectoryCache. TryGetValue(sidecar.Key.Substring(0, sidecar.Key.Length - FAT32_EA_TAIL.Length), out CompleteDirectoryEntry fileWithEa)) continue; // If not in debug mode we will consider the lack of EA bitflags to mean the EAs are corrupted or not real - if(!debug) + if(!_debug) if(!fileWithEa.Dirent.caseinfo.HasFlag(CaseInfo.NormalEaOld) && !fileWithEa.Dirent.caseinfo.HasFlag(CaseInfo.CriticalEa) && !fileWithEa.Dirent.caseinfo.HasFlag(CaseInfo.NormalEa) && @@ -852,12 +852,12 @@ namespace Aaru.Filesystems fileWithEa.Fat32Ea = sidecar.Value.Dirent; - if(!debug) - rootDirectoryCache.Remove(sidecar.Key); + if(!_debug) + _rootDirectoryCache.Remove(sidecar.Key); } } - mounted = true; + _mounted = true; return Errno.NoError; } @@ -865,11 +865,11 @@ namespace Aaru.Filesystems /// public Errno Unmount() { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; - mounted = false; - fatEntries = null; + _mounted = false; + _fatEntries = null; return Errno.NoError; } @@ -879,10 +879,10 @@ namespace Aaru.Filesystems { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; - stat = statfs.ShallowCopy(); + stat = _statfs.ShallowCopy(); return Errno.NoError; } diff --git a/Aaru.Filesystems/FAT/Xattr.cs b/Aaru.Filesystems/FAT/Xattr.cs index 2c4532b8c..a68e6eea3 100644 --- a/Aaru.Filesystems/FAT/Xattr.cs +++ b/Aaru.Filesystems/FAT/Xattr.cs @@ -42,25 +42,25 @@ namespace Aaru.Filesystems { public partial class FAT { - Dictionary> eaCache; + Dictionary> _eaCache; /// public Errno ListXAttr(string path, out List xattrs) { xattrs = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; // No other xattr recognized yet - if(cachedEaData is null && - !fat32) + if(_cachedEaData is null && + !_fat32) return Errno.NotSupported; if(path[0] == '/') path = path.Substring(1); - if(eaCache.TryGetValue(path.ToLower(cultureInfo), out Dictionary eas)) + if(_eaCache.TryGetValue(path.ToLower(_cultureInfo), out Dictionary eas)) { xattrs = eas.Keys.ToList(); @@ -75,7 +75,7 @@ namespace Aaru.Filesystems xattrs = new List(); - if(!fat32) + if(!_fat32) { if(entry.Dirent.ea_handle == 0) return Errno.NoError; @@ -93,7 +93,7 @@ namespace Aaru.Filesystems if(eas is null) return Errno.NoError; - eaCache.Add(path.ToLower(cultureInfo), eas); + _eaCache.Add(path.ToLower(_cultureInfo), eas); xattrs = eas.Keys.ToList(); return Errno.NoError; @@ -102,7 +102,7 @@ namespace Aaru.Filesystems /// public Errno GetXattr(string path, string xattr, ref byte[] buf) { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = ListXAttr(path, out List xattrs); @@ -113,13 +113,13 @@ namespace Aaru.Filesystems if(path[0] == '/') path = path.Substring(1); - if(!xattrs.Contains(xattr.ToLower(cultureInfo))) + if(!xattrs.Contains(xattr.ToLower(_cultureInfo))) return Errno.NoSuchExtendedAttribute; - if(!eaCache.TryGetValue(path.ToLower(cultureInfo), out Dictionary eas)) + if(!_eaCache.TryGetValue(path.ToLower(_cultureInfo), out Dictionary eas)) return Errno.InvalidArgument; - if(!eas.TryGetValue(xattr.ToLower(cultureInfo), out byte[] data)) + if(!eas.TryGetValue(xattr.ToLower(_cultureInfo), out byte[] data)) return Errno.InvalidArgument; buf = new byte[data.Length]; @@ -136,7 +136,7 @@ namespace Aaru.Filesystems foreach(uint cluster in rootDirectoryClusters) { byte[] buffer = - image.ReadSectors(firstClusterSector + (cluster * sectorsPerCluster), sectorsPerCluster); + _image.ReadSectors(_firstClusterSector + (cluster * _sectorsPerCluster), _sectorsPerCluster); eaMs.Write(buffer, 0, buffer.Length); } @@ -157,9 +157,9 @@ namespace Aaru.Filesystems int aIndex = eaHandle >> 7; // First 0x20 bytes are the magic number and unused words - ushort a = BitConverter.ToUInt16(cachedEaData, (aIndex * 2) + 0x20); + ushort a = BitConverter.ToUInt16(_cachedEaData, (aIndex * 2) + 0x20); - ushort b = BitConverter.ToUInt16(cachedEaData, (eaHandle * 2) + 0x200); + ushort b = BitConverter.ToUInt16(_cachedEaData, (eaHandle * 2) + 0x200); uint eaCluster = (uint)(a + b); @@ -167,17 +167,19 @@ namespace Aaru.Filesystems return null; EaHeader header = - Marshal.ByteArrayToStructureLittleEndian(cachedEaData, (int)(eaCluster * bytesPerCluster), + Marshal.ByteArrayToStructureLittleEndian(_cachedEaData, (int)(eaCluster * _bytesPerCluster), Marshal.SizeOf()); if(header.magic != 0x4145) return null; - uint eaLen = BitConverter.ToUInt32(cachedEaData, - (int)(eaCluster * bytesPerCluster) + Marshal.SizeOf()); + uint eaLen = BitConverter.ToUInt32(_cachedEaData, + (int)(eaCluster * _bytesPerCluster) + Marshal.SizeOf()); byte[] eaData = new byte[eaLen]; - Array.Copy(cachedEaData, (int)(eaCluster * bytesPerCluster) + Marshal.SizeOf(), eaData, 0, eaLen); + + Array.Copy(_cachedEaData, (int)(eaCluster * _bytesPerCluster) + Marshal.SizeOf(), eaData, 0, + eaLen); return GetEas(eaData); } @@ -190,7 +192,7 @@ namespace Aaru.Filesystems Dictionary eas = new Dictionary(); - if(debug) + if(_debug) eas.Add("com.microsoft.os2.fea", eaData); int pos = 4; @@ -228,17 +230,17 @@ namespace Aaru.Filesystems void CacheEaData() { - if(eaDirEntry.start_cluster == 0) + if(_eaDirEntry.start_cluster == 0) return; var eaDataMs = new MemoryStream(); - foreach(byte[] buffer in GetClusters(eaDirEntry.start_cluster). - Select(cluster => image.ReadSectors(firstClusterSector + (cluster * sectorsPerCluster), - sectorsPerCluster))) + foreach(byte[] buffer in GetClusters(_eaDirEntry.start_cluster). + Select(cluster => _image.ReadSectors(_firstClusterSector + (cluster * _sectorsPerCluster), + _sectorsPerCluster))) eaDataMs.Write(buffer, 0, buffer.Length); - cachedEaData = eaDataMs.ToArray(); + _cachedEaData = eaDataMs.ToArray(); } } } \ No newline at end of file diff --git a/Aaru.Filesystems/FATX/Dir.cs b/Aaru.Filesystems/FATX/Dir.cs index 4a30f0773..77a60e2ba 100644 --- a/Aaru.Filesystems/FATX/Dir.cs +++ b/Aaru.Filesystems/FATX/Dir.cs @@ -44,20 +44,21 @@ namespace Aaru.Filesystems { contents = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; if(string.IsNullOrWhiteSpace(path) || path == "/") { - contents = rootDirectory.Keys.ToList(); + contents = _rootDirectory.Keys.ToList(); return Errno.NoError; } - string cutPath = path.StartsWith("/") ? path.Substring(1).ToLower(cultureInfo) : path.ToLower(cultureInfo); + string cutPath = path.StartsWith("/") ? path.Substring(1).ToLower(_cultureInfo) + : path.ToLower(_cultureInfo); - if(directoryCache.TryGetValue(cutPath, out Dictionary currentDirectory)) + if(_directoryCache.TryGetValue(cutPath, out Dictionary currentDirectory)) { contents = currentDirectory.Keys.ToList(); @@ -70,7 +71,7 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); KeyValuePair entry = - rootDirectory.FirstOrDefault(t => t.Key.ToLower(cultureInfo) == pieces[0]); + _rootDirectory.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[0]); if(string.IsNullOrEmpty(entry.Key)) return Errno.NoSuchFile; @@ -80,11 +81,11 @@ namespace Aaru.Filesystems string currentPath = pieces[0]; - currentDirectory = rootDirectory; + currentDirectory = _rootDirectory; for(int p = 0; p < pieces.Length; p++) { - entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(cultureInfo) == pieces[p]); + entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[p]); if(string.IsNullOrEmpty(entry.Key)) return Errno.NoSuchFile; @@ -95,7 +96,7 @@ namespace Aaru.Filesystems currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}"; uint currentCluster = entry.Value.firstCluster; - if(directoryCache.TryGetValue(currentPath, out currentDirectory)) + if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) continue; uint[] clusters = GetClusters(currentCluster); @@ -103,15 +104,15 @@ namespace Aaru.Filesystems if(clusters is null) return Errno.InvalidArgument; - byte[] directoryBuffer = new byte[bytesPerCluster * clusters.Length]; + byte[] directoryBuffer = new byte[_bytesPerCluster * clusters.Length]; for(int i = 0; i < clusters.Length; i++) { byte[] buffer = - imagePlugin.ReadSectors(firstClusterSector + ((clusters[i] - 1) * sectorsPerCluster), - sectorsPerCluster); + _imagePlugin.ReadSectors(_firstClusterSector + ((clusters[i] - 1) * _sectorsPerCluster), + _sectorsPerCluster); - Array.Copy(buffer, 0, directoryBuffer, i * bytesPerCluster, bytesPerCluster); + Array.Copy(buffer, 0, directoryBuffer, i * _bytesPerCluster, _bytesPerCluster); } currentDirectory = new Dictionary(); @@ -120,7 +121,7 @@ namespace Aaru.Filesystems while(pos < directoryBuffer.Length) { - DirectoryEntry dirent = littleEndian + DirectoryEntry dirent = _littleEndian ? Marshal. ByteArrayToStructureLittleEndian(directoryBuffer, pos, Marshal.SizeOf()) @@ -146,7 +147,7 @@ namespace Aaru.Filesystems currentDirectory.Add(filename, dirent); } - directoryCache.Add(currentPath, currentDirectory); + _directoryCache.Add(currentPath, currentDirectory); } contents = currentDirectory?.Keys.ToList(); diff --git a/Aaru.Filesystems/FATX/FATX.cs b/Aaru.Filesystems/FATX/FATX.cs index 993ff5792..5ed24f398 100644 --- a/Aaru.Filesystems/FATX/FATX.cs +++ b/Aaru.Filesystems/FATX/FATX.cs @@ -42,21 +42,21 @@ namespace Aaru.Filesystems { public partial class XboxFatPlugin : IReadOnlyFilesystem { - uint bytesPerCluster; - CultureInfo cultureInfo; - bool debug; - Dictionary> directoryCache; - ushort[] fat16; - uint[] fat32; - ulong fatStartSector; - ulong firstClusterSector; - IMediaImage imagePlugin; - bool littleEndian; - bool mounted; - Dictionary rootDirectory; - uint sectorsPerCluster; - FileSystemInfo statfs; - Superblock superblock; + uint _bytesPerCluster; + CultureInfo _cultureInfo; + bool _debug; + Dictionary> _directoryCache; + ushort[] _fat16; + uint[] _fat32; + ulong _fatStartSector; + ulong _firstClusterSector; + IMediaImage _imagePlugin; + bool _littleEndian; + bool _mounted; + Dictionary _rootDirectory; + uint _sectorsPerCluster; + FileSystemInfo _statfs; + Superblock _superblock; public FileSystemType XmlFsType { get; private set; } public Encoding Encoding { get; private set; } diff --git a/Aaru.Filesystems/FATX/File.cs b/Aaru.Filesystems/FATX/File.cs index 31aeca5a3..9c15e7aca 100644 --- a/Aaru.Filesystems/FATX/File.cs +++ b/Aaru.Filesystems/FATX/File.cs @@ -46,7 +46,7 @@ namespace Aaru.Filesystems { deviceBlock = 0; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = Stat(path, out FileEntryInfo stat); @@ -55,7 +55,7 @@ namespace Aaru.Filesystems return err; if(stat.Attributes.HasFlag(FileAttributes.Directory) && - !debug) + !_debug) return Errno.IsDirectory; uint[] clusters = GetClusters((uint)stat.Inode); @@ -63,7 +63,7 @@ namespace Aaru.Filesystems if(fileBlock >= clusters.Length) return Errno.InvalidArgument; - deviceBlock = (long)(firstClusterSector + ((clusters[fileBlock] - 1) * sectorsPerCluster)); + deviceBlock = (long)(_firstClusterSector + ((clusters[fileBlock] - 1) * _sectorsPerCluster)); return Errno.NoError; } @@ -72,7 +72,7 @@ namespace Aaru.Filesystems { attributes = new FileAttributes(); - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = Stat(path, out FileEntryInfo stat); @@ -87,7 +87,7 @@ namespace Aaru.Filesystems public Errno Read(string path, long offset, long size, ref byte[] buf) { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = Stat(path, out FileEntryInfo stat); @@ -96,7 +96,7 @@ namespace Aaru.Filesystems return err; if(stat.Attributes.HasFlag(FileAttributes.Directory) && - !debug) + !_debug) return Errno.IsDirectory; if(offset >= stat.Length) @@ -107,11 +107,11 @@ namespace Aaru.Filesystems uint[] clusters = GetClusters((uint)stat.Inode); - long firstCluster = offset / bytesPerCluster; - long offsetInCluster = offset % bytesPerCluster; - long sizeInClusters = (size + offsetInCluster) / bytesPerCluster; + long firstCluster = offset / _bytesPerCluster; + long offsetInCluster = offset % _bytesPerCluster; + long sizeInClusters = (size + offsetInCluster) / _bytesPerCluster; - if((size + offsetInCluster) % bytesPerCluster > 0) + if((size + offsetInCluster) % _bytesPerCluster > 0) sizeInClusters++; var ms = new MemoryStream(); @@ -122,8 +122,9 @@ namespace Aaru.Filesystems return Errno.InvalidArgument; byte[] buffer = - imagePlugin.ReadSectors(firstClusterSector + ((clusters[i + firstCluster] - 1) * sectorsPerCluster), - sectorsPerCluster); + _imagePlugin. + ReadSectors(_firstClusterSector + ((clusters[i + firstCluster] - 1) * _sectorsPerCluster), + _sectorsPerCluster); ms.Write(buffer, 0, buffer.Length); } @@ -139,18 +140,18 @@ namespace Aaru.Filesystems { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; - if(debug && (string.IsNullOrEmpty(path) || path == "$" || path == "/")) + if(_debug && (string.IsNullOrEmpty(path) || path == "$" || path == "/")) { stat = new FileEntryInfo { Attributes = FileAttributes.Directory | FileAttributes.System | FileAttributes.Hidden, - Blocks = GetClusters(superblock.rootDirectoryCluster).Length, - BlockSize = bytesPerCluster, - Length = GetClusters(superblock.rootDirectoryCluster).Length * bytesPerCluster, - Inode = superblock.rootDirectoryCluster, + Blocks = GetClusters(_superblock.rootDirectoryCluster).Length, + BlockSize = _bytesPerCluster, + Length = GetClusters(_superblock.rootDirectoryCluster).Length * _bytesPerCluster, + Inode = _superblock.rootDirectoryCluster, Links = 1 }; @@ -165,24 +166,24 @@ namespace Aaru.Filesystems stat = new FileEntryInfo { Attributes = new FileAttributes(), - Blocks = entry.length / bytesPerCluster, - BlockSize = bytesPerCluster, + Blocks = entry.length / _bytesPerCluster, + BlockSize = _bytesPerCluster, Length = entry.length, Inode = entry.firstCluster, Links = 1, - CreationTime = littleEndian + CreationTime = _littleEndian ? DateHandlers.DosToDateTime(entry.creationDate, entry.creationTime).AddYears(20) : DateHandlers.DosToDateTime(entry.creationTime, entry.creationDate), - AccessTime = littleEndian + AccessTime = _littleEndian ? DateHandlers.DosToDateTime(entry.lastAccessDate, entry.lastAccessTime).AddYears(20) : DateHandlers.DosToDateTime(entry.lastAccessTime, entry.lastAccessDate), - LastWriteTime = littleEndian + LastWriteTime = _littleEndian ? DateHandlers.DosToDateTime(entry.lastWrittenDate, entry.lastWrittenTime). AddYears(20) : DateHandlers.DosToDateTime(entry.lastWrittenTime, entry.lastWrittenDate) }; - if(entry.length % bytesPerCluster > 0) + if(entry.length % _bytesPerCluster > 0) stat.Blocks++; if(entry.attributes.HasFlag(Attributes.Directory)) @@ -212,31 +213,31 @@ namespace Aaru.Filesystems if(startCluster == 0) return null; - if(fat16 is null) + if(_fat16 is null) { - if(startCluster >= fat32.Length) + if(startCluster >= _fat32.Length) return null; } - else if(startCluster >= fat16.Length) + else if(startCluster >= _fat16.Length) return null; List clusters = new List(); uint nextCluster = startCluster; - if(fat16 is null) + if(_fat16 is null) while((nextCluster & FAT32_MASK) > 0 && (nextCluster & FAT32_MASK) <= FAT32_FORMATTED) { clusters.Add(nextCluster); - nextCluster = fat32[nextCluster]; + nextCluster = _fat32[nextCluster]; } else while(nextCluster > 0 && nextCluster <= FAT16_FORMATTED) { clusters.Add(nextCluster); - nextCluster = fat16[nextCluster]; + nextCluster = _fat16[nextCluster]; } return clusters.ToArray(); @@ -246,7 +247,8 @@ namespace Aaru.Filesystems { entry = new DirectoryEntry(); - string cutPath = path.StartsWith("/") ? path.Substring(1).ToLower(cultureInfo) : path.ToLower(cultureInfo); + string cutPath = path.StartsWith("/") ? path.Substring(1).ToLower(_cultureInfo) + : path.ToLower(_cultureInfo); string[] pieces = cutPath.Split(new[] { @@ -266,12 +268,12 @@ namespace Aaru.Filesystems Dictionary parent; if(pieces.Length == 1) - parent = rootDirectory; - else if(!directoryCache.TryGetValue(parentPath, out parent)) + parent = _rootDirectory; + else if(!_directoryCache.TryGetValue(parentPath, out parent)) return Errno.InvalidArgument; KeyValuePair dirent = - parent.FirstOrDefault(t => t.Key.ToLower(cultureInfo) == pieces[^1]); + parent.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[^1]); if(string.IsNullOrEmpty(dirent.Key)) return Errno.NoSuchFile; diff --git a/Aaru.Filesystems/FATX/Super.cs b/Aaru.Filesystems/FATX/Super.cs index da1bed326..9adc605e1 100644 --- a/Aaru.Filesystems/FATX/Super.cs +++ b/Aaru.Filesystems/FATX/Super.cs @@ -50,14 +50,14 @@ namespace Aaru.Filesystems public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, Dictionary options, string @namespace) { - Encoding = Encoding.GetEncoding("iso-8859-15"); - littleEndian = true; + Encoding = Encoding.GetEncoding("iso-8859-15"); + _littleEndian = true; if(options == null) options = GetDefaultOptions(); if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out debug); + bool.TryParse(debugString, out _debug); if(imagePlugin.Info.SectorSize < 512) return Errno.InvalidArgument; @@ -66,42 +66,42 @@ namespace Aaru.Filesystems byte[] sector = imagePlugin.ReadSector(partition.Start); - superblock = Marshal.ByteArrayToStructureLittleEndian(sector); + _superblock = Marshal.ByteArrayToStructureLittleEndian(sector); - if(superblock.magic == FATX_CIGAM) + if(_superblock.magic == FATX_CIGAM) { - superblock = Marshal.ByteArrayToStructureBigEndian(sector); - littleEndian = false; + _superblock = Marshal.ByteArrayToStructureBigEndian(sector); + _littleEndian = false; } - if(superblock.magic != FATX_MAGIC) + if(_superblock.magic != FATX_MAGIC) return Errno.InvalidArgument; AaruConsole.DebugWriteLine("Xbox FAT plugin", - littleEndian ? "Filesystem is little endian" : "Filesystem is big endian"); + _littleEndian ? "Filesystem is little endian" : "Filesystem is big endian"); - int logicalSectorsPerPhysicalSectors = partition.Offset == 0 && littleEndian ? 8 : 1; + int logicalSectorsPerPhysicalSectors = partition.Offset == 0 && _littleEndian ? 8 : 1; AaruConsole.DebugWriteLine("Xbox FAT plugin", "logicalSectorsPerPhysicalSectors = {0}", logicalSectorsPerPhysicalSectors); - string volumeLabel = StringHandlers.CToString(superblock.volumeLabel, - !littleEndian ? Encoding.BigEndianUnicode : Encoding.Unicode, + string volumeLabel = StringHandlers.CToString(_superblock.volumeLabel, + !_littleEndian ? Encoding.BigEndianUnicode : Encoding.Unicode, true); XmlFsType = new FileSystemType { Type = "FATX filesystem", - ClusterSize = (uint)(superblock.sectorsPerCluster * logicalSectorsPerPhysicalSectors * + ClusterSize = (uint)(_superblock.sectorsPerCluster * logicalSectorsPerPhysicalSectors * imagePlugin.Info.SectorSize), VolumeName = volumeLabel, - VolumeSerial = $"{superblock.id:X8}" + VolumeSerial = $"{_superblock.id:X8}" }; XmlFsType.Clusters = (((partition.End - partition.Start) + 1) * imagePlugin.Info.SectorSize) / XmlFsType.ClusterSize; - statfs = new FileSystemInfo + _statfs = new FileSystemInfo { Blocks = XmlFsType.Clusters, FilenameLength = MAX_FILENAME, @@ -110,34 +110,34 @@ namespace Aaru.Filesystems Id = { IsInt = true, - Serial32 = superblock.magic + Serial32 = _superblock.magic }, PluginId = Id, - Type = littleEndian ? "Xbox FAT" : "Xbox 360 FAT", + Type = _littleEndian ? "Xbox FAT" : "Xbox 360 FAT", FreeBlocks = 0 // Requires traversing the FAT }; AaruConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.ClusterSize: {0}", XmlFsType.ClusterSize); AaruConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.VolumeName: {0}", XmlFsType.VolumeName); AaruConsole.DebugWriteLine("Xbox FAT plugin", "XmlFsType.VolumeSerial: {0}", XmlFsType.VolumeSerial); - AaruConsole.DebugWriteLine("Xbox FAT plugin", "stat.Blocks: {0}", statfs.Blocks); - AaruConsole.DebugWriteLine("Xbox FAT plugin", "stat.FilenameLength: {0}", statfs.FilenameLength); - AaruConsole.DebugWriteLine("Xbox FAT plugin", "stat.Id: {0}", statfs.Id.Serial32); - AaruConsole.DebugWriteLine("Xbox FAT plugin", "stat.Type: {0}", statfs.Type); + AaruConsole.DebugWriteLine("Xbox FAT plugin", "stat.Blocks: {0}", _statfs.Blocks); + AaruConsole.DebugWriteLine("Xbox FAT plugin", "stat.FilenameLength: {0}", _statfs.FilenameLength); + AaruConsole.DebugWriteLine("Xbox FAT plugin", "stat.Id: {0}", _statfs.Id.Serial32); + AaruConsole.DebugWriteLine("Xbox FAT plugin", "stat.Type: {0}", _statfs.Type); byte[] buffer; - fatStartSector = (FAT_START / imagePlugin.Info.SectorSize) + partition.Start; + _fatStartSector = (FAT_START / imagePlugin.Info.SectorSize) + partition.Start; uint fatSize; - AaruConsole.DebugWriteLine("Xbox FAT plugin", "fatStartSector: {0}", fatStartSector); + AaruConsole.DebugWriteLine("Xbox FAT plugin", "fatStartSector: {0}", _fatStartSector); - if(statfs.Blocks > MAX_XFAT16_CLUSTERS) + if(_statfs.Blocks > MAX_XFAT16_CLUSTERS) { AaruConsole.DebugWriteLine("Xbox FAT plugin", "Reading FAT32"); - fatSize = (uint)(((statfs.Blocks + 1) * sizeof(uint)) / imagePlugin.Info.SectorSize); + fatSize = (uint)(((_statfs.Blocks + 1) * sizeof(uint)) / imagePlugin.Info.SectorSize); - if((uint)(((statfs.Blocks + 1) * sizeof(uint)) % imagePlugin.Info.SectorSize) > 0) + if((uint)(((_statfs.Blocks + 1) * sizeof(uint)) % imagePlugin.Info.SectorSize) > 0) fatSize++; long fatClusters = (fatSize * imagePlugin.Info.SectorSize) / 4096; @@ -149,27 +149,27 @@ namespace Aaru.Filesystems AaruConsole.DebugWriteLine("Xbox FAT plugin", "FAT is {0} sectors", fatSize); - buffer = imagePlugin.ReadSectors(fatStartSector, fatSize); + buffer = imagePlugin.ReadSectors(_fatStartSector, fatSize); AaruConsole.DebugWriteLine("Xbox FAT plugin", "Casting FAT"); - fat32 = MemoryMarshal.Cast(buffer).ToArray(); + _fat32 = MemoryMarshal.Cast(buffer).ToArray(); - if(!littleEndian) - for(int i = 0; i < fat32.Length; i++) - fat32[i] = Swapping.Swap(fat32[i]); + if(!_littleEndian) + for(int i = 0; i < _fat32.Length; i++) + _fat32[i] = Swapping.Swap(_fat32[i]); - AaruConsole.DebugWriteLine("Xbox FAT plugin", "fat32[0] == FATX32_ID = {0}", fat32[0] == FATX32_ID); + AaruConsole.DebugWriteLine("Xbox FAT plugin", "fat32[0] == FATX32_ID = {0}", _fat32[0] == FATX32_ID); - if(fat32[0] != FATX32_ID) + if(_fat32[0] != FATX32_ID) return Errno.InvalidArgument; } else { AaruConsole.DebugWriteLine("Xbox FAT plugin", "Reading FAT16"); - fatSize = (uint)(((statfs.Blocks + 1) * sizeof(ushort)) / imagePlugin.Info.SectorSize); + fatSize = (uint)(((_statfs.Blocks + 1) * sizeof(ushort)) / imagePlugin.Info.SectorSize); - if((uint)(((statfs.Blocks + 1) * sizeof(ushort)) % imagePlugin.Info.SectorSize) > 0) + if((uint)(((_statfs.Blocks + 1) * sizeof(ushort)) % imagePlugin.Info.SectorSize) > 0) fatSize++; long fatClusters = (fatSize * imagePlugin.Info.SectorSize) / 4096; @@ -181,55 +181,55 @@ namespace Aaru.Filesystems AaruConsole.DebugWriteLine("Xbox FAT plugin", "FAT is {0} sectors", fatSize); - buffer = imagePlugin.ReadSectors(fatStartSector, fatSize); + buffer = imagePlugin.ReadSectors(_fatStartSector, fatSize); AaruConsole.DebugWriteLine("Xbox FAT plugin", "Casting FAT"); - fat16 = MemoryMarshal.Cast(buffer).ToArray(); + _fat16 = MemoryMarshal.Cast(buffer).ToArray(); - if(!littleEndian) - for(int i = 0; i < fat16.Length; i++) - fat16[i] = Swapping.Swap(fat16[i]); + if(!_littleEndian) + for(int i = 0; i < _fat16.Length; i++) + _fat16[i] = Swapping.Swap(_fat16[i]); - AaruConsole.DebugWriteLine("Xbox FAT plugin", "fat16[0] == FATX16_ID = {0}", fat16[0] == FATX16_ID); + AaruConsole.DebugWriteLine("Xbox FAT plugin", "fat16[0] == FATX16_ID = {0}", _fat16[0] == FATX16_ID); - if(fat16[0] != FATX16_ID) + if(_fat16[0] != FATX16_ID) return Errno.InvalidArgument; } - sectorsPerCluster = (uint)(superblock.sectorsPerCluster * logicalSectorsPerPhysicalSectors); - this.imagePlugin = imagePlugin; - firstClusterSector = fatStartSector + fatSize; - bytesPerCluster = sectorsPerCluster * imagePlugin.Info.SectorSize; + _sectorsPerCluster = (uint)(_superblock.sectorsPerCluster * logicalSectorsPerPhysicalSectors); + _imagePlugin = imagePlugin; + _firstClusterSector = _fatStartSector + fatSize; + _bytesPerCluster = _sectorsPerCluster * imagePlugin.Info.SectorSize; - AaruConsole.DebugWriteLine("Xbox FAT plugin", "sectorsPerCluster = {0}", sectorsPerCluster); - AaruConsole.DebugWriteLine("Xbox FAT plugin", "bytesPerCluster = {0}", bytesPerCluster); - AaruConsole.DebugWriteLine("Xbox FAT plugin", "firstClusterSector = {0}", firstClusterSector); + AaruConsole.DebugWriteLine("Xbox FAT plugin", "sectorsPerCluster = {0}", _sectorsPerCluster); + AaruConsole.DebugWriteLine("Xbox FAT plugin", "bytesPerCluster = {0}", _bytesPerCluster); + AaruConsole.DebugWriteLine("Xbox FAT plugin", "firstClusterSector = {0}", _firstClusterSector); - uint[] rootDirectoryClusters = GetClusters(superblock.rootDirectoryCluster); + uint[] rootDirectoryClusters = GetClusters(_superblock.rootDirectoryCluster); if(rootDirectoryClusters is null) return Errno.InvalidArgument; - byte[] rootDirectoryBuffer = new byte[bytesPerCluster * rootDirectoryClusters.Length]; + byte[] rootDirectoryBuffer = new byte[_bytesPerCluster * rootDirectoryClusters.Length]; AaruConsole.DebugWriteLine("Xbox FAT plugin", "Reading root directory"); for(int i = 0; i < rootDirectoryClusters.Length; i++) { buffer = - imagePlugin.ReadSectors(firstClusterSector + ((rootDirectoryClusters[i] - 1) * sectorsPerCluster), - sectorsPerCluster); + imagePlugin.ReadSectors(_firstClusterSector + ((rootDirectoryClusters[i] - 1) * _sectorsPerCluster), + _sectorsPerCluster); - Array.Copy(buffer, 0, rootDirectoryBuffer, i * bytesPerCluster, bytesPerCluster); + Array.Copy(buffer, 0, rootDirectoryBuffer, i * _bytesPerCluster, _bytesPerCluster); } - rootDirectory = new Dictionary(); + _rootDirectory = new Dictionary(); int pos = 0; while(pos < rootDirectoryBuffer.Length) { - DirectoryEntry entry = littleEndian + DirectoryEntry entry = _littleEndian ? Marshal. ByteArrayToStructureLittleEndian(rootDirectoryBuffer, pos, Marshal.SizeOf()) @@ -252,25 +252,25 @@ namespace Aaru.Filesystems string filename = Encoding.GetString(entry.filename, 0, entry.filenameSize); - rootDirectory.Add(filename, entry); + _rootDirectory.Add(filename, entry); } - cultureInfo = new CultureInfo("en-US", false); - directoryCache = new Dictionary>(); - mounted = true; + _cultureInfo = new CultureInfo("en-US", false); + _directoryCache = new Dictionary>(); + _mounted = true; return Errno.NoError; } public Errno Unmount() { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; - fat16 = null; - fat32 = null; - imagePlugin = null; - mounted = false; + _fat16 = null; + _fat32 = null; + _imagePlugin = null; + _mounted = false; return Errno.NoError; } @@ -279,10 +279,10 @@ namespace Aaru.Filesystems { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; - stat = statfs.ShallowCopy(); + stat = _statfs.ShallowCopy(); return Errno.NoError; } diff --git a/Aaru.Filesystems/FFS.cs b/Aaru.Filesystems/FFS.cs index e53006cf8..a0b24f301 100644 --- a/Aaru.Filesystems/FFS.cs +++ b/Aaru.Filesystems/FFS.cs @@ -248,71 +248,71 @@ namespace Aaru.Filesystems // Fun with seeking follows on superblock reading! ufs_sb_sectors = imagePlugin.ReadSectors(sb_offset, sb_size_in_sectors); - UFSSuperBlock ufs_sb = Marshal.ByteArrayToStructureLittleEndian(ufs_sb_sectors); + SuperBlock sb = Marshal.ByteArrayToStructureLittleEndian(ufs_sb_sectors); - UFSSuperBlock bs_sfu = Marshal.ByteArrayToStructureBigEndian(ufs_sb_sectors); + SuperBlock bs_sfu = Marshal.ByteArrayToStructureBigEndian(ufs_sb_sectors); - if((bs_sfu.fs_magic == UFS_MAGIC && ufs_sb.fs_magic == UFS_CIGAM) || - (bs_sfu.fs_magic == UFS_MAGIC_BW && ufs_sb.fs_magic == UFS_CIGAM_BW) || - (bs_sfu.fs_magic == UFS2_MAGIC && ufs_sb.fs_magic == UFS2_CIGAM) || - (bs_sfu.fs_magic == UFS_BAD_MAGIC && ufs_sb.fs_magic == UFS_BAD_CIGAM)) + if((bs_sfu.fs_magic == UFS_MAGIC && sb.fs_magic == UFS_CIGAM) || + (bs_sfu.fs_magic == UFS_MAGIC_BW && sb.fs_magic == UFS_CIGAM_BW) || + (bs_sfu.fs_magic == UFS2_MAGIC && sb.fs_magic == UFS2_CIGAM) || + (bs_sfu.fs_magic == UFS_BAD_MAGIC && sb.fs_magic == UFS_BAD_CIGAM)) { - ufs_sb = bs_sfu; - ufs_sb.fs_old_cstotal.cs_nbfree = Swapping.Swap(ufs_sb.fs_old_cstotal.cs_nbfree); - ufs_sb.fs_old_cstotal.cs_ndir = Swapping.Swap(ufs_sb.fs_old_cstotal.cs_ndir); - ufs_sb.fs_old_cstotal.cs_nffree = Swapping.Swap(ufs_sb.fs_old_cstotal.cs_nffree); - ufs_sb.fs_old_cstotal.cs_nifree = Swapping.Swap(ufs_sb.fs_old_cstotal.cs_nifree); - ufs_sb.fs_cstotal.cs_numclusters = Swapping.Swap(ufs_sb.fs_cstotal.cs_numclusters); - ufs_sb.fs_cstotal.cs_nbfree = Swapping.Swap(ufs_sb.fs_cstotal.cs_nbfree); - ufs_sb.fs_cstotal.cs_ndir = Swapping.Swap(ufs_sb.fs_cstotal.cs_ndir); - ufs_sb.fs_cstotal.cs_nffree = Swapping.Swap(ufs_sb.fs_cstotal.cs_nffree); - ufs_sb.fs_cstotal.cs_nifree = Swapping.Swap(ufs_sb.fs_cstotal.cs_nifree); - ufs_sb.fs_cstotal.cs_spare[0] = Swapping.Swap(ufs_sb.fs_cstotal.cs_spare[0]); - ufs_sb.fs_cstotal.cs_spare[1] = Swapping.Swap(ufs_sb.fs_cstotal.cs_spare[1]); - ufs_sb.fs_cstotal.cs_spare[2] = Swapping.Swap(ufs_sb.fs_cstotal.cs_spare[2]); + sb = bs_sfu; + sb.fs_old_cstotal.cs_nbfree = Swapping.Swap(sb.fs_old_cstotal.cs_nbfree); + sb.fs_old_cstotal.cs_ndir = Swapping.Swap(sb.fs_old_cstotal.cs_ndir); + sb.fs_old_cstotal.cs_nffree = Swapping.Swap(sb.fs_old_cstotal.cs_nffree); + sb.fs_old_cstotal.cs_nifree = Swapping.Swap(sb.fs_old_cstotal.cs_nifree); + sb.fs_cstotal.cs_numclusters = Swapping.Swap(sb.fs_cstotal.cs_numclusters); + sb.fs_cstotal.cs_nbfree = Swapping.Swap(sb.fs_cstotal.cs_nbfree); + sb.fs_cstotal.cs_ndir = Swapping.Swap(sb.fs_cstotal.cs_ndir); + sb.fs_cstotal.cs_nffree = Swapping.Swap(sb.fs_cstotal.cs_nffree); + sb.fs_cstotal.cs_nifree = Swapping.Swap(sb.fs_cstotal.cs_nifree); + sb.fs_cstotal.cs_spare[0] = Swapping.Swap(sb.fs_cstotal.cs_spare[0]); + sb.fs_cstotal.cs_spare[1] = Swapping.Swap(sb.fs_cstotal.cs_spare[1]); + sb.fs_cstotal.cs_spare[2] = Swapping.Swap(sb.fs_cstotal.cs_spare[2]); } - AaruConsole.DebugWriteLine("FFS plugin", "ufs_sb offset: 0x{0:X8}", sb_offset); - AaruConsole.DebugWriteLine("FFS plugin", "fs_rlink: 0x{0:X8}", ufs_sb.fs_rlink); - AaruConsole.DebugWriteLine("FFS plugin", "fs_sblkno: 0x{0:X8}", ufs_sb.fs_sblkno); - AaruConsole.DebugWriteLine("FFS plugin", "fs_cblkno: 0x{0:X8}", ufs_sb.fs_cblkno); - AaruConsole.DebugWriteLine("FFS plugin", "fs_iblkno: 0x{0:X8}", ufs_sb.fs_iblkno); - AaruConsole.DebugWriteLine("FFS plugin", "fs_dblkno: 0x{0:X8}", ufs_sb.fs_dblkno); - AaruConsole.DebugWriteLine("FFS plugin", "fs_size: 0x{0:X8}", ufs_sb.fs_size); - AaruConsole.DebugWriteLine("FFS plugin", "fs_dsize: 0x{0:X8}", ufs_sb.fs_dsize); - AaruConsole.DebugWriteLine("FFS plugin", "fs_ncg: 0x{0:X8}", ufs_sb.fs_ncg); - AaruConsole.DebugWriteLine("FFS plugin", "fs_bsize: 0x{0:X8}", ufs_sb.fs_bsize); - AaruConsole.DebugWriteLine("FFS plugin", "fs_fsize: 0x{0:X8}", ufs_sb.fs_fsize); - AaruConsole.DebugWriteLine("FFS plugin", "fs_frag: 0x{0:X8}", ufs_sb.fs_frag); - AaruConsole.DebugWriteLine("FFS plugin", "fs_minfree: 0x{0:X8}", ufs_sb.fs_minfree); - AaruConsole.DebugWriteLine("FFS plugin", "fs_bmask: 0x{0:X8}", ufs_sb.fs_bmask); - AaruConsole.DebugWriteLine("FFS plugin", "fs_fmask: 0x{0:X8}", ufs_sb.fs_fmask); - AaruConsole.DebugWriteLine("FFS plugin", "fs_bshift: 0x{0:X8}", ufs_sb.fs_bshift); - AaruConsole.DebugWriteLine("FFS plugin", "fs_fshift: 0x{0:X8}", ufs_sb.fs_fshift); - AaruConsole.DebugWriteLine("FFS plugin", "fs_maxcontig: 0x{0:X8}", ufs_sb.fs_maxcontig); - AaruConsole.DebugWriteLine("FFS plugin", "fs_maxbpg: 0x{0:X8}", ufs_sb.fs_maxbpg); - AaruConsole.DebugWriteLine("FFS plugin", "fs_fragshift: 0x{0:X8}", ufs_sb.fs_fragshift); - AaruConsole.DebugWriteLine("FFS plugin", "fs_fsbtodb: 0x{0:X8}", ufs_sb.fs_fsbtodb); - AaruConsole.DebugWriteLine("FFS plugin", "fs_sbsize: 0x{0:X8}", ufs_sb.fs_sbsize); - AaruConsole.DebugWriteLine("FFS plugin", "fs_csmask: 0x{0:X8}", ufs_sb.fs_csmask); - AaruConsole.DebugWriteLine("FFS plugin", "fs_csshift: 0x{0:X8}", ufs_sb.fs_csshift); - AaruConsole.DebugWriteLine("FFS plugin", "fs_nindir: 0x{0:X8}", ufs_sb.fs_nindir); - AaruConsole.DebugWriteLine("FFS plugin", "fs_inopb: 0x{0:X8}", ufs_sb.fs_inopb); - AaruConsole.DebugWriteLine("FFS plugin", "fs_optim: 0x{0:X8}", ufs_sb.fs_optim); - AaruConsole.DebugWriteLine("FFS plugin", "fs_id_1: 0x{0:X8}", ufs_sb.fs_id_1); - AaruConsole.DebugWriteLine("FFS plugin", "fs_id_2: 0x{0:X8}", ufs_sb.fs_id_2); - AaruConsole.DebugWriteLine("FFS plugin", "fs_csaddr: 0x{0:X8}", ufs_sb.fs_csaddr); - AaruConsole.DebugWriteLine("FFS plugin", "fs_cssize: 0x{0:X8}", ufs_sb.fs_cssize); - AaruConsole.DebugWriteLine("FFS plugin", "fs_cgsize: 0x{0:X8}", ufs_sb.fs_cgsize); - AaruConsole.DebugWriteLine("FFS plugin", "fs_ipg: 0x{0:X8}", ufs_sb.fs_ipg); - AaruConsole.DebugWriteLine("FFS plugin", "fs_fpg: 0x{0:X8}", ufs_sb.fs_fpg); - AaruConsole.DebugWriteLine("FFS plugin", "fs_fmod: 0x{0:X2}", ufs_sb.fs_fmod); - AaruConsole.DebugWriteLine("FFS plugin", "fs_clean: 0x{0:X2}", ufs_sb.fs_clean); - AaruConsole.DebugWriteLine("FFS plugin", "fs_ronly: 0x{0:X2}", ufs_sb.fs_ronly); - AaruConsole.DebugWriteLine("FFS plugin", "fs_flags: 0x{0:X2}", ufs_sb.fs_flags); - AaruConsole.DebugWriteLine("FFS plugin", "fs_magic: 0x{0:X8}", ufs_sb.fs_magic); + AaruConsole.DebugWriteLine("FFS plugin", "sb offset: 0x{0:X8}", sb_offset); + AaruConsole.DebugWriteLine("FFS plugin", "fs_rlink: 0x{0:X8}", sb.fs_rlink); + AaruConsole.DebugWriteLine("FFS plugin", "fs_sblkno: 0x{0:X8}", sb.fs_sblkno); + AaruConsole.DebugWriteLine("FFS plugin", "fs_cblkno: 0x{0:X8}", sb.fs_cblkno); + AaruConsole.DebugWriteLine("FFS plugin", "fs_iblkno: 0x{0:X8}", sb.fs_iblkno); + AaruConsole.DebugWriteLine("FFS plugin", "fs_dblkno: 0x{0:X8}", sb.fs_dblkno); + AaruConsole.DebugWriteLine("FFS plugin", "fs_size: 0x{0:X8}", sb.fs_size); + AaruConsole.DebugWriteLine("FFS plugin", "fs_dsize: 0x{0:X8}", sb.fs_dsize); + AaruConsole.DebugWriteLine("FFS plugin", "fs_ncg: 0x{0:X8}", sb.fs_ncg); + AaruConsole.DebugWriteLine("FFS plugin", "fs_bsize: 0x{0:X8}", sb.fs_bsize); + AaruConsole.DebugWriteLine("FFS plugin", "fs_fsize: 0x{0:X8}", sb.fs_fsize); + AaruConsole.DebugWriteLine("FFS plugin", "fs_frag: 0x{0:X8}", sb.fs_frag); + AaruConsole.DebugWriteLine("FFS plugin", "fs_minfree: 0x{0:X8}", sb.fs_minfree); + AaruConsole.DebugWriteLine("FFS plugin", "fs_bmask: 0x{0:X8}", sb.fs_bmask); + AaruConsole.DebugWriteLine("FFS plugin", "fs_fmask: 0x{0:X8}", sb.fs_fmask); + AaruConsole.DebugWriteLine("FFS plugin", "fs_bshift: 0x{0:X8}", sb.fs_bshift); + AaruConsole.DebugWriteLine("FFS plugin", "fs_fshift: 0x{0:X8}", sb.fs_fshift); + AaruConsole.DebugWriteLine("FFS plugin", "fs_maxcontig: 0x{0:X8}", sb.fs_maxcontig); + AaruConsole.DebugWriteLine("FFS plugin", "fs_maxbpg: 0x{0:X8}", sb.fs_maxbpg); + AaruConsole.DebugWriteLine("FFS plugin", "fs_fragshift: 0x{0:X8}", sb.fs_fragshift); + AaruConsole.DebugWriteLine("FFS plugin", "fs_fsbtodb: 0x{0:X8}", sb.fs_fsbtodb); + AaruConsole.DebugWriteLine("FFS plugin", "fs_sbsize: 0x{0:X8}", sb.fs_sbsize); + AaruConsole.DebugWriteLine("FFS plugin", "fs_csmask: 0x{0:X8}", sb.fs_csmask); + AaruConsole.DebugWriteLine("FFS plugin", "fs_csshift: 0x{0:X8}", sb.fs_csshift); + AaruConsole.DebugWriteLine("FFS plugin", "fs_nindir: 0x{0:X8}", sb.fs_nindir); + AaruConsole.DebugWriteLine("FFS plugin", "fs_inopb: 0x{0:X8}", sb.fs_inopb); + AaruConsole.DebugWriteLine("FFS plugin", "fs_optim: 0x{0:X8}", sb.fs_optim); + AaruConsole.DebugWriteLine("FFS plugin", "fs_id_1: 0x{0:X8}", sb.fs_id_1); + AaruConsole.DebugWriteLine("FFS plugin", "fs_id_2: 0x{0:X8}", sb.fs_id_2); + AaruConsole.DebugWriteLine("FFS plugin", "fs_csaddr: 0x{0:X8}", sb.fs_csaddr); + AaruConsole.DebugWriteLine("FFS plugin", "fs_cssize: 0x{0:X8}", sb.fs_cssize); + AaruConsole.DebugWriteLine("FFS plugin", "fs_cgsize: 0x{0:X8}", sb.fs_cgsize); + AaruConsole.DebugWriteLine("FFS plugin", "fs_ipg: 0x{0:X8}", sb.fs_ipg); + AaruConsole.DebugWriteLine("FFS plugin", "fs_fpg: 0x{0:X8}", sb.fs_fpg); + AaruConsole.DebugWriteLine("FFS plugin", "fs_fmod: 0x{0:X2}", sb.fs_fmod); + AaruConsole.DebugWriteLine("FFS plugin", "fs_clean: 0x{0:X2}", sb.fs_clean); + AaruConsole.DebugWriteLine("FFS plugin", "fs_ronly: 0x{0:X2}", sb.fs_ronly); + AaruConsole.DebugWriteLine("FFS plugin", "fs_flags: 0x{0:X2}", sb.fs_flags); + AaruConsole.DebugWriteLine("FFS plugin", "fs_magic: 0x{0:X8}", sb.fs_magic); - if(ufs_sb.fs_magic == UFS2_MAGIC) + if(sb.fs_magic == UFS2_MAGIC) fs_type_ufs2 = true; else { @@ -323,14 +323,14 @@ namespace Aaru.Filesystems fs_type_43bsd = true; // There is no way of knowing this is the version, but there is of knowing it is not. - if(ufs_sb.fs_link > 0) + if(sb.fs_link > 0) { fs_type_42bsd = true; // It was used in 4.2BSD fs_type_43bsd = false; } - if((ufs_sb.fs_maxfilesize & 0xFFFFFFFF) > SunOSEpoch && - DateHandlers.UnixUnsignedToDateTime(ufs_sb.fs_maxfilesize & 0xFFFFFFFF) < DateTime.Now) + if((sb.fs_maxfilesize & 0xFFFFFFFF) > SunOSEpoch && + DateHandlers.UnixUnsignedToDateTime(sb.fs_maxfilesize & 0xFFFFFFFF) < DateTime.Now) { fs_type_42bsd = false; fs_type_sun = true; @@ -338,8 +338,8 @@ namespace Aaru.Filesystems } // This is for sure, as it is shared with a sectors/track with non-x86 SunOS, Epoch is absurdly high for that - if(ufs_sb.fs_old_npsect > SunOSEpoch && - DateHandlers.UnixToDateTime(ufs_sb.fs_old_npsect) < DateTime.Now) + if(sb.fs_old_npsect > SunOSEpoch && + DateHandlers.UnixToDateTime(sb.fs_old_npsect) < DateTime.Now) { fs_type_42bsd = false; fs_type_sun86 = true; @@ -347,8 +347,8 @@ namespace Aaru.Filesystems fs_type_43bsd = false; } - if(ufs_sb.fs_cgrotor > 0x00000000 && - (uint)ufs_sb.fs_cgrotor < 0xFFFFFFFF) + if(sb.fs_cgrotor > 0x00000000 && + (uint)sb.fs_cgrotor < 0xFFFFFFFF) { fs_type_42bsd = false; fs_type_sun = false; @@ -358,10 +358,10 @@ namespace Aaru.Filesystems } // 4.3BSD code does not use these fields, they are always set up to 0 - fs_type_43bsd &= ufs_sb.fs_id_2 == 0 && ufs_sb.fs_id_1 == 0; + fs_type_43bsd &= sb.fs_id_2 == 0 && sb.fs_id_1 == 0; // This is the only 4.4BSD inode format - fs_type_44bsd |= ufs_sb.fs_old_inodefmt == 2; + fs_type_44bsd |= sb.fs_old_inodefmt == 2; } if(!fs_type_ufs2) @@ -391,51 +391,51 @@ namespace Aaru.Filesystems sbInformation.AppendLine("Guessed as UFS"); if(fs_type_42bsd) - sbInformation.AppendFormat("Linked list of filesystems: 0x{0:X8}", ufs_sb.fs_link).AppendLine(); + sbInformation.AppendFormat("Linked list of filesystems: 0x{0:X8}", sb.fs_link).AppendLine(); - sbInformation.AppendFormat("Superblock LBA: {0}", ufs_sb.fs_sblkno).AppendLine(); - sbInformation.AppendFormat("Cylinder-block LBA: {0}", ufs_sb.fs_cblkno).AppendLine(); - sbInformation.AppendFormat("inode-block LBA: {0}", ufs_sb.fs_iblkno).AppendLine(); - sbInformation.AppendFormat("First data block LBA: {0}", ufs_sb.fs_dblkno).AppendLine(); - sbInformation.AppendFormat("Cylinder group offset in cylinder: {0}", ufs_sb.fs_old_cgoffset).AppendLine(); + sbInformation.AppendFormat("Superblock LBA: {0}", sb.fs_sblkno).AppendLine(); + sbInformation.AppendFormat("Cylinder-block LBA: {0}", sb.fs_cblkno).AppendLine(); + sbInformation.AppendFormat("inode-block LBA: {0}", sb.fs_iblkno).AppendLine(); + sbInformation.AppendFormat("First data block LBA: {0}", sb.fs_dblkno).AppendLine(); + sbInformation.AppendFormat("Cylinder group offset in cylinder: {0}", sb.fs_old_cgoffset).AppendLine(); - sbInformation.AppendFormat("Volume last written on {0}", DateHandlers.UnixToDateTime(ufs_sb.fs_old_time)). + sbInformation.AppendFormat("Volume last written on {0}", DateHandlers.UnixToDateTime(sb.fs_old_time)). AppendLine(); - XmlFsType.ModificationDate = DateHandlers.UnixToDateTime(ufs_sb.fs_old_time); + XmlFsType.ModificationDate = DateHandlers.UnixToDateTime(sb.fs_old_time); XmlFsType.ModificationDateSpecified = true; - sbInformation.AppendFormat("{0} blocks in volume ({1} bytes)", ufs_sb.fs_old_size, - (long)ufs_sb.fs_old_size * ufs_sb.fs_fsize).AppendLine(); + sbInformation.AppendFormat("{0} blocks in volume ({1} bytes)", sb.fs_old_size, + (long)sb.fs_old_size * sb.fs_fsize).AppendLine(); - XmlFsType.Clusters = (ulong)ufs_sb.fs_old_size; - XmlFsType.ClusterSize = (uint)ufs_sb.fs_fsize; + XmlFsType.Clusters = (ulong)sb.fs_old_size; + XmlFsType.ClusterSize = (uint)sb.fs_fsize; - sbInformation.AppendFormat("{0} data blocks in volume ({1} bytes)", ufs_sb.fs_old_dsize, - (long)ufs_sb.fs_old_dsize * ufs_sb.fs_fsize).AppendLine(); + sbInformation.AppendFormat("{0} data blocks in volume ({1} bytes)", sb.fs_old_dsize, + (long)sb.fs_old_dsize * sb.fs_fsize).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(); - sbInformation.AppendFormat("{0} frags in a block", ufs_sb.fs_frag).AppendLine(); - sbInformation.AppendFormat("{0}% of blocks must be free", ufs_sb.fs_minfree).AppendLine(); - sbInformation.AppendFormat("{0}ms for optimal next block", ufs_sb.fs_old_rotdelay).AppendLine(); + sbInformation.AppendFormat("{0} cylinder groups in volume", sb.fs_ncg).AppendLine(); + sbInformation.AppendFormat("{0} bytes in a basic block", sb.fs_bsize).AppendLine(); + sbInformation.AppendFormat("{0} bytes in a frag block", sb.fs_fsize).AppendLine(); + sbInformation.AppendFormat("{0} frags in a block", sb.fs_frag).AppendLine(); + sbInformation.AppendFormat("{0}% of blocks must be free", sb.fs_minfree).AppendLine(); + sbInformation.AppendFormat("{0}ms for optimal next block", sb.fs_old_rotdelay).AppendLine(); - sbInformation.AppendFormat("disk rotates {0} times per second ({1}rpm)", ufs_sb.fs_old_rps, - ufs_sb.fs_old_rps * 60).AppendLine(); + sbInformation.AppendFormat("disk rotates {0} times per second ({1}rpm)", sb.fs_old_rps, sb.fs_old_rps * 60). + AppendLine(); - /* sbInformation.AppendFormat("fs_bmask: 0x{0:X8}", ufs_sb.fs_bmask).AppendLine(); - sbInformation.AppendFormat("fs_fmask: 0x{0:X8}", ufs_sb.fs_fmask).AppendLine(); - sbInformation.AppendFormat("fs_bshift: 0x{0:X8}", ufs_sb.fs_bshift).AppendLine(); - sbInformation.AppendFormat("fs_fshift: 0x{0:X8}", ufs_sb.fs_fshift).AppendLine();*/ - sbInformation.AppendFormat("{0} contiguous blocks at maximum", ufs_sb.fs_maxcontig).AppendLine(); - sbInformation.AppendFormat("{0} blocks per cylinder group at maximum", ufs_sb.fs_maxbpg).AppendLine(); - sbInformation.AppendFormat("Superblock is {0} bytes", ufs_sb.fs_sbsize).AppendLine(); - sbInformation.AppendFormat("NINDIR: 0x{0:X8}", ufs_sb.fs_nindir).AppendLine(); - sbInformation.AppendFormat("INOPB: 0x{0:X8}", ufs_sb.fs_inopb).AppendLine(); - sbInformation.AppendFormat("NSPF: 0x{0:X8}", ufs_sb.fs_old_nspf).AppendLine(); + /* sbInformation.AppendFormat("fs_bmask: 0x{0:X8}", sb.fs_bmask).AppendLine(); + sbInformation.AppendFormat("fs_fmask: 0x{0:X8}", sb.fs_fmask).AppendLine(); + sbInformation.AppendFormat("fs_bshift: 0x{0:X8}", sb.fs_bshift).AppendLine(); + sbInformation.AppendFormat("fs_fshift: 0x{0:X8}", sb.fs_fshift).AppendLine();*/ + sbInformation.AppendFormat("{0} contiguous blocks at maximum", sb.fs_maxcontig).AppendLine(); + sbInformation.AppendFormat("{0} blocks per cylinder group at maximum", sb.fs_maxbpg).AppendLine(); + sbInformation.AppendFormat("Superblock is {0} bytes", sb.fs_sbsize).AppendLine(); + sbInformation.AppendFormat("NINDIR: 0x{0:X8}", sb.fs_nindir).AppendLine(); + sbInformation.AppendFormat("INOPB: 0x{0:X8}", sb.fs_inopb).AppendLine(); + sbInformation.AppendFormat("NSPF: 0x{0:X8}", sb.fs_old_nspf).AppendLine(); - switch(ufs_sb.fs_optim) + switch(sb.fs_optim) { case 0: sbInformation.AppendLine("Filesystem will minimize allocation time"); @@ -446,138 +446,135 @@ namespace Aaru.Filesystems break; default: - sbInformation.AppendFormat("Unknown optimization value: 0x{0:X8}", ufs_sb.fs_optim).AppendLine(); + sbInformation.AppendFormat("Unknown optimization value: 0x{0:X8}", sb.fs_optim).AppendLine(); break; } if(fs_type_sun) - sbInformation.AppendFormat("{0} sectors/track", ufs_sb.fs_old_npsect).AppendLine(); + sbInformation.AppendFormat("{0} sectors/track", sb.fs_old_npsect).AppendLine(); else if(fs_type_sun86) - sbInformation.AppendFormat("Volume state on {0}", DateHandlers.UnixToDateTime(ufs_sb.fs_old_npsect)). + sbInformation.AppendFormat("Volume state on {0}", DateHandlers.UnixToDateTime(sb.fs_old_npsect)). AppendLine(); - sbInformation.AppendFormat("Hardware sector interleave: {0}", ufs_sb.fs_old_interleave).AppendLine(); - sbInformation.AppendFormat("Sector 0 skew: {0}/track", ufs_sb.fs_old_trackskew).AppendLine(); + sbInformation.AppendFormat("Hardware sector interleave: {0}", sb.fs_old_interleave).AppendLine(); + sbInformation.AppendFormat("Sector 0 skew: {0}/track", sb.fs_old_trackskew).AppendLine(); - 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(); - else if(fs_type_43bsd && - ufs_sb.fs_id_1 > 0 && - ufs_sb.fs_id_2 > 0) + if(!fs_type_43bsd && + sb.fs_id_1 > 0 && + sb.fs_id_2 > 0) + sbInformation.AppendFormat("Volume ID: 0x{0:X8}{1:X8}", sb.fs_id_1, sb.fs_id_2).AppendLine(); + else if(fs_type_43bsd && + sb.fs_id_1 > 0 && + sb.fs_id_2 > 0) { - sbInformation.AppendFormat("{0} µsec for head switch", ufs_sb.fs_id_1).AppendLine(); - sbInformation.AppendFormat("{0} µsec for track-to-track seek", ufs_sb.fs_id_2).AppendLine(); + sbInformation.AppendFormat("{0} µsec for head switch", sb.fs_id_1).AppendLine(); + sbInformation.AppendFormat("{0} µsec for track-to-track seek", sb.fs_id_2).AppendLine(); } - sbInformation.AppendFormat("Cylinder group summary LBA: {0}", ufs_sb.fs_old_csaddr).AppendLine(); - sbInformation.AppendFormat("{0} bytes in cylinder group summary", ufs_sb.fs_cssize).AppendLine(); - sbInformation.AppendFormat("{0} bytes in cylinder group", ufs_sb.fs_cgsize).AppendLine(); - sbInformation.AppendFormat("{0} tracks/cylinder", ufs_sb.fs_old_ntrak).AppendLine(); - sbInformation.AppendFormat("{0} sectors/track", ufs_sb.fs_old_nsect).AppendLine(); - sbInformation.AppendFormat("{0} sectors/cylinder", ufs_sb.fs_old_spc).AppendLine(); - sbInformation.AppendFormat("{0} cylinder in volume", ufs_sb.fs_old_ncyl).AppendLine(); - sbInformation.AppendFormat("{0} cylinders/group", ufs_sb.fs_old_cpg).AppendLine(); - sbInformation.AppendFormat("{0} inodes per cylinder group", ufs_sb.fs_ipg).AppendLine(); - sbInformation.AppendFormat("{0} blocks per group", ufs_sb.fs_fpg / ufs_sb.fs_frag).AppendLine(); - sbInformation.AppendFormat("{0} directories", ufs_sb.fs_old_cstotal.cs_ndir).AppendLine(); + sbInformation.AppendFormat("Cylinder group summary LBA: {0}", sb.fs_old_csaddr).AppendLine(); + sbInformation.AppendFormat("{0} bytes in cylinder group summary", sb.fs_cssize).AppendLine(); + sbInformation.AppendFormat("{0} bytes in cylinder group", sb.fs_cgsize).AppendLine(); + sbInformation.AppendFormat("{0} tracks/cylinder", sb.fs_old_ntrak).AppendLine(); + sbInformation.AppendFormat("{0} sectors/track", sb.fs_old_nsect).AppendLine(); + sbInformation.AppendFormat("{0} sectors/cylinder", sb.fs_old_spc).AppendLine(); + sbInformation.AppendFormat("{0} cylinder in volume", sb.fs_old_ncyl).AppendLine(); + sbInformation.AppendFormat("{0} cylinders/group", sb.fs_old_cpg).AppendLine(); + sbInformation.AppendFormat("{0} inodes per cylinder group", sb.fs_ipg).AppendLine(); + sbInformation.AppendFormat("{0} blocks per group", sb.fs_fpg / sb.fs_frag).AppendLine(); + sbInformation.AppendFormat("{0} directories", sb.fs_old_cstotal.cs_ndir).AppendLine(); - sbInformation.AppendFormat("{0} free blocks ({1} bytes)", ufs_sb.fs_old_cstotal.cs_nbfree, - (long)ufs_sb.fs_old_cstotal.cs_nbfree * ufs_sb.fs_fsize).AppendLine(); + sbInformation.AppendFormat("{0} free blocks ({1} bytes)", sb.fs_old_cstotal.cs_nbfree, + (long)sb.fs_old_cstotal.cs_nbfree * sb.fs_fsize).AppendLine(); - XmlFsType.FreeClusters = (ulong)ufs_sb.fs_old_cstotal.cs_nbfree; + XmlFsType.FreeClusters = (ulong)sb.fs_old_cstotal.cs_nbfree; XmlFsType.FreeClustersSpecified = true; - sbInformation.AppendFormat("{0} free inodes", ufs_sb.fs_old_cstotal.cs_nifree).AppendLine(); - sbInformation.AppendFormat("{0} free frags", ufs_sb.fs_old_cstotal.cs_nffree).AppendLine(); + sbInformation.AppendFormat("{0} free inodes", sb.fs_old_cstotal.cs_nifree).AppendLine(); + sbInformation.AppendFormat("{0} free frags", sb.fs_old_cstotal.cs_nffree).AppendLine(); - if(ufs_sb.fs_fmod == 1) + if(sb.fs_fmod == 1) { sbInformation.AppendLine("Superblock is under modification"); XmlFsType.Dirty = true; } - if(ufs_sb.fs_clean == 1) + if(sb.fs_clean == 1) sbInformation.AppendLine("Volume is clean"); - if(ufs_sb.fs_ronly == 1) + if(sb.fs_ronly == 1) sbInformation.AppendLine("Volume is read-only"); - sbInformation.AppendFormat("Volume flags: 0x{0:X2}", ufs_sb.fs_flags).AppendLine(); + sbInformation.AppendFormat("Volume flags: 0x{0:X2}", sb.fs_flags).AppendLine(); if(fs_type_ufs) - sbInformation.AppendFormat("Volume last mounted on \"{0}\"", StringHandlers.CToString(ufs_sb.fs_fsmnt)). + sbInformation.AppendFormat("Volume last mounted on \"{0}\"", StringHandlers.CToString(sb.fs_fsmnt)). AppendLine(); else if(fs_type_ufs2) { - sbInformation.AppendFormat("Volume last mounted on \"{0}\"", StringHandlers.CToString(ufs_sb.fs_fsmnt)). + sbInformation.AppendFormat("Volume last mounted on \"{0}\"", StringHandlers.CToString(sb.fs_fsmnt)). AppendLine(); - sbInformation.AppendFormat("Volume name: \"{0}\"", StringHandlers.CToString(ufs_sb.fs_volname)). + sbInformation.AppendFormat("Volume name: \"{0}\"", StringHandlers.CToString(sb.fs_volname)). AppendLine(); - XmlFsType.VolumeName = StringHandlers.CToString(ufs_sb.fs_volname); - sbInformation.AppendFormat("Volume ID: 0x{0:X16}", ufs_sb.fs_swuid).AppendLine(); + XmlFsType.VolumeName = StringHandlers.CToString(sb.fs_volname); + sbInformation.AppendFormat("Volume ID: 0x{0:X16}", sb.fs_swuid).AppendLine(); - //xmlFSType.VolumeSerial = string.Format("{0:X16}", ufs_sb.fs_swuid); - sbInformation.AppendFormat("Last searched cylinder group: {0}", ufs_sb.fs_cgrotor).AppendLine(); - sbInformation.AppendFormat("{0} contiguously allocated directories", ufs_sb.fs_contigdirs).AppendLine(); - sbInformation.AppendFormat("Standard superblock LBA: {0}", ufs_sb.fs_sblkno).AppendLine(); - sbInformation.AppendFormat("{0} directories", ufs_sb.fs_cstotal.cs_ndir).AppendLine(); + //xmlFSType.VolumeSerial = string.Format("{0:X16}", sb.fs_swuid); + sbInformation.AppendFormat("Last searched cylinder group: {0}", sb.fs_cgrotor).AppendLine(); + sbInformation.AppendFormat("{0} contiguously allocated directories", sb.fs_contigdirs).AppendLine(); + sbInformation.AppendFormat("Standard superblock LBA: {0}", sb.fs_sblkno).AppendLine(); + sbInformation.AppendFormat("{0} directories", sb.fs_cstotal.cs_ndir).AppendLine(); - sbInformation.AppendFormat("{0} free blocks ({1} bytes)", ufs_sb.fs_cstotal.cs_nbfree, - ufs_sb.fs_cstotal.cs_nbfree * ufs_sb.fs_fsize).AppendLine(); + sbInformation.AppendFormat("{0} free blocks ({1} bytes)", sb.fs_cstotal.cs_nbfree, + sb.fs_cstotal.cs_nbfree * sb.fs_fsize).AppendLine(); - XmlFsType.FreeClusters = (ulong)ufs_sb.fs_cstotal.cs_nbfree; + XmlFsType.FreeClusters = (ulong)sb.fs_cstotal.cs_nbfree; XmlFsType.FreeClustersSpecified = true; - sbInformation.AppendFormat("{0} free inodes", ufs_sb.fs_cstotal.cs_nifree).AppendLine(); - sbInformation.AppendFormat("{0} free frags", ufs_sb.fs_cstotal.cs_nffree).AppendLine(); - sbInformation.AppendFormat("{0} free clusters", ufs_sb.fs_cstotal.cs_numclusters).AppendLine(); + sbInformation.AppendFormat("{0} free inodes", sb.fs_cstotal.cs_nifree).AppendLine(); + sbInformation.AppendFormat("{0} free frags", sb.fs_cstotal.cs_nffree).AppendLine(); + sbInformation.AppendFormat("{0} free clusters", sb.fs_cstotal.cs_numclusters).AppendLine(); - sbInformation.AppendFormat("Volume last written on {0}", DateHandlers.UnixToDateTime(ufs_sb.fs_time)). + sbInformation.AppendFormat("Volume last written on {0}", DateHandlers.UnixToDateTime(sb.fs_time)). AppendLine(); - XmlFsType.ModificationDate = DateHandlers.UnixToDateTime(ufs_sb.fs_time); + XmlFsType.ModificationDate = DateHandlers.UnixToDateTime(sb.fs_time); XmlFsType.ModificationDateSpecified = true; - sbInformation.AppendFormat("{0} blocks ({1} bytes)", ufs_sb.fs_size, ufs_sb.fs_size * ufs_sb.fs_fsize). + sbInformation.AppendFormat("{0} blocks ({1} bytes)", sb.fs_size, sb.fs_size * sb.fs_fsize).AppendLine(); + + XmlFsType.Clusters = (ulong)sb.fs_size; + + sbInformation.AppendFormat("{0} data blocks ({1} bytes)", sb.fs_dsize, sb.fs_dsize * sb.fs_fsize). AppendLine(); - XmlFsType.Clusters = (ulong)ufs_sb.fs_size; - - sbInformation. - AppendFormat("{0} data blocks ({1} bytes)", ufs_sb.fs_dsize, ufs_sb.fs_dsize * ufs_sb.fs_fsize). - AppendLine(); - - sbInformation.AppendFormat("Cylinder group summary area LBA: {0}", ufs_sb.fs_csaddr).AppendLine(); - sbInformation.AppendFormat("{0} blocks pending of being freed", ufs_sb.fs_pendingblocks).AppendLine(); - sbInformation.AppendFormat("{0} inodes pending of being freed", ufs_sb.fs_pendinginodes).AppendLine(); + sbInformation.AppendFormat("Cylinder group summary area LBA: {0}", sb.fs_csaddr).AppendLine(); + sbInformation.AppendFormat("{0} blocks pending of being freed", sb.fs_pendingblocks).AppendLine(); + sbInformation.AppendFormat("{0} inodes pending of being freed", sb.fs_pendinginodes).AppendLine(); } if(fs_type_sun) - sbInformation.AppendFormat("Volume state on {0}", DateHandlers.UnixToDateTime(ufs_sb.fs_old_npsect)). + sbInformation.AppendFormat("Volume state on {0}", DateHandlers.UnixToDateTime(sb.fs_old_npsect)). AppendLine(); else if(fs_type_sun86) - sbInformation.AppendFormat("{0} sectors/track", ufs_sb.fs_state).AppendLine(); + sbInformation.AppendFormat("{0} sectors/track", sb.fs_state).AppendLine(); else if(fs_type_44bsd) { - sbInformation.AppendFormat("{0} blocks on cluster summary array", ufs_sb.fs_contigsumsize).AppendLine(); + sbInformation.AppendFormat("{0} blocks on cluster summary array", sb.fs_contigsumsize).AppendLine(); - sbInformation.AppendFormat("Maximum length of a symbolic link: {0}", ufs_sb.fs_maxsymlinklen). - AppendLine(); + sbInformation.AppendFormat("Maximum length of a symbolic link: {0}", sb.fs_maxsymlinklen).AppendLine(); - sbInformation.AppendFormat("A file can be {0} bytes at max", ufs_sb.fs_maxfilesize).AppendLine(); + sbInformation.AppendFormat("A file can be {0} bytes at max", sb.fs_maxfilesize).AppendLine(); - sbInformation.AppendFormat("Volume state on {0}", DateHandlers.UnixToDateTime(ufs_sb.fs_state)). + sbInformation.AppendFormat("Volume state on {0}", DateHandlers.UnixToDateTime(sb.fs_state)). AppendLine(); } - if(ufs_sb.fs_old_nrpos > 0) - sbInformation.AppendFormat("{0} rotational positions", ufs_sb.fs_old_nrpos).AppendLine(); + if(sb.fs_old_nrpos > 0) + sbInformation.AppendFormat("{0} rotational positions", sb.fs_old_nrpos).AppendLine(); - if(ufs_sb.fs_old_rotbloff > 0) - sbInformation.AppendFormat("{0} blocks per rotation", ufs_sb.fs_old_rotbloff).AppendLine(); + if(sb.fs_old_rotbloff > 0) + sbInformation.AppendFormat("{0} blocks per rotation", sb.fs_old_rotbloff).AppendLine(); information = sbInformation.ToString(); } @@ -614,7 +611,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct UFSSuperBlock + struct SuperBlock { /// linked list of file systems public readonly uint fs_link; diff --git a/Aaru.Filesystems/Fossil.cs b/Aaru.Filesystems/Fossil.cs index 09d7fa2b4..d649a3d75 100644 --- a/Aaru.Filesystems/Fossil.cs +++ b/Aaru.Filesystems/Fossil.cs @@ -63,8 +63,8 @@ namespace Aaru.Filesystems if(partition.Start + hdrSector > imagePlugin.Info.Sectors) return false; - byte[] sector = imagePlugin.ReadSector(partition.Start + hdrSector); - FossilHeader hdr = Marshal.ByteArrayToStructureBigEndian(sector); + byte[] sector = imagePlugin.ReadSector(partition.Start + hdrSector); + Header hdr = Marshal.ByteArrayToStructureBigEndian
(sector); AaruConsole.DebugWriteLine("Fossil plugin", "magic at 0x{0:X8} (expected 0x{1:X8})", hdr.magic, FOSSIL_HDR_MAGIC); @@ -84,8 +84,8 @@ namespace Aaru.Filesystems ulong hdrSector = HEADER_POS / imagePlugin.Info.SectorSize; - byte[] sector = imagePlugin.ReadSector(partition.Start + hdrSector); - FossilHeader hdr = Marshal.ByteArrayToStructureBigEndian(sector); + byte[] sector = imagePlugin.ReadSector(partition.Start + hdrSector); + Header hdr = Marshal.ByteArrayToStructureBigEndian
(sector); AaruConsole.DebugWriteLine("Fossil plugin", "magic at 0x{0:X8} (expected 0x{1:X8})", hdr.magic, FOSSIL_HDR_MAGIC); @@ -112,7 +112,7 @@ namespace Aaru.Filesystems if(sbLocation <= partition.End) { sector = imagePlugin.ReadSector(sbLocation); - FossilSuperBlock fsb = Marshal.ByteArrayToStructureBigEndian(sector); + SuperBlock fsb = Marshal.ByteArrayToStructureBigEndian(sector); AaruConsole.DebugWriteLine("Fossil plugin", "magic 0x{0:X8} (expected 0x{1:X8})", fsb.magic, FOSSIL_SB_MAGIC); @@ -134,7 +134,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct FossilHeader + struct Header { /// Magic number public readonly uint magic; @@ -153,7 +153,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct FossilSuperBlock + struct SuperBlock { /// Magic number public readonly uint magic; diff --git a/Aaru.Filesystems/HAMMER.cs b/Aaru.Filesystems/HAMMER.cs index f8bb35625..db5c1ead9 100644 --- a/Aaru.Filesystems/HAMMER.cs +++ b/Aaru.Filesystems/HAMMER.cs @@ -85,7 +85,7 @@ namespace Aaru.Filesystems var sb = new StringBuilder(); - HammerSuperBlock hammerSb; + SuperBlock superBlock; uint run = HAMMER_VOLHDR_SIZE / imagePlugin.Info.SectorSize; @@ -97,24 +97,24 @@ namespace Aaru.Filesystems ulong magic = BitConverter.ToUInt64(sbSector, 0); if(magic == HAMMER_FSBUF_VOLUME) - hammerSb = Marshal.ByteArrayToStructureLittleEndian(sbSector); + superBlock = Marshal.ByteArrayToStructureLittleEndian(sbSector); else - hammerSb = Marshal.ByteArrayToStructureBigEndian(sbSector); + superBlock = Marshal.ByteArrayToStructureBigEndian(sbSector); sb.AppendLine("HAMMER filesystem"); - sb.AppendFormat("Volume version: {0}", hammerSb.vol_version).AppendLine(); + sb.AppendFormat("Volume version: {0}", superBlock.vol_version).AppendLine(); - sb.AppendFormat("Volume {0} of {1} on this filesystem", hammerSb.vol_no + 1, hammerSb.vol_count). + sb.AppendFormat("Volume {0} of {1} on this filesystem", superBlock.vol_no + 1, superBlock.vol_count). AppendLine(); - sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(hammerSb.vol_label, Encoding)).AppendLine(); - sb.AppendFormat("Volume serial: {0}", hammerSb.vol_fsid).AppendLine(); - sb.AppendFormat("Filesystem type: {0}", hammerSb.vol_fstype).AppendLine(); - sb.AppendFormat("Boot area starts at {0}", hammerSb.vol_bot_beg).AppendLine(); - sb.AppendFormat("Memory log starts at {0}", hammerSb.vol_mem_beg).AppendLine(); - sb.AppendFormat("First volume buffer starts at {0}", hammerSb.vol_buf_beg).AppendLine(); - sb.AppendFormat("Volume ends at {0}", hammerSb.vol_buf_end).AppendLine(); + sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(superBlock.vol_label, Encoding)).AppendLine(); + sb.AppendFormat("Volume serial: {0}", superBlock.vol_fsid).AppendLine(); + sb.AppendFormat("Filesystem type: {0}", superBlock.vol_fstype).AppendLine(); + sb.AppendFormat("Boot area starts at {0}", superBlock.vol_bot_beg).AppendLine(); + sb.AppendFormat("Memory log starts at {0}", superBlock.vol_mem_beg).AppendLine(); + sb.AppendFormat("First volume buffer starts at {0}", superBlock.vol_buf_beg).AppendLine(); + sb.AppendFormat("Volume ends at {0}", superBlock.vol_buf_end).AppendLine(); XmlFsType = new FileSystemType { @@ -122,24 +122,25 @@ namespace Aaru.Filesystems ClusterSize = HAMMER_BIGBLOCK_SIZE, Dirty = false, Type = "HAMMER", - VolumeName = StringHandlers.CToString(hammerSb.vol_label, Encoding), - VolumeSerial = hammerSb.vol_fsid.ToString() + VolumeName = StringHandlers.CToString(superBlock.vol_label, Encoding), + VolumeSerial = superBlock.vol_fsid.ToString() }; - if(hammerSb.vol_no == hammerSb.vol_rootvol) + if(superBlock.vol_no == superBlock.vol_rootvol) { - sb.AppendFormat("Filesystem contains {0} \"big-blocks\" ({1} bytes)", hammerSb.vol0_stat_bigblocks, - hammerSb.vol0_stat_bigblocks * HAMMER_BIGBLOCK_SIZE).AppendLine(); + sb.AppendFormat("Filesystem contains {0} \"big-blocks\" ({1} bytes)", superBlock.vol0_stat_bigblocks, + superBlock.vol0_stat_bigblocks * HAMMER_BIGBLOCK_SIZE).AppendLine(); - sb.AppendFormat("Filesystem has {0} \"big-blocks\" free ({1} bytes)", hammerSb.vol0_stat_freebigblocks, - hammerSb.vol0_stat_freebigblocks * HAMMER_BIGBLOCK_SIZE).AppendLine(); + sb.AppendFormat("Filesystem has {0} \"big-blocks\" free ({1} bytes)", + superBlock.vol0_stat_freebigblocks, + superBlock.vol0_stat_freebigblocks * HAMMER_BIGBLOCK_SIZE).AppendLine(); - sb.AppendFormat("Filesystem has {0} inode used", hammerSb.vol0_stat_inodes).AppendLine(); + sb.AppendFormat("Filesystem has {0} inode used", superBlock.vol0_stat_inodes).AppendLine(); - XmlFsType.Clusters = (ulong)hammerSb.vol0_stat_bigblocks; - XmlFsType.FreeClusters = (ulong)hammerSb.vol0_stat_freebigblocks; + XmlFsType.Clusters = (ulong)superBlock.vol0_stat_bigblocks; + XmlFsType.FreeClusters = (ulong)superBlock.vol0_stat_freebigblocks; XmlFsType.FreeClustersSpecified = true; - XmlFsType.Files = (ulong)hammerSb.vol0_stat_inodes; + XmlFsType.Files = (ulong)superBlock.vol0_stat_inodes; XmlFsType.FilesSpecified = true; } @@ -151,7 +152,7 @@ namespace Aaru.Filesystems /// Hammer superblock [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")] - struct HammerSuperBlock + struct SuperBlock { /// for a valid header public readonly ulong vol_signature; diff --git a/Aaru.Filesystems/HPFS.cs b/Aaru.Filesystems/HPFS.cs index b917d2f3b..230c563c0 100644 --- a/Aaru.Filesystems/HPFS.cs +++ b/Aaru.Filesystems/HPFS.cs @@ -82,51 +82,49 @@ namespace Aaru.Filesystems byte[] hpfsSpSector = imagePlugin.ReadSector(17 + partition.Start); // Seek to spareblock, on logical sector 17 - HpfsBiosParameterBlock hpfsBpb = - Marshal.ByteArrayToStructureLittleEndian(hpfsBpbSector); + BiosParameterBlock bpb = Marshal.ByteArrayToStructureLittleEndian(hpfsBpbSector); - HpfsSuperBlock hpfsSb = Marshal.ByteArrayToStructureLittleEndian(hpfsSbSector); + SuperBlock hpfsSb = Marshal.ByteArrayToStructureLittleEndian(hpfsSbSector); - HpfsSpareBlock hpfsSp = Marshal.ByteArrayToStructureLittleEndian(hpfsSpSector); + SpareBlock sp = Marshal.ByteArrayToStructureLittleEndian(hpfsSpSector); - if(StringHandlers.CToString(hpfsBpb.fs_type) != "HPFS " || - hpfsSb.magic1 != 0xF995E849 || - hpfsSb.magic2 != 0xFA53E9C5 || - hpfsSp.magic1 != 0xF9911849 || - hpfsSp.magic2 != 0xFA5229C5) + if(StringHandlers.CToString(bpb.fs_type) != "HPFS " || + hpfsSb.magic1 != 0xF995E849 || + hpfsSb.magic2 != 0xFA53E9C5 || + sp.magic1 != 0xF9911849 || + sp.magic2 != 0xFA5229C5) { sb.AppendLine("This may not be HPFS, following information may be not correct."); - sb.AppendFormat("File system type: \"{0}\" (Should be \"HPFS \")", hpfsBpb.fs_type).AppendLine(); + sb.AppendFormat("File system type: \"{0}\" (Should be \"HPFS \")", bpb.fs_type).AppendLine(); sb.AppendFormat("Superblock magic1: 0x{0:X8} (Should be 0xF995E849)", hpfsSb.magic1).AppendLine(); sb.AppendFormat("Superblock magic2: 0x{0:X8} (Should be 0xFA53E9C5)", hpfsSb.magic2).AppendLine(); - sb.AppendFormat("Spareblock magic1: 0x{0:X8} (Should be 0xF9911849)", hpfsSp.magic1).AppendLine(); - sb.AppendFormat("Spareblock magic2: 0x{0:X8} (Should be 0xFA5229C5)", hpfsSp.magic2).AppendLine(); + sb.AppendFormat("Spareblock magic1: 0x{0:X8} (Should be 0xF9911849)", sp.magic1).AppendLine(); + sb.AppendFormat("Spareblock magic2: 0x{0:X8} (Should be 0xFA5229C5)", sp.magic2).AppendLine(); } - sb.AppendFormat("OEM name: {0}", StringHandlers.CToString(hpfsBpb.oem_name)).AppendLine(); - sb.AppendFormat("{0} bytes per sector", hpfsBpb.bps).AppendLine(); + sb.AppendFormat("OEM name: {0}", StringHandlers.CToString(bpb.oem_name)).AppendLine(); + sb.AppendFormat("{0} bytes per sector", bpb.bps).AppendLine(); // sb.AppendFormat("{0} sectors per cluster", hpfs_bpb.spc).AppendLine(); // sb.AppendFormat("{0} reserved sectors", hpfs_bpb.rsectors).AppendLine(); // sb.AppendFormat("{0} FATs", hpfs_bpb.fats_no).AppendLine(); // sb.AppendFormat("{0} entries on root directory", hpfs_bpb.root_ent).AppendLine(); // sb.AppendFormat("{0} mini sectors on volume", hpfs_bpb.sectors).AppendLine(); - sb.AppendFormat("Media descriptor: 0x{0:X2}", hpfsBpb.media).AppendLine(); + sb.AppendFormat("Media descriptor: 0x{0:X2}", bpb.media).AppendLine(); // sb.AppendFormat("{0} sectors per FAT", hpfs_bpb.spfat).AppendLine(); // sb.AppendFormat("{0} sectors per track", hpfs_bpb.sptrk).AppendLine(); // sb.AppendFormat("{0} heads", hpfs_bpb.heads).AppendLine(); - sb.AppendFormat("{0} sectors hidden before BPB", hpfsBpb.hsectors).AppendLine(); + sb.AppendFormat("{0} sectors hidden before BPB", bpb.hsectors).AppendLine(); - sb.AppendFormat("{0} sectors on volume ({1} bytes)", hpfsSb.sectors, hpfsSb.sectors * hpfsBpb.bps). - AppendLine(); + sb.AppendFormat("{0} sectors on volume ({1} bytes)", hpfsSb.sectors, hpfsSb.sectors * bpb.bps).AppendLine(); // sb.AppendFormat("{0} sectors on volume ({1} bytes)", hpfs_bpb.big_sectors, hpfs_bpb.big_sectors * hpfs_bpb.bps).AppendLine(); - sb.AppendFormat("BIOS Drive Number: 0x{0:X2}", hpfsBpb.drive_no).AppendLine(); - sb.AppendFormat("NT Flags: 0x{0:X2}", hpfsBpb.nt_flags).AppendLine(); - sb.AppendFormat("Signature: 0x{0:X2}", hpfsBpb.signature).AppendLine(); - sb.AppendFormat("Serial number: 0x{0:X8}", hpfsBpb.serial_no).AppendLine(); - sb.AppendFormat("Volume label: {0}", StringHandlers.CToString(hpfsBpb.volume_label, Encoding)).AppendLine(); + sb.AppendFormat("BIOS Drive Number: 0x{0:X2}", bpb.drive_no).AppendLine(); + sb.AppendFormat("NT Flags: 0x{0:X2}", bpb.nt_flags).AppendLine(); + sb.AppendFormat("Signature: 0x{0:X2}", bpb.signature).AppendLine(); + sb.AppendFormat("Serial number: 0x{0:X8}", bpb.serial_no).AppendLine(); + sb.AppendFormat("Volume label: {0}", StringHandlers.CToString(bpb.volume_label, Encoding)).AppendLine(); // sb.AppendFormat("Filesystem type: \"{0}\"", hpfs_bpb.fs_type).AppendLine(); @@ -156,92 +154,92 @@ namespace Aaru.Filesystems sb.AppendFormat("Sector of directory band bitmap: {0}", hpfsSb.dband_bitmap).AppendLine(); sb.AppendFormat("Sector of ACL directory: {0}", hpfsSb.acl_start).AppendLine(); - sb.AppendFormat("Sector of Hotfix directory: {0}", hpfsSp.hotfix_start).AppendLine(); - sb.AppendFormat("{0} used Hotfix entries", hpfsSp.hotfix_used).AppendLine(); - sb.AppendFormat("{0} total Hotfix entries", hpfsSp.hotfix_entries).AppendLine(); - sb.AppendFormat("{0} free spare DNodes", hpfsSp.spare_dnodes_free).AppendLine(); - sb.AppendFormat("{0} total spare DNodes", hpfsSp.spare_dnodes).AppendLine(); - sb.AppendFormat("Sector of codepage directory: {0}", hpfsSp.codepage_lsn).AppendLine(); - sb.AppendFormat("{0} codepages used in the volume", hpfsSp.codepages).AppendLine(); - sb.AppendFormat("SuperBlock CRC32: {0:X8}", hpfsSp.sb_crc32).AppendLine(); - sb.AppendFormat("SpareBlock CRC32: {0:X8}", hpfsSp.sp_crc32).AppendLine(); + sb.AppendFormat("Sector of Hotfix directory: {0}", sp.hotfix_start).AppendLine(); + sb.AppendFormat("{0} used Hotfix entries", sp.hotfix_used).AppendLine(); + sb.AppendFormat("{0} total Hotfix entries", sp.hotfix_entries).AppendLine(); + sb.AppendFormat("{0} free spare DNodes", sp.spare_dnodes_free).AppendLine(); + sb.AppendFormat("{0} total spare DNodes", sp.spare_dnodes).AppendLine(); + sb.AppendFormat("Sector of codepage directory: {0}", sp.codepage_lsn).AppendLine(); + sb.AppendFormat("{0} codepages used in the volume", sp.codepages).AppendLine(); + sb.AppendFormat("SuperBlock CRC32: {0:X8}", sp.sb_crc32).AppendLine(); + sb.AppendFormat("SpareBlock CRC32: {0:X8}", sp.sp_crc32).AppendLine(); sb.AppendLine("Flags:"); - sb.AppendLine((hpfsSp.flags1 & 0x01) == 0x01 ? "Filesystem is dirty." : "Filesystem is clean."); + sb.AppendLine((sp.flags1 & 0x01) == 0x01 ? "Filesystem is dirty." : "Filesystem is clean."); - if((hpfsSp.flags1 & 0x02) == 0x02) + if((sp.flags1 & 0x02) == 0x02) sb.AppendLine("Spare directory blocks are in use"); - if((hpfsSp.flags1 & 0x04) == 0x04) + if((sp.flags1 & 0x04) == 0x04) sb.AppendLine("Hotfixes are in use"); - if((hpfsSp.flags1 & 0x08) == 0x08) + if((sp.flags1 & 0x08) == 0x08) sb.AppendLine("Disk contains bad sectors"); - if((hpfsSp.flags1 & 0x10) == 0x10) + if((sp.flags1 & 0x10) == 0x10) sb.AppendLine("Disk has a bad bitmap"); - if((hpfsSp.flags1 & 0x20) == 0x20) + if((sp.flags1 & 0x20) == 0x20) sb.AppendLine("Filesystem was formatted fast"); - if((hpfsSp.flags1 & 0x40) == 0x40) + if((sp.flags1 & 0x40) == 0x40) sb.AppendLine("Unknown flag 0x40 on flags1 is active"); - if((hpfsSp.flags1 & 0x80) == 0x80) + if((sp.flags1 & 0x80) == 0x80) sb.AppendLine("Filesystem has been mounted by an old IFS"); - if((hpfsSp.flags2 & 0x01) == 0x01) + if((sp.flags2 & 0x01) == 0x01) sb.AppendLine("Install DASD limits"); - if((hpfsSp.flags2 & 0x02) == 0x02) + if((sp.flags2 & 0x02) == 0x02) sb.AppendLine("Resync DASD limits"); - if((hpfsSp.flags2 & 0x04) == 0x04) + if((sp.flags2 & 0x04) == 0x04) sb.AppendLine("DASD limits are operational"); - if((hpfsSp.flags2 & 0x08) == 0x08) + if((sp.flags2 & 0x08) == 0x08) sb.AppendLine("Multimedia is active"); - if((hpfsSp.flags2 & 0x10) == 0x10) + if((sp.flags2 & 0x10) == 0x10) sb.AppendLine("DCE ACLs are active"); - if((hpfsSp.flags2 & 0x20) == 0x20) + if((sp.flags2 & 0x20) == 0x20) sb.AppendLine("DASD limits are dirty"); - if((hpfsSp.flags2 & 0x40) == 0x40) + if((sp.flags2 & 0x40) == 0x40) sb.AppendLine("Unknown flag 0x40 on flags2 is active"); - if((hpfsSp.flags2 & 0x80) == 0x80) + if((sp.flags2 & 0x80) == 0x80) sb.AppendLine("Unknown flag 0x80 on flags2 is active"); XmlFsType = new FileSystemType(); // Theoretically everything from BPB to SB is boot code, should I hash everything or only the sector loaded by BIOS itself? - if(hpfsBpb.jump[0] == 0xEB && - hpfsBpb.jump[1] > 0x3C && - hpfsBpb.jump[1] < 0x80 && - hpfsBpb.signature2 == 0xAA55) + if(bpb.jump[0] == 0xEB && + bpb.jump[1] > 0x3C && + bpb.jump[1] < 0x80 && + bpb.signature2 == 0xAA55) { XmlFsType.Bootable = true; - string bootChk = Sha1Context.Data(hpfsBpb.boot_code, out byte[] _); + string bootChk = Sha1Context.Data(bpb.boot_code, out byte[] _); sb.AppendLine("Volume is bootable"); sb.AppendFormat("Boot code's SHA1: {0}", bootChk).AppendLine(); } - XmlFsType.Dirty |= (hpfsSp.flags1 & 0x01) == 0x01; + XmlFsType.Dirty |= (sp.flags1 & 0x01) == 0x01; XmlFsType.Clusters = hpfsSb.sectors; - XmlFsType.ClusterSize = hpfsBpb.bps; + XmlFsType.ClusterSize = bpb.bps; XmlFsType.Type = "HPFS"; - XmlFsType.VolumeName = StringHandlers.CToString(hpfsBpb.volume_label, Encoding); - XmlFsType.VolumeSerial = $"{hpfsBpb.serial_no:X8}"; - XmlFsType.SystemIdentifier = StringHandlers.CToString(hpfsBpb.oem_name); + XmlFsType.VolumeName = StringHandlers.CToString(bpb.volume_label, Encoding); + XmlFsType.VolumeSerial = $"{bpb.serial_no:X8}"; + XmlFsType.SystemIdentifier = StringHandlers.CToString(bpb.oem_name); information = sb.ToString(); } /// BIOS Parameter Block, at sector 0 [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HpfsBiosParameterBlock + struct BiosParameterBlock { /// 0x000, Jump to boot code [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] @@ -296,7 +294,7 @@ namespace Aaru.Filesystems /// HPFS superblock at sector 16 [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HpfsSuperBlock + struct SuperBlock { /// 0x000, 0xF995E849 public readonly uint magic1; @@ -348,7 +346,7 @@ namespace Aaru.Filesystems /// HPFS spareblock at sector 17 [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HpfsSpareBlock + struct SpareBlock { /// 0x000, 0xF9911849 public readonly uint magic1; diff --git a/Aaru.Filesystems/HPOFS/Consts.cs b/Aaru.Filesystems/HPOFS/Consts.cs index 4de35c099..b2c9f9ca8 100644 --- a/Aaru.Filesystems/HPOFS/Consts.cs +++ b/Aaru.Filesystems/HPOFS/Consts.cs @@ -34,15 +34,15 @@ namespace Aaru.Filesystems { public partial class HPOFS { - readonly byte[] hpofsType = + readonly byte[] _type = { 0x48, 0x50, 0x4F, 0x46, 0x53, 0x00, 0x00, 0x00 }; - readonly byte[] medinfoSignature = + readonly byte[] _medinfoSignature = { 0x4D, 0x45, 0x44, 0x49, 0x4E, 0x46, 0x4F, 0x20 }; - readonly byte[] volinfoSignature = + readonly byte[] _volinfoSignature = { 0x56, 0x4F, 0x4C, 0x49, 0x4E, 0x46, 0x4F, 0x20 }; diff --git a/Aaru.Filesystems/HPOFS/Info.cs b/Aaru.Filesystems/HPOFS/Info.cs index 83d6aad28..86a63f1f8 100644 --- a/Aaru.Filesystems/HPOFS/Info.cs +++ b/Aaru.Filesystems/HPOFS/Info.cs @@ -56,7 +56,7 @@ namespace Aaru.Filesystems BiosParameterBlock bpb = Marshal.ByteArrayToStructureLittleEndian(hpofsBpbSector); - return bpb.fs_type.SequenceEqual(hpofsType); + return bpb.fs_type.SequenceEqual(_type); } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, diff --git a/Aaru.Filesystems/ISO9660/Consts/CDi.cs b/Aaru.Filesystems/ISO9660/Consts/CDi.cs index be904fd15..080fdfd7c 100644 --- a/Aaru.Filesystems/ISO9660/Consts/CDi.cs +++ b/Aaru.Filesystems/ISO9660/Consts/CDi.cs @@ -40,9 +40,9 @@ namespace Aaru.Filesystems { public partial class ISO9660 { - const string CDI_MAGIC = "CD-I "; - static readonly int CdiDirectoryRecordSize = Marshal.SizeOf(); - static readonly int CdiSystemAreaSize = Marshal.SizeOf(); + const string CDI_MAGIC = "CD-I "; + static readonly int _cdiDirectoryRecordSize = Marshal.SizeOf(); + static readonly int _cdiSystemAreaSize = Marshal.SizeOf(); [Flags] enum CdiVolumeFlags : byte diff --git a/Aaru.Filesystems/ISO9660/Consts/ElTorito.cs b/Aaru.Filesystems/ISO9660/Consts/ElTorito.cs index d50f2528c..b1cc60ef1 100644 --- a/Aaru.Filesystems/ISO9660/Consts/ElTorito.cs +++ b/Aaru.Filesystems/ISO9660/Consts/ElTorito.cs @@ -56,8 +56,8 @@ namespace Aaru.Filesystems enum ElToritoEmulation : byte { - None = 0, Md2hd = 1, Mf2hd = 2, - Mf2ed = 3, Hdd = 4 + None = 0, Md2Hd = 1, Mf2Hd = 2, + Mf2Ed = 3, Hdd = 4 } [Flags] diff --git a/Aaru.Filesystems/ISO9660/Consts/HighSierra.cs b/Aaru.Filesystems/ISO9660/Consts/HighSierra.cs index 508ebf3d3..51c39b33f 100644 --- a/Aaru.Filesystems/ISO9660/Consts/HighSierra.cs +++ b/Aaru.Filesystems/ISO9660/Consts/HighSierra.cs @@ -37,7 +37,7 @@ namespace Aaru.Filesystems { public partial class ISO9660 { - const string HIGH_SIERRA_MAGIC = "CDROM"; - static readonly int HighSierraDirectoryRecordSize = Marshal.SizeOf(); + const string HIGH_SIERRA_MAGIC = "CDROM"; + static readonly int _highSierraDirectoryRecordSize = Marshal.SizeOf(); } } \ No newline at end of file diff --git a/Aaru.Filesystems/ISO9660/Consts/Internal.cs b/Aaru.Filesystems/ISO9660/Consts/Internal.cs index 811ad6fd1..5205503d3 100644 --- a/Aaru.Filesystems/ISO9660/Consts/Internal.cs +++ b/Aaru.Filesystems/ISO9660/Consts/Internal.cs @@ -39,8 +39,8 @@ namespace Aaru.Filesystems [SuppressMessage("ReSharper", "UnusedMember.Local")] public partial class ISO9660 { - const byte MODE2_FORM2 = 0x20; - static readonly int DirectoryRecordSize = Marshal.SizeOf(); + const byte MODE2_FORM2 = 0x20; + static readonly int _directoryRecordSize = Marshal.SizeOf(); enum Namespace { diff --git a/Aaru.Filesystems/ISO9660/Dir.cs b/Aaru.Filesystems/ISO9660/Dir.cs index 5175dba11..982ecbfe6 100644 --- a/Aaru.Filesystems/ISO9660/Dir.cs +++ b/Aaru.Filesystems/ISO9660/Dir.cs @@ -44,19 +44,19 @@ namespace Aaru.Filesystems { public partial class ISO9660 { - Dictionary> directoryCache; + Dictionary> _directoryCache; public Errno ReadDir(string path, out List contents) { contents = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; if(string.IsNullOrWhiteSpace(path) || path == "/") { - contents = GetFilenames(rootDirectoryCache); + contents = GetFilenames(_rootDirectoryCache); return Errno.NoError; } @@ -65,7 +65,7 @@ namespace Aaru.Filesystems ? path.Substring(1).ToLower(CultureInfo.CurrentUICulture) : path.ToLower(CultureInfo.CurrentUICulture); - if(directoryCache.TryGetValue(cutPath, out Dictionary currentDirectory)) + if(_directoryCache.TryGetValue(cutPath, out Dictionary currentDirectory)) { contents = currentDirectory.Keys.ToList(); @@ -78,7 +78,7 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); KeyValuePair entry = - rootDirectoryCache.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[0]); + _rootDirectoryCache.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[0]); if(string.IsNullOrEmpty(entry.Key)) return Errno.NoSuchFile; @@ -88,7 +88,7 @@ namespace Aaru.Filesystems string currentPath = pieces[0]; - currentDirectory = rootDirectoryCache; + currentDirectory = _rootDirectoryCache; for(int p = 0; p < pieces.Length; p++) { @@ -102,31 +102,31 @@ namespace Aaru.Filesystems currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}"; - if(directoryCache.TryGetValue(currentPath, out currentDirectory)) + if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) continue; if(entry.Value.Extents.Count == 0) return Errno.InvalidArgument; - currentDirectory = cdi + currentDirectory = _cdi ? DecodeCdiDirectory(entry.Value.Extents[0].extent, entry.Value.Extents[0].size, entry.Value.XattrLength) - : highSierra + : _highSierra ? DecodeHighSierraDirectory(entry.Value.Extents[0].extent, entry.Value.Extents[0].size, entry.Value.XattrLength) : DecodeIsoDirectory(entry.Value.Extents[0].extent, entry.Value.Extents[0].size, entry.Value.XattrLength); - if(usePathTable) - foreach(DecodedDirectoryEntry subDirectory in cdi + if(_usePathTable) + foreach(DecodedDirectoryEntry subDirectory in _cdi ? GetSubdirsFromCdiPathTable(currentPath) - : highSierra + : _highSierra ? GetSubdirsFromHighSierraPathTable(currentPath) : GetSubdirsFromIsoPathTable(currentPath)) currentDirectory[subDirectory.Filename] = subDirectory; - directoryCache.Add(currentPath, currentDirectory); + _directoryCache.Add(currentPath, currentDirectory); } contents = GetFilenames(currentDirectory); @@ -139,7 +139,7 @@ namespace Aaru.Filesystems List contents = new List(); foreach(DecodedDirectoryEntry entry in dirents.Values) - switch(@namespace) + switch(_namespace) { case Namespace.Normal: contents.Add(entry.Filename.EndsWith(";1", StringComparison.Ordinal) @@ -166,18 +166,18 @@ namespace Aaru.Filesystems byte[] data = ReadSingleExtent(xattrLength, size, (uint)start); - while(entryOff + CdiDirectoryRecordSize < data.Length) + while(entryOff + _cdiDirectoryRecordSize < data.Length) { CdiDirectoryRecord record = - Marshal.ByteArrayToStructureBigEndian(data, entryOff, CdiDirectoryRecordSize); + Marshal.ByteArrayToStructureBigEndian(data, entryOff, _cdiDirectoryRecordSize); if(record.length == 0) break; // Special entries for current and parent directories, skip them if(record.name_len == 1) - if(data[entryOff + DirectoryRecordSize] == 0 || - data[entryOff + DirectoryRecordSize] == 1) + if(data[entryOff + _directoryRecordSize] == 0 || + data[entryOff + _directoryRecordSize] == 1) { entryOff += record.length; @@ -187,7 +187,7 @@ namespace Aaru.Filesystems var entry = new DecodedDirectoryEntry { Size = record.size, - Filename = Encoding.GetString(data, entryOff + DirectoryRecordSize, record.name_len), + Filename = Encoding.GetString(data, entryOff + _directoryRecordSize, record.name_len), VolumeSequenceNumber = record.volume_sequence_number, Timestamp = DecodeHighSierraDateTime(record.date), XattrLength = record.xattr_len @@ -206,19 +206,19 @@ namespace Aaru.Filesystems continue; } - int systemAreaStart = entryOff + record.name_len + CdiDirectoryRecordSize; + int systemAreaStart = entryOff + record.name_len + _cdiDirectoryRecordSize; if(systemAreaStart % 2 != 0) systemAreaStart++; entry.CdiSystemArea = - Marshal.ByteArrayToStructureBigEndian(data, systemAreaStart, CdiSystemAreaSize); + Marshal.ByteArrayToStructureBigEndian(data, systemAreaStart, _cdiSystemAreaSize); if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.Directory)) entry.Flags |= FileFlags.Directory; if(!entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.Directory) || - !usePathTable) + !_usePathTable) entries[entry.Filename] = entry; entryOff += record.length; @@ -234,19 +234,19 @@ namespace Aaru.Filesystems byte[] data = ReadSingleExtent(xattrLength, size, (uint)start); - while(entryOff + DirectoryRecordSize < data.Length) + while(entryOff + _directoryRecordSize < data.Length) { HighSierraDirectoryRecord record = Marshal.ByteArrayToStructureLittleEndian(data, entryOff, - HighSierraDirectoryRecordSize); + _highSierraDirectoryRecordSize); if(record.length == 0) break; // Special entries for current and parent directories, skip them if(record.name_len == 1) - if(data[entryOff + DirectoryRecordSize] == 0 || - data[entryOff + DirectoryRecordSize] == 1) + if(data[entryOff + _directoryRecordSize] == 0 || + data[entryOff + _directoryRecordSize] == 1) { entryOff += record.length; @@ -259,7 +259,7 @@ namespace Aaru.Filesystems Flags = record.flags, Interleave = record.interleave, VolumeSequenceNumber = record.volume_sequence_number, - Filename = Encoding.GetString(data, entryOff + DirectoryRecordSize, record.name_len), + Filename = Encoding.GetString(data, entryOff + _directoryRecordSize, record.name_len), Timestamp = DecodeHighSierraDateTime(record.date), XattrLength = record.xattr_len }; @@ -270,7 +270,7 @@ namespace Aaru.Filesystems (record.extent, record.size) }; - if(entry.Flags.HasFlag(FileFlags.Directory) && usePathTable) + if(entry.Flags.HasFlag(FileFlags.Directory) && _usePathTable) { entryOff += record.length; @@ -283,7 +283,7 @@ namespace Aaru.Filesystems entryOff += record.length; } - if(useTransTbl) + if(_useTransTbl) DecodeTransTable(entries); return entries; @@ -296,18 +296,18 @@ namespace Aaru.Filesystems byte[] data = ReadSingleExtent(xattrLength, size, (uint)start); - while(entryOff + DirectoryRecordSize < data.Length) + while(entryOff + _directoryRecordSize < data.Length) { DirectoryRecord record = - Marshal.ByteArrayToStructureLittleEndian(data, entryOff, DirectoryRecordSize); + Marshal.ByteArrayToStructureLittleEndian(data, entryOff, _directoryRecordSize); if(record.length == 0) break; // Special entries for current and parent directories, skip them if(record.name_len == 1) - if(data[entryOff + DirectoryRecordSize] == 0 || - data[entryOff + DirectoryRecordSize] == 1) + if(data[entryOff + _directoryRecordSize] == 0 || + data[entryOff + _directoryRecordSize] == 1) { entryOff += record.length; @@ -319,9 +319,9 @@ namespace Aaru.Filesystems Size = record.size, Flags = record.flags, Filename = - joliet ? Encoding.BigEndianUnicode.GetString(data, entryOff + DirectoryRecordSize, - record.name_len) - : Encoding.GetString(data, entryOff + DirectoryRecordSize, record.name_len), + _joliet ? Encoding.BigEndianUnicode.GetString(data, entryOff + _directoryRecordSize, + record.name_len) + : Encoding.GetString(data, entryOff + _directoryRecordSize, record.name_len), FileUnitSize = record.file_unit_size, Interleave = record.interleave, VolumeSequenceNumber = record.volume_sequence_number, @@ -335,7 +335,7 @@ namespace Aaru.Filesystems (record.extent, record.size) }; - if(entry.Flags.HasFlag(FileFlags.Directory) && usePathTable) + if(entry.Flags.HasFlag(FileFlags.Directory) && _usePathTable) { entryOff += record.length; @@ -353,11 +353,11 @@ namespace Aaru.Filesystems entry.Filename = entry.Filename.Substring(0, entry.Filename.Length - 3) + ";1"; // This is a legal Joliet name, different from VMS version fields, but Nero MAX incorrectly creates these filenames - if(joliet && entry.Filename.EndsWith(";1", StringComparison.Ordinal)) + if(_joliet && entry.Filename.EndsWith(";1", StringComparison.Ordinal)) entry.Filename = entry.Filename.Substring(0, entry.Filename.Length - 2); - int systemAreaStart = entryOff + record.name_len + DirectoryRecordSize; - int systemAreaLength = record.length - record.name_len - DirectoryRecordSize; + int systemAreaStart = entryOff + record.name_len + _directoryRecordSize; + int systemAreaLength = record.length - record.name_len - _directoryRecordSize; if(systemAreaStart % 2 != 0) { @@ -432,11 +432,11 @@ namespace Aaru.Filesystems entryOff += record.length; } - if(useTransTbl) + if(_useTransTbl) DecodeTransTable(entries); // Relocated directories should be shown in correct place when using Rock Ridge namespace - return @namespace == Namespace.Rrip + return _namespace == Namespace.Rrip ? entries.Where(e => !e.Value.RockRidgeRelocated).ToDictionary(x => x.Key, x => x.Value) : entries; } @@ -775,7 +775,7 @@ namespace Aaru.Filesystems entry.SymbolicLink += slc.flags.HasFlag(SymlinkComponentFlags.Networkname) ? Environment.MachineName - : joliet + : _joliet ? Encoding.BigEndianUnicode.GetString(data, systemAreaOff + Marshal. @@ -799,7 +799,7 @@ namespace Aaru.Filesystems case RRIP_NAME: byte nmLength = data[systemAreaOff + 2]; - if(@namespace != Namespace.Rrip) + if(_namespace != Namespace.Rrip) { systemAreaOff += nmLength; @@ -813,7 +813,7 @@ namespace Aaru.Filesystems byte[] nm; if(alternateName.flags.HasFlag(AlternateNameFlags.Networkname)) - nm = joliet ? Encoding.BigEndianUnicode.GetBytes(Environment.MachineName) + nm = _joliet ? Encoding.BigEndianUnicode.GetBytes(Environment.MachineName) : Encoding.GetBytes(Environment.MachineName); else { @@ -833,7 +833,7 @@ namespace Aaru.Filesystems if(!alternateName.flags.HasFlag(AlternateNameFlags.Continue)) { - entry.Filename = joliet ? Encoding.BigEndianUnicode.GetString(entry.RockRidgeAlternateName) + entry.Filename = _joliet ? Encoding.BigEndianUnicode.GetString(entry.RockRidgeAlternateName) : Encoding.GetString(entry.RockRidgeAlternateName); entry.RockRidgeAlternateName = null; @@ -846,7 +846,7 @@ namespace Aaru.Filesystems byte clLength = data[systemAreaOff + 2]; // If we are not in Rock Ridge namespace, or we are using the Path Table, skip it - if(@namespace != Namespace.Rrip || usePathTable) + if(_namespace != Namespace.Rrip || _usePathTable) { systemAreaOff += clLength; @@ -1023,11 +1023,11 @@ namespace Aaru.Filesystems PathTableEntryInternal[] GetPathTableEntries(string path) { IEnumerable tableEntries; - List pathTableList = new List(pathTable); + List pathTableList = new List(_pathTable); if(path == "" || path == "/") - tableEntries = pathTable.Where(p => p.Parent == 1 && p != pathTable[0]); + tableEntries = _pathTable.Where(p => p.Parent == 1 && p != _pathTable[0]); else { string cutPath = path.StartsWith("/", StringComparison.Ordinal) @@ -1044,10 +1044,10 @@ namespace Aaru.Filesystems while(currentPiece < pieces.Length) { - PathTableEntryInternal currentEntry = pathTable.FirstOrDefault(p => p.Parent == currentParent && - p.Name.ToLower(CultureInfo. - CurrentUICulture) == - pieces[currentPiece]); + PathTableEntryInternal currentEntry = _pathTable.FirstOrDefault(p => p.Parent == currentParent && + p.Name.ToLower(CultureInfo. + CurrentUICulture) == + pieces[currentPiece]); if(currentEntry is null) break; @@ -1056,7 +1056,7 @@ namespace Aaru.Filesystems currentParent = pathTableList.IndexOf(currentEntry) + 1; } - tableEntries = pathTable.Where(p => p.Parent == currentParent); + tableEntries = _pathTable.Where(p => p.Parent == currentParent); } return tableEntries.ToArray(); @@ -1073,7 +1073,7 @@ namespace Aaru.Filesystems CdiDirectoryRecord record = Marshal.ByteArrayToStructureBigEndian(sector, tEntry.XattrLength, - CdiDirectoryRecordSize); + _cdiDirectoryRecordSize); if(record.length == 0) break; @@ -1096,13 +1096,13 @@ namespace Aaru.Filesystems if(record.flags.HasFlag(CdiFileFlags.Hidden)) entry.Flags |= FileFlags.Hidden; - int systemAreaStart = record.name_len + CdiDirectoryRecordSize; + int systemAreaStart = record.name_len + _cdiDirectoryRecordSize; if(systemAreaStart % 2 != 0) systemAreaStart++; entry.CdiSystemArea = - Marshal.ByteArrayToStructureBigEndian(sector, systemAreaStart, CdiSystemAreaSize); + Marshal.ByteArrayToStructureBigEndian(sector, systemAreaStart, _cdiSystemAreaSize); if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.Directory)) entry.Flags |= FileFlags.Directory; @@ -1124,7 +1124,7 @@ namespace Aaru.Filesystems DirectoryRecord record = Marshal.ByteArrayToStructureLittleEndian(sector, tEntry.XattrLength, - DirectoryRecordSize); + _directoryRecordSize); if(record.length == 0) break; @@ -1147,8 +1147,8 @@ namespace Aaru.Filesystems (record.extent, record.size) }; - int systemAreaStart = record.name_len + DirectoryRecordSize; - int systemAreaLength = record.length - record.name_len - DirectoryRecordSize; + int systemAreaStart = record.name_len + _directoryRecordSize; + int systemAreaLength = record.length - record.name_len - _directoryRecordSize; if(systemAreaStart % 2 != 0) { @@ -1175,7 +1175,7 @@ namespace Aaru.Filesystems HighSierraDirectoryRecord record = Marshal.ByteArrayToStructureLittleEndian(sector, tEntry.XattrLength, - HighSierraDirectoryRecordSize); + _highSierraDirectoryRecordSize); var entry = new DecodedDirectoryEntry { diff --git a/Aaru.Filesystems/ISO9660/File.cs b/Aaru.Filesystems/ISO9660/File.cs index 3db89ea5f..c281bc9fe 100644 --- a/Aaru.Filesystems/ISO9660/File.cs +++ b/Aaru.Filesystems/ISO9660/File.cs @@ -51,7 +51,7 @@ namespace Aaru.Filesystems { deviceBlock = 0; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry); @@ -60,7 +60,7 @@ namespace Aaru.Filesystems return err; if(entry.Flags.HasFlag(FileFlags.Directory) && - !debug) + !_debug) return Errno.IsDirectory; // TODO: Multi-extents @@ -76,7 +76,7 @@ namespace Aaru.Filesystems { attributes = new FileAttributes(); - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = Stat(path, out FileEntryInfo stat); @@ -94,7 +94,7 @@ namespace Aaru.Filesystems { buf = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry); @@ -103,7 +103,7 @@ namespace Aaru.Filesystems return err; if(entry.Flags.HasFlag(FileFlags.Directory) && - !debug) + !_debug) return Errno.IsDirectory; if(entry.Extents is null) @@ -138,7 +138,7 @@ namespace Aaru.Filesystems sizeInSectors++; byte[] buffer = - image.ReadSectorsLong((ulong)(entry.Extents[0].extent + firstSector), (uint)sizeInSectors); + _image.ReadSectorsLong((ulong)(entry.Extents[0].extent + firstSector), (uint)sizeInSectors); buf = new byte[size]; Array.Copy(buffer, offsetInSector, buf, 0, size); @@ -166,7 +166,7 @@ namespace Aaru.Filesystems { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry); @@ -357,8 +357,8 @@ namespace Aaru.Filesystems stat.Attributes |= FileAttributes.Symlink; if(entry.XattrLength == 0 || - cdi || - highSierra) + _cdi || + _highSierra) return Errno.NoError; if(entry.CdiSystemArea != null) @@ -453,7 +453,7 @@ namespace Aaru.Filesystems string parentPath = string.Join("/", pieces, 0, pieces.Length - 1); - if(!directoryCache.TryGetValue(parentPath, out _)) + if(!_directoryCache.TryGetValue(parentPath, out _)) { Errno err = ReadDir(parentPath, out _); @@ -464,8 +464,8 @@ namespace Aaru.Filesystems Dictionary parent; if(pieces.Length == 1) - parent = rootDirectoryCache; - else if(!directoryCache.TryGetValue(parentPath, out parent)) + parent = _rootDirectoryCache; + else if(!_directoryCache.TryGetValue(parentPath, out parent)) return Errno.InvalidArgument; KeyValuePair dirent = @@ -473,7 +473,7 @@ namespace Aaru.Filesystems if(string.IsNullOrEmpty(dirent.Key)) { - if(!joliet && + if(!_joliet && !pieces[^1].EndsWith(";1", StringComparison.Ordinal)) { dirent = parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == @@ -575,8 +575,8 @@ namespace Aaru.Filesystems try { byte[] fullSector = - image.ReadSectorTag(extents[i].extent + currentExtentSector, - SectorTagType.CdSectorSubHeader); + _image.ReadSectorTag(extents[i].extent + currentExtentSector, + SectorTagType.CdSectorSubHeader); ms.Write(fullSector, copy ? 0 : 4, 4); } diff --git a/Aaru.Filesystems/ISO9660/ISO9660.cs b/Aaru.Filesystems/ISO9660/ISO9660.cs index 2ef93e53b..20bb530b4 100644 --- a/Aaru.Filesystems/ISO9660/ISO9660.cs +++ b/Aaru.Filesystems/ISO9660/ISO9660.cs @@ -45,19 +45,19 @@ namespace Aaru.Filesystems [SuppressMessage("ReSharper", "UnusedType.Local")] public partial class ISO9660 : IReadOnlyFilesystem { - bool cdi; - bool debug; - bool highSierra; - IMediaImage image; - bool joliet; - bool mounted; - Namespace @namespace; - PathTableEntryInternal[] pathTable; - Dictionary rootDirectoryCache; - FileSystemInfo statfs; - bool useEvd; - bool usePathTable; - bool useTransTbl; + bool _cdi; + bool _debug; + bool _highSierra; + IMediaImage _image; + bool _joliet; + bool _mounted; + Namespace _namespace; + PathTableEntryInternal[] _pathTable; + Dictionary _rootDirectoryCache; + FileSystemInfo _statfs; + bool _useEvd; + bool _usePathTable; + bool _useTransTbl; public FileSystemType XmlFsType { get; private set; } public Encoding Encoding { get; private set; } diff --git a/Aaru.Filesystems/ISO9660/Info.cs b/Aaru.Filesystems/ISO9660/Info.cs index 5eac3c622..e0463702d 100644 --- a/Aaru.Filesystems/ISO9660/Info.cs +++ b/Aaru.Filesystems/ISO9660/Info.cs @@ -727,15 +727,15 @@ namespace Aaru.Filesystems isoMetadata.AppendLine("\tImage uses no emulation"); break; - case ElToritoEmulation.Md2hd: + case ElToritoEmulation.Md2Hd: isoMetadata.AppendLine("\tImage emulates a 5.25\" high-density (MD2HD, 1.2Mb) floppy"); break; - case ElToritoEmulation.Mf2hd: + case ElToritoEmulation.Mf2Hd: isoMetadata.AppendLine("\tImage emulates a 3.5\" high-density (MF2HD, 1.44Mb) floppy"); break; - case ElToritoEmulation.Mf2ed: + case ElToritoEmulation.Mf2Ed: isoMetadata.AppendLine("\tImage emulates a 3.5\" extra-density (MF2ED, 2.88Mb) floppy"); break; @@ -757,7 +757,7 @@ namespace Aaru.Filesystems toritoOff += EL_TORITO_ENTRY_SIZE; - const int SECTION_COUNTER = 2; + const int sectionCounter = 2; while(toritoOff < vdSector.Length && (vdSector[toritoOff] == (byte)ElToritoIndicator.Header || @@ -769,7 +769,7 @@ namespace Aaru.Filesystems toritoOff += EL_TORITO_ENTRY_SIZE; - isoMetadata.AppendFormat("Boot section {0}:", SECTION_COUNTER); + isoMetadata.AppendFormat("Boot section {0}:", sectionCounter); isoMetadata.AppendFormat("\tSection ID: {0}", Encoding.GetString(sectionHeader.identifier)). AppendLine(); @@ -812,17 +812,17 @@ namespace Aaru.Filesystems isoMetadata.AppendLine("\t\tImage uses no emulation"); break; - case ElToritoEmulation.Md2hd: + case ElToritoEmulation.Md2Hd: isoMetadata. AppendLine("\t\tImage emulates a 5.25\" high-density (MD2HD, 1.2Mb) floppy"); break; - case ElToritoEmulation.Mf2hd: + case ElToritoEmulation.Mf2Hd: isoMetadata. AppendLine("\t\tImage emulates a 3.5\" high-density (MF2HD, 1.44Mb) floppy"); break; - case ElToritoEmulation.Mf2ed: + case ElToritoEmulation.Mf2Ed: isoMetadata. AppendLine("\t\tImage emulates a 3.5\" extra-density (MF2ED, 2.88Mb) floppy"); diff --git a/Aaru.Filesystems/ISO9660/Mode2.cs b/Aaru.Filesystems/ISO9660/Mode2.cs index cc054a966..ebbfbca27 100644 --- a/Aaru.Filesystems/ISO9660/Mode2.cs +++ b/Aaru.Filesystems/ISO9660/Mode2.cs @@ -45,14 +45,14 @@ namespace Aaru.Filesystems // TODO: No more exceptions try { - data = image.ReadSectorLong(sector); + data = _image.ReadSectorLong(sector); } catch { - data = image.ReadSector(sector); + data = _image.ReadSector(sector); } - if(!debug) + if(!_debug) return Sector.GetUserData(data, interleaved, fileNumber); switch(data.Length) diff --git a/Aaru.Filesystems/ISO9660/Structs/CDi.cs b/Aaru.Filesystems/ISO9660/Structs/CDi.cs index f0e7d68f7..0861ec1cc 100644 --- a/Aaru.Filesystems/ISO9660/Structs/CDi.cs +++ b/Aaru.Filesystems/ISO9660/Structs/CDi.cs @@ -41,7 +41,7 @@ namespace Aaru.Filesystems { static DecodedVolumeDescriptor DecodeVolumeDescriptor(FileStructureVolumeDescriptor pvd) { - var decodedVD = new DecodedVolumeDescriptor + var decodedVd = new DecodedVolumeDescriptor { SystemIdentifier = StringHandlers.CToString(pvd.system_id).TrimEnd(), VolumeIdentifier = StringHandlers.CToString(pvd.volume_id).TrimEnd(), @@ -53,41 +53,41 @@ namespace Aaru.Filesystems if(pvd.creation_date[0] == '0' || pvd.creation_date[0] == 0x00) - decodedVD.CreationTime = DateTime.MinValue; + decodedVd.CreationTime = DateTime.MinValue; else - decodedVD.CreationTime = DateHandlers.HighSierraToDateTime(pvd.creation_date); + decodedVd.CreationTime = DateHandlers.HighSierraToDateTime(pvd.creation_date); if(pvd.modification_date[0] == '0' || pvd.modification_date[0] == 0x00) - decodedVD.HasModificationTime = false; + decodedVd.HasModificationTime = false; else { - decodedVD.HasModificationTime = true; - decodedVD.ModificationTime = DateHandlers.HighSierraToDateTime(pvd.modification_date); + decodedVd.HasModificationTime = true; + decodedVd.ModificationTime = DateHandlers.HighSierraToDateTime(pvd.modification_date); } if(pvd.expiration_date[0] == '0' || pvd.expiration_date[0] == 0x00) - decodedVD.HasExpirationTime = false; + decodedVd.HasExpirationTime = false; else { - decodedVD.HasExpirationTime = true; - decodedVD.ExpirationTime = DateHandlers.HighSierraToDateTime(pvd.expiration_date); + decodedVd.HasExpirationTime = true; + decodedVd.ExpirationTime = DateHandlers.HighSierraToDateTime(pvd.expiration_date); } if(pvd.effective_date[0] == '0' || pvd.effective_date[0] == 0x00) - decodedVD.HasEffectiveTime = false; + decodedVd.HasEffectiveTime = false; else { - decodedVD.HasEffectiveTime = true; - decodedVD.EffectiveTime = DateHandlers.HighSierraToDateTime(pvd.effective_date); + decodedVd.HasEffectiveTime = true; + decodedVd.EffectiveTime = DateHandlers.HighSierraToDateTime(pvd.effective_date); } - decodedVD.Blocks = pvd.volume_space_size; - decodedVD.BlockSize = pvd.logical_block_size; + decodedVd.Blocks = pvd.volume_space_size; + decodedVd.BlockSize = pvd.logical_block_size; - return decodedVD; + return decodedVd; } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs b/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs index 003d67c33..5b9d2adf4 100644 --- a/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs +++ b/Aaru.Filesystems/ISO9660/Structs/HighSierra.cs @@ -42,7 +42,7 @@ namespace Aaru.Filesystems { static DecodedVolumeDescriptor DecodeVolumeDescriptor(HighSierraPrimaryVolumeDescriptor pvd) { - var decodedVD = new DecodedVolumeDescriptor + var decodedVd = new DecodedVolumeDescriptor { SystemIdentifier = Encoding.ASCII.GetString(pvd.system_id).TrimEnd().Trim('\0'), VolumeIdentifier = Encoding.ASCII.GetString(pvd.volume_id).TrimEnd().Trim('\0'), @@ -54,41 +54,41 @@ namespace Aaru.Filesystems if(pvd.creation_date[0] == '0' || pvd.creation_date[0] == 0x00) - decodedVD.CreationTime = DateTime.MinValue; + decodedVd.CreationTime = DateTime.MinValue; else - decodedVD.CreationTime = DateHandlers.HighSierraToDateTime(pvd.creation_date); + decodedVd.CreationTime = DateHandlers.HighSierraToDateTime(pvd.creation_date); if(pvd.modification_date[0] == '0' || pvd.modification_date[0] == 0x00) - decodedVD.HasModificationTime = false; + decodedVd.HasModificationTime = false; else { - decodedVD.HasModificationTime = true; - decodedVD.ModificationTime = DateHandlers.HighSierraToDateTime(pvd.modification_date); + decodedVd.HasModificationTime = true; + decodedVd.ModificationTime = DateHandlers.HighSierraToDateTime(pvd.modification_date); } if(pvd.expiration_date[0] == '0' || pvd.expiration_date[0] == 0x00) - decodedVD.HasExpirationTime = false; + decodedVd.HasExpirationTime = false; else { - decodedVD.HasExpirationTime = true; - decodedVD.ExpirationTime = DateHandlers.HighSierraToDateTime(pvd.expiration_date); + decodedVd.HasExpirationTime = true; + decodedVd.ExpirationTime = DateHandlers.HighSierraToDateTime(pvd.expiration_date); } if(pvd.effective_date[0] == '0' || pvd.effective_date[0] == 0x00) - decodedVD.HasEffectiveTime = false; + decodedVd.HasEffectiveTime = false; else { - decodedVD.HasEffectiveTime = true; - decodedVD.EffectiveTime = DateHandlers.HighSierraToDateTime(pvd.effective_date); + decodedVd.HasEffectiveTime = true; + decodedVd.EffectiveTime = DateHandlers.HighSierraToDateTime(pvd.effective_date); } - decodedVD.Blocks = pvd.volume_space_size; - decodedVD.BlockSize = pvd.logical_block_size; + decodedVd.Blocks = pvd.volume_space_size; + decodedVd.BlockSize = pvd.logical_block_size; - return decodedVD; + return decodedVd; } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/ISO9660/Structs/ISO.cs b/Aaru.Filesystems/ISO9660/Structs/ISO.cs index c1e281c7c..ac8b771ca 100644 --- a/Aaru.Filesystems/ISO9660/Structs/ISO.cs +++ b/Aaru.Filesystems/ISO9660/Structs/ISO.cs @@ -43,7 +43,7 @@ namespace Aaru.Filesystems { static DecodedVolumeDescriptor DecodeVolumeDescriptor(PrimaryVolumeDescriptor pvd) { - var decodedVD = new DecodedVolumeDescriptor + var decodedVd = new DecodedVolumeDescriptor { SystemIdentifier = StringHandlers.CToString(pvd.system_id).TrimEnd(), VolumeIdentifier = StringHandlers.CToString(pvd.volume_id).TrimEnd(), @@ -55,41 +55,41 @@ namespace Aaru.Filesystems if(pvd.creation_date[0] == '0' || pvd.creation_date[0] == 0x00) - decodedVD.CreationTime = DateTime.MinValue; + decodedVd.CreationTime = DateTime.MinValue; else - decodedVD.CreationTime = DateHandlers.Iso9660ToDateTime(pvd.creation_date); + decodedVd.CreationTime = DateHandlers.Iso9660ToDateTime(pvd.creation_date); if(pvd.modification_date[0] == '0' || pvd.modification_date[0] == 0x00) - decodedVD.HasModificationTime = false; + decodedVd.HasModificationTime = false; else { - decodedVD.HasModificationTime = true; - decodedVD.ModificationTime = DateHandlers.Iso9660ToDateTime(pvd.modification_date); + decodedVd.HasModificationTime = true; + decodedVd.ModificationTime = DateHandlers.Iso9660ToDateTime(pvd.modification_date); } if(pvd.expiration_date[0] == '0' || pvd.expiration_date[0] == 0x00) - decodedVD.HasExpirationTime = false; + decodedVd.HasExpirationTime = false; else { - decodedVD.HasExpirationTime = true; - decodedVD.ExpirationTime = DateHandlers.Iso9660ToDateTime(pvd.expiration_date); + decodedVd.HasExpirationTime = true; + decodedVd.ExpirationTime = DateHandlers.Iso9660ToDateTime(pvd.expiration_date); } if(pvd.effective_date[0] == '0' || pvd.effective_date[0] == 0x00) - decodedVD.HasEffectiveTime = false; + decodedVd.HasEffectiveTime = false; else { - decodedVD.HasEffectiveTime = true; - decodedVD.EffectiveTime = DateHandlers.Iso9660ToDateTime(pvd.effective_date); + decodedVd.HasEffectiveTime = true; + decodedVd.EffectiveTime = DateHandlers.Iso9660ToDateTime(pvd.effective_date); } - decodedVD.Blocks = pvd.volume_space_size; - decodedVD.BlockSize = pvd.logical_block_size; + decodedVd.Blocks = pvd.volume_space_size; + decodedVd.BlockSize = pvd.logical_block_size; - return decodedVD; + return decodedVd; } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filesystems/ISO9660/Structs/Joliet.cs b/Aaru.Filesystems/ISO9660/Structs/Joliet.cs index df5aebf54..502fa48f9 100644 --- a/Aaru.Filesystems/ISO9660/Structs/Joliet.cs +++ b/Aaru.Filesystems/ISO9660/Structs/Joliet.cs @@ -41,7 +41,7 @@ namespace Aaru.Filesystems { static DecodedVolumeDescriptor DecodeJolietDescriptor(PrimaryVolumeDescriptor jolietvd) { - var decodedVD = new DecodedVolumeDescriptor + var decodedVd = new DecodedVolumeDescriptor { SystemIdentifier = Encoding.BigEndianUnicode.GetString(jolietvd.system_id).Replace('\u0000', ' '). TrimEnd(), @@ -59,41 +59,41 @@ namespace Aaru.Filesystems if(jolietvd.creation_date[0] < 0x31 || jolietvd.creation_date[0] > 0x39) - decodedVD.CreationTime = DateTime.MinValue; + decodedVd.CreationTime = DateTime.MinValue; else - decodedVD.CreationTime = DateHandlers.Iso9660ToDateTime(jolietvd.creation_date); + decodedVd.CreationTime = DateHandlers.Iso9660ToDateTime(jolietvd.creation_date); if(jolietvd.modification_date[0] < 0x31 || jolietvd.modification_date[0] > 0x39) - decodedVD.HasModificationTime = false; + decodedVd.HasModificationTime = false; else { - decodedVD.HasModificationTime = true; - decodedVD.ModificationTime = DateHandlers.Iso9660ToDateTime(jolietvd.modification_date); + decodedVd.HasModificationTime = true; + decodedVd.ModificationTime = DateHandlers.Iso9660ToDateTime(jolietvd.modification_date); } if(jolietvd.expiration_date[0] < 0x31 || jolietvd.expiration_date[0] > 0x39) - decodedVD.HasExpirationTime = false; + decodedVd.HasExpirationTime = false; else { - decodedVD.HasExpirationTime = true; - decodedVD.ExpirationTime = DateHandlers.Iso9660ToDateTime(jolietvd.expiration_date); + decodedVd.HasExpirationTime = true; + decodedVd.ExpirationTime = DateHandlers.Iso9660ToDateTime(jolietvd.expiration_date); } if(jolietvd.effective_date[0] < 0x31 || jolietvd.effective_date[0] > 0x39) - decodedVD.HasEffectiveTime = false; + decodedVd.HasEffectiveTime = false; else { - decodedVD.HasEffectiveTime = true; - decodedVD.EffectiveTime = DateHandlers.Iso9660ToDateTime(jolietvd.effective_date); + decodedVd.HasEffectiveTime = true; + decodedVd.EffectiveTime = DateHandlers.Iso9660ToDateTime(jolietvd.effective_date); } - decodedVD.Blocks = jolietvd.volume_space_size; - decodedVD.BlockSize = jolietvd.logical_block_size; + decodedVd.Blocks = jolietvd.volume_space_size; + decodedVd.BlockSize = jolietvd.logical_block_size; - return decodedVD; + return decodedVd; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/ISO9660/Super.cs b/Aaru.Filesystems/ISO9660/Super.cs index 06a74b43e..244ade0df 100644 --- a/Aaru.Filesystems/ISO9660/Super.cs +++ b/Aaru.Filesystems/ISO9660/Super.cs @@ -57,16 +57,16 @@ namespace Aaru.Filesystems options = GetDefaultOptions(); if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out debug); + bool.TryParse(debugString, out _debug); if(options.TryGetValue("use_path_table", out string usePathTableString)) - bool.TryParse(usePathTableString, out usePathTable); + bool.TryParse(usePathTableString, out _usePathTable); if(options.TryGetValue("use_trans_tbl", out string useTransTblString)) - bool.TryParse(useTransTblString, out useTransTbl); + bool.TryParse(useTransTblString, out _useTransTbl); if(options.TryGetValue("use_evd", out string useEvdString)) - bool.TryParse(useEvdString, out useEvd); + bool.TryParse(useEvdString, out _useEvd); // Default namespace if(@namespace is null) @@ -75,23 +75,23 @@ namespace Aaru.Filesystems switch(@namespace.ToLowerInvariant()) { case "normal": - this.@namespace = Namespace.Normal; + _namespace = Namespace.Normal; break; case "vms": - this.@namespace = Namespace.Vms; + _namespace = Namespace.Vms; break; case "joliet": - this.@namespace = Namespace.Joliet; + _namespace = Namespace.Joliet; break; case "rrip": - this.@namespace = Namespace.Rrip; + _namespace = Namespace.Rrip; break; case "romeo": - this.@namespace = Namespace.Romeo; + _namespace = Namespace.Romeo; break; default: return Errno.InvalidArgument; @@ -116,13 +116,13 @@ namespace Aaru.Filesystems byte[] vdSector = imagePlugin.ReadSector(16 + counter + partition.Start); int xaOff = vdSector.Length == 2336 ? 8 : 0; Array.Copy(vdSector, 0x009 + xaOff, hsMagic, 0, 5); - highSierra = Encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC; + _highSierra = Encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC; int hsOff = 0; - if(highSierra) + if(_highSierra) hsOff = 8; - cdi = false; + _cdi = false; List bvdSectors = new List(); List pvdSectors = new List(); List svdSectors = new List(); @@ -164,13 +164,13 @@ namespace Aaru.Filesystems break; } - cdi |= Encoding.GetString(vdMagic) == CDI_MAGIC; + _cdi |= Encoding.GetString(vdMagic) == CDI_MAGIC; switch(vdType) { case 0: { - if(debug) + if(_debug) bvdSectors.Add(16 + counter + partition.Start); break; @@ -178,15 +178,15 @@ namespace Aaru.Filesystems case 1: { - if(highSierra) + if(_highSierra) hsvd = Marshal. ByteArrayToStructureLittleEndian(vdSector); - else if(cdi) + else if(_cdi) fsvd = Marshal.ByteArrayToStructureBigEndian(vdSector); else pvd = Marshal.ByteArrayToStructureLittleEndian(vdSector); - if(debug) + if(_debug) pvdSectors.Add(16 + counter + partition.Start); break; @@ -211,20 +211,20 @@ namespace Aaru.Filesystems AaruConsole.DebugWriteLine("ISO9660 plugin", "Found unknown supplementary volume descriptor"); - if(debug) + if(_debug) svdSectors.Add(16 + counter + partition.Start); } else { - if(debug) + if(_debug) evdSectors.Add(16 + counter + partition.Start); - if(useEvd) + if(_useEvd) { // Basically until escape sequences are implemented, let the user chose the encoding. // This is the same as user chosing Romeo namespace, but using the EVD instead of the PVD - this.@namespace = Namespace.Romeo; - pvd = svd; + _namespace = Namespace.Romeo; + pvd = svd; } } @@ -233,7 +233,7 @@ namespace Aaru.Filesystems case 3: { - if(debug) + if(_debug) vpdSectors.Add(16 + counter + partition.Start); break; @@ -257,9 +257,9 @@ namespace Aaru.Filesystems return Errno.InvalidArgument; } - if(highSierra) + if(_highSierra) decodedVd = DecodeVolumeDescriptor(hsvd.Value); - else if(cdi) + else if(_cdi) decodedVd = DecodeVolumeDescriptor(fsvd.Value); else decodedVd = DecodeVolumeDescriptor(pvd.Value); @@ -267,7 +267,7 @@ namespace Aaru.Filesystems if(jolietvd != null) decodedJolietVd = DecodeJolietDescriptor(jolietvd.Value); - if(this.@namespace != Namespace.Romeo) + if(_namespace != Namespace.Romeo) Encoding = Encoding.ASCII; string fsFormat; @@ -276,9 +276,9 @@ namespace Aaru.Filesystems uint pathTableMsbLocation; uint pathTableLsbLocation = 0; // Initialize to 0 as ignored in CD-i - image = imagePlugin; + _image = imagePlugin; - if(highSierra) + if(_highSierra) { pathTableData = ReadSingleExtent(0, hsvd.Value.path_table_size, Swapping.Swap(hsvd.Value.mandatory_path_table_msb)); @@ -288,7 +288,7 @@ namespace Aaru.Filesystems pathTableMsbLocation = hsvd.Value.mandatory_path_table_msb; pathTableLsbLocation = hsvd.Value.mandatory_path_table_lsb; } - else if(cdi) + else if(_cdi) { pathTableData = ReadSingleExtent(0, fsvd.Value.path_table_size, fsvd.Value.path_table_addr); @@ -310,37 +310,37 @@ namespace Aaru.Filesystems pathTableLsbLocation = pvd.Value.type_l_path_table; } - pathTable = highSierra ? DecodeHighSierraPathTable(pathTableData) : DecodePathTable(pathTableData); + _pathTable = _highSierra ? DecodeHighSierraPathTable(pathTableData) : DecodePathTable(pathTableData); // High Sierra and CD-i do not support Joliet or RRIP - if((highSierra || cdi) && - this.@namespace != Namespace.Normal && - this.@namespace != Namespace.Vms) - this.@namespace = Namespace.Normal; + if((_highSierra || _cdi) && + _namespace != Namespace.Normal && + _namespace != Namespace.Vms) + _namespace = Namespace.Normal; if(jolietvd is null && - this.@namespace == Namespace.Joliet) - this.@namespace = Namespace.Normal; + _namespace == Namespace.Joliet) + _namespace = Namespace.Normal; uint rootLocation; uint rootSize; byte rootXattrLength = 0; - if(!cdi) + if(!_cdi) { - rootLocation = highSierra ? hsvd.Value.root_directory_record.extent + rootLocation = _highSierra ? hsvd.Value.root_directory_record.extent : pvd.Value.root_directory_record.extent; - rootXattrLength = highSierra ? hsvd.Value.root_directory_record.xattr_len + rootXattrLength = _highSierra ? hsvd.Value.root_directory_record.xattr_len : pvd.Value.root_directory_record.xattr_len; - if(highSierra) + if(_highSierra) rootSize = hsvd.Value.root_directory_record.size; else rootSize = pvd.Value.root_directory_record.size; if(pathTableData.Length > 1 && - rootLocation != pathTable[0].Extent) + rootLocation != _pathTable[0].Extent) { AaruConsole.DebugWriteLine("ISO9660 plugin", "Path table and PVD do not point to the same location for the root directory!"); @@ -349,7 +349,7 @@ namespace Aaru.Filesystems bool pvdWrongRoot = false; - if(highSierra) + if(_highSierra) { HighSierraDirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian(firstRootSector); @@ -373,11 +373,11 @@ namespace Aaru.Filesystems bool pathTableWrongRoot = false; - rootLocation = pathTable[0].Extent; + rootLocation = _pathTable[0].Extent; - firstRootSector = ReadSector(pathTable[0].Extent); + firstRootSector = ReadSector(_pathTable[0].Extent); - if(highSierra) + if(_highSierra) { HighSierraDirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian(firstRootSector); @@ -401,13 +401,13 @@ namespace Aaru.Filesystems return Errno.InvalidArgument; } - usePathTable = true; + _usePathTable = true; } } } else { - rootLocation = pathTable[0].Extent; + rootLocation = _pathTable[0].Extent; byte[] firstRootSector = ReadSector(rootLocation); @@ -416,21 +416,21 @@ namespace Aaru.Filesystems rootSize = rootEntry.size; - usePathTable = usePathTable || pathTable.Length == 1; - useTransTbl = false; + _usePathTable = _usePathTable || _pathTable.Length == 1; + _useTransTbl = false; } // In case the path table is incomplete - if(usePathTable && pathTableData.Length == 1) - usePathTable = false; + if(_usePathTable && pathTableData.Length == 1) + _usePathTable = false; - if(usePathTable && !cdi) + if(_usePathTable && !_cdi) { - rootLocation = pathTable[0].Extent; + rootLocation = _pathTable[0].Extent; byte[] firstRootSector = ReadSector(rootLocation); - if(highSierra) + if(_highSierra) { HighSierraDirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian(firstRootSector); @@ -445,7 +445,7 @@ namespace Aaru.Filesystems rootSize = rootEntry.size; } - rootXattrLength = pathTable[0].XattrLength; + rootXattrLength = _pathTable[0].XattrLength; } try @@ -462,37 +462,37 @@ namespace Aaru.Filesystems Saturn.IPBin? saturn = Saturn.DecodeIPBin(ipbinSector); Dreamcast.IPBin? dreamcast = Dreamcast.DecodeIPBin(ipbinSector); - if(this.@namespace == Namespace.Joliet || - this.@namespace == Namespace.Rrip) + if(_namespace == Namespace.Joliet || + _namespace == Namespace.Rrip) { - usePathTable = false; - useTransTbl = false; + _usePathTable = false; + _useTransTbl = false; } // Cannot traverse path table if we substitute the names for the ones in TRANS.TBL - if(useTransTbl) - usePathTable = false; + if(_useTransTbl) + _usePathTable = false; - if(this.@namespace != Namespace.Joliet) - rootDirectoryCache = cdi - ? DecodeCdiDirectory(rootLocation, rootSize, rootXattrLength) - : highSierra - ? DecodeHighSierraDirectory(rootLocation, rootSize, rootXattrLength) - : DecodeIsoDirectory(rootLocation, rootSize, rootXattrLength); + if(_namespace != Namespace.Joliet) + _rootDirectoryCache = _cdi + ? DecodeCdiDirectory(rootLocation, rootSize, rootXattrLength) + : _highSierra + ? DecodeHighSierraDirectory(rootLocation, rootSize, rootXattrLength) + : DecodeIsoDirectory(rootLocation, rootSize, rootXattrLength); XmlFsType.Type = fsFormat; if(jolietvd != null && - (this.@namespace == Namespace.Joliet || this.@namespace == Namespace.Rrip)) + (_namespace == Namespace.Joliet || _namespace == Namespace.Rrip)) { rootLocation = jolietvd.Value.root_directory_record.extent; rootXattrLength = jolietvd.Value.root_directory_record.xattr_len; rootSize = jolietvd.Value.root_directory_record.size; - joliet = true; + _joliet = true; - rootDirectoryCache = DecodeIsoDirectory(rootLocation, rootSize, rootXattrLength); + _rootDirectoryCache = DecodeIsoDirectory(rootLocation, rootSize, rootXattrLength); XmlFsType.VolumeName = decodedJolietVd.VolumeIdentifier; @@ -584,9 +584,9 @@ namespace Aaru.Filesystems } } - if(debug) + if(_debug) { - rootDirectoryCache.Add("$", new DecodedDirectoryEntry + _rootDirectoryCache.Add("$", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> { @@ -597,8 +597,8 @@ namespace Aaru.Filesystems Timestamp = decodedVd.CreationTime }); - if(!cdi) - rootDirectoryCache.Add("$PATH_TABLE.LSB", new DecodedDirectoryEntry + if(!_cdi) + _rootDirectoryCache.Add("$PATH_TABLE.LSB", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> { @@ -609,7 +609,7 @@ namespace Aaru.Filesystems Timestamp = decodedVd.CreationTime }); - rootDirectoryCache.Add("$PATH_TABLE.MSB", new DecodedDirectoryEntry + _rootDirectoryCache.Add("$PATH_TABLE.MSB", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> { @@ -621,7 +621,7 @@ namespace Aaru.Filesystems }); for(int i = 0; i < bvdSectors.Count; i++) - rootDirectoryCache.Add(i == 0 ? "$BOOT" : $"$BOOT_{i}", new DecodedDirectoryEntry + _rootDirectoryCache.Add(i == 0 ? "$BOOT" : $"$BOOT_{i}", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> { @@ -633,7 +633,7 @@ namespace Aaru.Filesystems }); for(int i = 0; i < pvdSectors.Count; i++) - rootDirectoryCache.Add(i == 0 ? "$PVD" : $"$PVD{i}", new DecodedDirectoryEntry + _rootDirectoryCache.Add(i == 0 ? "$PVD" : $"$PVD{i}", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> { @@ -645,7 +645,7 @@ namespace Aaru.Filesystems }); for(int i = 0; i < svdSectors.Count; i++) - rootDirectoryCache.Add(i == 0 ? "$SVD" : $"$SVD_{i}", new DecodedDirectoryEntry + _rootDirectoryCache.Add(i == 0 ? "$SVD" : $"$SVD_{i}", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> { @@ -657,7 +657,7 @@ namespace Aaru.Filesystems }); for(int i = 0; i < evdSectors.Count; i++) - rootDirectoryCache.Add(i == 0 ? "$EVD" : $"$EVD_{i}", new DecodedDirectoryEntry + _rootDirectoryCache.Add(i == 0 ? "$EVD" : $"$EVD_{i}", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> { @@ -669,7 +669,7 @@ namespace Aaru.Filesystems }); for(int i = 0; i < vpdSectors.Count; i++) - rootDirectoryCache.Add(i == 0 ? "$VPD" : $"$VPD_{i}", new DecodedDirectoryEntry + _rootDirectoryCache.Add(i == 0 ? "$VPD" : $"$VPD_{i}", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> { @@ -681,7 +681,7 @@ namespace Aaru.Filesystems }); if(segaCd != null) - rootDirectoryCache.Add("$IP.BIN", new DecodedDirectoryEntry + _rootDirectoryCache.Add("$IP.BIN", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> { @@ -693,7 +693,7 @@ namespace Aaru.Filesystems }); if(saturn != null) - rootDirectoryCache.Add("$IP.BIN", new DecodedDirectoryEntry + _rootDirectoryCache.Add("$IP.BIN", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> { @@ -705,7 +705,7 @@ namespace Aaru.Filesystems }); if(dreamcast != null) - rootDirectoryCache.Add("$IP.BIN", new DecodedDirectoryEntry + _rootDirectoryCache.Add("$IP.BIN", new DecodedDirectoryEntry { Extents = new List<(uint extent, uint size)> { @@ -721,39 +721,39 @@ namespace Aaru.Filesystems XmlFsType.Clusters = decodedVd.Blocks; XmlFsType.ClusterSize = decodedVd.BlockSize; - statfs = new FileSystemInfo + _statfs = new FileSystemInfo { Blocks = decodedVd.Blocks, - FilenameLength = (ushort)(jolietvd != null ? this.@namespace == Namespace.Joliet + FilenameLength = (ushort)(jolietvd != null ? _namespace == Namespace.Joliet ? 110 : 255 : 255), PluginId = Id, Type = fsFormat }; - directoryCache = new Dictionary>(); + _directoryCache = new Dictionary>(); - if(usePathTable) - foreach(DecodedDirectoryEntry subDirectory in cdi + if(_usePathTable) + foreach(DecodedDirectoryEntry subDirectory in _cdi ? GetSubdirsFromCdiPathTable("") - : highSierra + : _highSierra ? GetSubdirsFromHighSierraPathTable("") : GetSubdirsFromIsoPathTable("")) - rootDirectoryCache[subDirectory.Filename] = subDirectory; + _rootDirectoryCache[subDirectory.Filename] = subDirectory; - mounted = true; + _mounted = true; return Errno.NoError; } public Errno Unmount() { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; - rootDirectoryCache = null; - directoryCache = null; - mounted = false; + _rootDirectoryCache = null; + _directoryCache = null; + _mounted = false; return Errno.NoError; } @@ -762,10 +762,10 @@ namespace Aaru.Filesystems { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; - stat = statfs.ShallowCopy(); + stat = _statfs.ShallowCopy(); return Errno.NoError; } diff --git a/Aaru.Filesystems/ISO9660/Xattr.cs b/Aaru.Filesystems/ISO9660/Xattr.cs index d979cb7a2..d967324d9 100644 --- a/Aaru.Filesystems/ISO9660/Xattr.cs +++ b/Aaru.Filesystems/ISO9660/Xattr.cs @@ -44,7 +44,7 @@ namespace Aaru.Filesystems { xattrs = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry); @@ -83,7 +83,7 @@ namespace Aaru.Filesystems entry.Extents.Count == 0) return Errno.NoError; - byte[] sector = image.ReadSectorLong(entry.Extents[0].extent); + byte[] sector = _image.ReadSectorLong(entry.Extents[0].extent); if(sector[15] != 2) return Errno.NoError; @@ -98,7 +98,7 @@ namespace Aaru.Filesystems { buf = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry); diff --git a/Aaru.Filesystems/JFS.cs b/Aaru.Filesystems/JFS.cs index 65080b6b8..8a82dbf26 100644 --- a/Aaru.Filesystems/JFS.cs +++ b/Aaru.Filesystems/JFS.cs @@ -66,7 +66,7 @@ namespace Aaru.Filesystems if(sector.Length < 512) return false; - JfsSuperBlock jfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); + SuperBlock jfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); return jfsSb.s_magic == JFS_MAGIC; } @@ -83,80 +83,80 @@ namespace Aaru.Filesystems if(sector.Length < 512) return; - JfsSuperBlock jfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); + SuperBlock jfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); sb.AppendLine("JFS filesystem"); sb.AppendFormat("Version {0}", jfsSb.s_version).AppendLine(); sb.AppendFormat("{0} blocks of {1} bytes", jfsSb.s_size, jfsSb.s_bsize).AppendLine(); sb.AppendFormat("{0} blocks per allocation group", jfsSb.s_agsize).AppendLine(); - if(jfsSb.s_flags.HasFlag(JfsFlags.Unicode)) + if(jfsSb.s_flags.HasFlag(Flags.Unicode)) sb.AppendLine("Volume uses Unicode for directory entries"); - if(jfsSb.s_flags.HasFlag(JfsFlags.RemountRO)) + if(jfsSb.s_flags.HasFlag(Flags.RemountRO)) sb.AppendLine("Volume remounts read-only on error"); - if(jfsSb.s_flags.HasFlag(JfsFlags.Continue)) + if(jfsSb.s_flags.HasFlag(Flags.Continue)) sb.AppendLine("Volume continues on error"); - if(jfsSb.s_flags.HasFlag(JfsFlags.Panic)) + if(jfsSb.s_flags.HasFlag(Flags.Panic)) sb.AppendLine("Volume panics on error"); - if(jfsSb.s_flags.HasFlag(JfsFlags.UserQuota)) + if(jfsSb.s_flags.HasFlag(Flags.UserQuota)) sb.AppendLine("Volume has user quotas enabled"); - if(jfsSb.s_flags.HasFlag(JfsFlags.GroupQuota)) + if(jfsSb.s_flags.HasFlag(Flags.GroupQuota)) sb.AppendLine("Volume has group quotas enabled"); - if(jfsSb.s_flags.HasFlag(JfsFlags.NoJournal)) + if(jfsSb.s_flags.HasFlag(Flags.NoJournal)) sb.AppendLine("Volume is not using any journal"); - if(jfsSb.s_flags.HasFlag(JfsFlags.Discard)) + if(jfsSb.s_flags.HasFlag(Flags.Discard)) sb.AppendLine("Volume sends TRIM/UNMAP commands to underlying device"); - if(jfsSb.s_flags.HasFlag(JfsFlags.GroupCommit)) + if(jfsSb.s_flags.HasFlag(Flags.GroupCommit)) sb.AppendLine("Volume commits in groups of 1"); - if(jfsSb.s_flags.HasFlag(JfsFlags.LazyCommit)) + if(jfsSb.s_flags.HasFlag(Flags.LazyCommit)) sb.AppendLine("Volume commits lazy"); - if(jfsSb.s_flags.HasFlag(JfsFlags.Temporary)) + if(jfsSb.s_flags.HasFlag(Flags.Temporary)) sb.AppendLine("Volume does not commit to log"); - if(jfsSb.s_flags.HasFlag(JfsFlags.InlineLog)) + if(jfsSb.s_flags.HasFlag(Flags.InlineLog)) sb.AppendLine("Volume has log withing itself"); - if(jfsSb.s_flags.HasFlag(JfsFlags.InlineMoving)) + if(jfsSb.s_flags.HasFlag(Flags.InlineMoving)) sb.AppendLine("Volume has log withing itself and is moving it out"); - if(jfsSb.s_flags.HasFlag(JfsFlags.BadSAIT)) + if(jfsSb.s_flags.HasFlag(Flags.BadSAIT)) sb.AppendLine("Volume has bad current secondary ait"); - if(jfsSb.s_flags.HasFlag(JfsFlags.Sparse)) + if(jfsSb.s_flags.HasFlag(Flags.Sparse)) sb.AppendLine("Volume supports sparse files"); - if(jfsSb.s_flags.HasFlag(JfsFlags.DASDEnabled)) + if(jfsSb.s_flags.HasFlag(Flags.DASDEnabled)) sb.AppendLine("Volume has DASD limits enabled"); - if(jfsSb.s_flags.HasFlag(JfsFlags.DASDPrime)) + if(jfsSb.s_flags.HasFlag(Flags.DASDPrime)) sb.AppendLine("Volume primes DASD on boot"); - if(jfsSb.s_flags.HasFlag(JfsFlags.SwapBytes)) + if(jfsSb.s_flags.HasFlag(Flags.SwapBytes)) sb.AppendLine("Volume is in a big-endian system"); - if(jfsSb.s_flags.HasFlag(JfsFlags.DirIndex)) + if(jfsSb.s_flags.HasFlag(Flags.DirIndex)) sb.AppendLine("Volume has presistent indexes"); - if(jfsSb.s_flags.HasFlag(JfsFlags.Linux)) + if(jfsSb.s_flags.HasFlag(Flags.Linux)) sb.AppendLine("Volume supports Linux"); - if(jfsSb.s_flags.HasFlag(JfsFlags.DFS)) + if(jfsSb.s_flags.HasFlag(Flags.DFS)) sb.AppendLine("Volume supports DCE DFS LFS"); - if(jfsSb.s_flags.HasFlag(JfsFlags.OS2)) + if(jfsSb.s_flags.HasFlag(Flags.OS2)) sb.AppendLine("Volume supports OS/2, and is case insensitive"); - if(jfsSb.s_flags.HasFlag(JfsFlags.AIX)) + if(jfsSb.s_flags.HasFlag(Flags.AIX)) sb.AppendLine("Volume supports AIX"); if(jfsSb.s_state != 0) @@ -192,7 +192,7 @@ namespace Aaru.Filesystems } [Flags] - enum JfsFlags : uint + enum Flags : uint { Unicode = 0x00000001, RemountRO = 0x00000002, Continue = 0x00000004, Panic = 0x00000008, UserQuota = 0x00000010, GroupQuota = 0x00000020, @@ -205,14 +205,14 @@ namespace Aaru.Filesystems } [Flags] - enum JfsState : uint + enum State : uint { Clean = 0, Mounted = 1, Dirty = 2, Logredo = 4, Extendfs = 8 } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct JfsExtent + struct Extent { /// Leftmost 24 bits are extent length, rest 8 bits are most significant for public readonly uint len_addr; @@ -220,43 +220,43 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct JfsTimeStruct + struct TimeStruct { public readonly uint tv_sec; public readonly uint tv_nsec; } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct JfsSuperBlock + struct SuperBlock { - public readonly uint s_magic; - public readonly uint s_version; - public readonly ulong s_size; - public readonly uint s_bsize; - public readonly ushort s_l2bsize; - public readonly ushort s_l2bfactor; - public readonly uint s_pbsize; - public readonly ushort s_l1pbsize; - public readonly ushort pad; - public readonly uint s_agsize; - public readonly JfsFlags s_flags; - public readonly JfsState s_state; - public readonly uint s_compress; - public readonly JfsExtent s_ait2; - public readonly JfsExtent s_aim2; - public readonly uint s_logdev; - public readonly uint s_logserial; - public readonly JfsExtent s_logpxd; - public readonly JfsExtent s_fsckpxd; - public readonly JfsTimeStruct s_time; - public readonly uint s_fsckloglen; - public readonly sbyte s_fscklog; + public readonly uint s_magic; + public readonly uint s_version; + public readonly ulong s_size; + public readonly uint s_bsize; + public readonly ushort s_l2bsize; + public readonly ushort s_l2bfactor; + public readonly uint s_pbsize; + public readonly ushort s_l1pbsize; + public readonly ushort pad; + public readonly uint s_agsize; + public readonly Flags s_flags; + public readonly State s_state; + public readonly uint s_compress; + public readonly Extent s_ait2; + public readonly Extent s_aim2; + public readonly uint s_logdev; + public readonly uint s_logserial; + public readonly Extent s_logpxd; + public readonly Extent s_fsckpxd; + public readonly TimeStruct s_time; + public readonly uint s_fsckloglen; + public readonly sbyte s_fscklog; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] public readonly byte[] s_fpack; - public readonly ulong s_xsize; - public readonly JfsExtent s_xfsckpxd; - public readonly JfsExtent s_xlogpxd; - public readonly Guid s_uuid; + public readonly ulong s_xsize; + public readonly Extent s_xfsckpxd; + public readonly Extent s_xlogpxd; + public readonly Guid s_uuid; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public readonly byte[] s_label; public readonly Guid s_loguuid; diff --git a/Aaru.Filesystems/LIF.cs b/Aaru.Filesystems/LIF.cs index c5ebbdff8..729f0990e 100644 --- a/Aaru.Filesystems/LIF.cs +++ b/Aaru.Filesystems/LIF.cs @@ -58,8 +58,8 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize < 256) return false; - byte[] sector = imagePlugin.ReadSector(partition.Start); - LifSystemBlock lifSb = Marshal.ByteArrayToStructureBigEndian(sector); + byte[] sector = imagePlugin.ReadSector(partition.Start); + SystemBlock lifSb = Marshal.ByteArrayToStructureBigEndian(sector); AaruConsole.DebugWriteLine("LIF plugin", "magic 0x{0:X8} (expected 0x{1:X8})", lifSb.magic, LIF_MAGIC); return lifSb.magic == LIF_MAGIC; @@ -74,8 +74,8 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize < 256) return; - byte[] sector = imagePlugin.ReadSector(partition.Start); - LifSystemBlock lifSb = Marshal.ByteArrayToStructureBigEndian(sector); + byte[] sector = imagePlugin.ReadSector(partition.Start); + SystemBlock lifSb = Marshal.ByteArrayToStructureBigEndian(sector); if(lifSb.magic != LIF_MAGIC) return; @@ -109,7 +109,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct LifSystemBlock + struct SystemBlock { public readonly ushort magic; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] diff --git a/Aaru.Filesystems/LisaFS/Dir.cs b/Aaru.Filesystems/LisaFS/Dir.cs index b2e38d1bd..e8fc694d6 100644 --- a/Aaru.Filesystems/LisaFS/Dir.cs +++ b/Aaru.Filesystems/LisaFS/Dir.cs @@ -78,7 +78,7 @@ namespace Aaru.Filesystems.LisaFS // On debug add system files as readable files // Syntax similar to NTFS - if(debug && fileId == DIRID_ROOT) + if(_debug && fileId == DIRID_ROOT) { contents.Add("$MDDF"); contents.Add("$Boot"); @@ -97,7 +97,7 @@ namespace Aaru.Filesystems.LisaFS { // Do same trick as Mac OS X, replace filesystem '/' with '-', // as '-' is the path separator in Lisa OS - contents = (from entry in catalogCache where entry.parentID == dirId + contents = (from entry in _catalogCache where entry.parentID == dirId select StringHandlers.CToString(entry.filename, Encoding).Replace('/', '-')).ToList(); return Errno.NoError; @@ -106,14 +106,14 @@ namespace Aaru.Filesystems.LisaFS /// Reads, interprets and caches the Catalog File Errno ReadCatalog() { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; - catalogCache = new List(); + _catalogCache = new List(); // Do differently for V1 and V2 - if(mddf.fsversion == LISA_V2 || - mddf.fsversion == LISA_V1) + if(_mddf.fsversion == LISA_V2 || + _mddf.fsversion == LISA_V1) { Errno error = ReadFile((short)FILEID_CATALOG, out byte[] buf); @@ -163,14 +163,14 @@ namespace Aaru.Filesystems.LisaFS fileID = entV2.fileID, filename = new byte[32], fileType = entV2.fileType, - length = (int)srecords[entV2.fileID].filesize, + length = (int)_srecords[entV2.fileID].filesize, dtc = ext.dtc, dtm = ext.dtm }; Array.Copy(entV2.filename, 0, entV3.filename, 0, entV2.filenameLen); - catalogCache.Add(entV3); + _catalogCache.Add(entV3); } return Errno.NoError; @@ -181,15 +181,15 @@ namespace Aaru.Filesystems.LisaFS // Search for the first sector describing the catalog // While root catalog is not stored in S-Records, probably rest are? (unchecked) // If root catalog is not pointed in MDDF (unchecked) maybe it's always following S-Records File? - for(ulong i = 0; i < device.Info.Sectors; i++) + for(ulong i = 0; i < _device.Info.Sectors; i++) { - DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out LisaTag.PriamTag catTag); + DecodeTag(_device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out LisaTag.PriamTag catTag); if(catTag.FileId != FILEID_CATALOG || catTag.RelPage != 0) continue; - firstCatalogBlock = device.ReadSectors(i, 4); + firstCatalogBlock = _device.ReadSectors(i, 4); break; } @@ -204,13 +204,13 @@ namespace Aaru.Filesystems.LisaFS // Traverse double-linked list until first catalog block while(prevCatalogPointer != 0xFFFFFFFF) { - DecodeTag(device.ReadSectorTag(prevCatalogPointer + mddf.mddf_block + volumePrefix, SectorTagType.AppleSectorTag), + DecodeTag(_device.ReadSectorTag(prevCatalogPointer + _mddf.mddf_block + _volumePrefix, SectorTagType.AppleSectorTag), out LisaTag.PriamTag prevTag); if(prevTag.FileId != FILEID_CATALOG) return Errno.InvalidArgument; - firstCatalogBlock = device.ReadSectors(prevCatalogPointer + mddf.mddf_block + volumePrefix, 4); + firstCatalogBlock = _device.ReadSectors(prevCatalogPointer + _mddf.mddf_block + _volumePrefix, 4); prevCatalogPointer = BigEndianBitConverter.ToUInt32(firstCatalogBlock, 0x7F6); } @@ -225,13 +225,13 @@ namespace Aaru.Filesystems.LisaFS // Traverse double-linked list to read full catalog while(nextCatalogPointer != 0xFFFFFFFF) { - DecodeTag(device.ReadSectorTag(nextCatalogPointer + mddf.mddf_block + volumePrefix, SectorTagType.AppleSectorTag), + DecodeTag(_device.ReadSectorTag(nextCatalogPointer + _mddf.mddf_block + _volumePrefix, SectorTagType.AppleSectorTag), out LisaTag.PriamTag nextTag); if(nextTag.FileId != FILEID_CATALOG) return Errno.InvalidArgument; - byte[] nextCatalogBlock = device.ReadSectors(nextCatalogPointer + mddf.mddf_block + volumePrefix, 4); + byte[] nextCatalogBlock = _device.ReadSectors(nextCatalogPointer + _mddf.mddf_block + _volumePrefix, 4); nextCatalogPointer = BigEndianBitConverter.ToUInt32(nextCatalogBlock, 0x7FA); catalogBlocks.Add(nextCatalogBlock); } @@ -280,10 +280,10 @@ namespace Aaru.Filesystems.LisaFS Array.Copy(buf, offset + 0x38, entry.tail, 0, 8); if(ReadExtentsFile(entry.fileID, out _) == Errno.NoError) - if(!fileSizeCache.ContainsKey(entry.fileID)) + if(!_fileSizeCache.ContainsKey(entry.fileID)) { - catalogCache.Add(entry); - fileSizeCache.Add(entry.fileID, entry.length); + _catalogCache.Add(entry); + _fileSizeCache.Add(entry.fileID, entry.length); } offset += 64; @@ -311,10 +311,10 @@ namespace Aaru.Filesystems.LisaFS Array.Copy(buf, offset + 0x03, entry.filename, 0, E_NAME); - if(!directoryDtcCache.ContainsKey(entry.fileID)) - directoryDtcCache.Add(entry.fileID, DateHandlers.LisaToDateTime(entry.dtc)); + if(!_directoryDtcCache.ContainsKey(entry.fileID)) + _directoryDtcCache.Add(entry.fileID, DateHandlers.LisaToDateTime(entry.dtc)); - catalogCache.Add(entry); + _catalogCache.Add(entry); offset += 48; } @@ -329,7 +329,7 @@ namespace Aaru.Filesystems.LisaFS { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; stat = new FileEntryInfo @@ -342,11 +342,11 @@ namespace Aaru.Filesystems.LisaFS GID = 0, DeviceNo = 0, Length = 0, - BlockSize = mddf.datasize, + BlockSize = _mddf.datasize, Blocks = 0 }; - directoryDtcCache.TryGetValue(dirId, out DateTime tmp); + _directoryDtcCache.TryGetValue(dirId, out DateTime tmp); stat.CreationTime = tmp; return Errno.NoError; diff --git a/Aaru.Filesystems/LisaFS/Extent.cs b/Aaru.Filesystems/LisaFS/Extent.cs index d4e29159b..53327a46d 100644 --- a/Aaru.Filesystems/LisaFS/Extent.cs +++ b/Aaru.Filesystems/LisaFS/Extent.cs @@ -57,21 +57,21 @@ namespace Aaru.Filesystems.LisaFS { file = new ExtentFile(); - if(!mounted) + if(!_mounted) return Errno.AccessDenied; if(fileId < 4 || - (fileId == 4 && mddf.fsversion != LISA_V2 && mddf.fsversion != LISA_V1)) + (fileId == 4 && _mddf.fsversion != LISA_V2 && _mddf.fsversion != LISA_V1)) return Errno.InvalidArgument; - if(extentCache.TryGetValue(fileId, out file)) + if(_extentCache.TryGetValue(fileId, out file)) return Errno.NoError; // A file ID that cannot be stored in the S-Records File - if(fileId >= srecords.Length) + if(fileId >= _srecords.Length) return Errno.InvalidArgument; - ulong ptr = srecords[fileId].extent_ptr; + ulong ptr = _srecords[fileId].extent_ptr; // An invalid pointer denotes file does not exist if(ptr == 0xFFFFFFFF || @@ -79,20 +79,20 @@ namespace Aaru.Filesystems.LisaFS return Errno.NoSuchFile; // Pointers are relative to MDDF - ptr += mddf.mddf_block + volumePrefix; + ptr += _mddf.mddf_block + _volumePrefix; LisaTag.PriamTag extTag; // This happens on some disks. // This is a filesystem corruption that makes LisaOS crash on scavenge. // This code just allow to ignore that corruption by searching the Extents File using sector tags - if(ptr >= device.Info.Sectors) + if(ptr >= _device.Info.Sectors) { bool found = false; - for(ulong i = 0; i < device.Info.Sectors; i++) + for(ulong i = 0; i < _device.Info.Sectors; i++) { - DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out extTag); + DecodeTag(_device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out extTag); if(extTag.FileId != fileId * -1) continue; @@ -108,12 +108,12 @@ namespace Aaru.Filesystems.LisaFS } // Checks that the sector tag indicates its the Extents File we are searching for - DecodeTag(device.ReadSectorTag(ptr, SectorTagType.AppleSectorTag), out extTag); + DecodeTag(_device.ReadSectorTag(ptr, SectorTagType.AppleSectorTag), out extTag); if(extTag.FileId != (short)(-1 * fileId)) return Errno.NoSuchFile; - byte[] sector = mddf.fsversion == LISA_V1 ? device.ReadSectors(ptr, 2) : device.ReadSector(ptr); + byte[] sector = _mddf.fsversion == LISA_V1 ? _device.ReadSectors(ptr, 2) : _device.ReadSector(ptr); if(sector[0] >= 32 || sector[0] == 0) @@ -163,7 +163,7 @@ namespace Aaru.Filesystems.LisaFS int extentsCount = 0; int extentsOffset; - if(mddf.fsversion == LISA_V1) + if(_mddf.fsversion == LISA_V1) { file.length = BigEndianBitConverter.ToInt32(sector, 0x200); file.unknown9 = BigEndianBitConverter.ToInt32(sector, 0x204); @@ -193,12 +193,12 @@ namespace Aaru.Filesystems.LisaFS length = BigEndianBitConverter.ToInt16(sector, extentsOffset + (j * 6) + 4) }; - extentCache.Add(fileId, file); + _extentCache.Add(fileId, file); - if(!debug) + if(!_debug) return Errno.NoError; - if(printedExtents.Contains(fileId)) + if(_printedExtents.Contains(fileId)) return Errno.NoError; AaruConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].filenameLen = {1}", fileId, file.filenameLen); @@ -274,7 +274,7 @@ namespace Aaru.Filesystems.LisaFS AaruConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown10 = 0x{1:X4}", fileId, file.unknown10); - printedExtents.Add(fileId); + _printedExtents.Add(fileId); return Errno.NoError; } @@ -282,17 +282,17 @@ namespace Aaru.Filesystems.LisaFS /// Reads all the S-Records and caches it Errno ReadSRecords() { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; // Searches the S-Records place using MDDF pointers - byte[] sectors = device.ReadSectors(mddf.srec_ptr + mddf.mddf_block + volumePrefix, mddf.srec_len); + byte[] sectors = _device.ReadSectors(_mddf.srec_ptr + _mddf.mddf_block + _volumePrefix, _mddf.srec_len); // Each entry takes 14 bytes - srecords = new SRecord[sectors.Length / 14]; + _srecords = new SRecord[sectors.Length / 14]; - for(int s = 0; s < srecords.Length; s++) - srecords[s] = new SRecord + for(int s = 0; s < _srecords.Length; s++) + _srecords[s] = new SRecord { extent_ptr = BigEndianBitConverter.ToUInt32(sectors, 0x00 + (14 * s)), unknown = BigEndianBitConverter.ToUInt32(sectors, 0x04 + (14 * s)), diff --git a/Aaru.Filesystems/LisaFS/File.cs b/Aaru.Filesystems/LisaFS/File.cs index 23466c5b3..11d60a34e 100644 --- a/Aaru.Filesystems/LisaFS/File.cs +++ b/Aaru.Filesystems/LisaFS/File.cs @@ -77,7 +77,7 @@ namespace Aaru.Filesystems.LisaFS byte[] tmp; - if(debug) + if(_debug) switch(fileId) { case FILEID_BOOT_SIGNED: @@ -127,12 +127,12 @@ namespace Aaru.Filesystems.LisaFS { attributes = new FileAttributes(); - if(!mounted) + if(!_mounted) return Errno.AccessDenied; if(fileId < 4) { - if(!debug) + if(!_debug) return Errno.NoSuchFile; attributes = new FileAttributes(); @@ -190,8 +190,8 @@ namespace Aaru.Filesystems.LisaFS { buf = null; - if(!mounted || - !debug) + if(!_mounted || + !_debug) return Errno.AccessDenied; if(fileId > 4 || @@ -200,7 +200,7 @@ namespace Aaru.Filesystems.LisaFS fileId != FILEID_LOADER_SIGNED) return Errno.InvalidArgument; - if(systemFileCache.TryGetValue(fileId, out buf) && + if(_systemFileCache.TryGetValue(fileId, out buf) && !tags) return Errno.NoError; @@ -209,15 +209,15 @@ namespace Aaru.Filesystems.LisaFS if(fileId == FILEID_SRECORD) if(!tags) { - buf = device.ReadSectors(mddf.mddf_block + volumePrefix + mddf.srec_ptr, mddf.srec_len); - systemFileCache.Add(fileId, buf); + buf = _device.ReadSectors(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, _mddf.srec_len); + _systemFileCache.Add(fileId, buf); return Errno.NoError; } else { - buf = device.ReadSectorsTag(mddf.mddf_block + volumePrefix + mddf.srec_ptr, mddf.srec_len, - SectorTagType.AppleSectorTag); + buf = _device.ReadSectorsTag(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, _mddf.srec_len, + SectorTagType.AppleSectorTag); return Errno.NoError; } @@ -227,7 +227,7 @@ namespace Aaru.Filesystems.LisaFS // Should be enough to check 100 sectors? for(ulong i = 0; i < 100; i++) { - DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out sysTag); + DecodeTag(_device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out sysTag); if(sysTag.FileId == fileId) count++; @@ -236,17 +236,17 @@ namespace Aaru.Filesystems.LisaFS if(count == 0) return Errno.NoSuchFile; - buf = !tags ? new byte[count * device.Info.SectorSize] : new byte[count * devTagSize]; + buf = !tags ? new byte[count * _device.Info.SectorSize] : new byte[count * _devTagSize]; // Should be enough to check 100 sectors? for(ulong i = 0; i < 100; i++) { - DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out sysTag); + DecodeTag(_device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out sysTag); if(sysTag.FileId != fileId) continue; - byte[] sector = !tags ? device.ReadSector(i) : device.ReadSectorTag(i, SectorTagType.AppleSectorTag); + byte[] sector = !tags ? _device.ReadSector(i) : _device.ReadSectorTag(i, SectorTagType.AppleSectorTag); // Relative block for $Loader starts at $Boot block if(sysTag.FileId == FILEID_LOADER_SIGNED) @@ -256,7 +256,7 @@ namespace Aaru.Filesystems.LisaFS } if(!tags) - systemFileCache.Add(fileId, buf); + _systemFileCache.Add(fileId, buf); return Errno.NoError; } @@ -265,14 +265,14 @@ namespace Aaru.Filesystems.LisaFS { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno error; ExtentFile file; if(fileId <= 4) - if(!debug || + if(!_debug || fileId == 0) return Errno.NoSuchFile; else @@ -303,8 +303,8 @@ namespace Aaru.Filesystems.LisaFS stat.Inode = (ulong)fileId; stat.Links = 0; - stat.Length = mddf.datasize; - stat.BlockSize = mddf.datasize; + stat.Length = _mddf.datasize; + stat.BlockSize = _mddf.datasize; stat.Blocks = 1; } else @@ -314,15 +314,15 @@ namespace Aaru.Filesystems.LisaFS if(error != Errno.NoError) return error; - stat.CreationTime = fileId != 4 ? mddf.dtvc : mddf.dtcc; + stat.CreationTime = fileId != 4 ? _mddf.dtvc : _mddf.dtcc; - stat.BackupTime = mddf.dtvb; + stat.BackupTime = _mddf.dtvb; stat.Inode = (ulong)fileId; stat.Links = 0; stat.Length = buf.Length; - stat.BlockSize = mddf.datasize; - stat.Blocks = buf.Length / mddf.datasize; + stat.BlockSize = _mddf.datasize; + stat.Blocks = buf.Length / _mddf.datasize; } return Errno.NoError; @@ -351,12 +351,12 @@ namespace Aaru.Filesystems.LisaFS stat.Inode = (ulong)fileId; stat.Links = 1; - if(!fileSizeCache.TryGetValue(fileId, out int len)) - stat.Length = srecords[fileId].filesize; + if(!_fileSizeCache.TryGetValue(fileId, out int len)) + stat.Length = _srecords[fileId].filesize; else stat.Length = len; - stat.BlockSize = mddf.datasize; + stat.BlockSize = _mddf.datasize; stat.Blocks = file.length; return Errno.NoError; @@ -368,17 +368,17 @@ namespace Aaru.Filesystems.LisaFS { buf = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; - tags &= debug; + tags &= _debug; if(fileId < 4 || - (fileId == 4 && mddf.fsversion != LISA_V2 && mddf.fsversion != LISA_V1)) + (fileId == 4 && _mddf.fsversion != LISA_V2 && _mddf.fsversion != LISA_V1)) return Errno.InvalidArgument; if(!tags && - fileCache.TryGetValue(fileId, out buf)) + _fileCache.TryGetValue(fileId, out buf)) return Errno.NoError; Errno error = ReadExtentsFile(fileId, out ExtentFile file); @@ -389,9 +389,9 @@ namespace Aaru.Filesystems.LisaFS int sectorSize; if(tags) - sectorSize = devTagSize; + sectorSize = _devTagSize; else - sectorSize = (int)device.Info.SectorSize; + sectorSize = (int)_device.Info.SectorSize; byte[] temp = new byte[file.length * sectorSize]; @@ -402,11 +402,11 @@ namespace Aaru.Filesystems.LisaFS byte[] sector; if(!tags) - sector = device.ReadSectors((ulong)file.extents[i].start + mddf.mddf_block + volumePrefix, - (uint)file.extents[i].length); + sector = _device.ReadSectors((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix, + (uint)file.extents[i].length); else - sector = device.ReadSectorsTag((ulong)file.extents[i].start + mddf.mddf_block + volumePrefix, - (uint)file.extents[i].length, SectorTagType.AppleSectorTag); + sector = _device.ReadSectorsTag((ulong)file.extents[i].start + _mddf.mddf_block + _volumePrefix, + (uint)file.extents[i].length, SectorTagType.AppleSectorTag); Array.Copy(sector, 0, temp, offset, sector.Length); offset += sector.Length; @@ -414,13 +414,13 @@ namespace Aaru.Filesystems.LisaFS if(!tags) { - if(fileSizeCache.TryGetValue(fileId, out int realSize)) + if(_fileSizeCache.TryGetValue(fileId, out int realSize)) if(realSize > temp.Length) AaruConsole.ErrorWriteLine("File {0} gets truncated.", fileId); buf = temp; - fileCache.Add(fileId, buf); + _fileCache.Add(fileId, buf); } else buf = temp; @@ -433,7 +433,7 @@ namespace Aaru.Filesystems.LisaFS fileId = 0; isDir = false; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -451,10 +451,10 @@ namespace Aaru.Filesystems.LisaFS // Only V3 supports subdirectories if(pathElements.Length > 1 && - mddf.fsversion != LISA_V3) + _mddf.fsversion != LISA_V3) return Errno.NotSupported; - if(debug && pathElements.Length == 1) + if(_debug && pathElements.Length == 1) { if(string.Compare(pathElements[0], "$MDDF", StringComparison.InvariantCulture) == 0) { @@ -504,7 +504,7 @@ namespace Aaru.Filesystems.LisaFS { string wantedFilename = pathElements[0].Replace('-', '/'); - foreach(CatalogEntry entry in catalogCache) + foreach(CatalogEntry entry in _catalogCache) { string filename = StringHandlers.CToString(entry.filename, Encoding); diff --git a/Aaru.Filesystems/LisaFS/LisaFS.cs b/Aaru.Filesystems/LisaFS/LisaFS.cs index 470b536aa..8e60508c7 100644 --- a/Aaru.Filesystems/LisaFS/LisaFS.cs +++ b/Aaru.Filesystems/LisaFS/LisaFS.cs @@ -42,14 +42,13 @@ namespace Aaru.Filesystems.LisaFS // Variable names from Lisa API public partial class LisaFS : IReadOnlyFilesystem { - bool debug; - IMediaImage device; - int devTagSize; - - MDDF mddf; - bool mounted; - SRecord[] srecords; - ulong volumePrefix; + bool _debug; + IMediaImage _device; + int _devTagSize; + MDDF _mddf; + bool _mounted; + SRecord[] _srecords; + ulong _volumePrefix; public string Name => "Apple Lisa File System"; public Guid Id => new Guid("7E6034D1-D823-4248-A54D-239742B28391"); @@ -81,19 +80,19 @@ namespace Aaru.Filesystems.LisaFS #region Caches /// Caches Extents Files - Dictionary extentCache; + Dictionary _extentCache; /// Caches system files - Dictionary systemFileCache; + Dictionary _systemFileCache; /// Caches user files files - Dictionary fileCache; + Dictionary _fileCache; /// Caches catalogs - List catalogCache; + List _catalogCache; /// Caches file size - Dictionary fileSizeCache; + Dictionary _fileSizeCache; /// Lists Extents Files already printed in debug mode to not repeat them - List printedExtents; + List _printedExtents; /// Caches the creation times for subdirectories as to not have to traverse the Catalog File on each stat - Dictionary directoryDtcCache; + Dictionary _directoryDtcCache; #endregion Caches } } \ No newline at end of file diff --git a/Aaru.Filesystems/LisaFS/Super.cs b/Aaru.Filesystems/LisaFS/Super.cs index f9e93b8ef..a8339a2c1 100644 --- a/Aaru.Filesystems/LisaFS/Super.cs +++ b/Aaru.Filesystems/LisaFS/Super.cs @@ -54,14 +54,14 @@ namespace Aaru.Filesystems.LisaFS { try { - device = imagePlugin; + _device = imagePlugin; Encoding = new LisaRoman(); // Lisa OS is unable to work on disks without tags. // This code is designed like that. // However with some effort the code may be modified to ignore them. - if(device.Info.ReadableSectorTags == null || - !device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) + if(_device.Info.ReadableSectorTags == null || + !_device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) { AaruConsole.DebugWriteLine("LisaFS plugin", "Underlying device does not support Lisa tags"); @@ -69,7 +69,7 @@ namespace Aaru.Filesystems.LisaFS } // Minimal LisaOS disk is 3.5" single sided double density, 800 sectors - if(device.Info.Sectors < 800) + if(_device.Info.Sectors < 800) { AaruConsole.DebugWriteLine("LisaFS plugin", "Device is too small"); @@ -77,116 +77,116 @@ namespace Aaru.Filesystems.LisaFS } // MDDF cannot be at end of device, of course - volumePrefix = device.Info.Sectors; + _volumePrefix = _device.Info.Sectors; // LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors for(ulong i = 0; i < 100; i++) { - DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out LisaTag.PriamTag searchTag); + DecodeTag(_device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out LisaTag.PriamTag searchTag); AaruConsole.DebugWriteLine("LisaFS plugin", "Sector {0}, file ID 0x{1:X4}", i, searchTag.FileId); - if(volumePrefix == device.Info.Sectors && + if(_volumePrefix == _device.Info.Sectors && searchTag.FileId == FILEID_LOADER_SIGNED) - volumePrefix = i - 1; + _volumePrefix = i - 1; if(searchTag.FileId != FILEID_MDDF) continue; - devTagSize = device.ReadSectorTag(i, SectorTagType.AppleSectorTag).Length; + _devTagSize = _device.ReadSectorTag(i, SectorTagType.AppleSectorTag).Length; - byte[] sector = device.ReadSector(i); - mddf = new MDDF(); + byte[] sector = _device.ReadSector(i); + _mddf = new MDDF(); byte[] pString = new byte[33]; - mddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00); - mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02); - mddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A); + _mddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00); + _mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02); + _mddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A); Array.Copy(sector, 0x0C, pString, 0, 33); - mddf.volname = StringHandlers.PascalToString(pString, Encoding); - mddf.unknown1 = sector[0x2D]; + _mddf.volname = StringHandlers.PascalToString(pString, Encoding); + _mddf.unknown1 = sector[0x2D]; Array.Copy(sector, 0x2E, pString, 0, 33); // Prevent garbage - mddf.password = pString[0] <= 32 ? StringHandlers.PascalToString(pString, Encoding) : ""; - mddf.unknown2 = sector[0x4F]; - mddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50); - mddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54); + _mddf.password = pString[0] <= 32 ? StringHandlers.PascalToString(pString, Encoding) : ""; + _mddf.unknown2 = sector[0x4F]; + _mddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50); + _mddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54); uint lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x58); - mddf.dtvc = DateHandlers.LisaToDateTime(lisaTime); - lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x5C); - mddf.dtcc = DateHandlers.LisaToDateTime(lisaTime); - lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x60); - mddf.dtvb = DateHandlers.LisaToDateTime(lisaTime); - lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x64); - mddf.dtvs = DateHandlers.LisaToDateTime(lisaTime); - 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]; + _mddf.dtvc = DateHandlers.LisaToDateTime(lisaTime); + lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x5C); + _mddf.dtcc = DateHandlers.LisaToDateTime(lisaTime); + lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x60); + _mddf.dtvb = DateHandlers.LisaToDateTime(lisaTime); + lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x64); + _mddf.dtvs = DateHandlers.LisaToDateTime(lisaTime); + _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]; // Check that the MDDF is correct - if(mddf.mddf_block != i - volumePrefix || - mddf.vol_size > device.Info.Sectors || - mddf.vol_size - 1 != mddf.volsize_minus_one || - mddf.vol_size - i - 1 != mddf.volsize_minus_mddf_minus_one - volumePrefix || - mddf.datasize > mddf.blocksize || - mddf.blocksize < device.Info.SectorSize || - mddf.datasize != device.Info.SectorSize) + if(_mddf.mddf_block != i - _volumePrefix || + _mddf.vol_size > _device.Info.Sectors || + _mddf.vol_size - 1 != _mddf.volsize_minus_one || + _mddf.vol_size - i - 1 != _mddf.volsize_minus_mddf_minus_one - _volumePrefix || + _mddf.datasize > _mddf.blocksize || + _mddf.blocksize < _device.Info.SectorSize || + _mddf.datasize != _device.Info.SectorSize) { AaruConsole.DebugWriteLine("LisaFS plugin", "Incorrect MDDF found"); @@ -194,7 +194,7 @@ namespace Aaru.Filesystems.LisaFS } // Check MDDF version - switch(mddf.fsversion) + switch(_mddf.fsversion) { case LISA_V1: AaruConsole.DebugWriteLine("LisaFS plugin", "Mounting LisaFS v1"); @@ -209,29 +209,29 @@ namespace Aaru.Filesystems.LisaFS break; default: - AaruConsole.ErrorWriteLine("Cannot mount LisaFS version {0}", mddf.fsversion.ToString()); + AaruConsole.ErrorWriteLine("Cannot mount LisaFS version {0}", _mddf.fsversion.ToString()); return Errno.NotSupported; } // Initialize caches - extentCache = new Dictionary(); - systemFileCache = new Dictionary(); - fileCache = new Dictionary(); + _extentCache = new Dictionary(); + _systemFileCache = new Dictionary(); + _fileCache = new Dictionary(); //catalogCache = new Dictionary>(); - fileSizeCache = new Dictionary(); + _fileSizeCache = new Dictionary(); - mounted = true; + _mounted = true; if(options == null) options = GetDefaultOptions(); if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out debug); + bool.TryParse(debugString, out _debug); - if(debug) - printedExtents = new List(); + if(_debug) + _printedExtents = new List(); // Read the S-Records file Errno error = ReadSRecords(); @@ -243,10 +243,10 @@ namespace Aaru.Filesystems.LisaFS return error; } - directoryDtcCache = new Dictionary + _directoryDtcCache = new Dictionary { { - DIRID_ROOT, mddf.dtcc + DIRID_ROOT, _mddf.dtcc } }; @@ -258,20 +258,20 @@ namespace Aaru.Filesystems.LisaFS AaruConsole.DebugWriteLine("LisaFS plugin", "Cannot read Catalog File, error {0}", error.ToString()); - mounted = false; + _mounted = false; return error; } // If debug, cache system files - if(debug) + if(_debug) { error = ReadSystemFile(FILEID_BOOT_SIGNED, out _); if(error != Errno.NoError) { AaruConsole.DebugWriteLine("LisaFS plugin", "Unable to read boot blocks"); - mounted = false; + _mounted = false; return error; } @@ -281,7 +281,7 @@ namespace Aaru.Filesystems.LisaFS if(error != Errno.NoError) { AaruConsole.DebugWriteLine("LisaFS plugin", "Unable to read boot loader"); - mounted = false; + _mounted = false; return error; } @@ -291,7 +291,7 @@ namespace Aaru.Filesystems.LisaFS if(error != Errno.NoError) { AaruConsole.DebugWriteLine("LisaFS plugin", "Unable to read MDDF"); - mounted = false; + _mounted = false; return error; } @@ -301,7 +301,7 @@ namespace Aaru.Filesystems.LisaFS if(error != Errno.NoError) { AaruConsole.DebugWriteLine("LisaFS plugin", "Unable to read volume bitmap"); - mounted = false; + _mounted = false; return error; } @@ -311,7 +311,7 @@ namespace Aaru.Filesystems.LisaFS if(error != Errno.NoError) { AaruConsole.DebugWriteLine("LisaFS plugin", "Unable to read S-Records file"); - mounted = false; + _mounted = false; return error; } @@ -320,29 +320,29 @@ namespace Aaru.Filesystems.LisaFS // Create XML metadata for mounted filesystem XmlFsType = new FileSystemType(); - if(DateTime.Compare(mddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0) + if(DateTime.Compare(_mddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0) { - XmlFsType.BackupDate = mddf.dtvb; + XmlFsType.BackupDate = _mddf.dtvb; XmlFsType.BackupDateSpecified = true; } - XmlFsType.Clusters = mddf.vol_size; - XmlFsType.ClusterSize = (uint)(mddf.clustersize * mddf.datasize); + XmlFsType.Clusters = _mddf.vol_size; + XmlFsType.ClusterSize = (uint)(_mddf.clustersize * _mddf.datasize); - if(DateTime.Compare(mddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0) + if(DateTime.Compare(_mddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0) { - XmlFsType.CreationDate = mddf.dtvc; + XmlFsType.CreationDate = _mddf.dtvc; XmlFsType.CreationDateSpecified = true; } - XmlFsType.Dirty = mddf.vol_left_mounted != 0; - XmlFsType.Files = mddf.filecount; + XmlFsType.Dirty = _mddf.vol_left_mounted != 0; + XmlFsType.Files = _mddf.filecount; XmlFsType.FilesSpecified = true; - XmlFsType.FreeClusters = mddf.freecount; + XmlFsType.FreeClusters = _mddf.freecount; XmlFsType.FreeClustersSpecified = true; XmlFsType.Type = "LisaFS"; - XmlFsType.VolumeName = mddf.volname; - XmlFsType.VolumeSerial = $"{mddf.volid:X16}"; + XmlFsType.VolumeName = _mddf.volname; + XmlFsType.VolumeSerial = $"{_mddf.volid:X16}"; return Errno.NoError; } @@ -363,17 +363,17 @@ namespace Aaru.Filesystems.LisaFS /// Umounts this Lisa filesystem public Errno Unmount() { - mounted = false; - extentCache = null; - systemFileCache = null; - fileCache = null; - catalogCache = null; - fileSizeCache = null; - printedExtents = null; - mddf = new MDDF(); - volumePrefix = 0; - devTagSize = 0; - srecords = null; + _mounted = false; + _extentCache = null; + _systemFileCache = null; + _fileCache = null; + _catalogCache = null; + _fileSizeCache = null; + _printedExtents = null; + _mddf = new MDDF(); + _volumePrefix = 0; + _devTagSize = 0; + _srecords = null; return Errno.NoError; } @@ -385,18 +385,18 @@ namespace Aaru.Filesystems.LisaFS { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; stat = new FileSystemInfo { - Blocks = mddf.vol_size, + Blocks = _mddf.vol_size, FilenameLength = (ushort)E_NAME, - Files = mddf.filecount, - FreeBlocks = mddf.freecount, + Files = _mddf.filecount, + FreeBlocks = _mddf.freecount, Id = { - Serial64 = mddf.volid, + Serial64 = _mddf.volid, IsLong = true }, PluginId = Id @@ -404,7 +404,7 @@ namespace Aaru.Filesystems.LisaFS stat.FreeFiles = FILEID_MAX - stat.Files; - switch(mddf.fsversion) + switch(_mddf.fsversion) { case LISA_V1: stat.Type = "LisaFS v1"; diff --git a/Aaru.Filesystems/LisaFS/Xattr.cs b/Aaru.Filesystems/LisaFS/Xattr.cs index 7ca04039c..7166a6537 100644 --- a/Aaru.Filesystems/LisaFS/Xattr.cs +++ b/Aaru.Filesystems/LisaFS/Xattr.cs @@ -82,13 +82,13 @@ namespace Aaru.Filesystems.LisaFS { xattrs = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; // System files if(fileId < 4) { - if(!debug || + if(!_debug || fileId == 0) return Errno.InvalidArgument; @@ -97,7 +97,7 @@ namespace Aaru.Filesystems.LisaFS // Only MDDF contains an extended attributes if(fileId == FILEID_MDDF) { - byte[] buf = Encoding.ASCII.GetBytes(mddf.password); + byte[] buf = Encoding.ASCII.GetBytes(_mddf.password); // If the MDDF contains a password, show it if(buf.Length > 0) @@ -128,7 +128,7 @@ namespace Aaru.Filesystems.LisaFS } // On debug mode allow sector tags to be accessed as an xattr - if(debug) + if(_debug) xattrs.Add("com.apple.lisa.tags"); xattrs.Sort(); @@ -145,13 +145,13 @@ namespace Aaru.Filesystems.LisaFS { buf = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; // System files if(fileId < 4) { - if(!debug || + if(!_debug || fileId == 0) return Errno.InvalidArgument; @@ -159,13 +159,13 @@ namespace Aaru.Filesystems.LisaFS if(fileId == FILEID_MDDF) if(xattr == "com.apple.lisa.password") { - buf = Encoding.ASCII.GetBytes(mddf.password); + buf = Encoding.ASCII.GetBytes(_mddf.password); return Errno.NoError; } // But on debug mode even system files contain tags - if(debug && xattr == "com.apple.lisa.tags") + if(_debug && xattr == "com.apple.lisa.tags") return ReadSystemFile(fileId, out buf, true); return Errno.NoSuchExtendedAttribute; @@ -199,7 +199,7 @@ namespace Aaru.Filesystems.LisaFS return Errno.NoError; } - if(debug && xattr == "com.apple.lisa.tags") + if(_debug && xattr == "com.apple.lisa.tags") return ReadFile(fileId, out buf, true); return Errno.NoSuchExtendedAttribute; diff --git a/Aaru.Filesystems/Locus.cs b/Aaru.Filesystems/Locus.cs index 5eb185b74..a67de43aa 100644 --- a/Aaru.Filesystems/Locus.cs +++ b/Aaru.Filesystems/Locus.cs @@ -92,9 +92,9 @@ namespace Aaru.Filesystems for(ulong location = 0; location <= 8; location++) { - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; if(partition.Start + location + sbSize >= imagePlugin.Info.Sectors) @@ -102,10 +102,10 @@ namespace Aaru.Filesystems byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return false; - Locus_Superblock locusSb = Marshal.ByteArrayToStructureLittleEndian(sector); + Superblock locusSb = Marshal.ByteArrayToStructureLittleEndian(sector); AaruConsole.DebugWriteLine("Locus plugin", "magic at {1} = 0x{0:X8}", locusSb.s_magic, location); @@ -128,22 +128,22 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize < 512) return; - var locusSb = new Locus_Superblock(); + var locusSb = new Superblock(); byte[] sector = null; for(ulong location = 0; location <= 8; location++) { - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return; - locusSb = Marshal.ByteArrayToStructureLittleEndian(sector); + locusSb = Marshal.ByteArrayToStructureLittleEndian(sector); if(locusSb.s_magic == LOCUS_MAGIC || locusSb.s_magic == LOCUS_CIGAM || @@ -163,15 +163,15 @@ namespace Aaru.Filesystems if(locusSb.s_magic == LOCUS_CIGAM || locusSb.s_magic == LOCUS_CIGAM_OLD) { - locusSb = Marshal.ByteArrayToStructureBigEndian(sector); - locusSb.s_flags = (LocusFlags)Swapping.Swap((ushort)locusSb.s_flags); + locusSb = Marshal.ByteArrayToStructureBigEndian(sector); + locusSb.s_flags = (Flags)Swapping.Swap((ushort)locusSb.s_flags); } var sb = new StringBuilder(); sb.AppendLine(locusSb.s_magic == LOCUS_MAGIC_OLD ? "Locus filesystem (old)" : "Locus filesystem"); - int blockSize = locusSb.s_version == LocusVersion.SB_SB4096 ? 4096 : 1024; + int blockSize = locusSb.s_version == Version.SB_SB4096 ? 4096 : 1024; string s_fsmnt = StringHandlers.CToString(locusSb.s_fsmnt, Encoding); string s_fpack = StringHandlers.CToString(locusSb.s_fpack, Encoding); @@ -212,40 +212,40 @@ namespace Aaru.Filesystems sb.AppendFormat("There are an estimate of {0} free inodes before next search start", locusSb.s_nbehind). AppendLine(); - if(locusSb.s_flags.HasFlag(LocusFlags.SB_RDONLY)) + if(locusSb.s_flags.HasFlag(Flags.SB_RDONLY)) sb.AppendLine("Read-only volume"); - if(locusSb.s_flags.HasFlag(LocusFlags.SB_CLEAN)) + if(locusSb.s_flags.HasFlag(Flags.SB_CLEAN)) sb.AppendLine("Clean volume"); - if(locusSb.s_flags.HasFlag(LocusFlags.SB_DIRTY)) + if(locusSb.s_flags.HasFlag(Flags.SB_DIRTY)) sb.AppendLine("Dirty volume"); - if(locusSb.s_flags.HasFlag(LocusFlags.SB_RMV)) + if(locusSb.s_flags.HasFlag(Flags.SB_RMV)) sb.AppendLine("Removable volume"); - if(locusSb.s_flags.HasFlag(LocusFlags.SB_PRIMPACK)) + if(locusSb.s_flags.HasFlag(Flags.SB_PRIMPACK)) sb.AppendLine("This is the primary pack"); - if(locusSb.s_flags.HasFlag(LocusFlags.SB_REPLTYPE)) + if(locusSb.s_flags.HasFlag(Flags.SB_REPLTYPE)) sb.AppendLine("Replicated volume"); - if(locusSb.s_flags.HasFlag(LocusFlags.SB_USER)) + if(locusSb.s_flags.HasFlag(Flags.SB_USER)) sb.AppendLine("User replicated volume"); - if(locusSb.s_flags.HasFlag(LocusFlags.SB_BACKBONE)) + if(locusSb.s_flags.HasFlag(Flags.SB_BACKBONE)) sb.AppendLine("Backbone volume"); - if(locusSb.s_flags.HasFlag(LocusFlags.SB_NFS)) + if(locusSb.s_flags.HasFlag(Flags.SB_NFS)) sb.AppendLine("NFS volume"); - if(locusSb.s_flags.HasFlag(LocusFlags.SB_BYHAND)) + if(locusSb.s_flags.HasFlag(Flags.SB_BYHAND)) sb.AppendLine("Volume inhibits automatic fsck"); - if(locusSb.s_flags.HasFlag(LocusFlags.SB_NOSUID)) + if(locusSb.s_flags.HasFlag(Flags.SB_NOSUID)) sb.AppendLine("Set-uid/set-gid is disabled"); - if(locusSb.s_flags.HasFlag(LocusFlags.SB_SYNCW)) + if(locusSb.s_flags.HasFlag(Flags.SB_SYNCW)) sb.AppendLine("Volume uses synchronous writes"); sb.AppendFormat("Volume label: {0}", s_fsmnt).AppendLine(); @@ -265,7 +265,7 @@ namespace Aaru.Filesystems VolumeName = string.IsNullOrEmpty(s_fsmnt) ? s_fpack : s_fsmnt, ModificationDate = DateHandlers.UnixToDateTime(locusSb.s_time), ModificationDateSpecified = true, - Dirty = !locusSb.s_flags.HasFlag(LocusFlags.SB_CLEAN) || locusSb.s_flags.HasFlag(LocusFlags.SB_DIRTY), + Dirty = !locusSb.s_flags.HasFlag(Flags.SB_CLEAN) || locusSb.s_flags.HasFlag(Flags.SB_DIRTY), FreeClusters = (ulong)locusSb.s_tfree, FreeClustersSpecified = true }; @@ -273,7 +273,7 @@ namespace Aaru.Filesystems [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Locus_Superblock + struct Superblock { public readonly uint s_magic; /* identifies this as a locus filesystem */ /* defined as a constant below */ @@ -295,14 +295,14 @@ namespace Aaru.Filesystems public readonly time_t s_time; /* last super block update */ public readonly daddr_t s_tfree; /* total free blocks*/ - public readonly ino_t s_isize; /* size in blocks of i-list */ - public readonly short s_nfree; /* number of addresses in s_free */ - public LocusFlags s_flags; /* filsys flags, defined below */ - public readonly ino_t s_tinode; /* total free inodes */ - public readonly ino_t s_lasti; /* start place for circular search */ - public readonly ino_t s_nbehind; /* est # free inodes before s_lasti */ - public readonly pckno_t s_gfspack; /* global filesystem pack number */ - public readonly short s_ninode; /* number of i-nodes in s_inode */ + public readonly ino_t s_isize; /* size in blocks of i-list */ + public readonly short s_nfree; /* number of addresses in s_free */ + public Flags s_flags; /* filsys flags, defined below */ + public readonly ino_t s_tinode; /* total free inodes */ + public readonly ino_t s_lasti; /* start place for circular search */ + public readonly ino_t s_nbehind; /* est # free inodes before s_lasti */ + public readonly pckno_t s_gfspack; /* global filesystem pack number */ + public readonly short s_ninode; /* number of i-nodes in s_inode */ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public readonly short[] s_dinfo; /* interleave stuff */ @@ -310,10 +310,10 @@ namespace Aaru.Filesystems //#define s_skip s_dinfo[0] /* AIX defines */ //#define s_n s_dinfo[1] //#define s_cyl s_dinfo[1] /* AIX defines */ - public readonly byte s_flock; /* lock during free list manipulation */ - public readonly byte s_ilock; /* lock during i-list manipulation */ - public readonly byte s_fmod; /* super block modified flag */ - public readonly LocusVersion s_version; /* version of the data format in fs. */ + public readonly byte s_flock; /* lock during free list manipulation */ + public readonly byte s_ilock; /* lock during i-list manipulation */ + public readonly byte s_fmod; /* super block modified flag */ + public readonly Version s_version; /* version of the data format in fs. */ /* defined below. */ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public readonly byte[] s_fsmnt; /* name of this file system */ @@ -328,7 +328,7 @@ namespace Aaru.Filesystems [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Locus_OldSuperblock + struct OldSuperblock { public readonly uint s_magic; /* identifies this as a locus filesystem */ /* defined as a constant below */ @@ -350,14 +350,14 @@ namespace Aaru.Filesystems public readonly time_t s_time; /* last super block update */ public readonly daddr_t s_tfree; /* total free blocks*/ - public readonly ino_t s_isize; /* size in blocks of i-list */ - public readonly short s_nfree; /* number of addresses in s_free */ - public readonly LocusFlags s_flags; /* filsys flags, defined below */ - public readonly ino_t s_tinode; /* total free inodes */ - public readonly ino_t s_lasti; /* start place for circular search */ - public readonly ino_t s_nbehind; /* est # free inodes before s_lasti */ - public readonly pckno_t s_gfspack; /* global filesystem pack number */ - public readonly short s_ninode; /* number of i-nodes in s_inode */ + public readonly ino_t s_isize; /* size in blocks of i-list */ + public readonly short s_nfree; /* number of addresses in s_free */ + public readonly Flags s_flags; /* filsys flags, defined below */ + public readonly ino_t s_tinode; /* total free inodes */ + public readonly ino_t s_lasti; /* start place for circular search */ + public readonly ino_t s_nbehind; /* est # free inodes before s_lasti */ + public readonly pckno_t s_gfspack; /* global filesystem pack number */ + public readonly short s_ninode; /* number of i-nodes in s_inode */ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public readonly short[] s_dinfo; /* interleave stuff */ @@ -365,10 +365,10 @@ namespace Aaru.Filesystems //#define s_skip s_dinfo[0] /* AIX defines */ //#define s_n s_dinfo[1] //#define s_cyl s_dinfo[1] /* AIX defines */ - public readonly byte s_flock; /* lock during free list manipulation */ - public readonly byte s_ilock; /* lock during i-list manipulation */ - public readonly byte s_fmod; /* super block modified flag */ - public readonly LocusVersion s_version; /* version of the data format in fs. */ + public readonly byte s_flock; /* lock during free list manipulation */ + public readonly byte s_ilock; /* lock during i-list manipulation */ + public readonly byte s_fmod; /* super block modified flag */ + public readonly Version s_version; /* version of the data format in fs. */ /* defined below. */ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public readonly byte[] s_fsmnt; /* name of this file system */ @@ -383,7 +383,7 @@ namespace Aaru.Filesystems [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), Flags] - enum LocusFlags : ushort + enum Flags : ushort { SB_RDONLY = 0x1, /* no writes on filesystem */ SB_CLEAN = 0x2, /* fs unmounted cleanly (or checks run) */ SB_DIRTY = 0x4, /* fs mounted without CLEAN bit set */ SB_RMV = 0x8, /* fs is a removable file system */ @@ -398,7 +398,7 @@ namespace Aaru.Filesystems [SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"), Flags] - enum LocusVersion : byte + enum Version : byte { SB_SB4096 = 1, /* smallblock filesys with 4096 byte blocks */ SB_B1024 = 2, /* 1024 byte block filesystem */ NUMSCANDEV = 5 /* Used by scangfs(), refed in space.h */ diff --git a/Aaru.Filesystems/MicroDOS.cs b/Aaru.Filesystems/MicroDOS.cs index 0734a7636..c198ef36a 100644 --- a/Aaru.Filesystems/MicroDOS.cs +++ b/Aaru.Filesystems/MicroDOS.cs @@ -66,7 +66,7 @@ namespace Aaru.Filesystems byte[] bk0 = imagePlugin.ReadSector(0 + partition.Start); - MicroDosBlock0 block0 = Marshal.ByteArrayToStructureLittleEndian(bk0); + Block0 block0 = Marshal.ByteArrayToStructureLittleEndian(bk0); return block0.label == MAGIC && block0.mklabel == MAGIC2; } @@ -81,7 +81,7 @@ namespace Aaru.Filesystems byte[] bk0 = imagePlugin.ReadSector(0 + partition.Start); - MicroDosBlock0 block0 = Marshal.ByteArrayToStructureLittleEndian(bk0); + Block0 block0 = Marshal.ByteArrayToStructureLittleEndian(bk0); sb.AppendLine("MicroDOS filesystem"); sb.AppendFormat("Volume has {0} blocks ({1} bytes)", block0.blocks, block0.blocks * 512).AppendLine(); @@ -108,7 +108,7 @@ namespace Aaru.Filesystems // Followed by directory entries [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct MicroDosBlock0 + struct Block0 { /// BK starts booting here [MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] diff --git a/Aaru.Filesystems/MinixFS.cs b/Aaru.Filesystems/MinixFS.cs index 3e6b2b34c..6df526de7 100644 --- a/Aaru.Filesystems/MinixFS.cs +++ b/Aaru.Filesystems/MinixFS.cs @@ -252,12 +252,12 @@ namespace Aaru.Filesystems if(minix3) { - Minix3SuperBlock mnxSb; + SuperBlock3 mnxSb; if(littleEndian) - mnxSb = Marshal.ByteArrayToStructureLittleEndian(minixSbSector); + mnxSb = Marshal.ByteArrayToStructureLittleEndian(minixSbSector); else - mnxSb = Marshal.ByteArrayToStructureBigEndian(minixSbSector); + mnxSb = Marshal.ByteArrayToStructureBigEndian(minixSbSector); if(magic != MINIX3_MAGIC && magic != MINIX3_CIGAM) @@ -293,12 +293,12 @@ namespace Aaru.Filesystems } else { - MinixSuperBlock mnxSb; + SuperBlock mnxSb; if(littleEndian) - mnxSb = Marshal.ByteArrayToStructureLittleEndian(minixSbSector); + mnxSb = Marshal.ByteArrayToStructureLittleEndian(minixSbSector); else - mnxSb = Marshal.ByteArrayToStructureBigEndian(minixSbSector); + mnxSb = Marshal.ByteArrayToStructureBigEndian(minixSbSector); sb.AppendLine(minixVersion); sb.AppendFormat("{0} chars in filename", filenamesize).AppendLine(); @@ -332,7 +332,7 @@ namespace Aaru.Filesystems /// Superblock for Minix v1 and V2 filesystems [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct MinixSuperBlock + struct SuperBlock { /// 0x00, inodes on volume public readonly ushort s_ninodes; @@ -358,7 +358,7 @@ namespace Aaru.Filesystems /// Superblock for Minix v3 filesystems [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Minix3SuperBlock + struct SuperBlock3 { /// 0x00, inodes on volume public readonly uint s_ninodes; diff --git a/Aaru.Filesystems/NILFS2.cs b/Aaru.Filesystems/NILFS2.cs index 13499a064..62efea008 100644 --- a/Aaru.Filesystems/NILFS2.cs +++ b/Aaru.Filesystems/NILFS2.cs @@ -64,9 +64,9 @@ namespace Aaru.Filesystems if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; if(partition.Start + sbAddr + sbSize >= partition.End) @@ -74,10 +74,10 @@ namespace Aaru.Filesystems byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return false; - NILFS2_Superblock nilfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); + Superblock nilfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); return nilfsSb.magic == NILFS2_MAGIC; } @@ -96,17 +96,17 @@ namespace Aaru.Filesystems if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return; - NILFS2_Superblock nilfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); + Superblock nilfsSb = Marshal.ByteArrayToStructureLittleEndian(sector); if(nilfsSb.magic != NILFS2_MAGIC) return; @@ -156,49 +156,49 @@ namespace Aaru.Filesystems XmlFsType.Clusters = nilfsSb.dev_size / XmlFsType.ClusterSize; } - enum NILFS2_State : ushort + enum State : ushort { Valid = 0x0001, Error = 0x0002, Resize = 0x0004 } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct NILFS2_Superblock + struct Superblock { - public readonly uint rev_level; - public readonly ushort minor_rev_level; - public readonly ushort magic; - public readonly ushort bytes; - public readonly ushort flags; - public readonly uint crc_seed; - public readonly uint sum; - public readonly uint log_block_size; - public readonly ulong nsegments; - public readonly ulong dev_size; - public readonly ulong first_data_block; - public readonly uint blocks_per_segment; - public readonly uint r_segments_percentage; - public readonly ulong last_cno; - public readonly ulong last_pseg; - public readonly ulong last_seq; - public readonly ulong free_blocks_count; - public readonly ulong ctime; - public readonly ulong mtime; - public readonly ulong wtime; - public readonly ushort mnt_count; - public readonly ushort max_mnt_count; - public readonly NILFS2_State state; - public readonly ushort errors; - public readonly ulong lastcheck; - public readonly uint checkinterval; - public readonly uint creator_os; - public readonly ushort def_resuid; - public readonly ushort def_resgid; - public readonly uint first_ino; - public readonly ushort inode_size; - public readonly ushort dat_entry_size; - public readonly ushort checkpoint_size; - public readonly ushort segment_usage_size; - public readonly Guid uuid; + public readonly uint rev_level; + public readonly ushort minor_rev_level; + public readonly ushort magic; + public readonly ushort bytes; + public readonly ushort flags; + public readonly uint crc_seed; + public readonly uint sum; + public readonly uint log_block_size; + public readonly ulong nsegments; + public readonly ulong dev_size; + public readonly ulong first_data_block; + public readonly uint blocks_per_segment; + public readonly uint r_segments_percentage; + public readonly ulong last_cno; + public readonly ulong last_pseg; + public readonly ulong last_seq; + public readonly ulong free_blocks_count; + public readonly ulong ctime; + public readonly ulong mtime; + public readonly ulong wtime; + public readonly ushort mnt_count; + public readonly ushort max_mnt_count; + public readonly State state; + public readonly ushort errors; + public readonly ulong lastcheck; + public readonly uint checkinterval; + public readonly uint creator_os; + public readonly ushort def_resuid; + public readonly ushort def_resgid; + public readonly uint first_ino; + public readonly ushort inode_size; + public readonly ushort dat_entry_size; + public readonly ushort checkpoint_size; + public readonly ushort segment_usage_size; + public readonly Guid uuid; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)] public readonly byte[] volume_name; public readonly uint c_interval; diff --git a/Aaru.Filesystems/NTFS.cs b/Aaru.Filesystems/NTFS.cs index 8bf73a6bf..85e03f6b9 100644 --- a/Aaru.Filesystems/NTFS.cs +++ b/Aaru.Filesystems/NTFS.cs @@ -89,7 +89,7 @@ namespace Aaru.Filesystems byte[] ntfsBpb = imagePlugin.ReadSector(0 + partition.Start); - NtfsBootBlock ntfsBb = Marshal.ByteArrayToStructureLittleEndian(ntfsBpb); + BiosParameterBlock ntfsBb = Marshal.ByteArrayToStructureLittleEndian(ntfsBpb); sb.AppendFormat("{0} bytes per sector", ntfsBb.bps).AppendLine(); sb.AppendFormat("{0} sectors per cluster ({1} bytes)", ntfsBb.spc, ntfsBb.spc * ntfsBb.bps).AppendLine(); @@ -155,7 +155,7 @@ namespace Aaru.Filesystems /// NTFS $BOOT [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct NtfsBootBlock + struct BiosParameterBlock { // Start of BIOS Parameter Block /// 0x000, Jump to boot code diff --git a/Aaru.Filesystems/ODS.cs b/Aaru.Filesystems/ODS.cs index 73e2467f3..bb89d049c 100644 --- a/Aaru.Filesystems/ODS.cs +++ b/Aaru.Filesystems/ODS.cs @@ -107,7 +107,7 @@ namespace Aaru.Filesystems byte[] hbSector = imagePlugin.ReadSector(1 + partition.Start); - OdsHomeBlock homeblock = Marshal.ByteArrayToStructureLittleEndian(hbSector); + HomeBlock homeblock = Marshal.ByteArrayToStructureLittleEndian(hbSector); // Optical disc if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc && @@ -121,7 +121,7 @@ namespace Aaru.Filesystems hbSector = new byte[0x200]; Array.Copy(tmp, 0x200, hbSector, 0, 0x200); - homeblock = Marshal.ByteArrayToStructureLittleEndian(hbSector); + homeblock = Marshal.ByteArrayToStructureLittleEndian(hbSector); if(StringHandlers.CToString(homeblock.format) != "DECFILE11A " && StringHandlers.CToString(homeblock.format) != "DECFILE11B ") @@ -273,7 +273,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct OdsHomeBlock + struct HomeBlock { /// 0x000, LBN of THIS home block public readonly uint homelbn; diff --git a/Aaru.Filesystems/Opera/Consts.cs b/Aaru.Filesystems/Opera/Consts.cs index f06fe07cb..9166e66ad 100644 --- a/Aaru.Filesystems/Opera/Consts.cs +++ b/Aaru.Filesystems/Opera/Consts.cs @@ -48,7 +48,7 @@ namespace Aaru.Filesystems const uint TYPE_LBL = 0x2A6C626C; /// Catapult const uint TYPE_ZAP = 0x2A7A6170; - static readonly int DirectoryEntrySize = Marshal.SizeOf(); + static readonly int _directoryEntrySize = Marshal.SizeOf(); enum FileFlags : uint { diff --git a/Aaru.Filesystems/Opera/Dir.cs b/Aaru.Filesystems/Opera/Dir.cs index abff5124c..ef5c12d36 100644 --- a/Aaru.Filesystems/Opera/Dir.cs +++ b/Aaru.Filesystems/Opera/Dir.cs @@ -45,13 +45,13 @@ namespace Aaru.Filesystems { contents = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; if(string.IsNullOrWhiteSpace(path) || path == "/") { - contents = rootDirectoryCache.Keys.ToList(); + contents = _rootDirectoryCache.Keys.ToList(); return Errno.NoError; } @@ -60,7 +60,8 @@ namespace Aaru.Filesystems ? path.Substring(1).ToLower(CultureInfo.CurrentUICulture) : path.ToLower(CultureInfo.CurrentUICulture); - if(directoryCache.TryGetValue(cutPath, out Dictionary currentDirectory)) + if(_directoryCache.TryGetValue(cutPath, out Dictionary currentDirectory) + ) { contents = currentDirectory.Keys.ToList(); @@ -73,7 +74,7 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); KeyValuePair entry = - rootDirectoryCache.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[0]); + _rootDirectoryCache.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[0]); if(string.IsNullOrEmpty(entry.Key)) return Errno.NoSuchFile; @@ -83,7 +84,7 @@ namespace Aaru.Filesystems string currentPath = pieces[0]; - currentDirectory = rootDirectoryCache; + currentDirectory = _rootDirectoryCache; for(int p = 0; p < pieces.Length; p++) { @@ -97,7 +98,7 @@ namespace Aaru.Filesystems currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}"; - if(directoryCache.TryGetValue(currentPath, out currentDirectory)) + if(_directoryCache.TryGetValue(currentPath, out currentDirectory)) continue; if(entry.Value.pointers.Length < 1) @@ -105,7 +106,7 @@ namespace Aaru.Filesystems currentDirectory = DecodeDirectory((int)entry.Value.pointers[0]); - directoryCache.Add(currentPath, currentDirectory); + _directoryCache.Add(currentPath, currentDirectory); } contents = currentDirectory?.Keys.ToList(); @@ -124,7 +125,7 @@ namespace Aaru.Filesystems do { - byte[] data = image.ReadSectors((ulong)(nextBlock * volumeBlockSizeRatio), volumeBlockSizeRatio); + byte[] data = _image.ReadSectors((ulong)(nextBlock * _volumeBlockSizeRatio), _volumeBlockSizeRatio); header = Marshal.ByteArrayToStructureBigEndian(data); nextBlock = header.next_block + firstBlock; @@ -132,9 +133,9 @@ namespace Aaru.Filesystems var entry = new DirectoryEntry(); - while(off + DirectoryEntrySize < data.Length) + while(off + _directoryEntrySize < data.Length) { - entry = Marshal.ByteArrayToStructureBigEndian(data, off, DirectoryEntrySize); + entry = Marshal.ByteArrayToStructureBigEndian(data, off, _directoryEntrySize); string name = StringHandlers.CToString(entry.name, Encoding); var entryWithPointers = new DirectoryEntryWithPointers @@ -145,7 +146,7 @@ namespace Aaru.Filesystems for(int i = 0; i <= entry.last_copy; i++) entryWithPointers.pointers[i] = - BigEndianBitConverter.ToUInt32(data, off + DirectoryEntrySize + (i * 4)); + BigEndianBitConverter.ToUInt32(data, off + _directoryEntrySize + (i * 4)); entries.Add(name, entryWithPointers); @@ -153,7 +154,7 @@ namespace Aaru.Filesystems (entry.flags & (uint)FileFlags.LastEntryInBlock) != 0) break; - off += (int)(DirectoryEntrySize + ((entry.last_copy + 1) * 4)); + off += (int)(_directoryEntrySize + ((entry.last_copy + 1) * 4)); } if((entry.flags & (uint)FileFlags.LastEntry) != 0) diff --git a/Aaru.Filesystems/Opera/File.cs b/Aaru.Filesystems/Opera/File.cs index bc9593698..52751a6a7 100644 --- a/Aaru.Filesystems/Opera/File.cs +++ b/Aaru.Filesystems/Opera/File.cs @@ -44,7 +44,7 @@ namespace Aaru.Filesystems { deviceBlock = 0; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = GetFileEntry(path, out DirectoryEntryWithPointers entry); @@ -53,7 +53,7 @@ namespace Aaru.Filesystems return err; if((entry.entry.flags & FLAGS_MASK) == (uint)FileFlags.Directory && - !debug) + !_debug) return Errno.IsDirectory; deviceBlock = entry.pointers[0] + fileBlock; @@ -65,7 +65,7 @@ namespace Aaru.Filesystems { attributes = new FileAttributes(); - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = Stat(path, out FileEntryInfo stat); @@ -82,7 +82,7 @@ namespace Aaru.Filesystems { buf = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = GetFileEntry(path, out DirectoryEntryWithPointers entry); @@ -91,7 +91,7 @@ namespace Aaru.Filesystems return err; if((entry.entry.flags & FLAGS_MASK) == (uint)FileFlags.Directory && - !debug) + !_debug) return Errno.IsDirectory; if(entry.pointers.Length < 1) @@ -119,15 +119,15 @@ namespace Aaru.Filesystems uint fileBlockSizeRatio; - if(image.Info.SectorSize == 2336 || - image.Info.SectorSize == 2352 || - image.Info.SectorSize == 2448) + if(_image.Info.SectorSize == 2336 || + _image.Info.SectorSize == 2352 || + _image.Info.SectorSize == 2448) fileBlockSizeRatio = entry.entry.block_size / 2048; else - fileBlockSizeRatio = entry.entry.block_size / image.Info.SectorSize; + fileBlockSizeRatio = entry.entry.block_size / _image.Info.SectorSize; - byte[] buffer = image.ReadSectors((ulong)(entry.pointers[0] + (firstBlock * fileBlockSizeRatio)), - (uint)(sizeInBlocks * fileBlockSizeRatio)); + byte[] buffer = _image.ReadSectors((ulong)(entry.pointers[0] + (firstBlock * fileBlockSizeRatio)), + (uint)(sizeInBlocks * fileBlockSizeRatio)); buf = new byte[size]; Array.Copy(buffer, offsetInBlock, buf, 0, size); @@ -139,7 +139,7 @@ namespace Aaru.Filesystems { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; Errno err = GetFileEntry(path, out DirectoryEntryWithPointers entryWithPointers); @@ -188,7 +188,7 @@ namespace Aaru.Filesystems string parentPath = string.Join("/", pieces, 0, pieces.Length - 1); - if(!directoryCache.TryGetValue(parentPath, out _)) + if(!_directoryCache.TryGetValue(parentPath, out _)) { Errno err = ReadDir(parentPath, out _); @@ -199,8 +199,8 @@ namespace Aaru.Filesystems Dictionary parent; if(pieces.Length == 1) - parent = rootDirectoryCache; - else if(!directoryCache.TryGetValue(parentPath, out parent)) + parent = _rootDirectoryCache; + else if(!_directoryCache.TryGetValue(parentPath, out parent)) return Errno.InvalidArgument; KeyValuePair dirent = diff --git a/Aaru.Filesystems/Opera/Opera.cs b/Aaru.Filesystems/Opera/Opera.cs index e6bc8f0d6..0710f1998 100644 --- a/Aaru.Filesystems/Opera/Opera.cs +++ b/Aaru.Filesystems/Opera/Opera.cs @@ -41,13 +41,13 @@ namespace Aaru.Filesystems { public partial class OperaFS : IReadOnlyFilesystem { - bool debug; - Dictionary> directoryCache; - IMediaImage image; - bool mounted; - Dictionary rootDirectoryCache; - FileSystemInfo statfs; - uint volumeBlockSizeRatio; + bool _debug; + Dictionary> _directoryCache; + IMediaImage _image; + bool _mounted; + Dictionary _rootDirectoryCache; + FileSystemInfo _statfs; + uint _volumeBlockSizeRatio; public FileSystemType XmlFsType { get; private set; } public Encoding Encoding { get; private set; } diff --git a/Aaru.Filesystems/Opera/Super.cs b/Aaru.Filesystems/Opera/Super.cs index 4e7e76b1c..e41755943 100644 --- a/Aaru.Filesystems/Opera/Super.cs +++ b/Aaru.Filesystems/Opera/Super.cs @@ -52,7 +52,7 @@ namespace Aaru.Filesystems options = GetDefaultOptions(); if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out debug); + bool.TryParse(debugString, out _debug); byte[] sbSector = imagePlugin.ReadSector(0 + partition.Start); @@ -68,9 +68,9 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize == 2336 || imagePlugin.Info.SectorSize == 2352 || imagePlugin.Info.SectorSize == 2448) - volumeBlockSizeRatio = sb.block_size / 2048; + _volumeBlockSizeRatio = sb.block_size / 2048; else - volumeBlockSizeRatio = sb.block_size / imagePlugin.Info.SectorSize; + _volumeBlockSizeRatio = sb.block_size / imagePlugin.Info.SectorSize; XmlFsType = new FileSystemType { @@ -82,7 +82,7 @@ namespace Aaru.Filesystems VolumeSerial = $"{sb.volume_id:X8}" }; - statfs = new FileSystemInfo + _statfs = new FileSystemInfo { Blocks = sb.block_count, FilenameLength = MAX_NAME, @@ -96,21 +96,21 @@ namespace Aaru.Filesystems Type = "Opera" }; - image = imagePlugin; + _image = imagePlugin; int firstRootBlock = BigEndianBitConverter.ToInt32(sbSector, Marshal.SizeOf()); - rootDirectoryCache = DecodeDirectory(firstRootBlock); - directoryCache = new Dictionary>(); - mounted = true; + _rootDirectoryCache = DecodeDirectory(firstRootBlock); + _directoryCache = new Dictionary>(); + _mounted = true; return Errno.NoError; } public Errno Unmount() { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; - mounted = false; + _mounted = false; return Errno.NoError; } @@ -119,10 +119,10 @@ namespace Aaru.Filesystems { stat = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; - stat = statfs.ShallowCopy(); + stat = _statfs.ShallowCopy(); return Errno.NoError; } diff --git a/Aaru.Filesystems/PCFX.cs b/Aaru.Filesystems/PCFX.cs index 453000fcb..688465e52 100644 --- a/Aaru.Filesystems/PCFX.cs +++ b/Aaru.Filesystems/PCFX.cs @@ -72,8 +72,8 @@ namespace Aaru.Filesystems Encoding = Encoding.GetEncoding("shift_jis"); information = ""; - byte[] sector = imagePlugin.ReadSectors(partition.Start, 2); - PcfxHeader header = Marshal.ByteArrayToStructureLittleEndian(sector); + byte[] sector = imagePlugin.ReadSectors(partition.Start, 2); + Header header = Marshal.ByteArrayToStructureLittleEndian
(sector); string date; DateTime dateTime = DateTime.MinValue; @@ -127,7 +127,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct PcfxHeader + struct Header { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public readonly byte[] signature; diff --git a/Aaru.Filesystems/ProDOS.cs b/Aaru.Filesystems/ProDOS.cs index abd13317d..003b64c87 100644 --- a/Aaru.Filesystems/ProDOS.cs +++ b/Aaru.Filesystems/ProDOS.cs @@ -191,9 +191,9 @@ namespace Aaru.Filesystems } } - var rootDirectoryKeyBlock = new ProDOSRootDirectoryKeyBlock + var rootDirectoryKeyBlock = new RootDirectoryKeyBlock { - header = new ProDOSRootDirectoryHeader(), + header = new RootDirectoryHeader(), zero = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x00), next_pointer = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x02) }; @@ -337,7 +337,7 @@ namespace Aaru.Filesystems } /// ProDOS directory entry, decoded structure - struct ProDOSEntry + struct Entry { /// Type of file pointed by this entry Offset 0x00, mask 0xF0 public byte storage_type; @@ -372,7 +372,7 @@ namespace Aaru.Filesystems public ushort header_pointer; } - struct ProDOSRootDirectoryHeader + struct RootDirectoryHeader { /// Constant 0x0F Offset 0x04, mask 0xF0 public byte storage_type; @@ -405,7 +405,7 @@ namespace Aaru.Filesystems public ushort total_blocks; } - struct ProDOSDirectoryHeader + struct DirectoryHeader { /// Constant 0x0E Offset 0x04, mask 0xF0 public byte storage_type; @@ -437,47 +437,47 @@ namespace Aaru.Filesystems public byte parent_entry_length; } - struct ProDOSDirectoryKeyBlock + struct DirectoryKeyBlock { /// Always 0 Offset 0x00, 2 bytes public ushort zero; /// Pointer to next directory block, 0 if last Offset 0x02, 2 bytes public ushort next_pointer; /// Directory header Offset 0x04, 39 bytes - public ProDOSDirectoryHeader header; + public DirectoryHeader header; /// Directory entries Offset 0x2F, 39 bytes each, 12 entries - public ProDOSEntry[] entries; + public Entry[] entries; } - struct ProDOSRootDirectoryKeyBlock + struct RootDirectoryKeyBlock { /// Always 0 Offset 0x00, 2 bytes public ushort zero; /// Pointer to next directory block, 0 if last Offset 0x02, 2 bytes public ushort next_pointer; /// Directory header Offset 0x04, 39 bytes - public ProDOSRootDirectoryHeader header; + public RootDirectoryHeader header; /// Directory entries Offset 0x2F, 39 bytes each, 12 entries - public ProDOSEntry[] entries; + public Entry[] entries; } - struct ProDOSDirectoryBlock + struct DirectoryBlock { /// Pointer to previous directory block Offset 0x00, 2 bytes public ushort zero; /// Pointer to next directory block, 0 if last Offset 0x02, 2 bytes public ushort next_pointer; /// Directory entries Offset 0x2F, 39 bytes each, 13 entries - public ProDOSEntry[] entries; + public Entry[] entries; } - struct ProDOSIndexBlock + struct IndexBlock { /// Up to 256 pointers to blocks, 0 to indicate the block is sparsed (non-allocated) public ushort[] block_pointer; } - struct ProDOSMasterIndexBlock + struct MasterIndexBlock { /// Up to 128 pointers to index blocks public ushort[] index_block_pointer; diff --git a/Aaru.Filesystems/QNX4.cs b/Aaru.Filesystems/QNX4.cs index b95e78265..d0eafae69 100644 --- a/Aaru.Filesystems/QNX4.cs +++ b/Aaru.Filesystems/QNX4.cs @@ -46,7 +46,7 @@ namespace Aaru.Filesystems [SuppressMessage("ReSharper", "UnusedType.Local")] public class QNX4 : IFilesystem { - readonly byte[] qnx4_rootDir_fname = + readonly byte[] _rootDirFname = { 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -67,10 +67,10 @@ namespace Aaru.Filesystems if(sector.Length < 512) return false; - QNX4_Superblock qnxSb = Marshal.ByteArrayToStructureLittleEndian(sector); + Superblock qnxSb = Marshal.ByteArrayToStructureLittleEndian(sector); // Check root directory name - if(!qnx4_rootDir_fname.SequenceEqual(qnxSb.rootDir.di_fname)) + if(!_rootDirFname.SequenceEqual(qnxSb.rootDir.di_fname)) return false; // Check sizes are multiple of blocks @@ -107,7 +107,7 @@ namespace Aaru.Filesystems if(sector.Length < 512) return; - QNX4_Superblock qnxSb = Marshal.ByteArrayToStructureLittleEndian(sector); + Superblock qnxSb = Marshal.ByteArrayToStructureLittleEndian(sector); // Too much useless information /* @@ -201,36 +201,36 @@ namespace Aaru.Filesystems XmlFsType.Bootable |= qnxSb.boot.di_size != 0 || qnxSb.altBoot.di_size != 0; } - struct QNX4_Extent + struct Extent { public uint block; public uint length; } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct QNX4_Inode + struct Inode { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public readonly byte[] di_fname; - public readonly uint di_size; - public readonly QNX4_Extent di_first_xtnt; - public readonly uint di_xblk; - public readonly uint di_ftime; - public readonly uint di_mtime; - public readonly uint di_atime; - public readonly uint di_ctime; - public readonly ushort di_num_xtnts; - public readonly ushort di_mode; - public readonly ushort di_uid; - public readonly ushort di_gid; - public readonly ushort di_nlink; - public readonly uint di_zero; - public readonly byte di_type; - public readonly byte di_status; + public readonly uint di_size; + public readonly Extent di_first_xtnt; + public readonly uint di_xblk; + public readonly uint di_ftime; + public readonly uint di_mtime; + public readonly uint di_atime; + public readonly uint di_ctime; + public readonly ushort di_num_xtnts; + public readonly ushort di_mode; + public readonly ushort di_uid; + public readonly ushort di_gid; + public readonly ushort di_nlink; + public readonly uint di_zero; + public readonly byte di_type; + public readonly byte di_status; } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct QNX4_LinkInfo + struct LinkInfo { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 48)] public readonly byte[] dl_fname; @@ -242,7 +242,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct QNX4_ExtentBlock + struct ExtentBlock { public readonly uint next_xblk; public readonly uint prev_xblk; @@ -251,19 +251,19 @@ namespace Aaru.Filesystems public readonly byte[] spare; public readonly uint num_blocks; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 60)] - public readonly QNX4_Extent[] xtnts; + public readonly Extent[] xtnts; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public readonly byte[] signature; - public readonly QNX4_Extent first_xtnt; + public readonly Extent first_xtnt; } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct QNX4_Superblock + struct Superblock { - public readonly QNX4_Inode rootDir; - public readonly QNX4_Inode inode; - public readonly QNX4_Inode boot; - public readonly QNX4_Inode altBoot; + public readonly Inode rootDir; + public readonly Inode inode; + public readonly Inode boot; + public readonly Inode altBoot; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/QNX6.cs b/Aaru.Filesystems/QNX6.cs index 360c9957e..00cbf5714 100644 --- a/Aaru.Filesystems/QNX6.cs +++ b/Aaru.Filesystems/QNX6.cs @@ -67,9 +67,9 @@ namespace Aaru.Filesystems if(sector.Length < QNX6_SUPER_BLOCK_SIZE) return false; - QNX6_AudiSuperBlock audiSb = Marshal.ByteArrayToStructureLittleEndian(audiSector); + AudiSuperBlock audiSb = Marshal.ByteArrayToStructureLittleEndian(audiSector); - QNX6_SuperBlock qnxSb = Marshal.ByteArrayToStructureLittleEndian(sector); + SuperBlock qnxSb = Marshal.ByteArrayToStructureLittleEndian(sector); return qnxSb.magic == QNX6_MAGIC || audiSb.magic == QNX6_MAGIC; } @@ -89,9 +89,9 @@ namespace Aaru.Filesystems if(sector.Length < QNX6_SUPER_BLOCK_SIZE) return; - QNX6_AudiSuperBlock audiSb = Marshal.ByteArrayToStructureLittleEndian(audiSector); + AudiSuperBlock audiSb = Marshal.ByteArrayToStructureLittleEndian(audiSector); - QNX6_SuperBlock qnxSb = Marshal.ByteArrayToStructureLittleEndian(sector); + SuperBlock qnxSb = Marshal.ByteArrayToStructureLittleEndian(sector); bool audi = audiSb.magic == QNX6_MAGIC; @@ -167,7 +167,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct QNX6_RootNode + struct RootNode { public readonly ulong size; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] @@ -179,7 +179,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct QNX6_SuperBlock + struct SuperBlock { public readonly uint magic; public readonly uint checksum; @@ -191,20 +191,20 @@ namespace Aaru.Filesystems public readonly ushort version2; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public readonly byte[] volumeid; - public readonly uint blockSize; - public readonly uint numInodes; - public readonly uint freeInodes; - public readonly uint numBlocks; - public readonly uint freeBlocks; - public readonly uint allocationGroup; - public readonly QNX6_RootNode inode; - public readonly QNX6_RootNode bitmap; - public readonly QNX6_RootNode longfile; - public readonly QNX6_RootNode unknown; + public readonly uint blockSize; + public readonly uint numInodes; + public readonly uint freeInodes; + public readonly uint numBlocks; + public readonly uint freeBlocks; + public readonly uint allocationGroup; + public readonly RootNode inode; + public readonly RootNode bitmap; + public readonly RootNode longfile; + public readonly RootNode unknown; } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct QNX6_AudiSuperBlock + struct AudiSuperBlock { public readonly uint magic; public readonly uint checksum; @@ -213,16 +213,16 @@ namespace Aaru.Filesystems public readonly byte[] spare1; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] public readonly byte[] id; - public readonly uint blockSize; - public readonly uint numInodes; - public readonly uint freeInodes; - public readonly uint numBlocks; - public readonly uint freeBlocks; - public readonly uint spare2; - public readonly QNX6_RootNode inode; - public readonly QNX6_RootNode bitmap; - public readonly QNX6_RootNode longfile; - public readonly QNX6_RootNode unknown; + public readonly uint blockSize; + public readonly uint numInodes; + public readonly uint freeInodes; + public readonly uint numBlocks; + public readonly uint freeBlocks; + public readonly uint spare2; + public readonly RootNode inode; + public readonly RootNode bitmap; + public readonly RootNode longfile; + public readonly RootNode unknown; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/RBF.cs b/Aaru.Filesystems/RBF.cs index 74873077b..c4aaa0b2f 100644 --- a/Aaru.Filesystems/RBF.cs +++ b/Aaru.Filesystems/RBF.cs @@ -69,9 +69,9 @@ namespace Aaru.Filesystems { ulong location = (ulong)i; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; if(partition.Start + location + sbSize >= imagePlugin.Info.Sectors) @@ -79,11 +79,11 @@ namespace Aaru.Filesystems byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return false; - RBF_IdSector rbfSb = Marshal.ByteArrayToStructureBigEndian(sector); - RBF_NewIdSector rbf9000Sb = Marshal.ByteArrayToStructureBigEndian(sector); + IdSector rbfSb = Marshal.ByteArrayToStructureBigEndian(sector); + NewIdSector rbf9000Sb = Marshal.ByteArrayToStructureBigEndian(sector); AaruConsole.DebugWriteLine("RBF plugin", "magic at {0} = 0x{1:X8} or 0x{2:X8} (expected 0x{3:X8} or 0x{4:X8})", @@ -107,8 +107,8 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize < 256) return; - var rbfSb = new RBF_IdSector(); - var rbf9000Sb = new RBF_NewIdSector(); + var rbfSb = new IdSector(); + var rbf9000Sb = new NewIdSector(); foreach(int i in new[] { @@ -116,18 +116,18 @@ namespace Aaru.Filesystems }) { ulong location = (ulong)i; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return; - rbfSb = Marshal.ByteArrayToStructureBigEndian(sector); - rbf9000Sb = Marshal.ByteArrayToStructureBigEndian(sector); + rbfSb = Marshal.ByteArrayToStructureBigEndian(sector); + rbf9000Sb = Marshal.ByteArrayToStructureBigEndian(sector); AaruConsole.DebugWriteLine("RBF plugin", "magic at {0} = 0x{1:X8} or 0x{2:X8} (expected 0x{3:X8} or 0x{4:X8})", @@ -145,7 +145,7 @@ namespace Aaru.Filesystems return; if(rbf9000Sb.rid_sync == RBF_CNYS) - rbf9000Sb = (RBF_NewIdSector)Marshal.SwapStructureMembersEndian(rbf9000Sb); + rbf9000Sb = (NewIdSector)Marshal.SwapStructureMembersEndian(rbf9000Sb); var sb = new StringBuilder(); @@ -285,7 +285,7 @@ namespace Aaru.Filesystems /// Identification sector. Wherever the sector this resides on, becomes LSN 0. [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct RBF_IdSector + struct IdSector { /// Sectors on disk [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] @@ -342,7 +342,7 @@ namespace Aaru.Filesystems /// big or little endian. /// [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct RBF_NewIdSector + struct NewIdSector { /// Magic number public readonly uint rid_sync; diff --git a/Aaru.Filesystems/RT11.cs b/Aaru.Filesystems/RT11.cs index 74dc33786..c1169a608 100644 --- a/Aaru.Filesystems/RT11.cs +++ b/Aaru.Filesystems/RT11.cs @@ -80,7 +80,7 @@ namespace Aaru.Filesystems byte[] hbSector = imagePlugin.ReadSector(1 + partition.Start); - RT11HomeBlock homeblock = Marshal.ByteArrayToStructureLittleEndian(hbSector); + HomeBlock homeblock = Marshal.ByteArrayToStructureLittleEndian(hbSector); /* TODO: Is this correct? * Assembler: @@ -122,7 +122,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct RT11HomeBlock + struct HomeBlock { /// Bad block replacement table [MarshalAs(UnmanagedType.ByValArray, SizeConst = 130)] diff --git a/Aaru.Filesystems/ReFS.cs b/Aaru.Filesystems/ReFS.cs index 10dc0d8c3..ff9eca3b2 100644 --- a/Aaru.Filesystems/ReFS.cs +++ b/Aaru.Filesystems/ReFS.cs @@ -46,7 +46,7 @@ namespace Aaru.Filesystems public class ReFS : IFilesystem { const uint FSRS = 0x53525346; - readonly byte[] refsSignature = + readonly byte[] _signature = { 0x52, 0x65, 0x46, 0x53, 0x00, 0x00, 0x00, 0x00 }; @@ -58,9 +58,9 @@ namespace Aaru.Filesystems public bool Identify(IMediaImage imagePlugin, Partition partition) { - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; if(partition.Start + sbSize >= partition.End) @@ -68,13 +68,13 @@ namespace Aaru.Filesystems byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return false; - RefsVolumeHeader refsVhdr = Marshal.ByteArrayToStructureLittleEndian(sector); + VolumeHeader vhdr = Marshal.ByteArrayToStructureLittleEndian(sector); - return refsVhdr.identifier == FSRS && ArrayHelpers.ArrayIsNullOrEmpty(refsVhdr.mustBeZero) && - refsVhdr.signature.SequenceEqual(refsSignature); + return vhdr.identifier == FSRS && ArrayHelpers.ArrayIsNullOrEmpty(vhdr.mustBeZero) && + vhdr.signature.SequenceEqual(_signature); } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, @@ -83,9 +83,9 @@ namespace Aaru.Filesystems Encoding = Encoding.UTF8; information = ""; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; if(partition.Start + sbSize >= partition.End) @@ -93,67 +93,66 @@ namespace Aaru.Filesystems byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return; - RefsVolumeHeader refsVhdr = Marshal.ByteArrayToStructureLittleEndian(sector); + VolumeHeader vhdr = Marshal.ByteArrayToStructureLittleEndian(sector); AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.jump empty? = {0}", - ArrayHelpers.ArrayIsNullOrEmpty(refsVhdr.jump)); + ArrayHelpers.ArrayIsNullOrEmpty(vhdr.jump)); AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.signature = {0}", - StringHandlers.CToString(refsVhdr.signature)); + StringHandlers.CToString(vhdr.signature)); AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.mustBeZero empty? = {0}", - ArrayHelpers.ArrayIsNullOrEmpty(refsVhdr.mustBeZero)); + ArrayHelpers.ArrayIsNullOrEmpty(vhdr.mustBeZero)); AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.identifier = {0}", - StringHandlers.CToString(BitConverter.GetBytes(refsVhdr.identifier))); + StringHandlers.CToString(BitConverter.GetBytes(vhdr.identifier))); - AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.length = {0}", refsVhdr.length); - AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.checksum = 0x{0:X4}", refsVhdr.checksum); - AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.sectors = {0}", refsVhdr.sectors); - AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.bytesPerSector = {0}", refsVhdr.bytesPerSector); + AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.length = {0}", vhdr.length); + AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.checksum = 0x{0:X4}", vhdr.checksum); + AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.sectors = {0}", vhdr.sectors); + AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.bytesPerSector = {0}", vhdr.bytesPerSector); - AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.sectorsPerCluster = {0}", - refsVhdr.sectorsPerCluster); + AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.sectorsPerCluster = {0}", vhdr.sectorsPerCluster); - AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.unknown1 zero? = {0}", refsVhdr.unknown1 == 0); - AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.unknown2 zero? = {0}", refsVhdr.unknown2 == 0); - AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.unknown3 zero? = {0}", refsVhdr.unknown3 == 0); - AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.unknown4 zero? = {0}", refsVhdr.unknown4 == 0); + AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.unknown1 zero? = {0}", vhdr.unknown1 == 0); + AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.unknown2 zero? = {0}", vhdr.unknown2 == 0); + AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.unknown3 zero? = {0}", vhdr.unknown3 == 0); + AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.unknown4 zero? = {0}", vhdr.unknown4 == 0); AaruConsole.DebugWriteLine("ReFS plugin", "VolumeHeader.unknown5 empty? = {0}", - ArrayHelpers.ArrayIsNullOrEmpty(refsVhdr.unknown5)); + ArrayHelpers.ArrayIsNullOrEmpty(vhdr.unknown5)); - if(refsVhdr.identifier != FSRS || - !ArrayHelpers.ArrayIsNullOrEmpty(refsVhdr.mustBeZero) || - !refsVhdr.signature.SequenceEqual(refsSignature)) + if(vhdr.identifier != FSRS || + !ArrayHelpers.ArrayIsNullOrEmpty(vhdr.mustBeZero) || + !vhdr.signature.SequenceEqual(_signature)) return; var sb = new StringBuilder(); sb.AppendLine("Microsoft Resilient File System"); - sb.AppendFormat("Volume uses {0} bytes per sector", refsVhdr.bytesPerSector).AppendLine(); + sb.AppendFormat("Volume uses {0} bytes per sector", vhdr.bytesPerSector).AppendLine(); - sb.AppendFormat("Volume uses {0} sectors per cluster ({1} bytes)", refsVhdr.sectorsPerCluster, - refsVhdr.sectorsPerCluster * refsVhdr.bytesPerSector).AppendLine(); + sb.AppendFormat("Volume uses {0} sectors per cluster ({1} bytes)", vhdr.sectorsPerCluster, + vhdr.sectorsPerCluster * vhdr.bytesPerSector).AppendLine(); - sb.AppendFormat("Volume has {0} sectors ({1} bytes)", refsVhdr.sectors, - refsVhdr.sectors * refsVhdr.bytesPerSector).AppendLine(); + sb.AppendFormat("Volume has {0} sectors ({1} bytes)", vhdr.sectors, vhdr.sectors * vhdr.bytesPerSector). + AppendLine(); information = sb.ToString(); XmlFsType = new FileSystemType { Type = "Resilient File System", - ClusterSize = refsVhdr.bytesPerSector * refsVhdr.sectorsPerCluster, - Clusters = refsVhdr.sectors / refsVhdr.sectorsPerCluster + ClusterSize = vhdr.bytesPerSector * vhdr.sectorsPerCluster, + Clusters = vhdr.sectors / vhdr.sectorsPerCluster }; } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct RefsVolumeHeader + struct VolumeHeader { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public readonly byte[] jump; diff --git a/Aaru.Filesystems/Reiser.cs b/Aaru.Filesystems/Reiser.cs index 1fd4847b2..4d0444bc8 100644 --- a/Aaru.Filesystems/Reiser.cs +++ b/Aaru.Filesystems/Reiser.cs @@ -46,15 +46,15 @@ namespace Aaru.Filesystems { const uint REISER_SUPER_OFFSET = 0x10000; - readonly byte[] reiser35_magic = + readonly byte[] _magic35 = { 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x46, 0x73, 0x00, 0x00 }; - readonly byte[] reiser36_magic = + readonly byte[] _magic36 = { 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x32, 0x46, 0x73, 0x00 }; - readonly byte[] reiserJr_magic = + readonly byte[] _magicJr = { 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x33, 0x46, 0x73, 0x00 }; @@ -75,9 +75,9 @@ namespace Aaru.Filesystems if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; if(partition.Start + sbAddr + sbSize >= partition.End) @@ -85,13 +85,13 @@ namespace Aaru.Filesystems byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return false; - Reiser_Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian(sector); + Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian(sector); - return reiser35_magic.SequenceEqual(reiserSb.magic) || reiser36_magic.SequenceEqual(reiserSb.magic) || - reiserJr_magic.SequenceEqual(reiserSb.magic); + return _magic35.SequenceEqual(reiserSb.magic) || _magic36.SequenceEqual(reiserSb.magic) || + _magicJr.SequenceEqual(reiserSb.magic); } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, @@ -108,30 +108,30 @@ namespace Aaru.Filesystems if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return; - Reiser_Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian(sector); + Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian(sector); - if(!reiser35_magic.SequenceEqual(reiserSb.magic) && - !reiser36_magic.SequenceEqual(reiserSb.magic) && - !reiserJr_magic.SequenceEqual(reiserSb.magic)) + if(!_magic35.SequenceEqual(reiserSb.magic) && + !_magic36.SequenceEqual(reiserSb.magic) && + !_magicJr.SequenceEqual(reiserSb.magic)) return; var sb = new StringBuilder(); - if(reiser35_magic.SequenceEqual(reiserSb.magic)) + if(_magic35.SequenceEqual(reiserSb.magic)) sb.AppendLine("Reiser 3.5 filesystem"); - else if(reiser36_magic.SequenceEqual(reiserSb.magic)) + else if(_magic36.SequenceEqual(reiserSb.magic)) sb.AppendLine("Reiser 3.6 filesystem"); - else if(reiserJr_magic.SequenceEqual(reiserSb.magic)) + else if(_magicJr.SequenceEqual(reiserSb.magic)) sb.AppendLine("Reiser Jr. filesystem"); sb.AppendFormat("Volume has {0} blocks with {1} blocks free", reiserSb.block_count, reiserSb.free_blocks). @@ -156,11 +156,11 @@ namespace Aaru.Filesystems XmlFsType = new FileSystemType(); - if(reiser35_magic.SequenceEqual(reiserSb.magic)) + if(_magic35.SequenceEqual(reiserSb.magic)) XmlFsType.Type = "Reiser 3.5 filesystem"; - else if(reiser36_magic.SequenceEqual(reiserSb.magic)) + else if(_magic36.SequenceEqual(reiserSb.magic)) XmlFsType.Type = "Reiser 3.6 filesystem"; - else if(reiserJr_magic.SequenceEqual(reiserSb.magic)) + else if(_magicJr.SequenceEqual(reiserSb.magic)) XmlFsType.Type = "Reiser Jr. filesystem"; XmlFsType.ClusterSize = reiserSb.blocksize; @@ -177,7 +177,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ReiserJournalParams + struct JournalParameters { public readonly uint journal_1stblock; public readonly uint journal_dev; @@ -190,16 +190,16 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Reiser_Superblock + struct Superblock { - public readonly uint block_count; - public readonly uint free_blocks; - public readonly uint root_block; - public readonly ReiserJournalParams journal; - public readonly ushort blocksize; - public readonly ushort oid_maxsize; - public readonly ushort oid_cursize; - public readonly ushort umount_state; + public readonly uint block_count; + public readonly uint free_blocks; + public readonly uint root_block; + public readonly JournalParameters journal; + public readonly ushort blocksize; + public readonly ushort oid_maxsize; + public readonly ushort oid_cursize; + public readonly ushort umount_state; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public readonly byte[] magic; public readonly ushort fs_state; diff --git a/Aaru.Filesystems/Reiser4.cs b/Aaru.Filesystems/Reiser4.cs index 6cd0d5c28..72ea76d10 100644 --- a/Aaru.Filesystems/Reiser4.cs +++ b/Aaru.Filesystems/Reiser4.cs @@ -46,7 +46,7 @@ namespace Aaru.Filesystems { const uint REISER4_SUPER_OFFSET = 0x10000; - readonly byte[] reiser4_magic = + readonly byte[] _magic = { 0x52, 0x65, 0x49, 0x73, 0x45, 0x72, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -67,9 +67,9 @@ namespace Aaru.Filesystems if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; if(partition.Start + sbAddr + sbSize >= partition.End) @@ -77,12 +77,12 @@ namespace Aaru.Filesystems byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return false; - Reiser4_Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian(sector); + Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian(sector); - return reiser4_magic.SequenceEqual(reiserSb.magic); + return _magic.SequenceEqual(reiserSb.magic); } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, @@ -99,19 +99,19 @@ namespace Aaru.Filesystems if(sbAddr == 0) sbAddr = 1; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return; - Reiser4_Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian(sector); + Superblock reiserSb = Marshal.ByteArrayToStructureLittleEndian(sector); - if(!reiser4_magic.SequenceEqual(reiserSb.magic)) + if(!_magic.SequenceEqual(reiserSb.magic)) return; var sb = new StringBuilder(); @@ -135,7 +135,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Reiser4_Superblock + struct Superblock { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public readonly byte[] magic; diff --git a/Aaru.Filesystems/SFS.cs b/Aaru.Filesystems/SFS.cs index 6fdf7db3b..0c3cf9e39 100644 --- a/Aaru.Filesystems/SFS.cs +++ b/Aaru.Filesystems/SFS.cs @@ -105,10 +105,10 @@ namespace Aaru.Filesystems sbInformation.AppendFormat("Root node of the object B-tree resides in block {0}", rootBlock.objectnoderoot). AppendLine(); - if(rootBlock.bits.HasFlag(SFSFlags.CaseSensitive)) + if(rootBlock.bits.HasFlag(Flags.CaseSensitive)) sbInformation.AppendLine("Volume is case sensitive"); - if(rootBlock.bits.HasFlag(SFSFlags.RecyledFolder)) + if(rootBlock.bits.HasFlag(Flags.RecyledFolder)) sbInformation.AppendLine("Volume moves deleted files to a recycled folder"); information = sbInformation.ToString(); @@ -124,7 +124,7 @@ namespace Aaru.Filesystems } [Flags] - enum SFSFlags : byte + enum Flags : byte { RecyledFolder = 64, CaseSensitive = 128 } @@ -132,15 +132,15 @@ namespace Aaru.Filesystems [StructLayout(LayoutKind.Sequential, Pack = 1)] struct RootBlock { - public readonly uint blockId; - public readonly uint blockChecksum; - public readonly uint blockSelfPointer; - public readonly ushort version; - public readonly ushort sequence; - public readonly uint datecreated; - public readonly SFSFlags bits; - public readonly byte padding1; - public readonly ushort padding2; + public readonly uint blockId; + public readonly uint blockChecksum; + public readonly uint blockSelfPointer; + public readonly ushort version; + public readonly ushort sequence; + public readonly uint datecreated; + public readonly Flags bits; + public readonly byte padding1; + public readonly ushort padding2; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public readonly uint[] reserved1; public readonly ulong firstbyte; diff --git a/Aaru.Filesystems/SolarFS.cs b/Aaru.Filesystems/SolarFS.cs index 494460475..939a54d98 100644 --- a/Aaru.Filesystems/SolarFS.cs +++ b/Aaru.Filesystems/SolarFS.cs @@ -74,7 +74,7 @@ namespace Aaru.Filesystems var sb = new StringBuilder(); byte[] bpbSector = imagePlugin.ReadSector(0 + partition.Start); - var bpb = new SolarOSParameterBlock + var bpb = new BiosParameterBlock { bps = BitConverter.ToUInt16(bpbSector, 0x0B), root_ent = BitConverter.ToUInt16(bpbSector, 0x10), @@ -167,7 +167,7 @@ namespace Aaru.Filesystems information = sb.ToString(); } - struct SolarOSParameterBlock + struct BiosParameterBlock { /// 0x00, x86 jump (3 bytes), jumps to 0x60 public byte[] x86_jump; diff --git a/Aaru.Filesystems/Squash.cs b/Aaru.Filesystems/Squash.cs index 48a3da662..7e78ca3ee 100644 --- a/Aaru.Filesystems/Squash.cs +++ b/Aaru.Filesystems/Squash.cs @@ -72,17 +72,17 @@ namespace Aaru.Filesystems byte[] sector = imagePlugin.ReadSector(partition.Start); uint magic = BitConverter.ToUInt32(sector, 0x00); - var sqSb = new SquashSuperBlock(); + var sqSb = new SuperBlock(); bool littleEndian = true; switch(magic) { case SQUASH_MAGIC: - sqSb = Marshal.ByteArrayToStructureLittleEndian(sector); + sqSb = Marshal.ByteArrayToStructureLittleEndian(sector); break; case SQUASH_CIGAM: - sqSb = Marshal.ByteArrayToStructureBigEndian(sector); + sqSb = Marshal.ByteArrayToStructureBigEndian(sector); littleEndian = false; break; @@ -157,7 +157,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SquashSuperBlock + struct SuperBlock { public readonly uint magic; public readonly uint inodes; diff --git a/Aaru.Filesystems/UCSDPascal/Dir.cs b/Aaru.Filesystems/UCSDPascal/Dir.cs index 9eba7b957..6cfa7eb93 100644 --- a/Aaru.Filesystems/UCSDPascal/Dir.cs +++ b/Aaru.Filesystems/UCSDPascal/Dir.cs @@ -45,16 +45,16 @@ namespace Aaru.Filesystems.UCSDPascal { contents = null; - if(!mounted) + if(!_mounted) return Errno.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) return Errno.NotSupported; - contents = fileEntries.Select(ent => StringHandlers.PascalToString(ent.Filename, Encoding)).ToList(); + contents = _fileEntries.Select(ent => StringHandlers.PascalToString(ent.Filename, Encoding)).ToList(); - if(debug) + if(_debug) { contents.Add("$"); contents.Add("$Boot"); diff --git a/Aaru.Filesystems/UCSDPascal/File.cs b/Aaru.Filesystems/UCSDPascal/File.cs index 038afcdb0..6aaa2effc 100644 --- a/Aaru.Filesystems/UCSDPascal/File.cs +++ b/Aaru.Filesystems/UCSDPascal/File.cs @@ -44,14 +44,14 @@ namespace Aaru.Filesystems.UCSDPascal { deviceBlock = 0; - return !mounted ? Errno.AccessDenied : Errno.NotImplemented; + return !_mounted ? Errno.AccessDenied : Errno.NotImplemented; } public Errno GetAttributes(string path, out FileAttributes attributes) { attributes = new FileAttributes(); - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -74,7 +74,7 @@ namespace Aaru.Filesystems.UCSDPascal public Errno Read(string path, long offset, long size, ref byte[] buf) { - if(!mounted) + if(!_mounted) return Errno.AccessDenied; string[] pathElements = path.Split(new[] @@ -87,9 +87,9 @@ namespace Aaru.Filesystems.UCSDPascal byte[] file; - if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0)) - file = string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ? catalogBlocks : bootBlocks; + if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || + string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0)) + file = string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ? _catalogBlocks : _bootBlocks; else { Errno error = GetFileEntry(path, out PascalFileEntry entry); @@ -97,10 +97,10 @@ namespace Aaru.Filesystems.UCSDPascal if(error != Errno.NoError) return error; - byte[] tmp = device.ReadSectors((ulong)entry.FirstBlock * multiplier, - (uint)(entry.LastBlock - entry.FirstBlock) * multiplier); + byte[] tmp = _device.ReadSectors((ulong)entry.FirstBlock * _multiplier, + (uint)(entry.LastBlock - entry.FirstBlock) * _multiplier); - file = new byte[((entry.LastBlock - entry.FirstBlock - 1) * device.Info.SectorSize * multiplier) + + file = new byte[((entry.LastBlock - entry.FirstBlock - 1) * _device.Info.SectorSize * _multiplier) + entry.LastBytes]; Array.Copy(tmp, 0, file, 0, file.Length); @@ -131,26 +131,28 @@ namespace Aaru.Filesystems.UCSDPascal if(pathElements.Length != 1) return Errno.NotSupported; - if(debug) + if(_debug) if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0) { stat = new FileEntryInfo { Attributes = FileAttributes.System, - BlockSize = device.Info.SectorSize * multiplier, + BlockSize = _device.Info.SectorSize * _multiplier, Links = 1 }; if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0) { - stat.Blocks = (catalogBlocks.Length / stat.BlockSize) + (catalogBlocks.Length % stat.BlockSize); - stat.Length = catalogBlocks.Length; + stat.Blocks = (_catalogBlocks.Length / stat.BlockSize) + + (_catalogBlocks.Length % stat.BlockSize); + + stat.Length = _catalogBlocks.Length; } else { - stat.Blocks = (bootBlocks.Length / stat.BlockSize) + (catalogBlocks.Length % stat.BlockSize); - stat.Length = bootBlocks.Length; + stat.Blocks = (_bootBlocks.Length / stat.BlockSize) + (_catalogBlocks.Length % stat.BlockSize); + stat.Length = _bootBlocks.Length; } return Errno.NoError; @@ -163,11 +165,12 @@ namespace Aaru.Filesystems.UCSDPascal stat = new FileEntryInfo { - Attributes = FileAttributes.File, - Blocks = entry.LastBlock - entry.FirstBlock, - BlockSize = device.Info.SectorSize * multiplier, + Attributes = FileAttributes.File, + Blocks = entry.LastBlock - entry.FirstBlock, + BlockSize = _device.Info.SectorSize * _multiplier, LastWriteTimeUtc = DateHandlers.UcsdPascalToDateTime(entry.ModificationTime), - Length = ((entry.LastBlock - entry.FirstBlock) * device.Info.SectorSize * multiplier) + entry.LastBytes, + Length = ((entry.LastBlock - entry.FirstBlock) * _device.Info.SectorSize * _multiplier) + + entry.LastBytes, Links = 1 }; @@ -178,13 +181,13 @@ namespace Aaru.Filesystems.UCSDPascal { entry = new PascalFileEntry(); - foreach(PascalFileEntry ent in fileEntries.Where(ent => - string.Compare(path, - StringHandlers. - PascalToString(ent.Filename, - Encoding), - StringComparison. - InvariantCultureIgnoreCase) == 0)) + foreach(PascalFileEntry ent in _fileEntries.Where(ent => + string.Compare(path, + StringHandlers. + PascalToString(ent.Filename, + Encoding), + StringComparison. + InvariantCultureIgnoreCase) == 0)) { entry = ent; diff --git a/Aaru.Filesystems/UCSDPascal/Info.cs b/Aaru.Filesystems/UCSDPascal/Info.cs index f5fb4e3e7..d9fa1b8c2 100644 --- a/Aaru.Filesystems/UCSDPascal/Info.cs +++ b/Aaru.Filesystems/UCSDPascal/Info.cs @@ -50,10 +50,10 @@ namespace Aaru.Filesystems.UCSDPascal if(partition.Length < 3) return false; - multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); + _multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); // Blocks 0 and 1 are boot code - byte[] volBlock = imagePlugin.ReadSectors((multiplier * 2) + partition.Start, multiplier); + byte[] volBlock = imagePlugin.ReadSectors((_multiplier * 2) + partition.Start, _multiplier); // On Apple II, it's little endian // TODO: Fix @@ -91,7 +91,7 @@ namespace Aaru.Filesystems.UCSDPascal // Last volume record block must be after first block, and before end of device if(volEntry.LastBlock <= volEntry.FirstBlock || - (ulong)volEntry.LastBlock > (imagePlugin.Info.Sectors / multiplier) - 2) + (ulong)volEntry.LastBlock > (imagePlugin.Info.Sectors / _multiplier) - 2) return false; // Volume record entry type must be volume or secure @@ -105,7 +105,7 @@ namespace Aaru.Filesystems.UCSDPascal // Volume blocks is equal to volume sectors if(volEntry.Blocks < 0 || - (ulong)volEntry.Blocks != imagePlugin.Info.Sectors / multiplier) + (ulong)volEntry.Blocks != imagePlugin.Info.Sectors / _multiplier) return false; // There can be not less than zero files @@ -118,13 +118,13 @@ namespace Aaru.Filesystems.UCSDPascal Encoding = encoding ?? new Apple2(); var sbInformation = new StringBuilder(); information = ""; - multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); + _multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); if(imagePlugin.Info.Sectors < 3) return; // Blocks 0 and 1 are boot code - byte[] volBlock = imagePlugin.ReadSectors((multiplier * 2) + partition.Start, multiplier); + byte[] volBlock = imagePlugin.ReadSectors((_multiplier * 2) + partition.Start, _multiplier); // On Apple //, it's little endian // TODO: Fix @@ -152,7 +152,7 @@ namespace Aaru.Filesystems.UCSDPascal // Last volume record block must be after first block, and before end of device if(volEntry.LastBlock <= volEntry.FirstBlock || - (ulong)volEntry.LastBlock > (imagePlugin.Info.Sectors / multiplier) - 2) + (ulong)volEntry.LastBlock > (imagePlugin.Info.Sectors / _multiplier) - 2) return; // Volume record entry type must be volume or secure @@ -166,7 +166,7 @@ namespace Aaru.Filesystems.UCSDPascal // Volume blocks is equal to volume sectors if(volEntry.Blocks < 0 || - (ulong)volEntry.Blocks != imagePlugin.Info.Sectors / multiplier) + (ulong)volEntry.Blocks != imagePlugin.Info.Sectors / _multiplier) return; // There can be not less than zero files @@ -191,7 +191,7 @@ namespace Aaru.Filesystems.UCSDPascal XmlFsType = new FileSystemType { - Bootable = !ArrayHelpers.ArrayIsNullOrEmpty(imagePlugin.ReadSectors(partition.Start, multiplier * 2)), + Bootable = !ArrayHelpers.ArrayIsNullOrEmpty(imagePlugin.ReadSectors(partition.Start, _multiplier * 2)), Clusters = (ulong)volEntry.Blocks, ClusterSize = imagePlugin.Info.SectorSize, Files = (ulong)volEntry.Files, diff --git a/Aaru.Filesystems/UCSDPascal/Super.cs b/Aaru.Filesystems/UCSDPascal/Super.cs index a78aa3fcb..c78db84ef 100644 --- a/Aaru.Filesystems/UCSDPascal/Super.cs +++ b/Aaru.Filesystems/UCSDPascal/Super.cs @@ -48,101 +48,101 @@ namespace Aaru.Filesystems.UCSDPascal public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, Dictionary options, string @namespace) { - device = imagePlugin; + _device = imagePlugin; Encoding = encoding ?? new Apple2(); if(options == null) options = GetDefaultOptions(); if(options.TryGetValue("debug", out string debugString)) - bool.TryParse(debugString, out debug); + bool.TryParse(debugString, out _debug); - if(device.Info.Sectors < 3) + if(_device.Info.Sectors < 3) return Errno.InvalidArgument; - multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); + _multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); // Blocks 0 and 1 are boot code - catalogBlocks = device.ReadSectors(multiplier * 2, multiplier); + _catalogBlocks = _device.ReadSectors(_multiplier * 2, _multiplier); // On Apple //, it's little endian // TODO: Fix //BigEndianBitConverter.IsLittleEndian = // multiplier == 2 ? !BitConverter.IsLittleEndian : BitConverter.IsLittleEndian; - mountedVolEntry.FirstBlock = BigEndianBitConverter.ToInt16(catalogBlocks, 0x00); - mountedVolEntry.LastBlock = BigEndianBitConverter.ToInt16(catalogBlocks, 0x02); - mountedVolEntry.EntryType = (PascalFileKind)BigEndianBitConverter.ToInt16(catalogBlocks, 0x04); - mountedVolEntry.VolumeName = new byte[8]; - Array.Copy(catalogBlocks, 0x06, mountedVolEntry.VolumeName, 0, 8); - mountedVolEntry.Blocks = BigEndianBitConverter.ToInt16(catalogBlocks, 0x0E); - mountedVolEntry.Files = BigEndianBitConverter.ToInt16(catalogBlocks, 0x10); - mountedVolEntry.Dummy = BigEndianBitConverter.ToInt16(catalogBlocks, 0x12); - mountedVolEntry.LastBoot = BigEndianBitConverter.ToInt16(catalogBlocks, 0x14); - mountedVolEntry.Tail = BigEndianBitConverter.ToInt32(catalogBlocks, 0x16); + _mountedVolEntry.FirstBlock = BigEndianBitConverter.ToInt16(_catalogBlocks, 0x00); + _mountedVolEntry.LastBlock = BigEndianBitConverter.ToInt16(_catalogBlocks, 0x02); + _mountedVolEntry.EntryType = (PascalFileKind)BigEndianBitConverter.ToInt16(_catalogBlocks, 0x04); + _mountedVolEntry.VolumeName = new byte[8]; + Array.Copy(_catalogBlocks, 0x06, _mountedVolEntry.VolumeName, 0, 8); + _mountedVolEntry.Blocks = BigEndianBitConverter.ToInt16(_catalogBlocks, 0x0E); + _mountedVolEntry.Files = BigEndianBitConverter.ToInt16(_catalogBlocks, 0x10); + _mountedVolEntry.Dummy = BigEndianBitConverter.ToInt16(_catalogBlocks, 0x12); + _mountedVolEntry.LastBoot = BigEndianBitConverter.ToInt16(_catalogBlocks, 0x14); + _mountedVolEntry.Tail = BigEndianBitConverter.ToInt32(_catalogBlocks, 0x16); - if(mountedVolEntry.FirstBlock != 0 || - mountedVolEntry.LastBlock <= mountedVolEntry.FirstBlock || - (ulong)mountedVolEntry.LastBlock > (device.Info.Sectors / multiplier) - 2 || - (mountedVolEntry.EntryType != PascalFileKind.Volume && - mountedVolEntry.EntryType != PascalFileKind.Secure) || - mountedVolEntry.VolumeName[0] > 7 || - mountedVolEntry.Blocks < 0 || - (ulong)mountedVolEntry.Blocks != device.Info.Sectors / multiplier || - mountedVolEntry.Files < 0) + if(_mountedVolEntry.FirstBlock != 0 || + _mountedVolEntry.LastBlock <= _mountedVolEntry.FirstBlock || + (ulong)_mountedVolEntry.LastBlock > (_device.Info.Sectors / _multiplier) - 2 || + (_mountedVolEntry.EntryType != PascalFileKind.Volume && + _mountedVolEntry.EntryType != PascalFileKind.Secure) || + _mountedVolEntry.VolumeName[0] > 7 || + _mountedVolEntry.Blocks < 0 || + (ulong)_mountedVolEntry.Blocks != _device.Info.Sectors / _multiplier || + _mountedVolEntry.Files < 0) return Errno.InvalidArgument; - catalogBlocks = device.ReadSectors(multiplier * 2, - (uint)(mountedVolEntry.LastBlock - mountedVolEntry.FirstBlock - 2) * - multiplier); + _catalogBlocks = _device.ReadSectors(_multiplier * 2, + (uint)(_mountedVolEntry.LastBlock - _mountedVolEntry.FirstBlock - 2) * + _multiplier); int offset = 26; - fileEntries = new List(); + _fileEntries = new List(); - while(offset + 26 < catalogBlocks.Length) + while(offset + 26 < _catalogBlocks.Length) { var entry = new PascalFileEntry { Filename = new byte[16], - FirstBlock = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x00), - LastBlock = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x02), - EntryType = (PascalFileKind)BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x04), - LastBytes = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x16), - ModificationTime = BigEndianBitConverter.ToInt16(catalogBlocks, offset + 0x18) + FirstBlock = BigEndianBitConverter.ToInt16(_catalogBlocks, offset + 0x00), + LastBlock = BigEndianBitConverter.ToInt16(_catalogBlocks, offset + 0x02), + EntryType = (PascalFileKind)BigEndianBitConverter.ToInt16(_catalogBlocks, offset + 0x04), + LastBytes = BigEndianBitConverter.ToInt16(_catalogBlocks, offset + 0x16), + ModificationTime = BigEndianBitConverter.ToInt16(_catalogBlocks, offset + 0x18) }; - Array.Copy(catalogBlocks, offset + 0x06, entry.Filename, 0, 16); + Array.Copy(_catalogBlocks, offset + 0x06, entry.Filename, 0, 16); if(entry.Filename[0] <= 15 && entry.Filename[0] > 0) - fileEntries.Add(entry); + _fileEntries.Add(entry); offset += 26; } - bootBlocks = device.ReadSectors(0, 2 * multiplier); + _bootBlocks = _device.ReadSectors(0, 2 * _multiplier); XmlFsType = new FileSystemType { - Bootable = !ArrayHelpers.ArrayIsNullOrEmpty(bootBlocks), - Clusters = (ulong)mountedVolEntry.Blocks, - ClusterSize = device.Info.SectorSize, - Files = (ulong)mountedVolEntry.Files, + Bootable = !ArrayHelpers.ArrayIsNullOrEmpty(_bootBlocks), + Clusters = (ulong)_mountedVolEntry.Blocks, + ClusterSize = _device.Info.SectorSize, + Files = (ulong)_mountedVolEntry.Files, FilesSpecified = true, Type = "UCSD Pascal", - VolumeName = StringHandlers.PascalToString(mountedVolEntry.VolumeName, Encoding) + VolumeName = StringHandlers.PascalToString(_mountedVolEntry.VolumeName, Encoding) }; - mounted = true; + _mounted = true; return Errno.NoError; } public Errno Unmount() { - mounted = false; - fileEntries = null; + _mounted = false; + _fileEntries = null; return Errno.NoError; } @@ -151,18 +151,18 @@ namespace Aaru.Filesystems.UCSDPascal { stat = new FileSystemInfo { - Blocks = (ulong)mountedVolEntry.Blocks, + Blocks = (ulong)_mountedVolEntry.Blocks, FilenameLength = 16, - Files = (ulong)mountedVolEntry.Files, + Files = (ulong)_mountedVolEntry.Files, FreeBlocks = 0, PluginId = Id, Type = "UCSD Pascal" }; stat.FreeBlocks = - (ulong)(mountedVolEntry.Blocks - (mountedVolEntry.LastBlock - mountedVolEntry.FirstBlock)); + (ulong)(_mountedVolEntry.Blocks - (_mountedVolEntry.LastBlock - _mountedVolEntry.FirstBlock)); - foreach(PascalFileEntry entry in fileEntries) + foreach(PascalFileEntry entry in _fileEntries) stat.FreeBlocks -= (ulong)(entry.LastBlock - entry.FirstBlock); return Errno.NotImplemented; diff --git a/Aaru.Filesystems/UCSDPascal/UCSDPascal.cs b/Aaru.Filesystems/UCSDPascal/UCSDPascal.cs index aa795d51f..dfef3b97b 100644 --- a/Aaru.Filesystems/UCSDPascal/UCSDPascal.cs +++ b/Aaru.Filesystems/UCSDPascal/UCSDPascal.cs @@ -42,17 +42,15 @@ namespace Aaru.Filesystems.UCSDPascal // Information from Call-A.P.P.L.E. Pascal Disk Directory Structure public partial class PascalPlugin : IReadOnlyFilesystem { - byte[] bootBlocks; - byte[] catalogBlocks; - - bool debug; - IMediaImage device; - List fileEntries; - bool mounted; - - PascalVolumeEntry mountedVolEntry; + byte[] _bootBlocks; + byte[] _catalogBlocks; + bool _debug; + IMediaImage _device; + List _fileEntries; + bool _mounted; + PascalVolumeEntry _mountedVolEntry; /// Apple II disks use 256 bytes / sector, but filesystem assumes it's 512 bytes / sector - uint multiplier; + uint _multiplier; public FileSystemType XmlFsType { get; private set; } public string Name => "U.C.S.D. Pascal filesystem"; diff --git a/Aaru.Filesystems/UDF.cs b/Aaru.Filesystems/UDF.cs index cabc2819c..0b3d1b847 100644 --- a/Aaru.Filesystems/UDF.cs +++ b/Aaru.Filesystems/UDF.cs @@ -48,7 +48,7 @@ namespace Aaru.Filesystems [SuppressMessage("ReSharper", "UnusedMember.Local")] public class UDF : IFilesystem { - readonly byte[] UDF_Magic = + readonly byte[] _magic = { 0x2A, 0x4F, 0x53, 0x54, 0x41, 0x20, 0x55, 0x44, 0x46, 0x20, 0x43, 0x6F, 0x6D, 0x70, 0x6C, 0x69, 0x61, 0x6E, 0x74, 0x00, 0x00, 0x00, 0x00 @@ -150,7 +150,7 @@ namespace Aaru.Filesystems LogicalVolumeDescriptor lvd = Marshal.ByteArrayToStructureLittleEndian(sector); - return UDF_Magic.SequenceEqual(lvd.domainIdentifier.identifier); + return _magic.SequenceEqual(lvd.domainIdentifier.identifier); } } else diff --git a/Aaru.Filesystems/UNICOS.cs b/Aaru.Filesystems/UNICOS.cs index 37c7be843..70d8db1ba 100644 --- a/Aaru.Filesystems/UNICOS.cs +++ b/Aaru.Filesystems/UNICOS.cs @@ -70,17 +70,17 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize < 512) return false; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return false; - UNICOS_Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian(sector); + Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian(sector); AaruConsole.DebugWriteLine("UNICOS plugin", "magic = 0x{0:X16} (expected 0x{1:X16})", unicosSb.s_magic, UNICOS_MAGIC); @@ -97,17 +97,17 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize < 512) return; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return; - UNICOS_Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian(sector); + Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian(sector); if(unicosSb.s_magic != UNICOS_MAGIC) return; @@ -167,7 +167,7 @@ namespace Aaru.Filesystems [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")] - struct UNICOS_Superblock + struct Superblock { public readonly ulong s_magic; /* magic number to indicate file system type */ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] diff --git a/Aaru.Filesystems/UNIXBFS.cs b/Aaru.Filesystems/UNIXBFS.cs index 1d967782d..e791723c6 100644 --- a/Aaru.Filesystems/UNIXBFS.cs +++ b/Aaru.Filesystems/UNIXBFS.cs @@ -71,7 +71,7 @@ namespace Aaru.Filesystems byte[] bfsSbSector = imagePlugin.ReadSector(0 + partition.Start); byte[] sbStrings = new byte[6]; - var bfsSb = new BFSSuperBlock + var bfsSb = new SuperBlock { s_magic = BitConverter.ToUInt32(bfsSbSector, 0x00), s_start = BitConverter.ToUInt32(bfsSbSector, 0x04), @@ -116,7 +116,7 @@ namespace Aaru.Filesystems information = sb.ToString(); } - struct BFSSuperBlock + struct SuperBlock { /// 0x00, 0x1BADFACE public uint s_magic; diff --git a/Aaru.Filesystems/VxFS.cs b/Aaru.Filesystems/VxFS.cs index c0ee9bcdc..9c108b0d3 100644 --- a/Aaru.Filesystems/VxFS.cs +++ b/Aaru.Filesystems/VxFS.cs @@ -74,7 +74,7 @@ namespace Aaru.Filesystems ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize; byte[] sector = imagePlugin.ReadSector(partition.Start + vmfsSuperOff); - VxSuperBlock vxSb = Marshal.ByteArrayToStructureLittleEndian(sector); + SuperBlock vxSb = Marshal.ByteArrayToStructureLittleEndian(sector); var sbInformation = new StringBuilder(); @@ -119,7 +119,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct VxSuperBlock + struct SuperBlock { /// Magic number public readonly uint vs_magic; diff --git a/Aaru.Filesystems/XFS.cs b/Aaru.Filesystems/XFS.cs index 4578bdcd6..056154798 100644 --- a/Aaru.Filesystems/XFS.cs +++ b/Aaru.Filesystems/XFS.cs @@ -61,26 +61,26 @@ namespace Aaru.Filesystems // Misaligned if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc) { - uint sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); + uint sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); - if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) + if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return false; - byte[] sbpiece = new byte[Marshal.SizeOf()]; + byte[] sbpiece = new byte[Marshal.SizeOf()]; foreach(int location in new[] { 0, 0x200, 0x400 }) { - Array.Copy(sector, location, sbpiece, 0, Marshal.SizeOf()); + Array.Copy(sector, location, sbpiece, 0, Marshal.SizeOf()); - XFS_Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); + Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); AaruConsole.DebugWriteLine("XFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8})", location, xfsSb.magicnum, XFS_MAGIC); @@ -97,17 +97,17 @@ namespace Aaru.Filesystems { ulong location = (ulong)i; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return false; - XFS_Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian(sector); + Superblock xfsSb = Marshal.ByteArrayToStructureBigEndian(sector); AaruConsole.DebugWriteLine("XFS plugin", "magic at {0} = 0x{1:X8} (expected 0x{2:X8})", location, xfsSb.magicnum, XFS_MAGIC); @@ -128,31 +128,31 @@ namespace Aaru.Filesystems if(imagePlugin.Info.SectorSize < 512) return; - var xfsSb = new XFS_Superblock(); + var xfsSb = new Superblock(); // Misaligned if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc) { - uint sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); + uint sbSize = (uint)((Marshal.SizeOf() + 0x400) / imagePlugin.Info.SectorSize); - if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) + if((Marshal.SizeOf() + 0x400) % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return; - byte[] sbpiece = new byte[Marshal.SizeOf()]; + byte[] sbpiece = new byte[Marshal.SizeOf()]; foreach(int location in new[] { 0, 0x200, 0x400 }) { - Array.Copy(sector, location, sbpiece, 0, Marshal.SizeOf()); + Array.Copy(sector, location, sbpiece, 0, Marshal.SizeOf()); - xfsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); + xfsSb = Marshal.ByteArrayToStructureBigEndian(sbpiece); AaruConsole.DebugWriteLine("XFS plugin", "magic at 0x{0:X3} = 0x{1:X8} (expected 0x{2:X8})", location, xfsSb.magicnum, XFS_MAGIC); @@ -168,17 +168,17 @@ namespace Aaru.Filesystems }) { ulong location = (ulong)i; - uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); + uint sbSize = (uint)(Marshal.SizeOf() / imagePlugin.Info.SectorSize); - if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) + if(Marshal.SizeOf() % imagePlugin.Info.SectorSize != 0) sbSize++; byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize); - if(sector.Length < Marshal.SizeOf()) + if(sector.Length < Marshal.SizeOf()) return; - xfsSb = Marshal.ByteArrayToStructureBigEndian(sector); + xfsSb = Marshal.ByteArrayToStructureBigEndian(sector); AaruConsole.DebugWriteLine("XFS plugin", "magic at {0} = 0x{1:X8} (expected 0x{2:X8})", location, xfsSb.magicnum, XFS_MAGIC); @@ -226,7 +226,7 @@ namespace Aaru.Filesystems } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct XFS_Superblock + struct Superblock { public readonly uint magicnum; public readonly uint blocksize; diff --git a/Aaru.Filesystems/Xia.cs b/Aaru.Filesystems/Xia.cs index d97cdc76f..4925b415b 100644 --- a/Aaru.Filesystems/Xia.cs +++ b/Aaru.Filesystems/Xia.cs @@ -62,7 +62,7 @@ namespace Aaru.Filesystems public bool Identify(IMediaImage imagePlugin, Partition partition) { - int sbSizeInBytes = Marshal.SizeOf(); + int sbSizeInBytes = Marshal.SizeOf(); uint sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) @@ -71,8 +71,8 @@ namespace Aaru.Filesystems if(sbSizeInSectors + partition.Start >= partition.End) return false; - byte[] sbSector = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors); - XiaSuperBlock supblk = Marshal.ByteArrayToStructureLittleEndian(sbSector); + byte[] sbSector = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors); + SuperBlock supblk = Marshal.ByteArrayToStructureLittleEndian(sbSector); return supblk.s_magic == XIAFS_SUPER_MAGIC; } @@ -85,14 +85,14 @@ namespace Aaru.Filesystems var sb = new StringBuilder(); - int sbSizeInBytes = Marshal.SizeOf(); + int sbSizeInBytes = Marshal.SizeOf(); uint sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) sbSizeInSectors++; - byte[] sbSector = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors); - XiaSuperBlock supblk = Marshal.ByteArrayToStructureLittleEndian(sbSector); + byte[] sbSector = imagePlugin.ReadSectors(partition.Start, sbSizeInSectors); + SuperBlock supblk = Marshal.ByteArrayToStructureLittleEndian(sbSector); sb.AppendFormat("{0} bytes per zone", supblk.s_zone_size).AppendLine(); @@ -133,7 +133,7 @@ namespace Aaru.Filesystems /// Xia superblock [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct XiaSuperBlock + struct SuperBlock { /// 1st sector reserved for boot [MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] @@ -174,7 +174,7 @@ namespace Aaru.Filesystems /// Xia directory entry [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct XiaDirect + struct DirectoryEntry { public readonly uint d_ino; public readonly ushort d_rec_len; @@ -185,7 +185,7 @@ namespace Aaru.Filesystems /// Xia inode [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct XiaInode + struct Inode { public readonly ushort i_mode; public readonly ushort i_nlinks; diff --git a/Aaru.Filesystems/exFAT.cs b/Aaru.Filesystems/exFAT.cs index 13c4a4c7a..a483994a1 100644 --- a/Aaru.Filesystems/exFAT.cs +++ b/Aaru.Filesystems/exFAT.cs @@ -46,9 +46,9 @@ namespace Aaru.Filesystems [SuppressMessage("ReSharper", "UnusedMember.Local")] public class exFAT : IFilesystem { - readonly Guid OEM_FLASH_PARAMETER_GUID = new Guid("0A0C7E46-3399-4021-90C8-FA6D389C4BA2"); + readonly Guid _oemFlashParameterGuid = new Guid("0A0C7E46-3399-4021-90C8-FA6D389C4BA2"); - readonly byte[] signature = + readonly byte[] _signature = { 0x45, 0x58, 0x46, 0x41, 0x54, 0x20, 0x20, 0x20 }; @@ -71,7 +71,7 @@ namespace Aaru.Filesystems VolumeBootRecord vbr = Marshal.ByteArrayToStructureLittleEndian(vbrSector); - return signature.SequenceEqual(vbr.signature); + return _signature.SequenceEqual(vbr.signature); } public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, @@ -132,7 +132,7 @@ namespace Aaru.Filesystems foreach(OemParameter parameter in parametersTable.parameters) { - if(parameter.OemParameterType == OEM_FLASH_PARAMETER_GUID) + if(parameter.OemParameterType == _oemFlashParameterGuid) { sb.AppendFormat("OEM Parameters {0}:", count).AppendLine(); sb.AppendFormat("\t{0} bytes in erase block", parameter.eraseBlockSize).AppendLine(); diff --git a/Aaru.Filesystems/ext2FS.cs b/Aaru.Filesystems/ext2FS.cs index 22e455c91..72f027804 100644 --- a/Aaru.Filesystems/ext2FS.cs +++ b/Aaru.Filesystems/ext2FS.cs @@ -176,7 +176,7 @@ namespace Aaru.Filesystems if(sbSectorOff + partition.Start >= partition.End) return false; - int sbSizeInBytes = Marshal.SizeOf(); + int sbSizeInBytes = Marshal.SizeOf(); uint sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) @@ -207,7 +207,7 @@ namespace Aaru.Filesystems bool ext3 = false; bool ext4 = false; - int sbSizeInBytes = Marshal.SizeOf(); + int sbSizeInBytes = Marshal.SizeOf(); uint sbSizeInSectors = (uint)(sbSizeInBytes / imagePlugin.Info.SectorSize); if(sbSizeInBytes % imagePlugin.Info.SectorSize > 0) @@ -219,7 +219,7 @@ namespace Aaru.Filesystems byte[] sbSector = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSizeInSectors); byte[] sblock = new byte[sbSizeInBytes]; Array.Copy(sbSector, sbOff, sblock, 0, sbSizeInBytes); - ext2FSSuperBlock supblk = Marshal.ByteArrayToStructureLittleEndian(sblock); + SuperBlock supblk = Marshal.ByteArrayToStructureLittleEndian(sblock); XmlFsType = new FileSystemType(); @@ -750,7 +750,7 @@ namespace Aaru.Filesystems /// ext2/3/4 superblock [StructLayout(LayoutKind.Sequential, Pack = 1), SuppressMessage("ReSharper", "InconsistentNaming")] - struct ext2FSSuperBlock + struct SuperBlock { /// 0x000, inodes on volume public readonly uint inodes; diff --git a/Aaru.Filesystems/extFS.cs b/Aaru.Filesystems/extFS.cs index 175b4fc39..e551706e2 100644 --- a/Aaru.Filesystems/extFS.cs +++ b/Aaru.Filesystems/extFS.cs @@ -98,7 +98,7 @@ namespace Aaru.Filesystems byte[] sbSector = new byte[512]; Array.Copy(sblock, sbOff, sbSector, 0, 512); - var extSb = new extFSSuperBlock + var extSb = new SuperBlock { inodes = BitConverter.ToUInt32(sbSector, 0x000), zones = BitConverter.ToUInt32(sbSector, 0x004), @@ -138,7 +138,7 @@ namespace Aaru.Filesystems /// ext superblock [SuppressMessage("ReSharper", "InconsistentNaming")] - struct extFSSuperBlock + struct SuperBlock { /// 0x000, inodes on volume public uint inodes; diff --git a/Aaru.Filters/AppleDouble.cs b/Aaru.Filters/AppleDouble.cs index 72914a5e3..b6d531659 100644 --- a/Aaru.Filters/AppleDouble.cs +++ b/Aaru.Filters/AppleDouble.cs @@ -45,80 +45,79 @@ namespace Aaru.Filters [SuppressMessage("ReSharper", "UnusedMember.Local")] public class AppleDouble : IFilter { - const uint AppleDoubleMagic = 0x00051607; - const uint AppleDoubleVersion = 0x00010000; - const uint AppleDoubleVersion2 = 0x00020000; - readonly byte[] DOSHome = + const uint MAGIC = 0x00051607; + const uint VERSION = 0x00010000; + const uint VERSION2 = 0x00020000; + readonly byte[] _dosHome = { 0x4D, 0x53, 0x2D, 0x44, 0x4F, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - readonly byte[] MacintoshHome = + readonly byte[] _macintoshHome = { 0x4D, 0x61, 0x63, 0x69, 0x6E, 0x74, 0x6F, 0x73, 0x68, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - readonly byte[] OSXHome = + readonly byte[] _osxHome = { 0x4D, 0x61, 0x63, 0x20, 0x4F, 0x53, 0x20, 0x58, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - readonly byte[] ProDOSHome = + readonly byte[] _proDosHome = { 0x50, 0x72, 0x6F, 0x44, 0x4F, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - readonly byte[] UNIXHome = + readonly byte[] _unixHome = { 0x55, 0x6E, 0x69, 0x78, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - readonly byte[] VMXHome = + readonly byte[] _vmsHome = { 0x56, 0x41, 0x58, 0x20, 0x56, 0x4D, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - string basePath; - DateTime creationTime; - - AppleDoubleEntry dataFork; - AppleDoubleHeader header; - string headerPath; - DateTime lastWriteTime; - bool opened; - AppleDoubleEntry rsrcFork; + string _basePath; + DateTime _creationTime; + AppleDoubleEntry _dataFork; + AppleDoubleHeader _header; + string _headerPath; + DateTime _lastWriteTime; + bool _opened; + AppleDoubleEntry _rsrcFork; public string Name => "AppleDouble"; public Guid Id => new Guid("1B2165EE-C9DF-4B21-BBBB-9E5892B2DF4D"); public string Author => "Natalia Portillo"; - public void Close() => opened = false; + public void Close() => _opened = false; - public string GetBasePath() => basePath; + public string GetBasePath() => _basePath; - public DateTime GetCreationTime() => creationTime; + public DateTime GetCreationTime() => _creationTime; - public long GetDataForkLength() => dataFork.length; + public long GetDataForkLength() => _dataFork.length; - public Stream GetDataForkStream() => new FileStream(basePath, FileMode.Open, FileAccess.Read); + public Stream GetDataForkStream() => new FileStream(_basePath, FileMode.Open, FileAccess.Read); - public string GetFilename() => Path.GetFileName(basePath); + public string GetFilename() => Path.GetFileName(_basePath); - public DateTime GetLastWriteTime() => lastWriteTime; + public DateTime GetLastWriteTime() => _lastWriteTime; - public long GetLength() => dataFork.length + rsrcFork.length; + public long GetLength() => _dataFork.length + _rsrcFork.length; - public string GetParentFolder() => Path.GetDirectoryName(basePath); + public string GetParentFolder() => Path.GetDirectoryName(_basePath); - public string GetPath() => basePath; + public string GetPath() => _basePath; - public long GetResourceForkLength() => rsrcFork.length; + public long GetResourceForkLength() => _rsrcFork.length; public Stream GetResourceForkStream() { - if(rsrcFork.length == 0) + if(_rsrcFork.length == 0) return null; - return new OffsetStream(headerPath, FileMode.Open, FileAccess.Read, rsrcFork.offset, - (rsrcFork.offset + rsrcFork.length) - 1); + return new OffsetStream(_headerPath, FileMode.Open, FileAccess.Read, _rsrcFork.offset, + (_rsrcFork.offset + _rsrcFork.length) - 1); } - public bool HasResourceFork() => rsrcFork.length > 0; + public bool HasResourceFork() => _rsrcFork.length > 0; public bool Identify(byte[] buffer) => false; @@ -137,174 +136,173 @@ namespace Aaru.Filters return false; // Prepend data fork name with "R." - string ProDosAppleDouble = Path.Combine(parentFolder, "R." + filename); + string proDosAppleDouble = Path.Combine(parentFolder, "R." + filename); // Prepend data fork name with '%' - string UNIXAppleDouble = Path.Combine(parentFolder, "%" + filename); + string unixAppleDouble = Path.Combine(parentFolder, "%" + filename); // Change file extension to ADF - string DOSAppleDouble = Path.Combine(parentFolder, filenameNoExt + ".ADF"); + string dosAppleDouble = Path.Combine(parentFolder, filenameNoExt + ".ADF"); // Change file extension to adf - string DOSAppleDoubleLower = Path.Combine(parentFolder, filenameNoExt + ".adf"); + string dosAppleDoubleLower = Path.Combine(parentFolder, filenameNoExt + ".adf"); // Store AppleDouble header file in ".AppleDouble" folder with same name - string NetatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", filename); + string netatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", filename); // Store AppleDouble header file in "resource.frk" folder with same name - string DAVEAppleDouble = Path.Combine(parentFolder, "resource.frk", filename); + string daveAppleDouble = Path.Combine(parentFolder, "resource.frk", filename); // Prepend data fork name with "._" - string OSXAppleDouble = Path.Combine(parentFolder, "._" + filename); + string osxAppleDouble = Path.Combine(parentFolder, "._" + filename); // Adds ".rsrc" extension - string UnArAppleDouble = Path.Combine(parentFolder, filename + ".rsrc"); + string unArAppleDouble = Path.Combine(parentFolder, filename + ".rsrc"); // Check AppleDouble created by A/UX in ProDOS filesystem - if(File.Exists(ProDosAppleDouble)) + if(File.Exists(proDosAppleDouble)) { - var prodosStream = new FileStream(ProDosAppleDouble, FileMode.Open, FileAccess.Read); + var prodosStream = new FileStream(proDosAppleDouble, FileMode.Open, FileAccess.Read); if(prodosStream.Length > 26) { - byte[] prodos_b = new byte[26]; - prodosStream.Read(prodos_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(prodos_b); + byte[] prodosB = new byte[26]; + prodosStream.Read(prodosB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(prodosB); prodosStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) return true; } } // Check AppleDouble created by A/UX in UFS filesystem - if(File.Exists(UNIXAppleDouble)) + if(File.Exists(unixAppleDouble)) { - var unixStream = new FileStream(UNIXAppleDouble, FileMode.Open, FileAccess.Read); + var unixStream = new FileStream(unixAppleDouble, FileMode.Open, FileAccess.Read); if(unixStream.Length > 26) { - byte[] unix_b = new byte[26]; - unixStream.Read(unix_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(unix_b); + byte[] unixB = new byte[26]; + unixStream.Read(unixB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(unixB); unixStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) return true; } } // Check AppleDouble created by A/UX in FAT filesystem - if(File.Exists(DOSAppleDouble)) + if(File.Exists(dosAppleDouble)) { - var dosStream = new FileStream(DOSAppleDouble, FileMode.Open, FileAccess.Read); + var dosStream = new FileStream(dosAppleDouble, FileMode.Open, FileAccess.Read); if(dosStream.Length > 26) { - byte[] dos_b = new byte[26]; - dosStream.Read(dos_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(dos_b); + byte[] dosB = new byte[26]; + dosStream.Read(dosB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(dosB); dosStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) return true; } } // Check AppleDouble created by A/UX in case preserving FAT filesystem - if(File.Exists(DOSAppleDoubleLower)) + if(File.Exists(dosAppleDoubleLower)) { - var doslStream = new FileStream(DOSAppleDoubleLower, FileMode.Open, FileAccess.Read); + var doslStream = new FileStream(dosAppleDoubleLower, FileMode.Open, FileAccess.Read); if(doslStream.Length > 26) { - byte[] dosl_b = new byte[26]; - doslStream.Read(dosl_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(dosl_b); + byte[] doslB = new byte[26]; + doslStream.Read(doslB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(doslB); doslStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) return true; } } // Check AppleDouble created by Netatalk - if(File.Exists(NetatalkAppleDouble)) + if(File.Exists(netatalkAppleDouble)) { - var netatalkStream = new FileStream(NetatalkAppleDouble, FileMode.Open, FileAccess.Read); + var netatalkStream = new FileStream(netatalkAppleDouble, FileMode.Open, FileAccess.Read); if(netatalkStream.Length > 26) { - byte[] netatalk_b = new byte[26]; - netatalkStream.Read(netatalk_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(netatalk_b); + byte[] netatalkB = new byte[26]; + netatalkStream.Read(netatalkB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(netatalkB); netatalkStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) return true; } } // Check AppleDouble created by DAVE - if(File.Exists(DAVEAppleDouble)) + if(File.Exists(daveAppleDouble)) { - var daveStream = new FileStream(DAVEAppleDouble, FileMode.Open, FileAccess.Read); + var daveStream = new FileStream(daveAppleDouble, FileMode.Open, FileAccess.Read); if(daveStream.Length > 26) { - byte[] dave_b = new byte[26]; - daveStream.Read(dave_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(dave_b); + byte[] daveB = new byte[26]; + daveStream.Read(daveB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(daveB); daveStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) return true; } } // Check AppleDouble created by Mac OS X - if(File.Exists(OSXAppleDouble)) + if(File.Exists(osxAppleDouble)) { - var osxStream = new FileStream(OSXAppleDouble, FileMode.Open, FileAccess.Read); + var osxStream = new FileStream(osxAppleDouble, FileMode.Open, FileAccess.Read); if(osxStream.Length > 26) { - byte[] osx_b = new byte[26]; - osxStream.Read(osx_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(osx_b); + byte[] osxB = new byte[26]; + osxStream.Read(osxB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(osxB); osxStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) return true; } } // Check AppleDouble created by UnAr (from The Unarchiver) - if(!File.Exists(UnArAppleDouble)) + if(!File.Exists(unArAppleDouble)) return false; - var unarStream = new FileStream(UnArAppleDouble, FileMode.Open, FileAccess.Read); + var unarStream = new FileStream(unArAppleDouble, FileMode.Open, FileAccess.Read); if(unarStream.Length <= 26) return false; - byte[] unar_b = new byte[26]; - unarStream.Read(unar_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(unar_b); + byte[] unarB = new byte[26]; + unarStream.Read(unarB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(unarB); unarStream.Close(); - return header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2); + return _header.magic == MAGIC && (_header.version == VERSION || _header.version == VERSION2); } - public bool IsOpened() => opened; + public bool IsOpened() => _opened; // Now way to have two files in a single byte array public void Open(byte[] buffer) => throw new NotSupportedException(); @@ -325,191 +323,191 @@ namespace Aaru.Filters throw new ArgumentNullException(nameof(path)); // Prepend data fork name with "R." - string ProDosAppleDouble = Path.Combine(parentFolder, "R." + filename); + string proDosAppleDouble = Path.Combine(parentFolder, "R." + filename); // Prepend data fork name with '%' - string UNIXAppleDouble = Path.Combine(parentFolder, "%" + filename); + string unixAppleDouble = Path.Combine(parentFolder, "%" + filename); // Change file extension to ADF - string DOSAppleDouble = Path.Combine(parentFolder, filenameNoExt + ".ADF"); + string dosAppleDouble = Path.Combine(parentFolder, filenameNoExt + ".ADF"); // Change file extension to adf - string DOSAppleDoubleLower = Path.Combine(parentFolder, filenameNoExt + ".adf"); + string dosAppleDoubleLower = Path.Combine(parentFolder, filenameNoExt + ".adf"); // Store AppleDouble header file in ".AppleDouble" folder with same name - string NetatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", filename); + string netatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", filename); // Store AppleDouble header file in "resource.frk" folder with same name - string DAVEAppleDouble = Path.Combine(parentFolder, "resource.frk", filename); + string daveAppleDouble = Path.Combine(parentFolder, "resource.frk", filename); // Prepend data fork name with "._" - string OSXAppleDouble = Path.Combine(parentFolder, "._" + filename); + string osxAppleDouble = Path.Combine(parentFolder, "._" + filename); // Adds ".rsrc" extension - string UnArAppleDouble = Path.Combine(parentFolder, filename + ".rsrc"); + string unArAppleDouble = Path.Combine(parentFolder, filename + ".rsrc"); // Check AppleDouble created by A/UX in ProDOS filesystem - if(File.Exists(ProDosAppleDouble)) + if(File.Exists(proDosAppleDouble)) { - var prodosStream = new FileStream(ProDosAppleDouble, FileMode.Open, FileAccess.Read); + var prodosStream = new FileStream(proDosAppleDouble, FileMode.Open, FileAccess.Read); if(prodosStream.Length > 26) { - byte[] prodos_b = new byte[26]; - prodosStream.Read(prodos_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(prodos_b); + byte[] prodosB = new byte[26]; + prodosStream.Read(prodosB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(prodosB); prodosStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) - headerPath = ProDosAppleDouble; + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) + _headerPath = proDosAppleDouble; } } // Check AppleDouble created by A/UX in UFS filesystem - if(File.Exists(UNIXAppleDouble)) + if(File.Exists(unixAppleDouble)) { - var unixStream = new FileStream(UNIXAppleDouble, FileMode.Open, FileAccess.Read); + var unixStream = new FileStream(unixAppleDouble, FileMode.Open, FileAccess.Read); if(unixStream.Length > 26) { - byte[] unix_b = new byte[26]; - unixStream.Read(unix_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(unix_b); + byte[] unixB = new byte[26]; + unixStream.Read(unixB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(unixB); unixStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) - headerPath = UNIXAppleDouble; + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) + _headerPath = unixAppleDouble; } } // Check AppleDouble created by A/UX in FAT filesystem - if(File.Exists(DOSAppleDouble)) + if(File.Exists(dosAppleDouble)) { - var dosStream = new FileStream(DOSAppleDouble, FileMode.Open, FileAccess.Read); + var dosStream = new FileStream(dosAppleDouble, FileMode.Open, FileAccess.Read); if(dosStream.Length > 26) { - byte[] dos_b = new byte[26]; - dosStream.Read(dos_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(dos_b); + byte[] dosB = new byte[26]; + dosStream.Read(dosB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(dosB); dosStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) - headerPath = DOSAppleDouble; + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) + _headerPath = dosAppleDouble; } } // Check AppleDouble created by A/UX in case preserving FAT filesystem - if(File.Exists(DOSAppleDoubleLower)) + if(File.Exists(dosAppleDoubleLower)) { - var doslStream = new FileStream(DOSAppleDoubleLower, FileMode.Open, FileAccess.Read); + var doslStream = new FileStream(dosAppleDoubleLower, FileMode.Open, FileAccess.Read); if(doslStream.Length > 26) { - byte[] dosl_b = new byte[26]; - doslStream.Read(dosl_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(dosl_b); + byte[] doslB = new byte[26]; + doslStream.Read(doslB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(doslB); doslStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) - headerPath = DOSAppleDoubleLower; + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) + _headerPath = dosAppleDoubleLower; } } // Check AppleDouble created by Netatalk - if(File.Exists(NetatalkAppleDouble)) + if(File.Exists(netatalkAppleDouble)) { - var netatalkStream = new FileStream(NetatalkAppleDouble, FileMode.Open, FileAccess.Read); + var netatalkStream = new FileStream(netatalkAppleDouble, FileMode.Open, FileAccess.Read); if(netatalkStream.Length > 26) { - byte[] netatalk_b = new byte[26]; - netatalkStream.Read(netatalk_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(netatalk_b); + byte[] netatalkB = new byte[26]; + netatalkStream.Read(netatalkB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(netatalkB); netatalkStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) - headerPath = NetatalkAppleDouble; + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) + _headerPath = netatalkAppleDouble; } } // Check AppleDouble created by DAVE - if(File.Exists(DAVEAppleDouble)) + if(File.Exists(daveAppleDouble)) { - var daveStream = new FileStream(DAVEAppleDouble, FileMode.Open, FileAccess.Read); + var daveStream = new FileStream(daveAppleDouble, FileMode.Open, FileAccess.Read); if(daveStream.Length > 26) { - byte[] dave_b = new byte[26]; - daveStream.Read(dave_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(dave_b); + byte[] daveB = new byte[26]; + daveStream.Read(daveB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(daveB); daveStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) - headerPath = DAVEAppleDouble; + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) + _headerPath = daveAppleDouble; } } // Check AppleDouble created by Mac OS X - if(File.Exists(OSXAppleDouble)) + if(File.Exists(osxAppleDouble)) { - var osxStream = new FileStream(OSXAppleDouble, FileMode.Open, FileAccess.Read); + var osxStream = new FileStream(osxAppleDouble, FileMode.Open, FileAccess.Read); if(osxStream.Length > 26) { - byte[] osx_b = new byte[26]; - osxStream.Read(osx_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(osx_b); + byte[] osxB = new byte[26]; + osxStream.Read(osxB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(osxB); osxStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) - headerPath = OSXAppleDouble; + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) + _headerPath = osxAppleDouble; } } // Check AppleDouble created by UnAr (from The Unarchiver) - if(File.Exists(UnArAppleDouble)) + if(File.Exists(unArAppleDouble)) { - var unarStream = new FileStream(UnArAppleDouble, FileMode.Open, FileAccess.Read); + var unarStream = new FileStream(unArAppleDouble, FileMode.Open, FileAccess.Read); if(unarStream.Length > 26) { - byte[] unar_b = new byte[26]; - unarStream.Read(unar_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(unar_b); + byte[] unarB = new byte[26]; + unarStream.Read(unarB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(unarB); unarStream.Close(); - if(header.magic == AppleDoubleMagic && - (header.version == AppleDoubleVersion || header.version == AppleDoubleVersion2)) - headerPath = UnArAppleDouble; + if(_header.magic == MAGIC && + (_header.version == VERSION || _header.version == VERSION2)) + _headerPath = unArAppleDouble; } } - var fs = new FileStream(headerPath, FileMode.Open, FileAccess.Read); + var fs = new FileStream(_headerPath, FileMode.Open, FileAccess.Read); fs.Seek(0, SeekOrigin.Begin); - byte[] hdr_b = new byte[26]; - fs.Read(hdr_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + byte[] hdrB = new byte[26]; + fs.Read(hdrB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); - AppleDoubleEntry[] entries = new AppleDoubleEntry[header.entries]; + AppleDoubleEntry[] entries = new AppleDoubleEntry[_header.entries]; - for(int i = 0; i < header.entries; i++) + for(int i = 0; i < _header.entries; i++) { byte[] entry = new byte[12]; fs.Read(entry, 0, 12); entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } - creationTime = DateTime.UtcNow; - lastWriteTime = creationTime; + _creationTime = DateTime.UtcNow; + _lastWriteTime = _creationTime; foreach(AppleDoubleEntry entry in entries) switch((AppleDoubleEntryID)entry.id) @@ -519,14 +517,14 @@ namespace Aaru.Filters break; case AppleDoubleEntryID.FileDates: fs.Seek(entry.offset, SeekOrigin.Begin); - byte[] dates_b = new byte[16]; - fs.Read(dates_b, 0, 16); + byte[] datesB = new byte[16]; + fs.Read(datesB, 0, 16); AppleDoubleFileDates dates = - Marshal.ByteArrayToStructureBigEndian(dates_b); + Marshal.ByteArrayToStructureBigEndian(datesB); - creationTime = DateHandlers.UnixUnsignedToDateTime(dates.creationDate); - lastWriteTime = DateHandlers.UnixUnsignedToDateTime(dates.modificationDate); + _creationTime = DateHandlers.UnixUnsignedToDateTime(dates.creationDate); + _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(dates.modificationDate); break; case AppleDoubleEntryID.FileInfo: @@ -534,47 +532,47 @@ namespace Aaru.Filters byte[] finfo = new byte[entry.length]; fs.Read(finfo, 0, finfo.Length); - if(MacintoshHome.SequenceEqual(header.homeFilesystem)) + if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) { AppleDoubleMacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); - lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); + _creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); + _lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); } - else if(ProDOSHome.SequenceEqual(header.homeFilesystem)) + else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { AppleDoubleProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); - lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); + _creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); + _lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); } - else if(UNIXHome.SequenceEqual(header.homeFilesystem)) + else if(_unixHome.SequenceEqual(_header.homeFilesystem)) { - AppleDoubleUNIXFileInfo unixinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + AppleDoubleUnixFileInfo unixinfo = + Marshal.ByteArrayToStructureBigEndian(finfo); - creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); - lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); + _creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); + _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); } - else if(DOSHome.SequenceEqual(header.homeFilesystem)) + else if(_dosHome.SequenceEqual(_header.homeFilesystem)) { AppleDoubleDOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - lastWriteTime = + _lastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } break; case AppleDoubleEntryID.ResourceFork: - rsrcFork = entry; + _rsrcFork = entry; break; } - dataFork = new AppleDoubleEntry + _dataFork = new AppleDoubleEntry { id = (uint)AppleDoubleEntryID.DataFork }; @@ -582,13 +580,13 @@ namespace Aaru.Filters if(File.Exists(path)) { var dataFs = new FileStream(path, FileMode.Open, FileAccess.Read); - dataFork.length = (uint)dataFs.Length; + _dataFork.length = (uint)dataFs.Length; dataFs.Close(); } fs.Close(); - opened = true; - basePath = path; + _opened = true; + _basePath = path; } enum AppleDoubleEntryID : uint @@ -597,7 +595,7 @@ namespace Aaru.Filters RealName = 3, Comment = 4, Icon = 5, ColorIcon = 6, FileInfo = 7, FileDates = 8, FinderInfo = 9, MacFileInfo = 10, ProDOSFileInfo = 11, - DOSFileInfo = 12, ShortName = 13, AFPFileInfo = 14, + DOSFileInfo = 12, ShortName = 13, AfpFileInfo = 14, DirectoryID = 15 } @@ -638,7 +636,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleDoubleUNIXFileInfo + struct AppleDoubleUnixFileInfo { public readonly uint creationDate; public readonly uint accessDate; diff --git a/Aaru.Filters/AppleSingle.cs b/Aaru.Filters/AppleSingle.cs index e1651a2de..1d4fcea7e 100644 --- a/Aaru.Filters/AppleSingle.cs +++ b/Aaru.Filters/AppleSingle.cs @@ -45,44 +45,43 @@ namespace Aaru.Filters [SuppressMessage("ReSharper", "UnusedMember.Local")] public class AppleSingle : IFilter { - const uint AppleSingleMagic = 0x00051600; - const uint AppleSingleVersion = 0x00010000; - const uint AppleSingleVersion2 = 0x00020000; - readonly byte[] DOSHome = + const uint MAGIC = 0x00051600; + const uint VERSION = 0x00010000; + const uint VERSION2 = 0x00020000; + readonly byte[] _dosHome = { 0x4D, 0x53, 0x2D, 0x44, 0x4F, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - readonly byte[] MacintoshHome = + readonly byte[] _macintoshHome = { 0x4D, 0x61, 0x63, 0x69, 0x6E, 0x74, 0x6F, 0x73, 0x68, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - readonly byte[] OSXHome = + readonly byte[] _osxHome = { 0x4D, 0x61, 0x63, 0x20, 0x4F, 0x53, 0x20, 0x58, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - readonly byte[] ProDOSHome = + readonly byte[] _proDosHome = { 0x50, 0x72, 0x6F, 0x44, 0x4F, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - readonly byte[] UNIXHome = + readonly byte[] _unixHome = { 0x55, 0x6E, 0x69, 0x78, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - readonly byte[] VMSHome = + readonly byte[] _vmsHome = { 0x56, 0x41, 0x58, 0x20, 0x56, 0x4D, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - string basePath; - byte[] bytes; - DateTime creationTime; - - AppleSingleEntry dataFork; - AppleSingleHeader header; - bool isBytes, isStream, isPath, opened; - DateTime lastWriteTime; - AppleSingleEntry rsrcFork; - Stream stream; + string _basePath; + byte[] _bytes; + DateTime _creationTime; + AppleSingleEntry _dataFork; + AppleSingleHeader _header; + bool _isBytes, _isStream, _isPath, _opened; + DateTime _lastWriteTime; + AppleSingleEntry _rsrcFork; + Stream _stream; public string Name => "AppleSingle"; public Guid Id => new Guid("A69B20E8-F4D3-42BB-BD2B-4A7263394A05"); @@ -90,69 +89,69 @@ namespace Aaru.Filters public void Close() { - bytes = null; - stream?.Close(); - isBytes = false; - isStream = false; - isPath = false; - opened = false; + _bytes = null; + _stream?.Close(); + _isBytes = false; + _isStream = false; + _isPath = false; + _opened = false; } - public string GetBasePath() => basePath; + public string GetBasePath() => _basePath; - public DateTime GetCreationTime() => creationTime; + public DateTime GetCreationTime() => _creationTime; - public long GetDataForkLength() => dataFork.length; + public long GetDataForkLength() => _dataFork.length; public Stream GetDataForkStream() { - if(dataFork.length == 0) + if(_dataFork.length == 0) return null; - if(isBytes) - return new OffsetStream(bytes, dataFork.offset, (dataFork.offset + dataFork.length) - 1); + if(_isBytes) + return new OffsetStream(_bytes, _dataFork.offset, (_dataFork.offset + _dataFork.length) - 1); - if(isStream) - return new OffsetStream(stream, dataFork.offset, (dataFork.offset + dataFork.length) - 1); + if(_isStream) + return new OffsetStream(_stream, _dataFork.offset, (_dataFork.offset + _dataFork.length) - 1); - if(isPath) - return new OffsetStream(basePath, FileMode.Open, FileAccess.Read, dataFork.offset, - (dataFork.offset + dataFork.length) - 1); + if(_isPath) + return new OffsetStream(_basePath, FileMode.Open, FileAccess.Read, _dataFork.offset, + (_dataFork.offset + _dataFork.length) - 1); return null; } - public string GetFilename() => Path.GetFileName(basePath); + public string GetFilename() => Path.GetFileName(_basePath); - public DateTime GetLastWriteTime() => lastWriteTime; + public DateTime GetLastWriteTime() => _lastWriteTime; - public long GetLength() => dataFork.length + rsrcFork.length; + public long GetLength() => _dataFork.length + _rsrcFork.length; - public string GetParentFolder() => Path.GetDirectoryName(basePath); + public string GetParentFolder() => Path.GetDirectoryName(_basePath); - public string GetPath() => basePath; + public string GetPath() => _basePath; - public long GetResourceForkLength() => rsrcFork.length; + public long GetResourceForkLength() => _rsrcFork.length; public Stream GetResourceForkStream() { - if(rsrcFork.length == 0) + if(_rsrcFork.length == 0) return null; - if(isBytes) - return new OffsetStream(bytes, rsrcFork.offset, (rsrcFork.offset + rsrcFork.length) - 1); + if(_isBytes) + return new OffsetStream(_bytes, _rsrcFork.offset, (_rsrcFork.offset + _rsrcFork.length) - 1); - if(isStream) - return new OffsetStream(stream, rsrcFork.offset, (rsrcFork.offset + rsrcFork.length) - 1); + if(_isStream) + return new OffsetStream(_stream, _rsrcFork.offset, (_rsrcFork.offset + _rsrcFork.length) - 1); - if(isPath) - return new OffsetStream(basePath, FileMode.Open, FileAccess.Read, rsrcFork.offset, - (rsrcFork.offset + rsrcFork.length) - 1); + if(_isPath) + return new OffsetStream(_basePath, FileMode.Open, FileAccess.Read, _rsrcFork.offset, + (_rsrcFork.offset + _rsrcFork.length) - 1); return null; } - public bool HasResourceFork() => rsrcFork.length > 0; + public bool HasResourceFork() => _rsrcFork.length > 0; public bool Identify(byte[] buffer) { @@ -160,12 +159,11 @@ namespace Aaru.Filters buffer.Length < 26) return false; - byte[] hdr_b = new byte[26]; - Array.Copy(buffer, 0, hdr_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + byte[] hdrB = new byte[26]; + Array.Copy(buffer, 0, hdrB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); - return header.magic == AppleSingleMagic && - (header.version == AppleSingleVersion || header.version == AppleSingleVersion2); + return _header.magic == MAGIC && (_header.version == VERSION || _header.version == VERSION2); } public bool Identify(Stream stream) @@ -174,13 +172,12 @@ namespace Aaru.Filters stream.Length < 26) return false; - byte[] hdr_b = new byte[26]; + byte[] hdrB = new byte[26]; stream.Seek(0, SeekOrigin.Begin); - stream.Read(hdr_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + stream.Read(hdrB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); - return header.magic == AppleSingleMagic && - (header.version == AppleSingleVersion || header.version == AppleSingleVersion2); + return _header.magic == MAGIC && (_header.version == VERSION || _header.version == VERSION2); } public bool Identify(string path) @@ -190,56 +187,55 @@ namespace Aaru.Filters if(fstream.Length < 26) return false; - byte[] hdr_b = new byte[26]; - fstream.Read(hdr_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + byte[] hdrB = new byte[26]; + fstream.Read(hdrB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); fstream.Close(); - return header.magic == AppleSingleMagic && - (header.version == AppleSingleVersion || header.version == AppleSingleVersion2); + return _header.magic == MAGIC && (_header.version == VERSION || _header.version == VERSION2); } - public bool IsOpened() => opened; + public bool IsOpened() => _opened; public void Open(byte[] buffer) { var ms = new MemoryStream(buffer); ms.Seek(0, SeekOrigin.Begin); - byte[] hdr_b = new byte[26]; - ms.Read(hdr_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + byte[] hdrB = new byte[26]; + ms.Read(hdrB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); - AppleSingleEntry[] entries = new AppleSingleEntry[header.entries]; + AppleSingleEntry[] entries = new AppleSingleEntry[_header.entries]; - for(int i = 0; i < header.entries; i++) + for(int i = 0; i < _header.entries; i++) { byte[] entry = new byte[12]; ms.Read(entry, 0, 12); entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } - creationTime = DateTime.UtcNow; - lastWriteTime = creationTime; + _creationTime = DateTime.UtcNow; + _lastWriteTime = _creationTime; foreach(AppleSingleEntry entry in entries) switch((AppleSingleEntryID)entry.id) { case AppleSingleEntryID.DataFork: - dataFork = entry; + _dataFork = entry; break; case AppleSingleEntryID.FileDates: ms.Seek(entry.offset, SeekOrigin.Begin); - byte[] dates_b = new byte[16]; - ms.Read(dates_b, 0, 16); + byte[] datesB = new byte[16]; + ms.Read(datesB, 0, 16); AppleSingleFileDates dates = - Marshal.ByteArrayToStructureBigEndian(dates_b); + Marshal.ByteArrayToStructureBigEndian(datesB); - creationTime = DateHandlers.UnixUnsignedToDateTime(dates.creationDate); - lastWriteTime = DateHandlers.UnixUnsignedToDateTime(dates.modificationDate); + _creationTime = DateHandlers.UnixUnsignedToDateTime(dates.creationDate); + _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(dates.modificationDate); break; case AppleSingleEntryID.FileInfo: @@ -247,89 +243,89 @@ namespace Aaru.Filters byte[] finfo = new byte[entry.length]; ms.Read(finfo, 0, finfo.Length); - if(MacintoshHome.SequenceEqual(header.homeFilesystem)) + if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) { AppleSingleMacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); - lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); + _creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); + _lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); } - else if(ProDOSHome.SequenceEqual(header.homeFilesystem)) + else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { AppleSingleProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); - lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); + _creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); + _lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); } - else if(UNIXHome.SequenceEqual(header.homeFilesystem)) + else if(_unixHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleUNIXFileInfo unixinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + AppleSingleUnixFileInfo unixinfo = + Marshal.ByteArrayToStructureBigEndian(finfo); - creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); - lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); + _creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); + _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); } - else if(DOSHome.SequenceEqual(header.homeFilesystem)) + else if(_dosHome.SequenceEqual(_header.homeFilesystem)) { AppleSingleDOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - lastWriteTime = + _lastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } break; case AppleSingleEntryID.ResourceFork: - rsrcFork = entry; + _rsrcFork = entry; break; } ms.Close(); - opened = true; - isBytes = true; - bytes = buffer; + _opened = true; + _isBytes = true; + _bytes = buffer; } public void Open(Stream stream) { stream.Seek(0, SeekOrigin.Begin); - byte[] hdr_b = new byte[26]; - stream.Read(hdr_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + byte[] hdrB = new byte[26]; + stream.Read(hdrB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); - AppleSingleEntry[] entries = new AppleSingleEntry[header.entries]; + AppleSingleEntry[] entries = new AppleSingleEntry[_header.entries]; - for(int i = 0; i < header.entries; i++) + for(int i = 0; i < _header.entries; i++) { byte[] entry = new byte[12]; stream.Read(entry, 0, 12); entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } - creationTime = DateTime.UtcNow; - lastWriteTime = creationTime; + _creationTime = DateTime.UtcNow; + _lastWriteTime = _creationTime; foreach(AppleSingleEntry entry in entries) switch((AppleSingleEntryID)entry.id) { case AppleSingleEntryID.DataFork: - dataFork = entry; + _dataFork = entry; break; case AppleSingleEntryID.FileDates: stream.Seek(entry.offset, SeekOrigin.Begin); - byte[] dates_b = new byte[16]; - stream.Read(dates_b, 0, 16); + byte[] datesB = new byte[16]; + stream.Read(datesB, 0, 16); AppleSingleFileDates dates = - Marshal.ByteArrayToStructureBigEndian(dates_b); + Marshal.ByteArrayToStructureBigEndian(datesB); - creationTime = DateHandlers.MacToDateTime(dates.creationDate); - lastWriteTime = DateHandlers.MacToDateTime(dates.modificationDate); + _creationTime = DateHandlers.MacToDateTime(dates.creationDate); + _lastWriteTime = DateHandlers.MacToDateTime(dates.modificationDate); break; case AppleSingleEntryID.FileInfo: @@ -337,50 +333,50 @@ namespace Aaru.Filters byte[] finfo = new byte[entry.length]; stream.Read(finfo, 0, finfo.Length); - if(MacintoshHome.SequenceEqual(header.homeFilesystem)) + if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) { AppleSingleMacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); - lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); + _creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); + _lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); } - else if(ProDOSHome.SequenceEqual(header.homeFilesystem)) + else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { AppleSingleProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); - lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); + _creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); + _lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); } - else if(UNIXHome.SequenceEqual(header.homeFilesystem)) + else if(_unixHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleUNIXFileInfo unixinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + AppleSingleUnixFileInfo unixinfo = + Marshal.ByteArrayToStructureBigEndian(finfo); - creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); - lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); + _creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); + _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); } - else if(DOSHome.SequenceEqual(header.homeFilesystem)) + else if(_dosHome.SequenceEqual(_header.homeFilesystem)) { AppleSingleDOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - lastWriteTime = + _lastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } break; case AppleSingleEntryID.ResourceFork: - rsrcFork = entry; + _rsrcFork = entry; break; } stream.Seek(0, SeekOrigin.Begin); - opened = true; - isStream = true; - this.stream = stream; + _opened = true; + _isStream = true; + _stream = stream; } public void Open(string path) @@ -388,39 +384,39 @@ namespace Aaru.Filters var fs = new FileStream(path, FileMode.Open, FileAccess.Read); fs.Seek(0, SeekOrigin.Begin); - byte[] hdr_b = new byte[26]; - fs.Read(hdr_b, 0, 26); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + byte[] hdrB = new byte[26]; + fs.Read(hdrB, 0, 26); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); - AppleSingleEntry[] entries = new AppleSingleEntry[header.entries]; + AppleSingleEntry[] entries = new AppleSingleEntry[_header.entries]; - for(int i = 0; i < header.entries; i++) + for(int i = 0; i < _header.entries; i++) { byte[] entry = new byte[12]; fs.Read(entry, 0, 12); entries[i] = Marshal.ByteArrayToStructureBigEndian(entry); } - creationTime = DateTime.UtcNow; - lastWriteTime = creationTime; + _creationTime = DateTime.UtcNow; + _lastWriteTime = _creationTime; foreach(AppleSingleEntry entry in entries) switch((AppleSingleEntryID)entry.id) { case AppleSingleEntryID.DataFork: - dataFork = entry; + _dataFork = entry; break; case AppleSingleEntryID.FileDates: fs.Seek(entry.offset, SeekOrigin.Begin); - byte[] dates_b = new byte[16]; - fs.Read(dates_b, 0, 16); + byte[] datesB = new byte[16]; + fs.Read(datesB, 0, 16); AppleSingleFileDates dates = - Marshal.ByteArrayToStructureBigEndian(dates_b); + Marshal.ByteArrayToStructureBigEndian(datesB); - creationTime = DateHandlers.MacToDateTime(dates.creationDate); - lastWriteTime = DateHandlers.MacToDateTime(dates.modificationDate); + _creationTime = DateHandlers.MacToDateTime(dates.creationDate); + _lastWriteTime = DateHandlers.MacToDateTime(dates.modificationDate); break; case AppleSingleEntryID.FileInfo: @@ -428,50 +424,50 @@ namespace Aaru.Filters byte[] finfo = new byte[entry.length]; fs.Read(finfo, 0, finfo.Length); - if(MacintoshHome.SequenceEqual(header.homeFilesystem)) + if(_macintoshHome.SequenceEqual(_header.homeFilesystem)) { AppleSingleMacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); - lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); + _creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); + _lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); } - else if(ProDOSHome.SequenceEqual(header.homeFilesystem)) + else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { AppleSingleProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); - lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); + _creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); + _lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); } - else if(UNIXHome.SequenceEqual(header.homeFilesystem)) + else if(_unixHome.SequenceEqual(_header.homeFilesystem)) { - AppleSingleUNIXFileInfo unixinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + AppleSingleUnixFileInfo unixinfo = + Marshal.ByteArrayToStructureBigEndian(finfo); - creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); - lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); + _creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); + _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); } - else if(DOSHome.SequenceEqual(header.homeFilesystem)) + else if(_dosHome.SequenceEqual(_header.homeFilesystem)) { AppleSingleDOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); - lastWriteTime = + _lastWriteTime = DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); } break; case AppleSingleEntryID.ResourceFork: - rsrcFork = entry; + _rsrcFork = entry; break; } fs.Close(); - opened = true; - isPath = true; - basePath = path; + _opened = true; + _isPath = true; + _basePath = path; } enum AppleSingleEntryID : uint @@ -480,7 +476,7 @@ namespace Aaru.Filters RealName = 3, Comment = 4, Icon = 5, ColorIcon = 6, FileInfo = 7, FileDates = 8, FinderInfo = 9, MacFileInfo = 10, ProDOSFileInfo = 11, - DOSFileInfo = 12, ShortName = 13, AFPFileInfo = 14, + DOSFileInfo = 12, ShortName = 13, AfpFileInfo = 14, DirectoryID = 15 } @@ -521,7 +517,7 @@ namespace Aaru.Filters } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AppleSingleUNIXFileInfo + struct AppleSingleUnixFileInfo { public readonly uint creationDate; public readonly uint accessDate; diff --git a/Aaru.Filters/BZip2.cs b/Aaru.Filters/BZip2.cs index a90258a48..de12702a1 100644 --- a/Aaru.Filters/BZip2.cs +++ b/Aaru.Filters/BZip2.cs @@ -41,13 +41,13 @@ namespace Aaru.Filters /// Decompress bz2 files while reading public class BZip2 : IFilter { - string basePath; - DateTime creationTime; - Stream dataStream; - long decompressedSize; - Stream innerStream; - DateTime lastWriteTime; - bool opened; + string _basePath; + DateTime _creationTime; + Stream _dataStream; + long _decompressedSize; + Stream _innerStream; + DateTime _lastWriteTime; + bool _opened; public string Name => "BZip2"; public Guid Id => new Guid("FCCFB0C3-32EF-40D8-9714-2333F6AC72A9"); @@ -55,17 +55,17 @@ namespace Aaru.Filters public void Close() { - dataStream?.Close(); - dataStream = null; - basePath = null; - opened = false; + _dataStream?.Close(); + _dataStream = null; + _basePath = null; + _opened = false; } - public string GetBasePath() => basePath; + public string GetBasePath() => _basePath; - public Stream GetDataForkStream() => innerStream; + public Stream GetDataForkStream() => _innerStream; - public string GetPath() => basePath; + public string GetPath() => _basePath; public Stream GetResourceForkStream() => null; @@ -144,60 +144,60 @@ namespace Aaru.Filters public void Open(byte[] buffer) { - dataStream = new MemoryStream(buffer); - basePath = null; - creationTime = DateTime.UtcNow; - lastWriteTime = creationTime; - innerStream = new ForcedSeekStream(dataStream, CompressionMode.Decompress, false); - decompressedSize = innerStream.Length; - opened = true; + _dataStream = new MemoryStream(buffer); + _basePath = null; + _creationTime = DateTime.UtcNow; + _lastWriteTime = _creationTime; + _innerStream = new ForcedSeekStream(_dataStream, CompressionMode.Decompress, false); + _decompressedSize = _innerStream.Length; + _opened = true; } public void Open(Stream stream) { - dataStream = stream; - basePath = null; - creationTime = DateTime.UtcNow; - lastWriteTime = creationTime; - innerStream = new ForcedSeekStream(dataStream, CompressionMode.Decompress, false); - decompressedSize = innerStream.Length; - opened = true; + _dataStream = stream; + _basePath = null; + _creationTime = DateTime.UtcNow; + _lastWriteTime = _creationTime; + _innerStream = new ForcedSeekStream(_dataStream, CompressionMode.Decompress, false); + _decompressedSize = _innerStream.Length; + _opened = true; } public void Open(string path) { - dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); - basePath = Path.GetFullPath(path); + _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); + _basePath = Path.GetFullPath(path); var fi = new FileInfo(path); - creationTime = fi.CreationTimeUtc; - lastWriteTime = fi.LastWriteTimeUtc; - innerStream = new ForcedSeekStream(dataStream, CompressionMode.Decompress, false); - decompressedSize = innerStream.Length; - opened = true; + _creationTime = fi.CreationTimeUtc; + _lastWriteTime = fi.LastWriteTimeUtc; + _innerStream = new ForcedSeekStream(_dataStream, CompressionMode.Decompress, false); + _decompressedSize = _innerStream.Length; + _opened = true; } - public DateTime GetCreationTime() => creationTime; + public DateTime GetCreationTime() => _creationTime; - public long GetDataForkLength() => decompressedSize; + public long GetDataForkLength() => _decompressedSize; - public DateTime GetLastWriteTime() => lastWriteTime; + public DateTime GetLastWriteTime() => _lastWriteTime; - public long GetLength() => decompressedSize; + public long GetLength() => _decompressedSize; public long GetResourceForkLength() => 0; public string GetFilename() { - if(basePath?.EndsWith(".bz2", StringComparison.InvariantCultureIgnoreCase) == true) - return basePath.Substring(0, basePath.Length - 4); + if(_basePath?.EndsWith(".bz2", StringComparison.InvariantCultureIgnoreCase) == true) + return _basePath.Substring(0, _basePath.Length - 4); - return basePath?.EndsWith(".bzip2", StringComparison.InvariantCultureIgnoreCase) == true - ? basePath.Substring(0, basePath.Length - 6) : basePath; + return _basePath?.EndsWith(".bzip2", StringComparison.InvariantCultureIgnoreCase) == true + ? _basePath.Substring(0, _basePath.Length - 6) : _basePath; } - public string GetParentFolder() => Path.GetDirectoryName(basePath); + public string GetParentFolder() => Path.GetDirectoryName(_basePath); - public bool IsOpened() => opened; + public bool IsOpened() => _opened; } } \ No newline at end of file diff --git a/Aaru.Filters/ForcedSeekStream.cs b/Aaru.Filters/ForcedSeekStream.cs index fbb4a7b4d..7679117dc 100644 --- a/Aaru.Filters/ForcedSeekStream.cs +++ b/Aaru.Filters/ForcedSeekStream.cs @@ -42,20 +42,20 @@ namespace Aaru.Filters public class ForcedSeekStream : Stream where T : Stream { const int BUFFER_LEN = 1048576; - readonly string backFile; - readonly FileStream backStream; - readonly T baseStream; - long streamLength; + readonly string _backFile; + readonly FileStream _backStream; + readonly T _baseStream; + long _streamLength; /// Initializes a new instance of the class. /// The real (uncompressed) length of the stream. /// Parameters that are used to create the base stream. public ForcedSeekStream(long length, params object[] args) { - streamLength = length; - baseStream = (T)Activator.CreateInstance(typeof(T), args); - backFile = Path.GetTempFileName(); - backStream = new FileStream(backFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None); + _streamLength = length; + _baseStream = (T)Activator.CreateInstance(typeof(T), args); + _backFile = Path.GetTempFileName(); + _backStream = new FileStream(_backFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None); if(length == 0) CalculateLength(); @@ -65,23 +65,23 @@ namespace Aaru.Filters /// Parameters that are used to create the base stream. public ForcedSeekStream(params object[] args) { - baseStream = (T)Activator.CreateInstance(typeof(T), args); - backFile = Path.GetTempFileName(); - backStream = new FileStream(backFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None); + _baseStream = (T)Activator.CreateInstance(typeof(T), args); + _backFile = Path.GetTempFileName(); + _backStream = new FileStream(_backFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None); CalculateLength(); } - public override bool CanRead => baseStream.CanRead; + public override bool CanRead => _baseStream.CanRead; public override bool CanSeek => true; public override bool CanWrite => false; - public override long Length => streamLength; + public override long Length => _streamLength; public override long Position { - get => backStream.Position; + get => _backStream.Position; set => SetPosition(value); } @@ -98,28 +98,28 @@ namespace Aaru.Filters do { byte[] buffer = new byte[BUFFER_LEN]; - read = baseStream.Read(buffer, 0, BUFFER_LEN); - backStream.Write(buffer, 0, read); + read = _baseStream.Read(buffer, 0, BUFFER_LEN); + _backStream.Write(buffer, 0, read); } while(read == BUFFER_LEN); - streamLength = backStream.Length; - backStream.Position = 0; + _streamLength = _backStream.Length; + _backStream.Position = 0; } void SetPosition(long position) { - if(position == backStream.Position) + if(position == _backStream.Position) return; - if(position < backStream.Length) + if(position < _backStream.Length) { - backStream.Position = position; + _backStream.Position = position; return; } - backStream.Position = backStream.Length; - long toposition = position - backStream.Position; + _backStream.Position = _backStream.Length; + long toposition = position - _backStream.Position; int fullBufferReads = (int)(toposition / BUFFER_LEN); int restToRead = (int)(toposition % BUFFER_LEN); byte[] buffer; @@ -127,41 +127,41 @@ namespace Aaru.Filters for(int i = 0; i < fullBufferReads; i++) { buffer = new byte[BUFFER_LEN]; - baseStream.Read(buffer, 0, BUFFER_LEN); - backStream.Write(buffer, 0, BUFFER_LEN); + _baseStream.Read(buffer, 0, BUFFER_LEN); + _backStream.Write(buffer, 0, BUFFER_LEN); } buffer = new byte[restToRead]; - baseStream.Read(buffer, 0, restToRead); - backStream.Write(buffer, 0, restToRead); + _baseStream.Read(buffer, 0, restToRead); + _backStream.Write(buffer, 0, restToRead); } public override void Flush() { - baseStream.Flush(); - backStream.Flush(); + _baseStream.Flush(); + _backStream.Flush(); } public override int Read(byte[] buffer, int offset, int count) { - if(backStream.Position + count <= backStream.Length) - return backStream.Read(buffer, offset, count); + if(_backStream.Position + count <= _backStream.Length) + return _backStream.Read(buffer, offset, count); - SetPosition(backStream.Position + count); - SetPosition(backStream.Position - count); + SetPosition(_backStream.Position + count); + SetPosition(_backStream.Position - count); - return backStream.Read(buffer, offset, count); + return _backStream.Read(buffer, offset, count); } public override int ReadByte() { - if(backStream.Position + 1 <= backStream.Length) - return backStream.ReadByte(); + if(_backStream.Position + 1 <= _backStream.Length) + return _backStream.ReadByte(); - SetPosition(backStream.Position + 1); - SetPosition(backStream.Position - 1); + SetPosition(_backStream.Position + 1); + SetPosition(_backStream.Position - 1); - return backStream.ReadByte(); + return _backStream.ReadByte(); } public override long Seek(long offset, SeekOrigin origin) @@ -179,19 +179,19 @@ namespace Aaru.Filters if(offset > 0) throw new IOException("Cannot seek after stream end."); - if(streamLength == 0) + if(_streamLength == 0) CalculateLength(); - SetPosition(streamLength + offset); + SetPosition(_streamLength + offset); break; default: - SetPosition(backStream.Position + offset); + SetPosition(_backStream.Position + offset); break; } - return backStream.Position; + return _backStream.Position; } public override void SetLength(long value) => throw new NotSupportedException(); @@ -200,14 +200,14 @@ namespace Aaru.Filters public override void Close() { - backStream?.Close(); - File.Delete(backFile); + _backStream?.Close(); + File.Delete(_backFile); } ~ForcedSeekStream() { - backStream?.Close(); - File.Delete(backFile); + _backStream?.Close(); + File.Delete(_backFile); } } } \ No newline at end of file diff --git a/Aaru.Filters/GZip.cs b/Aaru.Filters/GZip.cs index 77027dd88..1b57e972a 100644 --- a/Aaru.Filters/GZip.cs +++ b/Aaru.Filters/GZip.cs @@ -41,13 +41,13 @@ namespace Aaru.Filters /// Decompress gzip files while reading public class GZip : IFilter { - string basePath; - DateTime creationTime; - Stream dataStream; - uint decompressedSize; - DateTime lastWriteTime; - bool opened; - Stream zStream; + string _basePath; + DateTime _creationTime; + Stream _dataStream; + uint _decompressedSize; + DateTime _lastWriteTime; + bool _opened; + Stream _zStream; public string Name => "GZip"; public Guid Id => new Guid("F4996661-4A29-42C9-A2C7-3904EF40F3B0"); @@ -55,17 +55,17 @@ namespace Aaru.Filters public void Close() { - dataStream?.Close(); - dataStream = null; - basePath = null; - opened = false; + _dataStream?.Close(); + _dataStream = null; + _basePath = null; + _opened = false; } - public string GetBasePath() => basePath; + public string GetBasePath() => _basePath; - public Stream GetDataForkStream() => zStream; + public Stream GetDataForkStream() => _zStream; - public string GetPath() => basePath; + public string GetPath() => _basePath; public Stream GetResourceForkStream() => null; @@ -101,102 +101,102 @@ namespace Aaru.Filters public void Open(byte[] buffer) { - byte[] mtime_b = new byte[4]; - byte[] isize_b = new byte[4]; + byte[] mtimeB = new byte[4]; + byte[] isizeB = new byte[4]; - dataStream = new MemoryStream(buffer); - basePath = null; + _dataStream = new MemoryStream(buffer); + _basePath = null; - dataStream.Seek(4, SeekOrigin.Begin); - dataStream.Read(mtime_b, 0, 4); - dataStream.Seek(-4, SeekOrigin.End); - dataStream.Read(isize_b, 0, 4); - dataStream.Seek(0, SeekOrigin.Begin); + _dataStream.Seek(4, SeekOrigin.Begin); + _dataStream.Read(mtimeB, 0, 4); + _dataStream.Seek(-4, SeekOrigin.End); + _dataStream.Read(isizeB, 0, 4); + _dataStream.Seek(0, SeekOrigin.Begin); - uint mtime = BitConverter.ToUInt32(mtime_b, 0); - uint isize = BitConverter.ToUInt32(isize_b, 0); + uint mtime = BitConverter.ToUInt32(mtimeB, 0); + uint isize = BitConverter.ToUInt32(isizeB, 0); - decompressedSize = isize; - creationTime = DateHandlers.UnixUnsignedToDateTime(mtime); - lastWriteTime = creationTime; + _decompressedSize = isize; + _creationTime = DateHandlers.UnixUnsignedToDateTime(mtime); + _lastWriteTime = _creationTime; - zStream = new ForcedSeekStream(decompressedSize, dataStream, CompressionMode.Decompress); + _zStream = new ForcedSeekStream(_decompressedSize, _dataStream, CompressionMode.Decompress); - opened = true; + _opened = true; } public void Open(Stream stream) { - byte[] mtime_b = new byte[4]; - byte[] isize_b = new byte[4]; + byte[] mtimeB = new byte[4]; + byte[] isizeB = new byte[4]; - dataStream = stream; - basePath = null; + _dataStream = stream; + _basePath = null; - dataStream.Seek(4, SeekOrigin.Begin); - dataStream.Read(mtime_b, 0, 4); - dataStream.Seek(-4, SeekOrigin.End); - dataStream.Read(isize_b, 0, 4); - dataStream.Seek(0, SeekOrigin.Begin); + _dataStream.Seek(4, SeekOrigin.Begin); + _dataStream.Read(mtimeB, 0, 4); + _dataStream.Seek(-4, SeekOrigin.End); + _dataStream.Read(isizeB, 0, 4); + _dataStream.Seek(0, SeekOrigin.Begin); - uint mtime = BitConverter.ToUInt32(mtime_b, 0); - uint isize = BitConverter.ToUInt32(isize_b, 0); + uint mtime = BitConverter.ToUInt32(mtimeB, 0); + uint isize = BitConverter.ToUInt32(isizeB, 0); - decompressedSize = isize; - creationTime = DateHandlers.UnixUnsignedToDateTime(mtime); - lastWriteTime = creationTime; + _decompressedSize = isize; + _creationTime = DateHandlers.UnixUnsignedToDateTime(mtime); + _lastWriteTime = _creationTime; - zStream = new ForcedSeekStream(decompressedSize, dataStream, CompressionMode.Decompress); + _zStream = new ForcedSeekStream(_decompressedSize, _dataStream, CompressionMode.Decompress); - opened = true; + _opened = true; } public void Open(string path) { - byte[] mtime_b = new byte[4]; - byte[] isize_b = new byte[4]; + byte[] mtimeB = new byte[4]; + byte[] isizeB = new byte[4]; - dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); - basePath = Path.GetFullPath(path); + _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); + _basePath = Path.GetFullPath(path); - dataStream.Seek(4, SeekOrigin.Begin); - dataStream.Read(mtime_b, 0, 4); - dataStream.Seek(-4, SeekOrigin.End); - dataStream.Read(isize_b, 0, 4); - dataStream.Seek(0, SeekOrigin.Begin); + _dataStream.Seek(4, SeekOrigin.Begin); + _dataStream.Read(mtimeB, 0, 4); + _dataStream.Seek(-4, SeekOrigin.End); + _dataStream.Read(isizeB, 0, 4); + _dataStream.Seek(0, SeekOrigin.Begin); - uint mtime = BitConverter.ToUInt32(mtime_b, 0); - uint isize = BitConverter.ToUInt32(isize_b, 0); + uint mtime = BitConverter.ToUInt32(mtimeB, 0); + uint isize = BitConverter.ToUInt32(isizeB, 0); - decompressedSize = isize; + _decompressedSize = isize; var fi = new FileInfo(path); - creationTime = fi.CreationTimeUtc; - lastWriteTime = DateHandlers.UnixUnsignedToDateTime(mtime); - zStream = new ForcedSeekStream(decompressedSize, dataStream, CompressionMode.Decompress); - opened = true; + _creationTime = fi.CreationTimeUtc; + _lastWriteTime = DateHandlers.UnixUnsignedToDateTime(mtime); + _zStream = new ForcedSeekStream(_decompressedSize, _dataStream, CompressionMode.Decompress); + _opened = true; } - public DateTime GetCreationTime() => creationTime; + public DateTime GetCreationTime() => _creationTime; - public long GetDataForkLength() => decompressedSize; + public long GetDataForkLength() => _decompressedSize; - public DateTime GetLastWriteTime() => lastWriteTime; + public DateTime GetLastWriteTime() => _lastWriteTime; - public long GetLength() => decompressedSize; + public long GetLength() => _decompressedSize; public long GetResourceForkLength() => 0; public string GetFilename() { - if(basePath?.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase) == true) - return basePath.Substring(0, basePath.Length - 3); + if(_basePath?.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase) == true) + return _basePath.Substring(0, _basePath.Length - 3); - return basePath?.EndsWith(".gzip", StringComparison.InvariantCultureIgnoreCase) == true - ? basePath.Substring(0, basePath.Length - 5) : basePath; + return _basePath?.EndsWith(".gzip", StringComparison.InvariantCultureIgnoreCase) == true + ? _basePath.Substring(0, _basePath.Length - 5) : _basePath; } - public string GetParentFolder() => Path.GetDirectoryName(basePath); + public string GetParentFolder() => Path.GetDirectoryName(_basePath); - public bool IsOpened() => opened; + public bool IsOpened() => _opened; } } \ No newline at end of file diff --git a/Aaru.Filters/LZip.cs b/Aaru.Filters/LZip.cs index 52619a6e0..a1b7d1e9a 100644 --- a/Aaru.Filters/LZip.cs +++ b/Aaru.Filters/LZip.cs @@ -41,13 +41,13 @@ namespace Aaru.Filters /// Decompress lzip files while reading public class LZip : IFilter { - string basePath; - DateTime creationTime; - Stream dataStream; - long decompressedSize; - Stream innerStream; - DateTime lastWriteTime; - bool opened; + string _basePath; + DateTime _creationTime; + Stream _dataStream; + long _decompressedSize; + Stream _innerStream; + DateTime _lastWriteTime; + bool _opened; public string Name => "LZip"; public Guid Id => new Guid("09D715E9-20C0-48B1-A8D9-D8897CEC57C9"); @@ -55,17 +55,17 @@ namespace Aaru.Filters public void Close() { - dataStream?.Close(); - dataStream = null; - basePath = null; - opened = false; + _dataStream?.Close(); + _dataStream = null; + _basePath = null; + _opened = false; } - public string GetBasePath() => basePath; + public string GetBasePath() => _basePath; - public Stream GetDataForkStream() => innerStream; + public Stream GetDataForkStream() => _innerStream; - public string GetPath() => basePath; + public string GetPath() => _basePath; public Stream GetResourceForkStream() => null; @@ -104,70 +104,70 @@ namespace Aaru.Filters public void Open(byte[] buffer) { - dataStream = new MemoryStream(buffer); - basePath = null; - creationTime = DateTime.UtcNow; - lastWriteTime = creationTime; - decompressedSize = BitConverter.ToInt64(buffer, buffer.Length - 16); + _dataStream = new MemoryStream(buffer); + _basePath = null; + _creationTime = DateTime.UtcNow; + _lastWriteTime = _creationTime; + _decompressedSize = BitConverter.ToInt64(buffer, buffer.Length - 16); - innerStream = new ForcedSeekStream(decompressedSize, dataStream, CompressionMode.Decompress); + _innerStream = new ForcedSeekStream(_decompressedSize, _dataStream, CompressionMode.Decompress); - opened = true; + _opened = true; } public void Open(Stream stream) { - dataStream = stream; - basePath = null; - creationTime = DateTime.UtcNow; - lastWriteTime = creationTime; + _dataStream = stream; + _basePath = null; + _creationTime = DateTime.UtcNow; + _lastWriteTime = _creationTime; byte[] tmp = new byte[8]; - dataStream.Seek(-16, SeekOrigin.End); - dataStream.Read(tmp, 0, 8); - decompressedSize = BitConverter.ToInt64(tmp, 0); - dataStream.Seek(0, SeekOrigin.Begin); - innerStream = new ForcedSeekStream(decompressedSize, dataStream, CompressionMode.Decompress); - opened = true; + _dataStream.Seek(-16, SeekOrigin.End); + _dataStream.Read(tmp, 0, 8); + _decompressedSize = BitConverter.ToInt64(tmp, 0); + _dataStream.Seek(0, SeekOrigin.Begin); + _innerStream = new ForcedSeekStream(_decompressedSize, _dataStream, CompressionMode.Decompress); + _opened = true; } public void Open(string path) { - dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); - basePath = Path.GetFullPath(path); + _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); + _basePath = Path.GetFullPath(path); var fi = new FileInfo(path); - creationTime = fi.CreationTimeUtc; - lastWriteTime = fi.LastWriteTimeUtc; + _creationTime = fi.CreationTimeUtc; + _lastWriteTime = fi.LastWriteTimeUtc; byte[] tmp = new byte[8]; - dataStream.Seek(-16, SeekOrigin.End); - dataStream.Read(tmp, 0, 8); - decompressedSize = BitConverter.ToInt64(tmp, 0); - dataStream.Seek(0, SeekOrigin.Begin); - innerStream = new ForcedSeekStream(decompressedSize, dataStream, CompressionMode.Decompress); - opened = true; + _dataStream.Seek(-16, SeekOrigin.End); + _dataStream.Read(tmp, 0, 8); + _decompressedSize = BitConverter.ToInt64(tmp, 0); + _dataStream.Seek(0, SeekOrigin.Begin); + _innerStream = new ForcedSeekStream(_decompressedSize, _dataStream, CompressionMode.Decompress); + _opened = true; } - public DateTime GetCreationTime() => creationTime; + public DateTime GetCreationTime() => _creationTime; - public long GetDataForkLength() => decompressedSize; + public long GetDataForkLength() => _decompressedSize; - public DateTime GetLastWriteTime() => lastWriteTime; + public DateTime GetLastWriteTime() => _lastWriteTime; - public long GetLength() => decompressedSize; + public long GetLength() => _decompressedSize; public long GetResourceForkLength() => 0; public string GetFilename() { - if(basePath?.EndsWith(".lz", StringComparison.InvariantCultureIgnoreCase) == true) - return basePath.Substring(0, basePath.Length - 3); + if(_basePath?.EndsWith(".lz", StringComparison.InvariantCultureIgnoreCase) == true) + return _basePath.Substring(0, _basePath.Length - 3); - return basePath?.EndsWith(".lzip", StringComparison.InvariantCultureIgnoreCase) == true - ? basePath.Substring(0, basePath.Length - 5) : basePath; + return _basePath?.EndsWith(".lzip", StringComparison.InvariantCultureIgnoreCase) == true + ? _basePath.Substring(0, _basePath.Length - 5) : _basePath; } - public string GetParentFolder() => Path.GetDirectoryName(basePath); + public string GetParentFolder() => Path.GetDirectoryName(_basePath); - public bool IsOpened() => opened; + public bool IsOpened() => _opened; } } \ No newline at end of file diff --git a/Aaru.Filters/MacBinary.cs b/Aaru.Filters/MacBinary.cs index bd7a6adfc..017c9a588 100644 --- a/Aaru.Filters/MacBinary.cs +++ b/Aaru.Filters/MacBinary.cs @@ -44,18 +44,17 @@ namespace Aaru.Filters /// Decodes MacBinary files public class MacBinary : IFilter { - const uint MACBINARY_MAGIC = 0x6D42494E; - string basePath; - byte[] bytes; - DateTime creationTime; - - long dataForkOff; - string filename; - MacBinaryHeader header; - bool isBytes, isStream, isPath, opened; - DateTime lastWriteTime; - long rsrcForkOff; - Stream stream; + const uint MAGIC = 0x6D42494E; + string _basePath; + byte[] _bytes; + DateTime _creationTime; + long _dataForkOff; + string _filename; + MacBinaryHeader _header; + bool _isBytes, _isStream, _isPath, _opened; + DateTime _lastWriteTime; + long _rsrcForkOff; + Stream _stream; public string Name => "MacBinary"; public Guid Id => new Guid("D7C321D3-E51F-45DF-A150-F6BFDF0D7704"); @@ -63,69 +62,69 @@ namespace Aaru.Filters public void Close() { - bytes = null; - stream?.Close(); - isBytes = false; - isStream = false; - isPath = false; - opened = false; + _bytes = null; + _stream?.Close(); + _isBytes = false; + _isStream = false; + _isPath = false; + _opened = false; } - public string GetBasePath() => basePath; + public string GetBasePath() => _basePath; - public DateTime GetCreationTime() => creationTime; + public DateTime GetCreationTime() => _creationTime; - public long GetDataForkLength() => header.dataLength; + public long GetDataForkLength() => _header.dataLength; public Stream GetDataForkStream() { - if(header.dataLength == 0) + if(_header.dataLength == 0) return null; - if(isBytes) - return new OffsetStream(bytes, dataForkOff, (dataForkOff + header.dataLength) - 1); + if(_isBytes) + return new OffsetStream(_bytes, _dataForkOff, (_dataForkOff + _header.dataLength) - 1); - if(isStream) - return new OffsetStream(stream, dataForkOff, (dataForkOff + header.dataLength) - 1); + if(_isStream) + return new OffsetStream(_stream, _dataForkOff, (_dataForkOff + _header.dataLength) - 1); - if(isPath) - return new OffsetStream(basePath, FileMode.Open, FileAccess.Read, dataForkOff, - (dataForkOff + header.dataLength) - 1); + if(_isPath) + return new OffsetStream(_basePath, FileMode.Open, FileAccess.Read, _dataForkOff, + (_dataForkOff + _header.dataLength) - 1); return null; } - public string GetFilename() => filename; + public string GetFilename() => _filename; - public DateTime GetLastWriteTime() => lastWriteTime; + public DateTime GetLastWriteTime() => _lastWriteTime; - public long GetLength() => header.dataLength + header.resourceLength; + public long GetLength() => _header.dataLength + _header.resourceLength; - public string GetParentFolder() => Path.GetDirectoryName(basePath); + public string GetParentFolder() => Path.GetDirectoryName(_basePath); - public string GetPath() => basePath; + public string GetPath() => _basePath; - public long GetResourceForkLength() => header.resourceLength; + public long GetResourceForkLength() => _header.resourceLength; public Stream GetResourceForkStream() { - if(header.resourceLength == 0) + if(_header.resourceLength == 0) return null; - if(isBytes) - return new OffsetStream(bytes, rsrcForkOff, (rsrcForkOff + header.resourceLength) - 1); + if(_isBytes) + return new OffsetStream(_bytes, _rsrcForkOff, (_rsrcForkOff + _header.resourceLength) - 1); - if(isStream) - return new OffsetStream(stream, rsrcForkOff, (rsrcForkOff + header.resourceLength) - 1); + if(_isStream) + return new OffsetStream(_stream, _rsrcForkOff, (_rsrcForkOff + _header.resourceLength) - 1); - if(isPath) - return new OffsetStream(basePath, FileMode.Open, FileAccess.Read, rsrcForkOff, - (rsrcForkOff + header.resourceLength) - 1); + if(_isPath) + return new OffsetStream(_basePath, FileMode.Open, FileAccess.Read, _rsrcForkOff, + (_rsrcForkOff + _header.resourceLength) - 1); return null; } - public bool HasResourceFork() => header.resourceLength > 0; + public bool HasResourceFork() => _header.resourceLength > 0; public bool Identify(byte[] buffer) { @@ -133,14 +132,14 @@ namespace Aaru.Filters buffer.Length < 128) return false; - byte[] hdr_b = new byte[128]; - Array.Copy(buffer, 0, hdr_b, 0, 128); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + byte[] hdrB = new byte[128]; + Array.Copy(buffer, 0, hdrB, 0, 128); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); - return header.magic == MACBINARY_MAGIC || (header.version == 0 && header.filename[0] > 0 && - header.filename[0] < 64 && header.zero1 == 0 && - header.zero2 == 0 && header.reserved == 0 && - (header.dataLength > 0 || header.resourceLength > 0)); + return _header.magic == MAGIC || (_header.version == 0 && _header.filename[0] > 0 && + _header.filename[0] < 64 && _header.zero1 == 0 && _header.zero2 == 0 && + _header.reserved == 0 && + (_header.dataLength > 0 || _header.resourceLength > 0)); } public bool Identify(Stream stream) @@ -149,15 +148,15 @@ namespace Aaru.Filters stream.Length < 128) return false; - byte[] hdr_b = new byte[128]; + byte[] hdrB = new byte[128]; stream.Seek(0, SeekOrigin.Begin); - stream.Read(hdr_b, 0, 128); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + stream.Read(hdrB, 0, 128); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); - return header.magic == MACBINARY_MAGIC || (header.version == 0 && header.filename[0] > 0 && - header.filename[0] < 64 && header.zero1 == 0 && - header.zero2 == 0 && header.reserved == 0 && - (header.dataLength > 0 || header.resourceLength > 0)); + return _header.magic == MAGIC || (_header.version == 0 && _header.filename[0] > 0 && + _header.filename[0] < 64 && _header.zero1 == 0 && _header.zero2 == 0 && + _header.reserved == 0 && + (_header.dataLength > 0 || _header.resourceLength > 0)); } public bool Identify(string path) @@ -167,83 +166,83 @@ namespace Aaru.Filters if(fstream.Length < 128) return false; - byte[] hdr_b = new byte[128]; - fstream.Read(hdr_b, 0, 128); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + byte[] hdrB = new byte[128]; + fstream.Read(hdrB, 0, 128); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); fstream.Close(); - return header.magic == MACBINARY_MAGIC || (header.version == 0 && header.filename[0] > 0 && - header.filename[0] < 64 && header.zero1 == 0 && - header.zero2 == 0 && header.reserved == 0 && - (header.dataLength > 0 || header.resourceLength > 0)); + return _header.magic == MAGIC || (_header.version == 0 && _header.filename[0] > 0 && + _header.filename[0] < 64 && _header.zero1 == 0 && _header.zero2 == 0 && + _header.reserved == 0 && + (_header.dataLength > 0 || _header.resourceLength > 0)); } - public bool IsOpened() => opened; + public bool IsOpened() => _opened; public void Open(byte[] buffer) { var ms = new MemoryStream(buffer); ms.Seek(0, SeekOrigin.Begin); - byte[] hdr_b = new byte[128]; - ms.Read(hdr_b, 0, 128); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + byte[] hdrB = new byte[128]; + ms.Read(hdrB, 0, 128); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); uint blocks = 1; - blocks += (uint)(header.secondaryHeaderLength / 128); + blocks += (uint)(_header.secondaryHeaderLength / 128); - if(header.secondaryHeaderLength % 128 > 0) + if(_header.secondaryHeaderLength % 128 > 0) blocks++; - dataForkOff = blocks * 128; - blocks += header.dataLength / 128; + _dataForkOff = blocks * 128; + blocks += _header.dataLength / 128; - if(header.dataLength % 128 > 0) + if(_header.dataLength % 128 > 0) blocks++; - rsrcForkOff = blocks * 128; + _rsrcForkOff = blocks * 128; - filename = StringHandlers.PascalToString(header.filename, Encoding.GetEncoding("macintosh")); - creationTime = DateHandlers.MacToDateTime(header.creationTime); - lastWriteTime = DateHandlers.MacToDateTime(header.modificationTime); + _filename = StringHandlers.PascalToString(_header.filename, Encoding.GetEncoding("macintosh")); + _creationTime = DateHandlers.MacToDateTime(_header.creationTime); + _lastWriteTime = DateHandlers.MacToDateTime(_header.modificationTime); ms.Close(); - opened = true; - isBytes = true; - bytes = buffer; + _opened = true; + _isBytes = true; + _bytes = buffer; } public void Open(Stream stream) { stream.Seek(0, SeekOrigin.Begin); - byte[] hdr_b = new byte[128]; - stream.Read(hdr_b, 0, 128); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + byte[] hdrB = new byte[128]; + stream.Read(hdrB, 0, 128); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); uint blocks = 1; - blocks += (uint)(header.secondaryHeaderLength / 128); + blocks += (uint)(_header.secondaryHeaderLength / 128); - if(header.secondaryHeaderLength % 128 > 0) + if(_header.secondaryHeaderLength % 128 > 0) blocks++; - dataForkOff = blocks * 128; - blocks += header.dataLength / 128; + _dataForkOff = blocks * 128; + blocks += _header.dataLength / 128; - if(header.dataLength % 128 > 0) + if(_header.dataLength % 128 > 0) blocks++; - rsrcForkOff = blocks * 128; + _rsrcForkOff = blocks * 128; - filename = StringHandlers.PascalToString(header.filename, Encoding.GetEncoding("macintosh")); - creationTime = DateHandlers.MacToDateTime(header.creationTime); - lastWriteTime = DateHandlers.MacToDateTime(header.modificationTime); + _filename = StringHandlers.PascalToString(_header.filename, Encoding.GetEncoding("macintosh")); + _creationTime = DateHandlers.MacToDateTime(_header.creationTime); + _lastWriteTime = DateHandlers.MacToDateTime(_header.modificationTime); stream.Seek(0, SeekOrigin.Begin); - opened = true; - isStream = true; - this.stream = stream; + _opened = true; + _isStream = true; + _stream = stream; } public void Open(string path) @@ -251,32 +250,32 @@ namespace Aaru.Filters var fs = new FileStream(path, FileMode.Open, FileAccess.Read); fs.Seek(0, SeekOrigin.Begin); - byte[] hdr_b = new byte[128]; - fs.Read(hdr_b, 0, 128); - header = Marshal.ByteArrayToStructureBigEndian(hdr_b); + byte[] hdrB = new byte[128]; + fs.Read(hdrB, 0, 128); + _header = Marshal.ByteArrayToStructureBigEndian(hdrB); uint blocks = 1; - blocks += (uint)(header.secondaryHeaderLength / 128); + blocks += (uint)(_header.secondaryHeaderLength / 128); - if(header.secondaryHeaderLength % 128 > 0) + if(_header.secondaryHeaderLength % 128 > 0) blocks++; - dataForkOff = blocks * 128; - blocks += header.dataLength / 128; + _dataForkOff = blocks * 128; + blocks += _header.dataLength / 128; - if(header.dataLength % 128 > 0) + if(_header.dataLength % 128 > 0) blocks++; - rsrcForkOff = blocks * 128; + _rsrcForkOff = blocks * 128; - filename = StringHandlers.PascalToString(header.filename, Encoding.GetEncoding("macintosh")); - creationTime = DateHandlers.MacToDateTime(header.creationTime); - lastWriteTime = DateHandlers.MacToDateTime(header.modificationTime); + _filename = StringHandlers.PascalToString(_header.filename, Encoding.GetEncoding("macintosh")); + _creationTime = DateHandlers.MacToDateTime(_header.creationTime); + _lastWriteTime = DateHandlers.MacToDateTime(_header.modificationTime); fs.Close(); - opened = true; - isPath = true; - basePath = path; + _opened = true; + _isPath = true; + _basePath = path; } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filters/OffsetStream.cs b/Aaru.Filters/OffsetStream.cs index 206526d41..f9ca6cbc4 100644 --- a/Aaru.Filters/OffsetStream.cs +++ b/Aaru.Filters/OffsetStream.cs @@ -43,9 +43,9 @@ namespace Aaru.Filters /// Creates a stream that is a subset of another stream. public class OffsetStream : Stream { - readonly Stream baseStream; - readonly long streamEnd; - readonly long streamStart; + readonly Stream _baseStream; + readonly long _streamEnd; + readonly long _streamStart; public OffsetStream(Stream stream, long start, long end) { @@ -55,12 +55,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = stream; + _baseStream = stream; - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -73,12 +73,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new FileStream(path, mode, access, share, bufferSize, options); + _baseStream = new FileStream(path, mode, access, share, bufferSize, options); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -90,12 +90,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new FileStream(handle, access); + _baseStream = new FileStream(handle, access); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -107,12 +107,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new FileStream(handle, access, bufferSize); + _baseStream = new FileStream(handle, access, bufferSize); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -125,12 +125,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new FileStream(handle, access, bufferSize, isAsync); + _baseStream = new FileStream(handle, access, bufferSize, isAsync); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -143,12 +143,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new FileStream(path, mode, access, share, bufferSize, useAsync); + _baseStream = new FileStream(path, mode, access, share, bufferSize, useAsync); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -161,12 +161,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new FileStream(path, mode, access, share, bufferSize); + _baseStream = new FileStream(path, mode, access, share, bufferSize); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -178,12 +178,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new FileStream(path, mode, access, share); + _baseStream = new FileStream(path, mode, access, share); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -195,12 +195,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new FileStream(path, mode, access); + _baseStream = new FileStream(path, mode, access); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -212,12 +212,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new FileStream(path, mode); + _baseStream = new FileStream(path, mode); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -230,12 +230,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new MemoryStream(buffer, index, count, writable, publiclyVisible); + _baseStream = new MemoryStream(buffer, index, count, writable, publiclyVisible); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -247,12 +247,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new MemoryStream(buffer, index, count, writable); + _baseStream = new MemoryStream(buffer, index, count, writable); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -264,12 +264,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new MemoryStream(buffer, index, count); + _baseStream = new MemoryStream(buffer, index, count); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -281,12 +281,12 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new MemoryStream(buffer, writable); + _baseStream = new MemoryStream(buffer, writable); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } @@ -298,90 +298,90 @@ namespace Aaru.Filters if(end < 0) throw new ArgumentOutOfRangeException(nameof(end), "End can't be a negative number."); - streamStart = start; - streamEnd = end; + _streamStart = start; + _streamEnd = end; - baseStream = new MemoryStream(buffer); + _baseStream = new MemoryStream(buffer); - if(end > baseStream.Length) + if(end > _baseStream.Length) throw new ArgumentOutOfRangeException(nameof(end), "End is after stream end."); } - public override bool CanRead => baseStream.CanRead; + public override bool CanRead => _baseStream.CanRead; - public override bool CanSeek => baseStream.CanSeek; + public override bool CanSeek => _baseStream.CanSeek; - public override bool CanWrite => baseStream.CanWrite; + public override bool CanWrite => _baseStream.CanWrite; - public override long Length => (streamEnd - streamStart) + 1; + public override long Length => (_streamEnd - _streamStart) + 1; public override long Position { - get => baseStream.Position - streamStart; + get => _baseStream.Position - _streamStart; set { - if(value + streamStart > streamEnd) + if(value + _streamStart > _streamEnd) throw new IOException("Cannot set position past stream end."); - baseStream.Position = value; + _baseStream.Position = value; } } ~OffsetStream() { - baseStream.Close(); - baseStream.Dispose(); + _baseStream.Close(); + _baseStream.Dispose(); } public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { - if(baseStream.Position + count > streamEnd) + if(_baseStream.Position + count > _streamEnd) throw new IOException("Cannot read past stream end."); - return baseStream.BeginRead(buffer, offset, count, callback, state); + return _baseStream.BeginRead(buffer, offset, count, callback, state); } public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { - if(baseStream.Position + count > streamEnd) + if(_baseStream.Position + count > _streamEnd) throw new IOException("Cannot write past stream end."); - return baseStream.BeginWrite(buffer, offset, count, callback, state); + return _baseStream.BeginWrite(buffer, offset, count, callback, state); } - public override void Close() => baseStream.Close(); + public override void Close() => _baseStream.Close(); protected new void Dispose() { - baseStream.Dispose(); + _baseStream.Dispose(); base.Dispose(); } - public override int EndRead(IAsyncResult asyncResult) => baseStream.EndRead(asyncResult); + public override int EndRead(IAsyncResult asyncResult) => _baseStream.EndRead(asyncResult); - public override void EndWrite(IAsyncResult asyncResult) => baseStream.EndWrite(asyncResult); + public override void EndWrite(IAsyncResult asyncResult) => _baseStream.EndWrite(asyncResult); - public override int ReadByte() => baseStream.Position == streamEnd + 1 ? -1 : baseStream.ReadByte(); + public override int ReadByte() => _baseStream.Position == _streamEnd + 1 ? -1 : _baseStream.ReadByte(); public override void WriteByte(byte value) { - if(baseStream.Position + 1 > streamEnd) + if(_baseStream.Position + 1 > _streamEnd) throw new IOException("Cannot write past stream end."); - baseStream.WriteByte(value); + _baseStream.WriteByte(value); } - public override void Flush() => baseStream.Flush(); + public override void Flush() => _baseStream.Flush(); public override int Read(byte[] buffer, int offset, int count) { - if(baseStream.Position + count > streamEnd + 1) + if(_baseStream.Position + count > _streamEnd + 1) throw new IOException("Cannot read past stream end."); - return baseStream.Read(buffer, offset, count); + return _baseStream.Read(buffer, offset, count); } public override long Seek(long offset, SeekOrigin origin) @@ -389,20 +389,20 @@ namespace Aaru.Filters switch(origin) { case SeekOrigin.Begin: - if(offset + streamStart > streamEnd) + if(offset + _streamStart > _streamEnd) throw new IOException("Cannot seek past stream end."); - return baseStream.Seek(offset + streamStart, SeekOrigin.Begin) - streamStart; + return _baseStream.Seek(offset + _streamStart, SeekOrigin.Begin) - _streamStart; case SeekOrigin.End: - if(offset - (baseStream.Length - streamEnd) < streamStart) + if(offset - (_baseStream.Length - _streamEnd) < _streamStart) throw new IOException("Cannot seek before stream start."); - return baseStream.Seek(offset - (baseStream.Length - streamEnd), SeekOrigin.End) - streamStart; + return _baseStream.Seek(offset - (_baseStream.Length - _streamEnd), SeekOrigin.End) - _streamStart; default: - if(offset + baseStream.Position > streamEnd) + if(offset + _baseStream.Position > _streamEnd) throw new IOException("Cannot seek past stream end."); - return baseStream.Seek(offset, SeekOrigin.Current) - streamStart; + return _baseStream.Seek(offset, SeekOrigin.Current) - _streamStart; } } @@ -411,10 +411,10 @@ namespace Aaru.Filters public override void Write(byte[] buffer, int offset, int count) { - if(baseStream.Position + count > streamEnd) + if(_baseStream.Position + count > _streamEnd) throw new IOException("Cannot write past stream end."); - baseStream.Write(buffer, offset, count); + _baseStream.Write(buffer, offset, count); } } } \ No newline at end of file diff --git a/Aaru.Filters/PCExchange.cs b/Aaru.Filters/PCExchange.cs index b9bef438b..df7db647e 100644 --- a/Aaru.Filters/PCExchange.cs +++ b/Aaru.Filters/PCExchange.cs @@ -45,50 +45,49 @@ namespace Aaru.Filters { /// Decodes PCExchange files [SuppressMessage("ReSharper", "UnusedMember.Local")] - public class PCExchange : IFilter + public class PcExchange : IFilter { const string FILE_ID = "FILEID.DAT"; const string FINDER_INFO = "FINDER.DAT"; const string RESOURCES = "RESOURCE.FRK"; - string basePath; - DateTime creationTime; - long dataLen; - string dataPath; - DateTime lastWriteTime; - - bool opened; - long rsrcLen; - string rsrcPath; + string _basePath; + DateTime _creationTime; + long _dataLen; + string _dataPath; + DateTime _lastWriteTime; + bool _opened; + long _rsrcLen; + string _rsrcPath; public string Name => "PCExchange"; public Guid Id => new Guid("9264EB9F-D634-4F9B-BE12-C24CD44988C6"); public string Author => "Natalia Portillo"; - public void Close() => opened = false; + public void Close() => _opened = false; - public string GetBasePath() => basePath; + public string GetBasePath() => _basePath; - public DateTime GetCreationTime() => creationTime; + public DateTime GetCreationTime() => _creationTime; - public long GetDataForkLength() => dataLen; + public long GetDataForkLength() => _dataLen; - public Stream GetDataForkStream() => new FileStream(dataPath, FileMode.Open, FileAccess.Read); + public Stream GetDataForkStream() => new FileStream(_dataPath, FileMode.Open, FileAccess.Read); - public string GetFilename() => Path.GetFileName(basePath); + public string GetFilename() => Path.GetFileName(_basePath); - public DateTime GetLastWriteTime() => lastWriteTime; + public DateTime GetLastWriteTime() => _lastWriteTime; - public long GetLength() => dataLen + rsrcLen; + public long GetLength() => _dataLen + _rsrcLen; - public string GetParentFolder() => Path.GetDirectoryName(basePath); + public string GetParentFolder() => Path.GetDirectoryName(_basePath); - public string GetPath() => basePath; + public string GetPath() => _basePath; - public long GetResourceForkLength() => rsrcLen; + public long GetResourceForkLength() => _rsrcLen; - public Stream GetResourceForkStream() => new FileStream(rsrcPath, FileMode.Open, FileAccess.Read); + public Stream GetResourceForkStream() => new FileStream(_rsrcPath, FileMode.Open, FileAccess.Read); - public bool HasResourceFork() => rsrcPath != null; + public bool HasResourceFork() => _rsrcPath != null; public bool Identify(byte[] buffer) => false; @@ -116,21 +115,21 @@ namespace Aaru.Filters while(finderDatStream.Position + 0x5C <= finderDatStream.Length) { - var datEntry = new PCExchangeEntry(); - byte[] datEntry_b = new byte[Marshal.SizeOf(datEntry)]; - finderDatStream.Read(datEntry_b, 0, Marshal.SizeOf(datEntry)); - datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntry_b); + var datEntry = new PcExchangeEntry(); + byte[] datEntryB = new byte[Marshal.SizeOf(datEntry)]; + finderDatStream.Read(datEntryB, 0, Marshal.SizeOf(datEntry)); + datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntryB); // TODO: Add support for encoding on filters string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh")); - byte[] tmpDosName_b = new byte[8]; - byte[] tmpDosExt_b = new byte[3]; - Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8); - Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3); + byte[] tmpDosNameB = new byte[8]; + byte[] tmpDosExtB = new byte[3]; + Array.Copy(datEntry.dosName, 0, tmpDosNameB, 0, 8); + Array.Copy(datEntry.dosName, 8, tmpDosExtB, 0, 3); - string dosName = Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." + - Encoding.ASCII.GetString(tmpDosExt_b).Trim(); + string dosName = Encoding.ASCII.GetString(tmpDosNameB).Trim() + "." + + Encoding.ASCII.GetString(tmpDosExtB).Trim(); string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture); @@ -155,7 +154,7 @@ namespace Aaru.Filters return dataFound && rsrcFound; } - public bool IsOpened() => opened; + public bool IsOpened() => _opened; public void Open(byte[] buffer) => throw new NotSupportedException(); @@ -173,20 +172,20 @@ namespace Aaru.Filters while(finderDatStream.Position + 0x5C <= finderDatStream.Length) { - var datEntry = new PCExchangeEntry(); - byte[] datEntry_b = new byte[Marshal.SizeOf(datEntry)]; - finderDatStream.Read(datEntry_b, 0, Marshal.SizeOf(datEntry)); - datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntry_b); + var datEntry = new PcExchangeEntry(); + byte[] datEntryB = new byte[Marshal.SizeOf(datEntry)]; + finderDatStream.Read(datEntryB, 0, Marshal.SizeOf(datEntry)); + datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntryB); string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh")); - byte[] tmpDosName_b = new byte[8]; - byte[] tmpDosExt_b = new byte[3]; - Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8); - Array.Copy(datEntry.dosName, 8, tmpDosExt_b, 0, 3); + byte[] tmpDosNameB = new byte[8]; + byte[] tmpDosExtB = new byte[3]; + Array.Copy(datEntry.dosName, 0, tmpDosNameB, 0, 8); + Array.Copy(datEntry.dosName, 8, tmpDosExtB, 0, 3); - string dosName = Encoding.ASCII.GetString(tmpDosName_b).Trim() + "." + - Encoding.ASCII.GetString(tmpDosExt_b).Trim(); + string dosName = Encoding.ASCII.GetString(tmpDosNameB).Trim() + "." + + Encoding.ASCII.GetString(tmpDosExtB).Trim(); string dosNameLow = dosName.ToLower(CultureInfo.CurrentCulture); @@ -196,38 +195,38 @@ namespace Aaru.Filters continue; if(File.Exists(Path.Combine(parentFolder, macName ?? throw new InvalidOperationException()))) - dataPath = Path.Combine(parentFolder, macName); + _dataPath = Path.Combine(parentFolder, macName); else if(File.Exists(Path.Combine(parentFolder, dosName))) - dataPath = Path.Combine(parentFolder, dosName); + _dataPath = Path.Combine(parentFolder, dosName); else if(File.Exists(Path.Combine(parentFolder, dosNameLow))) - dataPath = Path.Combine(parentFolder, dosNameLow); + _dataPath = Path.Combine(parentFolder, dosNameLow); else - dataPath = null; + _dataPath = null; if(File.Exists(Path.Combine(parentFolder, RESOURCES, dosName))) - rsrcPath = Path.Combine(parentFolder, RESOURCES, dosName); + _rsrcPath = Path.Combine(parentFolder, RESOURCES, dosName); else if(File.Exists(Path.Combine(parentFolder, RESOURCES, dosNameLow))) - rsrcPath = Path.Combine(parentFolder, RESOURCES, dosNameLow); + _rsrcPath = Path.Combine(parentFolder, RESOURCES, dosNameLow); else - rsrcPath = null; + _rsrcPath = null; - lastWriteTime = DateHandlers.MacToDateTime(datEntry.modificationDate); - creationTime = DateHandlers.MacToDateTime(datEntry.creationDate); + _lastWriteTime = DateHandlers.MacToDateTime(datEntry.modificationDate); + _creationTime = DateHandlers.MacToDateTime(datEntry.creationDate); break; } - dataLen = new FileInfo(dataPath ?? throw new InvalidOperationException()).Length; - rsrcLen = new FileInfo(rsrcPath ?? throw new InvalidOperationException()).Length; + _dataLen = new FileInfo(_dataPath ?? throw new InvalidOperationException()).Length; + _rsrcLen = new FileInfo(_rsrcPath ?? throw new InvalidOperationException()).Length; - basePath = path; - opened = true; + _basePath = path; + _opened = true; finderDatStream.Close(); } [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct PCExchangeEntry + struct PcExchangeEntry { /// /// Name in Macintosh. If PCExchange version supports FAT's LFN they are the same. Illegal characters for FAT get diff --git a/Aaru.Filters/XZ.cs b/Aaru.Filters/XZ.cs index cdee95735..35c091fdf 100644 --- a/Aaru.Filters/XZ.cs +++ b/Aaru.Filters/XZ.cs @@ -40,13 +40,13 @@ namespace Aaru.Filters /// Decompress xz files while reading public class XZ : IFilter { - string basePath; - DateTime creationTime; - Stream dataStream; - long decompressedSize; - Stream innerStream; - DateTime lastWriteTime; - bool opened; + string _basePath; + DateTime _creationTime; + Stream _dataStream; + long _decompressedSize; + Stream _innerStream; + DateTime _lastWriteTime; + bool _opened; public string Name => "XZ"; public Guid Id => new Guid("666A8617-0444-4C05-9F4F-DF0FD758D0D2"); @@ -54,17 +54,17 @@ namespace Aaru.Filters public void Close() { - dataStream?.Close(); - dataStream = null; - basePath = null; - opened = false; + _dataStream?.Close(); + _dataStream = null; + _basePath = null; + _opened = false; } - public string GetBasePath() => basePath; + public string GetBasePath() => _basePath; - public Stream GetDataForkStream() => innerStream; + public Stream GetDataForkStream() => _innerStream; - public string GetPath() => basePath; + public string GetPath() => _basePath; public Stream GetResourceForkStream() => null; @@ -111,89 +111,89 @@ namespace Aaru.Filters public void Open(byte[] buffer) { - dataStream = new MemoryStream(buffer); - basePath = null; - creationTime = DateTime.UtcNow; - lastWriteTime = creationTime; + _dataStream = new MemoryStream(buffer); + _basePath = null; + _creationTime = DateTime.UtcNow; + _lastWriteTime = _creationTime; GuessSize(); - innerStream = new ForcedSeekStream(decompressedSize, dataStream); - opened = true; + _innerStream = new ForcedSeekStream(_decompressedSize, _dataStream); + _opened = true; } public void Open(Stream stream) { - dataStream = stream; - basePath = null; - creationTime = DateTime.UtcNow; - lastWriteTime = creationTime; + _dataStream = stream; + _basePath = null; + _creationTime = DateTime.UtcNow; + _lastWriteTime = _creationTime; GuessSize(); - innerStream = new ForcedSeekStream(decompressedSize, dataStream); - opened = true; + _innerStream = new ForcedSeekStream(_decompressedSize, _dataStream); + _opened = true; } public void Open(string path) { - dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); - basePath = Path.GetFullPath(path); + _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); + _basePath = Path.GetFullPath(path); var fi = new FileInfo(path); - creationTime = fi.CreationTimeUtc; - lastWriteTime = fi.LastWriteTimeUtc; + _creationTime = fi.CreationTimeUtc; + _lastWriteTime = fi.LastWriteTimeUtc; GuessSize(); - innerStream = new ForcedSeekStream(decompressedSize, dataStream); - opened = true; + _innerStream = new ForcedSeekStream(_decompressedSize, _dataStream); + _opened = true; } - public DateTime GetCreationTime() => creationTime; + public DateTime GetCreationTime() => _creationTime; - public long GetDataForkLength() => decompressedSize; + public long GetDataForkLength() => _decompressedSize; - public DateTime GetLastWriteTime() => lastWriteTime; + public DateTime GetLastWriteTime() => _lastWriteTime; - public long GetLength() => decompressedSize; + public long GetLength() => _decompressedSize; public long GetResourceForkLength() => 0; public string GetFilename() { - if(basePath?.EndsWith(".xz", StringComparison.InvariantCultureIgnoreCase) == true) - return basePath.Substring(0, basePath.Length - 3); + if(_basePath?.EndsWith(".xz", StringComparison.InvariantCultureIgnoreCase) == true) + return _basePath.Substring(0, _basePath.Length - 3); - return basePath?.EndsWith(".xzip", StringComparison.InvariantCultureIgnoreCase) == true - ? basePath.Substring(0, basePath.Length - 5) : basePath; + return _basePath?.EndsWith(".xzip", StringComparison.InvariantCultureIgnoreCase) == true + ? _basePath.Substring(0, _basePath.Length - 5) : _basePath; } - public string GetParentFolder() => Path.GetDirectoryName(basePath); + public string GetParentFolder() => Path.GetDirectoryName(_basePath); - public bool IsOpened() => opened; + public bool IsOpened() => _opened; void GuessSize() { - decompressedSize = 0; + _decompressedSize = 0; // Seek to footer backwards size field - dataStream.Seek(-8, SeekOrigin.End); + _dataStream.Seek(-8, SeekOrigin.End); byte[] tmp = new byte[4]; - dataStream.Read(tmp, 0, 4); + _dataStream.Read(tmp, 0, 4); uint backwardSize = (BitConverter.ToUInt32(tmp, 0) + 1) * 4; // Seek to first indexed record - dataStream.Seek(-12 - (backwardSize - 2), SeekOrigin.End); + _dataStream.Seek(-12 - (backwardSize - 2), SeekOrigin.End); // Skip compressed size tmp = new byte[backwardSize - 2]; - dataStream.Read(tmp, 0, tmp.Length); + _dataStream.Read(tmp, 0, tmp.Length); ulong number = 0; int ignore = Decode(tmp, tmp.Length, ref number); // Get compressed size - dataStream.Seek(-12 - (backwardSize - 2 - ignore), SeekOrigin.End); + _dataStream.Seek(-12 - (backwardSize - 2 - ignore), SeekOrigin.End); tmp = new byte[backwardSize - 2 - ignore]; - dataStream.Read(tmp, 0, tmp.Length); + _dataStream.Read(tmp, 0, tmp.Length); Decode(tmp, tmp.Length, ref number); - decompressedSize = (long)number; + _decompressedSize = (long)number; - dataStream.Seek(0, SeekOrigin.Begin); + _dataStream.Seek(0, SeekOrigin.Begin); } int Decode(byte[] buf, int sizeMax, ref ulong num) diff --git a/Aaru.Filters/ZZZNoFilter.cs b/Aaru.Filters/ZZZNoFilter.cs index a61d215cb..2f0ede51b 100644 --- a/Aaru.Filters/ZZZNoFilter.cs +++ b/Aaru.Filters/ZZZNoFilter.cs @@ -39,11 +39,11 @@ namespace Aaru.Filters /// No filter for reading files not recognized by any filter public class ZZZNoFilter : IFilter { - string basePath; - DateTime creationTime; - Stream dataStream; - DateTime lastWriteTime; - bool opened; + string _basePath; + DateTime _creationTime; + Stream _dataStream; + DateTime _lastWriteTime; + bool _opened; public string Name => "No filter"; public Guid Id => new Guid("12345678-AAAA-BBBB-CCCC-123456789000"); @@ -51,17 +51,17 @@ namespace Aaru.Filters public void Close() { - dataStream?.Close(); - dataStream = null; - basePath = null; - opened = false; + _dataStream?.Close(); + _dataStream = null; + _basePath = null; + _opened = false; } - public string GetBasePath() => basePath; + public string GetBasePath() => _basePath; - public Stream GetDataForkStream() => dataStream; + public Stream GetDataForkStream() => _dataStream; - public string GetPath() => basePath; + public string GetPath() => _basePath; public Stream GetResourceForkStream() => null; @@ -75,46 +75,46 @@ namespace Aaru.Filters public void Open(byte[] buffer) { - dataStream = new MemoryStream(buffer); - basePath = null; - creationTime = DateTime.UtcNow; - lastWriteTime = creationTime; - opened = true; + _dataStream = new MemoryStream(buffer); + _basePath = null; + _creationTime = DateTime.UtcNow; + _lastWriteTime = _creationTime; + _opened = true; } public void Open(Stream stream) { - dataStream = stream; - basePath = null; - creationTime = DateTime.UtcNow; - lastWriteTime = creationTime; - opened = true; + _dataStream = stream; + _basePath = null; + _creationTime = DateTime.UtcNow; + _lastWriteTime = _creationTime; + _opened = true; } public void Open(string path) { - dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); - basePath = Path.GetFullPath(path); + _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); + _basePath = Path.GetFullPath(path); var fi = new FileInfo(path); - creationTime = fi.CreationTimeUtc; - lastWriteTime = fi.LastWriteTimeUtc; - opened = true; + _creationTime = fi.CreationTimeUtc; + _lastWriteTime = fi.LastWriteTimeUtc; + _opened = true; } - public DateTime GetCreationTime() => creationTime; + public DateTime GetCreationTime() => _creationTime; - public long GetDataForkLength() => dataStream.Length; + public long GetDataForkLength() => _dataStream.Length; - public DateTime GetLastWriteTime() => lastWriteTime; + public DateTime GetLastWriteTime() => _lastWriteTime; - public long GetLength() => dataStream.Length; + public long GetLength() => _dataStream.Length; public long GetResourceForkLength() => 0; - public string GetFilename() => Path.GetFileName(basePath); + public string GetFilename() => Path.GetFileName(_basePath); - public string GetParentFolder() => Path.GetDirectoryName(basePath); + public string GetParentFolder() => Path.GetDirectoryName(_basePath); - public bool IsOpened() => opened; + public bool IsOpened() => _opened; } } \ No newline at end of file diff --git a/Aaru.Helpers b/Aaru.Helpers index e64f731a5..bc471c3ff 160000 --- a/Aaru.Helpers +++ b/Aaru.Helpers @@ -1 +1 @@ -Subproject commit e64f731a55babbbaea9d7a83c9723310f614b9a5 +Subproject commit bc471c3ff84134692081cd89f85f6f49df9de28a diff --git a/Aaru.Images/AaruFormat/AaruFormat.cs b/Aaru.Images/AaruFormat/AaruFormat.cs index 8d04f7ebc..1d1d5623d 100644 --- a/Aaru.Images/AaruFormat/AaruFormat.cs +++ b/Aaru.Images/AaruFormat/AaruFormat.cs @@ -83,88 +83,88 @@ namespace Aaru.DiscImages { public partial class AaruFormat : IWritableOpticalImage, IVerifiableImage, IWritableTapeImage { - bool alreadyWrittenZero; + bool _alreadyWrittenZero; /// Cache of uncompressed blocks. - Dictionary blockCache; + Dictionary _blockCache; /// Cache of block headers. - Dictionary blockHeaderCache; + Dictionary _blockHeaderCache; /// Stream used for writing blocks. - NonClosableStream blockStream; + NonClosableStream _blockStream; /// Provides checksum for deduplication of sectors. - SHA256 checksumProvider; - bool compress; + SHA256 _checksumProvider; + bool _compress; /// Provides CRC64. - Crc64Context crc64; + Crc64Context _crc64; /// Header of the currently writing block. - BlockHeader currentBlockHeader; + BlockHeader _currentBlockHeader; /// Sector offset of writing position in currently writing block. - uint currentBlockOffset; + uint _currentBlockOffset; /// Current size in bytes of the block cache - uint currentCacheSize; + uint _currentCacheSize; /// Cache of DDT entries. - Dictionary ddtEntryCache; - NonClosableStream decompressedStream; - bool deduplicate; + Dictionary _ddtEntryCache; + NonClosableStream _decompressedStream; + bool _deduplicate; /// On-memory deduplication table indexed by checksum. - Dictionary deduplicationTable; + Dictionary _deduplicationTable; /// writer. - AudioEncoder flakeWriter; + AudioEncoder _flakeWriter; /// settings. - EncoderSettings flakeWriterSettings; + EncoderSettings _flakeWriterSettings; /// Block with logical geometry. - GeometryBlock geometryBlock; + GeometryBlock _geometryBlock; /// Image header. - AaruHeader header; + AaruHeader _header; /// Image information. - ImageInfo imageInfo; + ImageInfo _imageInfo; /// Image data stream. - Stream imageStream; + Stream _imageStream; /// Index. - List index; + List _index; /// If set to true, the DDT entries are in-memory. - bool inMemoryDdt; - ulong lastWrittenBlock; + bool _inMemoryDdt; + ulong _lastWrittenBlock; /// LZMA stream. - LzmaStream lzmaBlockStream; + LzmaStream _lzmaBlockStream; /// LZMA properties. - LzmaEncoderProperties lzmaEncoderProperties; - Md5Context md5Provider; + LzmaEncoderProperties _lzmaEncoderProperties; + Md5Context _md5Provider; /// Cache of media tags. - Dictionary mediaTags; - byte[] mode2Subheaders; + Dictionary _mediaTags; + byte[] _mode2Subheaders; /// If DDT is on-disk, this is the image stream offset at which it starts. - long outMemoryDdtPosition; - bool rewinded; + long _outMemoryDdtPosition; + bool _rewinded; /// Cache for data that prefixes the user data on a sector (e.g. sync). - byte[] sectorPrefix; - uint[] sectorPrefixDdt; - NonClosableStream sectorPrefixMs; + byte[] _sectorPrefix; + uint[] _sectorPrefixDdt; + NonClosableStream _sectorPrefixMs; /// Cache for data that goes side by side with user data (e.g. CompactDisc subchannel). - byte[] sectorSubchannel; + byte[] _sectorSubchannel; /// Cache for data that suffixes the user data on a sector (e.g. edc, ecc). - byte[] sectorSuffix; - uint[] sectorSuffixDdt; - NonClosableStream sectorSuffixMs; - Sha1Context sha1Provider; - Sha256Context sha256Provider; + byte[] _sectorSuffix; + uint[] _sectorSuffixDdt; + NonClosableStream _sectorSuffixMs; + Sha1Context _sha1Provider; + Sha256Context _sha256Provider; /// Shift for calculating number of sectors in a block. - byte shift; - SpamSumContext spamsumProvider; + byte _shift; + SpamSumContext _spamsumProvider; /// Cache for bytes to write/rad on-disk. - byte[] structureBytes; + byte[] _structureBytes; /// Cache for pointer for marshaling structures. - IntPtr structurePointer; - Dictionary tapeDdt; + IntPtr _structurePointer; + Dictionary _tapeDdt; /// Cache of CompactDisc track's flags - Dictionary trackFlags; + Dictionary _trackFlags; /// Cache of CompactDisc track's ISRC - Dictionary trackIsrcs; + Dictionary _trackIsrcs; /// In-memory deduplication table - ulong[] userDataDdt; - bool writingLong; - ulong writtenSectors; + ulong[] _userDataDdt; + bool _writingLong; + ulong _writtenSectors; - public AaruFormat() => imageInfo = new ImageInfo + public AaruFormat() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/AaruFormat/CdEcc.cs b/Aaru.Images/AaruFormat/CdEcc.cs index 6ec9c9ff2..92291689c 100644 --- a/Aaru.Images/AaruFormat/CdEcc.cs +++ b/Aaru.Images/AaruFormat/CdEcc.cs @@ -38,39 +38,39 @@ namespace Aaru.DiscImages { public partial class AaruFormat { - byte[] eccBTable; - byte[] eccFTable; - uint[] edcTable; - bool initedEdc; + byte[] _eccBTable; + byte[] _eccFTable; + uint[] _edcTable; + bool _initedEdc; void EccInit() { - if(initedEdc) + if(_initedEdc) return; - eccFTable = new byte[256]; - eccBTable = new byte[256]; - edcTable = new uint[256]; + _eccFTable = new byte[256]; + _eccBTable = new byte[256]; + _edcTable = new uint[256]; for(uint i = 0; i < 256; i++) { uint edc = i; uint j = (uint)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0)); - eccFTable[i] = (byte)j; - eccBTable[i ^ j] = (byte)i; + _eccFTable[i] = (byte)j; + _eccBTable[i ^ j] = (byte)i; for(j = 0; j < 8; j++) edc = (edc >> 1) ^ ((edc & 1) > 0 ? 0xD8018001 : 0); - edcTable[i] = edc; + _edcTable[i] = edc; } - initedEdc = true; + _initedEdc = true; } bool SuffixIsCorrect(byte[] sector) { - if(!initedEdc) + if(!_initedEdc) EccInit(); if(sector[0x814] != 0x00 || // reserved (8 bytes) @@ -99,7 +99,7 @@ namespace Aaru.DiscImages int pos = 0; for(; size > 0; size--) - edc = (edc >> 8) ^ edcTable[(edc ^ sector[pos++]) & 0xFF]; + edc = (edc >> 8) ^ _edcTable[(edc ^ sector[pos++]) & 0xFF]; uint calculatedEdc = edc; @@ -108,7 +108,7 @@ namespace Aaru.DiscImages bool SuffixIsCorrectMode2(byte[] sector) { - if(!initedEdc) + if(!_initedEdc) EccInit(); byte[] zeroaddress = new byte[4]; @@ -129,7 +129,7 @@ namespace Aaru.DiscImages int pos = 0x10; for(; size > 0; size--) - edc = (edc >> 8) ^ edcTable[(edc ^ sector[pos++]) & 0xFF]; + edc = (edc >> 8) ^ _edcTable[(edc ^ sector[pos++]) & 0xFF]; uint calculatedEdc = edc; @@ -159,10 +159,10 @@ namespace Aaru.DiscImages eccA ^= temp; eccB ^= temp; - eccA = eccFTable[eccA]; + eccA = _eccFTable[eccA]; } - eccA = eccBTable[eccFTable[eccA] ^ eccB]; + eccA = _eccBTable[_eccFTable[eccA] ^ eccB]; if(ecc[major + eccOffset] != eccA || ecc[major + majorCount + eccOffset] != (eccA ^ eccB)) @@ -195,10 +195,10 @@ namespace Aaru.DiscImages eccA ^= temp; eccB ^= temp; - eccA = eccFTable[eccA]; + eccA = _eccFTable[eccA]; } - eccA = eccBTable[eccFTable[eccA] ^ eccB]; + eccA = _eccBTable[_eccFTable[eccA] ^ eccB]; ecc[major + eccOffset] = eccA; ecc[major + majorCount + eccOffset] = (byte)(eccA ^ eccB); } @@ -274,7 +274,7 @@ namespace Aaru.DiscImages { byte[] computedEdc; - if(!initedEdc) + if(!_initedEdc) EccInit(); switch(type) @@ -345,13 +345,13 @@ namespace Aaru.DiscImages uint ComputeEdc(uint edc, byte[] src, int size, int srcOffset = 0) { - if(!initedEdc) + if(!_initedEdc) EccInit(); int pos = srcOffset; for(; size > 0; size--) - edc = (edc >> 8) ^ edcTable[(edc ^ src[pos++]) & 0xFF]; + edc = (edc >> 8) ^ _edcTable[(edc ^ src[pos++]) & 0xFF]; return edc; } diff --git a/Aaru.Images/AaruFormat/Helpers.cs b/Aaru.Images/AaruFormat/Helpers.cs index fd3eb49e2..7db28e545 100644 --- a/Aaru.Images/AaruFormat/Helpers.cs +++ b/Aaru.Images/AaruFormat/Helpers.cs @@ -46,45 +46,45 @@ namespace Aaru.DiscImages void SetMetadataFromTags() { // Search for SecureDigital CID - if(mediaTags.TryGetValue(MediaTagType.SD_CID, out byte[] sdCid)) + if(_mediaTags.TryGetValue(MediaTagType.SD_CID, out byte[] sdCid)) { CID decoded = Decoders.SecureDigital.Decoders.DecodeCID(sdCid); - if(string.IsNullOrWhiteSpace(imageInfo.DriveManufacturer)) - imageInfo.DriveManufacturer = VendorString.Prettify(decoded.Manufacturer); + if(string.IsNullOrWhiteSpace(_imageInfo.DriveManufacturer)) + _imageInfo.DriveManufacturer = VendorString.Prettify(decoded.Manufacturer); - if(string.IsNullOrWhiteSpace(imageInfo.DriveModel)) - imageInfo.DriveModel = decoded.ProductName; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) + _imageInfo.DriveModel = decoded.ProductName; - if(string.IsNullOrWhiteSpace(imageInfo.DriveFirmwareRevision)) - imageInfo.DriveFirmwareRevision = + if(string.IsNullOrWhiteSpace(_imageInfo.DriveFirmwareRevision)) + _imageInfo.DriveFirmwareRevision = $"{(decoded.ProductRevision & 0xF0) >> 4:X2}.{decoded.ProductRevision & 0x0F:X2}"; - if(string.IsNullOrWhiteSpace(imageInfo.DriveSerialNumber)) - imageInfo.DriveSerialNumber = $"{decoded.ProductSerialNumber}"; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveSerialNumber)) + _imageInfo.DriveSerialNumber = $"{decoded.ProductSerialNumber}"; } // Search for MultiMediaCard CID - if(mediaTags.TryGetValue(MediaTagType.MMC_CID, out byte[] mmcCid)) + if(_mediaTags.TryGetValue(MediaTagType.MMC_CID, out byte[] mmcCid)) { Decoders.MMC.CID decoded = Decoders.MMC.Decoders.DecodeCID(mmcCid); - if(string.IsNullOrWhiteSpace(imageInfo.DriveManufacturer)) - imageInfo.DriveManufacturer = Decoders.MMC.VendorString.Prettify(decoded.Manufacturer); + if(string.IsNullOrWhiteSpace(_imageInfo.DriveManufacturer)) + _imageInfo.DriveManufacturer = Decoders.MMC.VendorString.Prettify(decoded.Manufacturer); - if(string.IsNullOrWhiteSpace(imageInfo.DriveModel)) - imageInfo.DriveModel = decoded.ProductName; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) + _imageInfo.DriveModel = decoded.ProductName; - if(string.IsNullOrWhiteSpace(imageInfo.DriveFirmwareRevision)) - imageInfo.DriveFirmwareRevision = + if(string.IsNullOrWhiteSpace(_imageInfo.DriveFirmwareRevision)) + _imageInfo.DriveFirmwareRevision = $"{(decoded.ProductRevision & 0xF0) >> 4:X2}.{decoded.ProductRevision & 0x0F:X2}"; - if(string.IsNullOrWhiteSpace(imageInfo.DriveSerialNumber)) - imageInfo.DriveSerialNumber = $"{decoded.ProductSerialNumber}"; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveSerialNumber)) + _imageInfo.DriveSerialNumber = $"{decoded.ProductSerialNumber}"; } // Search for SCSI INQUIRY - if(mediaTags.TryGetValue(MediaTagType.SCSI_INQUIRY, out byte[] scsiInquiry)) + if(_mediaTags.TryGetValue(MediaTagType.SCSI_INQUIRY, out byte[] scsiInquiry)) { Inquiry? nullableInquiry = Inquiry.Decode(scsiInquiry); @@ -92,21 +92,21 @@ namespace Aaru.DiscImages { Inquiry inquiry = nullableInquiry.Value; - if(string.IsNullOrWhiteSpace(imageInfo.DriveManufacturer)) - imageInfo.DriveManufacturer = StringHandlers.CToString(inquiry.VendorIdentification)?.Trim(); + if(string.IsNullOrWhiteSpace(_imageInfo.DriveManufacturer)) + _imageInfo.DriveManufacturer = StringHandlers.CToString(inquiry.VendorIdentification)?.Trim(); - if(string.IsNullOrWhiteSpace(imageInfo.DriveModel)) - imageInfo.DriveModel = StringHandlers.CToString(inquiry.ProductIdentification)?.Trim(); + if(string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) + _imageInfo.DriveModel = StringHandlers.CToString(inquiry.ProductIdentification)?.Trim(); - if(string.IsNullOrWhiteSpace(imageInfo.DriveFirmwareRevision)) - imageInfo.DriveFirmwareRevision = + if(string.IsNullOrWhiteSpace(_imageInfo.DriveFirmwareRevision)) + _imageInfo.DriveFirmwareRevision = StringHandlers.CToString(inquiry.ProductRevisionLevel)?.Trim(); } } // Search for ATA or ATAPI IDENTIFY - if(!mediaTags.TryGetValue(MediaTagType.ATA_IDENTIFY, out byte[] ataIdentify) && - !mediaTags.TryGetValue(MediaTagType.ATAPI_IDENTIFY, out ataIdentify)) + if(!_mediaTags.TryGetValue(MediaTagType.ATA_IDENTIFY, out byte[] ataIdentify) && + !_mediaTags.TryGetValue(MediaTagType.ATAPI_IDENTIFY, out ataIdentify)) return; Identify.IdentifyDevice? nullableIdentify = CommonTypes.Structs.Devices.ATA.Identify.Decode(ataIdentify); @@ -119,22 +119,22 @@ namespace Aaru.DiscImages string[] separated = identify.Model.Split(' '); if(separated.Length == 1) - if(string.IsNullOrWhiteSpace(imageInfo.DriveModel)) - imageInfo.DriveModel = separated[0]; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) + _imageInfo.DriveModel = separated[0]; else { - if(string.IsNullOrWhiteSpace(imageInfo.DriveManufacturer)) - imageInfo.DriveManufacturer = separated[0]; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveManufacturer)) + _imageInfo.DriveManufacturer = separated[0]; - if(string.IsNullOrWhiteSpace(imageInfo.DriveModel)) - imageInfo.DriveModel = separated[^1]; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) + _imageInfo.DriveModel = separated[^1]; } - if(string.IsNullOrWhiteSpace(imageInfo.DriveFirmwareRevision)) - imageInfo.DriveFirmwareRevision = identify.FirmwareRevision; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveFirmwareRevision)) + _imageInfo.DriveFirmwareRevision = identify.FirmwareRevision; - if(string.IsNullOrWhiteSpace(imageInfo.DriveSerialNumber)) - imageInfo.DriveSerialNumber = identify.SerialNumber; + if(string.IsNullOrWhiteSpace(_imageInfo.DriveSerialNumber)) + _imageInfo.DriveSerialNumber = identify.SerialNumber; } // Get the CICM XML media type from Aaru media type @@ -241,24 +241,24 @@ namespace Aaru.DiscImages // Gets a DDT entry ulong GetDdtEntry(ulong sectorAddress) { - if(inMemoryDdt) - return userDataDdt[sectorAddress]; + if(_inMemoryDdt) + return _userDataDdt[sectorAddress]; - if(ddtEntryCache.TryGetValue(sectorAddress, out ulong entry)) + if(_ddtEntryCache.TryGetValue(sectorAddress, out ulong entry)) return entry; - long oldPosition = imageStream.Position; - imageStream.Position = outMemoryDdtPosition + Marshal.SizeOf(); - imageStream.Position += (long)(sectorAddress * sizeof(ulong)); + long oldPosition = _imageStream.Position; + _imageStream.Position = _outMemoryDdtPosition + Marshal.SizeOf(); + _imageStream.Position += (long)(sectorAddress * sizeof(ulong)); byte[] temp = new byte[sizeof(ulong)]; - imageStream.Read(temp, 0, sizeof(ulong)); - imageStream.Position = oldPosition; - entry = BitConverter.ToUInt64(temp, 0); + _imageStream.Read(temp, 0, sizeof(ulong)); + _imageStream.Position = oldPosition; + entry = BitConverter.ToUInt64(temp, 0); - if(ddtEntryCache.Count >= MAX_DDT_ENTRY_CACHE) - ddtEntryCache.Clear(); + if(_ddtEntryCache.Count >= MAX_DDT_ENTRY_CACHE) + _ddtEntryCache.Clear(); - ddtEntryCache.Add(sectorAddress, entry); + _ddtEntryCache.Add(sectorAddress, entry); return entry; } @@ -266,21 +266,21 @@ namespace Aaru.DiscImages // Sets a DDT entry void SetDdtEntry(ulong sectorAddress, ulong pointer) { - if(inMemoryDdt) + if(_inMemoryDdt) { if(IsTape) - tapeDdt[sectorAddress] = pointer; + _tapeDdt[sectorAddress] = pointer; else - userDataDdt[sectorAddress] = pointer; + _userDataDdt[sectorAddress] = pointer; return; } - long oldPosition = imageStream.Position; - imageStream.Position = outMemoryDdtPosition + Marshal.SizeOf(); - imageStream.Position += (long)(sectorAddress * sizeof(ulong)); - imageStream.Write(BitConverter.GetBytes(pointer), 0, sizeof(ulong)); - imageStream.Position = oldPosition; + long oldPosition = _imageStream.Position; + _imageStream.Position = _outMemoryDdtPosition + Marshal.SizeOf(); + _imageStream.Position += (long)(sectorAddress * sizeof(ulong)); + _imageStream.Write(BitConverter.GetBytes(pointer), 0, sizeof(ulong)); + _imageStream.Position = oldPosition; } // Converts between image data type and Aaru media tag type diff --git a/Aaru.Images/AaruFormat/Identify.cs b/Aaru.Images/AaruFormat/Identify.cs index 9fc7d34e2..181be2ae7 100644 --- a/Aaru.Images/AaruFormat/Identify.cs +++ b/Aaru.Images/AaruFormat/Identify.cs @@ -40,18 +40,18 @@ namespace Aaru.DiscImages { public bool Identify(IFilter imageFilter) { - imageStream = imageFilter.GetDataForkStream(); - imageStream.Seek(0, SeekOrigin.Begin); + _imageStream = imageFilter.GetDataForkStream(); + _imageStream.Seek(0, SeekOrigin.Begin); - if(imageStream.Length < Marshal.SizeOf()) + if(_imageStream.Length < Marshal.SizeOf()) return false; - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - header = Marshal.ByteArrayToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + _header = Marshal.ByteArrayToStructureLittleEndian(_structureBytes); - return (header.identifier == DIC_MAGIC || header.identifier == AARU_MAGIC) && - header.imageMajorVersion <= AARUFMT_VERSION; + return (_header.identifier == DIC_MAGIC || _header.identifier == AARU_MAGIC) && + _header.imageMajorVersion <= AARUFMT_VERSION; } } } \ No newline at end of file diff --git a/Aaru.Images/AaruFormat/Properties.cs b/Aaru.Images/AaruFormat/Properties.cs index 8b8afce01..f6ea1ca09 100644 --- a/Aaru.Images/AaruFormat/Properties.cs +++ b/Aaru.Images/AaruFormat/Properties.cs @@ -56,7 +56,7 @@ namespace Aaru.DiscImages OpticalImageCapabilities.CanStoreNotCdSessions | OpticalImageCapabilities.CanStoreNotCdTracks | OpticalImageCapabilities.CanStoreIndexes; - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Aaru Format"; public Guid Id => new Guid("49360069-1784-4A2F-B723-0C844D610B0A"); public string Format => "Aaru"; diff --git a/Aaru.Images/AaruFormat/Read.cs b/Aaru.Images/AaruFormat/Read.cs index f4ec3f21c..5566e8d30 100644 --- a/Aaru.Images/AaruFormat/Read.cs +++ b/Aaru.Images/AaruFormat/Read.cs @@ -60,31 +60,32 @@ namespace Aaru.DiscImages { AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); - imageStream = imageFilter.GetDataForkStream(); - imageStream.Seek(0, SeekOrigin.Begin); + _imageStream = imageFilter.GetDataForkStream(); + _imageStream.Seek(0, SeekOrigin.Begin); - if(imageStream.Length < Marshal.SizeOf()) + if(_imageStream.Length < Marshal.SizeOf()) return false; - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - header = Marshal.ByteArrayToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + _header = Marshal.ByteArrayToStructureLittleEndian(_structureBytes); - if(header.imageMajorVersion > AARUFMT_VERSION) - throw new FeatureUnsupportedImageException($"Image version {header.imageMajorVersion} not recognized."); + if(_header.imageMajorVersion > AARUFMT_VERSION) + throw + new FeatureUnsupportedImageException($"Image version {_header.imageMajorVersion} not recognized."); - imageInfo.Application = header.application; - imageInfo.ApplicationVersion = $"{header.applicationMajorVersion}.{header.applicationMinorVersion}"; - imageInfo.Version = $"{header.imageMajorVersion}.{header.imageMinorVersion}"; - imageInfo.MediaType = header.mediaType; + _imageInfo.Application = _header.application; + _imageInfo.ApplicationVersion = $"{_header.applicationMajorVersion}.{_header.applicationMinorVersion}"; + _imageInfo.Version = $"{_header.imageMajorVersion}.{_header.imageMinorVersion}"; + _imageInfo.MediaType = _header.mediaType; AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); // Read the index header - imageStream.Position = (long)header.indexOffset; - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - IndexHeader idxHeader = Marshal.SpanToStructureLittleEndian(structureBytes); + _imageStream.Position = (long)_header.indexOffset; + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + IndexHeader idxHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); if(idxHeader.identifier != BlockType.Index && idxHeader.identifier != BlockType.Index2) @@ -92,69 +93,69 @@ namespace Aaru.DiscImages if(idxHeader.identifier == BlockType.Index2) { - imageStream.Position = (long)header.indexOffset; - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - IndexHeader2 idxHeader2 = Marshal.SpanToStructureLittleEndian(structureBytes); + _imageStream.Position = (long)_header.indexOffset; + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + IndexHeader2 idxHeader2 = Marshal.SpanToStructureLittleEndian(_structureBytes); AaruConsole.DebugWriteLine("Aaru Format plugin", "Index at {0} contains {1} entries", - header.indexOffset, idxHeader2.entries); + _header.indexOffset, idxHeader2.entries); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); // Fill in-memory index - index = new List(); + _index = new List(); for(ulong i = 0; i < idxHeader2.entries; i++) { - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - IndexEntry entry = Marshal.SpanToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + IndexEntry entry = Marshal.SpanToStructureLittleEndian(_structureBytes); AaruConsole.DebugWriteLine("Aaru Format plugin", "Block type {0} with data type {1} is indexed to be at {2}", entry.blockType, entry.dataType, entry.offset); - index.Add(entry); + _index.Add(entry); } } else { AaruConsole.DebugWriteLine("Aaru Format plugin", "Index at {0} contains {1} entries", - header.indexOffset, idxHeader.entries); + _header.indexOffset, idxHeader.entries); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); // Fill in-memory index - index = new List(); + _index = new List(); for(ushort i = 0; i < idxHeader.entries; i++) { - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - IndexEntry entry = Marshal.SpanToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + IndexEntry entry = Marshal.SpanToStructureLittleEndian(_structureBytes); AaruConsole.DebugWriteLine("Aaru Format plugin", "Block type {0} with data type {1} is indexed to be at {2}", entry.blockType, entry.dataType, entry.offset); - index.Add(entry); + _index.Add(entry); } } AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); - imageInfo.ImageSize = 0; + _imageInfo.ImageSize = 0; bool foundUserDataDdt = false; - mediaTags = new Dictionary(); + _mediaTags = new Dictionary(); List compactDiscIndexes = null; - foreach(IndexEntry entry in index) + foreach(IndexEntry entry in _index) { - imageStream.Position = (long)entry.offset; + _imageStream.Position = (long)entry.offset; switch(entry.blockType) { @@ -163,18 +164,18 @@ namespace Aaru.DiscImages if(entry.dataType == DataType.NoData) break; - imageStream.Position = (long)entry.offset; + _imageStream.Position = (long)entry.offset; - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - BlockHeader blockHeader = Marshal.SpanToStructureLittleEndian(structureBytes); - imageInfo.ImageSize += blockHeader.cmpLength; + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + BlockHeader blockHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); + _imageInfo.ImageSize += blockHeader.cmpLength; // Unused, skip if(entry.dataType == DataType.UserData) { - if(blockHeader.sectorSize > imageInfo.SectorSize) - imageInfo.SectorSize = blockHeader.sectorSize; + if(blockHeader.sectorSize > _imageInfo.SectorSize) + _imageInfo.SectorSize = blockHeader.sectorSize; break; } @@ -222,8 +223,8 @@ namespace Aaru.DiscImages DateTime startDecompress = DateTime.Now; byte[] compressedTag = new byte[blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; - imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); - imageStream.Read(compressedTag, 0, compressedTag.Length); + _imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); + _imageStream.Read(compressedTag, 0, compressedTag.Length); var compressedTagMs = new MemoryStream(compressedTag); var lzmaBlock = new LzmaStream(lzmaProperties, compressedTagMs); data = new byte[blockHeader.length]; @@ -245,7 +246,7 @@ namespace Aaru.DiscImages else if(blockHeader.compression == CompressionType.None) { data = new byte[blockHeader.length]; - imageStream.Read(data, 0, (int)blockHeader.length); + _imageStream.Read(data, 0, (int)blockHeader.length); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -278,17 +279,17 @@ namespace Aaru.DiscImages case DataType.CdSectorPrefixCorrected: if(entry.dataType == DataType.CdSectorPrefixCorrected) { - sectorPrefixMs = new NonClosableStream(); - sectorPrefixMs.Write(data, 0, data.Length); + _sectorPrefixMs = new NonClosableStream(); + _sectorPrefixMs.Write(data, 0, data.Length); } else - sectorPrefix = data; + _sectorPrefix = data; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -298,36 +299,36 @@ namespace Aaru.DiscImages case DataType.CdSectorSuffixCorrected: if(entry.dataType == DataType.CdSectorSuffixCorrected) { - sectorSuffixMs = new NonClosableStream(); - sectorSuffixMs.Write(data, 0, data.Length); + _sectorSuffixMs = new NonClosableStream(); + _sectorSuffixMs.Write(data, 0, data.Length); } else - sectorSuffix = data; + _sectorSuffix = data; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); break; case DataType.CdSectorSubchannel: - sectorSubchannel = data; + _sectorSubchannel = data; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -336,17 +337,17 @@ namespace Aaru.DiscImages case DataType.AppleProfileTag: case DataType.AppleSonyTag: case DataType.PriamDataTowerTag: - sectorSubchannel = data; + _sectorSubchannel = data; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) - imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); break; case DataType.CompactDiscMode2Subheader: - mode2Subheaders = data; + _mode2Subheaders = data; AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -355,16 +356,16 @@ namespace Aaru.DiscImages default: MediaTagType mediaTagType = GetMediaTagTypeForDataType(blockHeader.type); - if(mediaTags.ContainsKey(mediaTagType)) + if(_mediaTags.ContainsKey(mediaTagType)) { AaruConsole.DebugWriteLine("Aaru Format plugin", "Media tag type {0} duplicated, removing previous entry...", mediaTagType); - mediaTags.Remove(mediaTagType); + _mediaTags.Remove(mediaTagType); } - mediaTags.Add(mediaTagType, data); + _mediaTags.Add(mediaTagType, data); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -374,18 +375,18 @@ namespace Aaru.DiscImages break; case BlockType.DeDuplicationTable: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - DdtHeader ddtHeader = Marshal.SpanToStructureLittleEndian(structureBytes); - imageInfo.ImageSize += ddtHeader.cmpLength; + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + DdtHeader ddtHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); + _imageInfo.ImageSize += ddtHeader.cmpLength; if(ddtHeader.identifier != BlockType.DeDuplicationTable) break; if(entry.dataType == DataType.UserData) { - imageInfo.Sectors = ddtHeader.entries; - shift = ddtHeader.shift; + _imageInfo.Sectors = ddtHeader.entries; + _shift = ddtHeader.shift; AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -398,17 +399,17 @@ namespace Aaru.DiscImages DateTime ddtStart = DateTime.UtcNow; byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; - imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); - imageStream.Read(compressedDdt, 0, compressedDdt.Length); + _imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); + _imageStream.Read(compressedDdt, 0, compressedDdt.Length); var compressedDdtMs = new MemoryStream(compressedDdt); var lzmaDdt = new LzmaStream(lzmaProperties, compressedDdtMs); byte[] decompressedDdt = new byte[ddtHeader.length]; lzmaDdt.Read(decompressedDdt, 0, (int)ddtHeader.length); lzmaDdt.Close(); compressedDdtMs.Close(); - userDataDdt = MemoryMarshal.Cast(decompressedDdt).ToArray(); + _userDataDdt = MemoryMarshal.Cast(decompressedDdt).ToArray(); DateTime ddtEnd = DateTime.UtcNow; - inMemoryDdt = true; + _inMemoryDdt = true; AaruConsole.DebugWriteLine("Aaru Format plugin", "Took {0} seconds to decompress DDT", @@ -419,8 +420,8 @@ namespace Aaru.DiscImages break; case CompressionType.None: - inMemoryDdt = false; - outMemoryDdtPosition = (long)entry.offset; + _inMemoryDdt = false; + _outMemoryDdtPosition = (long)entry.offset; AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -450,8 +451,8 @@ namespace Aaru.DiscImages DateTime ddtStart = DateTime.UtcNow; byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; - imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); - imageStream.Read(compressedDdt, 0, compressedDdt.Length); + _imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); + _imageStream.Read(compressedDdt, 0, compressedDdt.Length); var compressedDdtMs = new MemoryStream(compressedDdt); var lzmaDdt = new LzmaStream(lzmaProperties, compressedDdtMs); lzmaDdt.Read(decompressedDdt, 0, (int)ddtHeader.length); @@ -468,7 +469,7 @@ namespace Aaru.DiscImages break; case CompressionType.None: - imageStream.Read(decompressedDdt, 0, decompressedDdt.Length); + _imageStream.Read(decompressedDdt, 0, decompressedDdt.Length); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -482,9 +483,9 @@ namespace Aaru.DiscImages cdDdt = MemoryMarshal.Cast(decompressedDdt).ToArray(); if(entry.dataType == DataType.CdSectorPrefixCorrected) - sectorPrefixDdt = cdDdt; + _sectorPrefixDdt = cdDdt; else if(entry.dataType == DataType.CdSectorSuffixCorrected) - sectorSuffixDdt = cdDdt; + _sectorSuffixDdt = cdDdt; AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -494,20 +495,20 @@ namespace Aaru.DiscImages // Logical geometry block. It doesn't have a CRC coz, well, it's not so important case BlockType.GeometryBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - geometryBlock = Marshal.SpanToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + _geometryBlock = Marshal.SpanToStructureLittleEndian(_structureBytes); - if(geometryBlock.identifier == BlockType.GeometryBlock) + if(_geometryBlock.identifier == BlockType.GeometryBlock) { AaruConsole.DebugWriteLine("Aaru Format plugin", "Geometry set to {0} cylinders {1} heads {2} sectors per track", - geometryBlock.cylinders, geometryBlock.heads, - geometryBlock.sectorsPerTrack); + _geometryBlock.cylinders, _geometryBlock.heads, + _geometryBlock.sectorsPerTrack); - imageInfo.Cylinders = geometryBlock.cylinders; - imageInfo.Heads = geometryBlock.heads; - imageInfo.SectorsPerTrack = geometryBlock.sectorsPerTrack; + _imageInfo.Cylinders = _geometryBlock.cylinders; + _imageInfo.Heads = _geometryBlock.heads; + _imageInfo.SectorsPerTrack = _geometryBlock.sectorsPerTrack; AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -517,11 +518,11 @@ namespace Aaru.DiscImages // Metadata block case BlockType.MetadataBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); MetadataBlock metadataBlock = - Marshal.SpanToStructureLittleEndian(structureBytes); + Marshal.SpanToStructureLittleEndian(_structureBytes); if(metadataBlock.identifier != entry.blockType) { @@ -536,152 +537,153 @@ namespace Aaru.DiscImages entry.offset); byte[] metadata = new byte[metadataBlock.blockSize]; - imageStream.Position = (long)entry.offset; - imageStream.Read(metadata, 0, metadata.Length); + _imageStream.Position = (long)entry.offset; + _imageStream.Read(metadata, 0, metadata.Length); if(metadataBlock.mediaSequence > 0 && metadataBlock.lastMediaSequence > 0) { - imageInfo.MediaSequence = metadataBlock.mediaSequence; - imageInfo.LastMediaSequence = metadataBlock.lastMediaSequence; + _imageInfo.MediaSequence = metadataBlock.mediaSequence; + _imageInfo.LastMediaSequence = metadataBlock.lastMediaSequence; AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting media sequence as {0} of {1}", - imageInfo.MediaSequence, imageInfo.LastMediaSequence); + _imageInfo.MediaSequence, _imageInfo.LastMediaSequence); } if(metadataBlock.creatorLength > 0 && metadataBlock.creatorLength + metadataBlock.creatorOffset <= metadata.Length) { - imageInfo.Creator = Encoding.Unicode.GetString(metadata, (int)metadataBlock.creatorOffset, - (int)(metadataBlock.creatorLength - 2)); + _imageInfo.Creator = Encoding.Unicode.GetString(metadata, (int)metadataBlock.creatorOffset, + (int)(metadataBlock.creatorLength - 2)); - AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting creator: {0}", imageInfo.Creator); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting creator: {0}", + _imageInfo.Creator); } if(metadataBlock.commentsOffset > 0 && metadataBlock.commentsLength + metadataBlock.commentsOffset <= metadata.Length) { - imageInfo.Comments = + _imageInfo.Comments = Encoding.Unicode.GetString(metadata, (int)metadataBlock.commentsOffset, (int)(metadataBlock.commentsLength - 2)); AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting comments: {0}", - imageInfo.Comments); + _imageInfo.Comments); } if(metadataBlock.mediaTitleOffset > 0 && metadataBlock.mediaTitleLength + metadataBlock.mediaTitleOffset <= metadata.Length) { - imageInfo.MediaTitle = + _imageInfo.MediaTitle = Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaTitleOffset, (int)(metadataBlock.mediaTitleLength - 2)); AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting media title: {0}", - imageInfo.MediaTitle); + _imageInfo.MediaTitle); } if(metadataBlock.mediaManufacturerOffset > 0 && metadataBlock.mediaManufacturerLength + metadataBlock.mediaManufacturerOffset <= metadata.Length) { - imageInfo.MediaManufacturer = + _imageInfo.MediaManufacturer = Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaManufacturerOffset, (int)(metadataBlock.mediaManufacturerLength - 2)); AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting media manufacturer: {0}", - imageInfo.MediaManufacturer); + _imageInfo.MediaManufacturer); } if(metadataBlock.mediaModelOffset > 0 && metadataBlock.mediaModelLength + metadataBlock.mediaModelOffset <= metadata.Length) { - imageInfo.MediaModel = + _imageInfo.MediaModel = Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaModelOffset, (int)(metadataBlock.mediaModelLength - 2)); AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting media model: {0}", - imageInfo.MediaModel); + _imageInfo.MediaModel); } if(metadataBlock.mediaSerialNumberOffset > 0 && metadataBlock.mediaSerialNumberLength + metadataBlock.mediaSerialNumberOffset <= metadata.Length) { - imageInfo.MediaSerialNumber = + _imageInfo.MediaSerialNumber = Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaSerialNumberOffset, (int)(metadataBlock.mediaSerialNumberLength - 2)); AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting media serial number: {0}", - imageInfo.MediaSerialNumber); + _imageInfo.MediaSerialNumber); } if(metadataBlock.mediaBarcodeOffset > 0 && metadataBlock.mediaBarcodeLength + metadataBlock.mediaBarcodeOffset <= metadata.Length) { - imageInfo.MediaBarcode = + _imageInfo.MediaBarcode = Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaBarcodeOffset, (int)(metadataBlock.mediaBarcodeLength - 2)); AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting media barcode: {0}", - imageInfo.MediaBarcode); + _imageInfo.MediaBarcode); } if(metadataBlock.mediaPartNumberOffset > 0 && metadataBlock.mediaPartNumberLength + metadataBlock.mediaPartNumberOffset <= metadata.Length) { - imageInfo.MediaPartNumber = + _imageInfo.MediaPartNumber = Encoding.Unicode.GetString(metadata, (int)metadataBlock.mediaPartNumberOffset, (int)(metadataBlock.mediaPartNumberLength - 2)); AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting media part number: {0}", - imageInfo.MediaPartNumber); + _imageInfo.MediaPartNumber); } if(metadataBlock.driveManufacturerOffset > 0 && metadataBlock.driveManufacturerLength + metadataBlock.driveManufacturerOffset <= metadata.Length) { - imageInfo.DriveManufacturer = + _imageInfo.DriveManufacturer = Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveManufacturerOffset, (int)(metadataBlock.driveManufacturerLength - 2)); AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting drive manufacturer: {0}", - imageInfo.DriveManufacturer); + _imageInfo.DriveManufacturer); } if(metadataBlock.driveModelOffset > 0 && metadataBlock.driveModelLength + metadataBlock.driveModelOffset <= metadata.Length) { - imageInfo.DriveModel = + _imageInfo.DriveModel = Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveModelOffset, (int)(metadataBlock.driveModelLength - 2)); AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting drive model: {0}", - imageInfo.DriveModel); + _imageInfo.DriveModel); } if(metadataBlock.driveSerialNumberOffset > 0 && metadataBlock.driveSerialNumberLength + metadataBlock.driveSerialNumberOffset <= metadata.Length) { - imageInfo.DriveSerialNumber = + _imageInfo.DriveSerialNumber = Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveSerialNumberOffset, (int)(metadataBlock.driveSerialNumberLength - 2)); AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting drive serial number: {0}", - imageInfo.DriveSerialNumber); + _imageInfo.DriveSerialNumber); } if(metadataBlock.driveFirmwareRevisionOffset > 0 && metadataBlock.driveFirmwareRevisionLength + metadataBlock.driveFirmwareRevisionOffset <= metadata.Length) { - imageInfo.DriveFirmwareRevision = + _imageInfo.DriveFirmwareRevision = Encoding.Unicode.GetString(metadata, (int)metadataBlock.driveFirmwareRevisionOffset, (int)(metadataBlock.driveFirmwareRevisionLength - 2)); AaruConsole.DebugWriteLine("Aaru Format plugin", "Setting drive firmware revision: {0}", - imageInfo.DriveFirmwareRevision); + _imageInfo.DriveFirmwareRevision); } AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", @@ -691,9 +693,9 @@ namespace Aaru.DiscImages // Optical disc tracks block case BlockType.TracksBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - TracksHeader tracksHeader = Marshal.SpanToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + TracksHeader tracksHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); if(tracksHeader.identifier != BlockType.TracksBlock) { @@ -704,9 +706,9 @@ namespace Aaru.DiscImages break; } - structureBytes = new byte[Marshal.SizeOf() * tracksHeader.entries]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - Crc64Context.Data(structureBytes, out byte[] trksCrc); + _structureBytes = new byte[Marshal.SizeOf() * tracksHeader.entries]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + Crc64Context.Data(_structureBytes, out byte[] trksCrc); if(BitConverter.ToUInt64(trksCrc, 0) != tracksHeader.crc64) { @@ -717,22 +719,22 @@ namespace Aaru.DiscImages break; } - imageStream.Position -= structureBytes.Length; + _imageStream.Position -= _structureBytes.Length; - Tracks = new List(); - trackFlags = new Dictionary(); - trackIsrcs = new Dictionary(); + Tracks = new List(); + _trackFlags = new Dictionary(); + _trackIsrcs = new Dictionary(); AaruConsole.DebugWriteLine("Aaru Format plugin", "Found {0} tracks at position {0}", tracksHeader.entries, entry.offset); for(ushort i = 0; i < tracksHeader.entries; i++) { - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); TrackEntry trackEntry = - Marshal.ByteArrayToStructureLittleEndian(structureBytes); + Marshal.ByteArrayToStructureLittleEndian(_structureBytes); Tracks.Add(new Track { @@ -747,20 +749,20 @@ namespace Aaru.DiscImages TrackFilter = imageFilter }); - trackFlags.Add(trackEntry.sequence, trackEntry.flags); - trackIsrcs.Add(trackEntry.sequence, trackEntry.isrc); + _trackFlags.Add(trackEntry.sequence, trackEntry.flags); + _trackIsrcs.Add(trackEntry.sequence, trackEntry.isrc); } - if(trackFlags.Count > 0 && - !imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackFlags)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); + if(_trackFlags.Count > 0 && + !_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackFlags)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); - if(trackIsrcs.Count > 0 && - !imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc); + if(_trackIsrcs.Count > 0 && + !_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc); - imageInfo.HasPartitions = true; - imageInfo.HasSessions = true; + _imageInfo.HasPartitions = true; + _imageInfo.HasSessions = true; AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -769,11 +771,11 @@ namespace Aaru.DiscImages // CICM XML metadata block case BlockType.CicmBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); CicmMetadataBlock cicmBlock = - Marshal.SpanToStructureLittleEndian(structureBytes); + Marshal.SpanToStructureLittleEndian(_structureBytes); if(cicmBlock.identifier != BlockType.CicmBlock) break; @@ -785,7 +787,7 @@ namespace Aaru.DiscImages GC.GetTotalMemory(false)); byte[] cicmBytes = new byte[cicmBlock.length]; - imageStream.Read(cicmBytes, 0, cicmBytes.Length); + _imageStream.Read(cicmBytes, 0, cicmBytes.Length); var cicmMs = new MemoryStream(cicmBytes); var cicmXs = new XmlSerializer(typeof(CICMMetadataType)); @@ -810,11 +812,11 @@ namespace Aaru.DiscImages // Dump hardware block case BlockType.DumpHardwareBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); DumpHardwareHeader dumpBlock = - Marshal.SpanToStructureLittleEndian(structureBytes); + Marshal.SpanToStructureLittleEndian(_structureBytes); if(dumpBlock.identifier != BlockType.DumpHardwareBlock) break; @@ -825,9 +827,9 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); - structureBytes = new byte[dumpBlock.length]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - Crc64Context.Data(structureBytes, out byte[] dumpCrc); + _structureBytes = new byte[dumpBlock.length]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + Crc64Context.Data(_structureBytes, out byte[] dumpCrc); if(BitConverter.ToUInt64(dumpCrc, 0) != dumpBlock.crc64) { @@ -838,17 +840,17 @@ namespace Aaru.DiscImages break; } - imageStream.Position -= structureBytes.Length; + _imageStream.Position -= _structureBytes.Length; DumpHardware = new List(); for(ushort i = 0; i < dumpBlock.entries; i++) { - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); DumpHardwareEntry dumpEntry = - Marshal.SpanToStructureLittleEndian(structureBytes); + Marshal.SpanToStructureLittleEndian(_structureBytes); var dump = new DumpHardwareType { @@ -861,64 +863,64 @@ namespace Aaru.DiscImages if(dumpEntry.manufacturerLength > 0) { tmp = new byte[dumpEntry.manufacturerLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; - dump.Manufacturer = Encoding.UTF8.GetString(tmp); + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; + dump.Manufacturer = Encoding.UTF8.GetString(tmp); } if(dumpEntry.modelLength > 0) { tmp = new byte[dumpEntry.modelLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; - dump.Model = Encoding.UTF8.GetString(tmp); + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; + dump.Model = Encoding.UTF8.GetString(tmp); } if(dumpEntry.revisionLength > 0) { tmp = new byte[dumpEntry.revisionLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; - dump.Revision = Encoding.UTF8.GetString(tmp); + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; + dump.Revision = Encoding.UTF8.GetString(tmp); } if(dumpEntry.firmwareLength > 0) { tmp = new byte[dumpEntry.firmwareLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; - dump.Firmware = Encoding.UTF8.GetString(tmp); + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; + dump.Firmware = Encoding.UTF8.GetString(tmp); } if(dumpEntry.serialLength > 0) { tmp = new byte[dumpEntry.serialLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; - dump.Serial = Encoding.UTF8.GetString(tmp); + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; + dump.Serial = Encoding.UTF8.GetString(tmp); } if(dumpEntry.softwareNameLength > 0) { tmp = new byte[dumpEntry.softwareNameLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; - dump.Software.Name = Encoding.UTF8.GetString(tmp); + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; + dump.Software.Name = Encoding.UTF8.GetString(tmp); } if(dumpEntry.softwareVersionLength > 0) { tmp = new byte[dumpEntry.softwareVersionLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; dump.Software.Version = Encoding.UTF8.GetString(tmp); } if(dumpEntry.softwareOperatingSystemLength > 0) { tmp = new byte[dumpEntry.softwareOperatingSystemLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; dump.Software.OperatingSystem = Encoding.UTF8.GetString(tmp); } @@ -926,7 +928,7 @@ namespace Aaru.DiscImages for(uint j = 0; j < dumpEntry.extents; j++) { - imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Read(tmp, 0, tmp.Length); dump.Extents[j] = new ExtentType { @@ -951,11 +953,11 @@ namespace Aaru.DiscImages // Tape partition block case BlockType.TapePartitionBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); TapePartitionHeader partitionHeader = - Marshal.SpanToStructureLittleEndian(structureBytes); + Marshal.SpanToStructureLittleEndian(_structureBytes); if(partitionHeader.identifier != BlockType.TapePartitionBlock) break; @@ -964,7 +966,7 @@ namespace Aaru.DiscImages entry.offset); byte[] tapePartitionBytes = new byte[partitionHeader.length]; - imageStream.Read(tapePartitionBytes, 0, tapePartitionBytes.Length); + _imageStream.Read(tapePartitionBytes, 0, tapePartitionBytes.Length); Span tapePartitions = MemoryMarshal.Cast(tapePartitionBytes); @@ -985,9 +987,11 @@ namespace Aaru.DiscImages // Tape file block case BlockType.TapeFileBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - TapeFileHeader fileHeader = Marshal.SpanToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + + TapeFileHeader fileHeader = + Marshal.SpanToStructureLittleEndian(_structureBytes); if(fileHeader.identifier != BlockType.TapeFileBlock) break; @@ -996,7 +1000,7 @@ namespace Aaru.DiscImages entry.offset); byte[] tapeFileBytes = new byte[fileHeader.length]; - imageStream.Read(tapeFileBytes, 0, tapeFileBytes.Length); + _imageStream.Read(tapeFileBytes, 0, tapeFileBytes.Length); Span tapeFiles = MemoryMarshal.Cast(tapeFileBytes); Files = new List(); @@ -1015,11 +1019,11 @@ namespace Aaru.DiscImages // Optical disc tracks block case BlockType.CompactDiscIndexesBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); CompactDiscIndexesHeader indexesHeader = - Marshal.SpanToStructureLittleEndian(structureBytes); + Marshal.SpanToStructureLittleEndian(_structureBytes); if(indexesHeader.identifier != BlockType.CompactDiscIndexesBlock) { @@ -1030,9 +1034,9 @@ namespace Aaru.DiscImages break; } - structureBytes = new byte[Marshal.SizeOf() * indexesHeader.entries]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - Crc64Context.Data(structureBytes, out byte[] idsxCrc); + _structureBytes = new byte[Marshal.SizeOf() * indexesHeader.entries]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + Crc64Context.Data(_structureBytes, out byte[] idsxCrc); if(BitConverter.ToUInt64(idsxCrc, 0) != indexesHeader.crc64) { @@ -1043,7 +1047,7 @@ namespace Aaru.DiscImages break; } - imageStream.Position -= structureBytes.Length; + _imageStream.Position -= _structureBytes.Length; compactDiscIndexes = new List(); @@ -1053,12 +1057,12 @@ namespace Aaru.DiscImages for(ushort i = 0; i < indexesHeader.entries; i++) { - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); compactDiscIndexes.Add(Marshal. ByteArrayToStructureLittleEndian(structureBytes)); + >(_structureBytes)); } AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", @@ -1071,39 +1075,39 @@ namespace Aaru.DiscImages if(!foundUserDataDdt) throw new ImageNotSupportedException("Could not find user data deduplication table."); - imageInfo.CreationTime = DateTime.FromFileTimeUtc(header.creationTime); - AaruConsole.DebugWriteLine("Aaru Format plugin", "Image created on {0}", imageInfo.CreationTime); - imageInfo.LastModificationTime = DateTime.FromFileTimeUtc(header.lastWrittenTime); + _imageInfo.CreationTime = DateTime.FromFileTimeUtc(_header.creationTime); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Image created on {0}", _imageInfo.CreationTime); + _imageInfo.LastModificationTime = DateTime.FromFileTimeUtc(_header.lastWrittenTime); AaruConsole.DebugWriteLine("Aaru Format plugin", "Image last written on {0}", - imageInfo.LastModificationTime); + _imageInfo.LastModificationTime); - imageInfo.XmlMediaType = GetXmlMediaType(header.mediaType); + _imageInfo.XmlMediaType = GetXmlMediaType(_header.mediaType); - if(geometryBlock.identifier != BlockType.GeometryBlock && - imageInfo.XmlMediaType == XmlMediaType.BlockMedia) + if(_geometryBlock.identifier != BlockType.GeometryBlock && + _imageInfo.XmlMediaType == XmlMediaType.BlockMedia) { - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; } - imageInfo.ReadableMediaTags.AddRange(mediaTags.Keys); + _imageInfo.ReadableMediaTags.AddRange(_mediaTags.Keys); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); // Initialize caches - blockCache = new Dictionary(); - blockHeaderCache = new Dictionary(); - currentCacheSize = 0; + _blockCache = new Dictionary(); + _blockHeaderCache = new Dictionary(); + _currentCacheSize = 0; - if(!inMemoryDdt) - ddtEntryCache = new Dictionary(); + if(!_inMemoryDdt) + _ddtEntryCache = new Dictionary(); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); // Initialize tracks, sessions and partitions - if(imageInfo.XmlMediaType == XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType == XmlMediaType.OpticalDisc) { AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -1115,26 +1119,26 @@ namespace Aaru.DiscImages { new Track { - TrackBytesPerSector = (int)imageInfo.SectorSize, - TrackEndSector = imageInfo.Sectors - 1, + TrackBytesPerSector = (int)_imageInfo.SectorSize, + TrackEndSector = _imageInfo.Sectors - 1, TrackFile = imageFilter.GetFilename(), TrackFileType = "BINARY", TrackFilter = imageFilter, - TrackRawBytesPerSector = (int)imageInfo.SectorSize, + TrackRawBytesPerSector = (int)_imageInfo.SectorSize, TrackSession = 1, TrackSequence = 1, TrackType = TrackType.Data } }; - trackFlags = new Dictionary + _trackFlags = new Dictionary { { 1, (byte)CdFlags.DataTrack } }; - trackIsrcs = new Dictionary(); + _trackIsrcs = new Dictionary(); } AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", @@ -1208,10 +1212,10 @@ namespace Aaru.DiscImages tracks[i].TrackBytesPerSector = sector.Length; tracks[i].TrackRawBytesPerSector = - (sectorPrefix != null && sectorSuffix != null) || - (sectorPrefixDdt != null && sectorSuffixDdt != null) ? 2352 : sector.Length; + (_sectorPrefix != null && _sectorSuffix != null) || + (_sectorPrefixDdt != null && _sectorSuffixDdt != null) ? 2352 : sector.Length; - if(sectorSubchannel == null) + if(_sectorSubchannel == null) continue; tracks[i].TrackSubchannelFile = tracks[i].TrackFile; @@ -1250,54 +1254,54 @@ namespace Aaru.DiscImages SetMetadataFromTags(); - if(sectorSuffixDdt != null) + if(_sectorSuffixDdt != null) EccInit(); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) return true; - if(imageInfo.MediaType != MediaType.CD && - imageInfo.MediaType != MediaType.CDDA && - imageInfo.MediaType != MediaType.CDG && - imageInfo.MediaType != MediaType.CDEG && - imageInfo.MediaType != MediaType.CDI && - imageInfo.MediaType != MediaType.CDROM && - imageInfo.MediaType != MediaType.CDROMXA && - imageInfo.MediaType != MediaType.CDPLUS && - imageInfo.MediaType != MediaType.CDMO && - imageInfo.MediaType != MediaType.CDR && - imageInfo.MediaType != MediaType.CDRW && - imageInfo.MediaType != MediaType.CDMRW && - imageInfo.MediaType != MediaType.VCD && - imageInfo.MediaType != MediaType.SVCD && - imageInfo.MediaType != MediaType.PCD && - imageInfo.MediaType != MediaType.DTSCD && - imageInfo.MediaType != MediaType.CDMIDI && - imageInfo.MediaType != MediaType.CDV && - imageInfo.MediaType != MediaType.CDIREADY && - imageInfo.MediaType != MediaType.FMTOWNS && - imageInfo.MediaType != MediaType.PS1CD && - imageInfo.MediaType != MediaType.PS2CD && - imageInfo.MediaType != MediaType.MEGACD && - imageInfo.MediaType != MediaType.SATURNCD && - imageInfo.MediaType != MediaType.GDROM && - imageInfo.MediaType != MediaType.GDR && - imageInfo.MediaType != MediaType.MilCD && - imageInfo.MediaType != MediaType.SuperCDROM2 && - imageInfo.MediaType != MediaType.JaguarCD && - imageInfo.MediaType != MediaType.ThreeDO && - imageInfo.MediaType != MediaType.PCFX && - imageInfo.MediaType != MediaType.NeoGeoCD && - imageInfo.MediaType != MediaType.CDTV && - imageInfo.MediaType != MediaType.CD32 && - imageInfo.MediaType != MediaType.Playdia && - imageInfo.MediaType != MediaType.Pippin && - imageInfo.MediaType != MediaType.VideoNow && - imageInfo.MediaType != MediaType.VideoNowColor && - imageInfo.MediaType != MediaType.VideoNowXp && - imageInfo.MediaType != MediaType.CVD) + if(_imageInfo.MediaType != MediaType.CD && + _imageInfo.MediaType != MediaType.CDDA && + _imageInfo.MediaType != MediaType.CDG && + _imageInfo.MediaType != MediaType.CDEG && + _imageInfo.MediaType != MediaType.CDI && + _imageInfo.MediaType != MediaType.CDROM && + _imageInfo.MediaType != MediaType.CDROMXA && + _imageInfo.MediaType != MediaType.CDPLUS && + _imageInfo.MediaType != MediaType.CDMO && + _imageInfo.MediaType != MediaType.CDR && + _imageInfo.MediaType != MediaType.CDRW && + _imageInfo.MediaType != MediaType.CDMRW && + _imageInfo.MediaType != MediaType.VCD && + _imageInfo.MediaType != MediaType.SVCD && + _imageInfo.MediaType != MediaType.PCD && + _imageInfo.MediaType != MediaType.DTSCD && + _imageInfo.MediaType != MediaType.CDMIDI && + _imageInfo.MediaType != MediaType.CDV && + _imageInfo.MediaType != MediaType.CDIREADY && + _imageInfo.MediaType != MediaType.FMTOWNS && + _imageInfo.MediaType != MediaType.PS1CD && + _imageInfo.MediaType != MediaType.PS2CD && + _imageInfo.MediaType != MediaType.MEGACD && + _imageInfo.MediaType != MediaType.SATURNCD && + _imageInfo.MediaType != MediaType.GDROM && + _imageInfo.MediaType != MediaType.GDR && + _imageInfo.MediaType != MediaType.MilCD && + _imageInfo.MediaType != MediaType.SuperCDROM2 && + _imageInfo.MediaType != MediaType.JaguarCD && + _imageInfo.MediaType != MediaType.ThreeDO && + _imageInfo.MediaType != MediaType.PCFX && + _imageInfo.MediaType != MediaType.NeoGeoCD && + _imageInfo.MediaType != MediaType.CDTV && + _imageInfo.MediaType != MediaType.CD32 && + _imageInfo.MediaType != MediaType.Playdia && + _imageInfo.MediaType != MediaType.Pippin && + _imageInfo.MediaType != MediaType.VideoNow && + _imageInfo.MediaType != MediaType.VideoNowColor && + _imageInfo.MediaType != MediaType.VideoNowXp && + _imageInfo.MediaType != MediaType.CVD) foreach(Track track in Tracks) { track.TrackPregap = 0; @@ -1309,7 +1313,7 @@ namespace Aaru.DiscImages public byte[] ReadDiskTag(MediaTagType tag) { - if(mediaTags.TryGetValue(tag, out byte[] data)) + if(_mediaTags.TryGetValue(tag, out byte[] data)) return data; throw new FeatureNotPresentImageException("Requested tag is not present in image"); @@ -1317,24 +1321,24 @@ namespace Aaru.DiscImages public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); ulong ddtEntry = GetDdtEntry(sectorAddress); - uint offsetMask = (uint)((1 << shift) - 1); + uint offsetMask = (uint)((1 << _shift) - 1); ulong offset = ddtEntry & offsetMask; - ulong blockOffset = ddtEntry >> shift; + ulong blockOffset = ddtEntry >> _shift; // Partially written image... as we can't know the real sector size just assume it's common :/ if(ddtEntry == 0) - return new byte[imageInfo.SectorSize]; + return new byte[_imageInfo.SectorSize]; byte[] sector; // Check if block is cached - if(blockCache.TryGetValue(blockOffset, out byte[] block) && - blockHeaderCache.TryGetValue(blockOffset, out BlockHeader blockHeader)) + if(_blockCache.TryGetValue(blockOffset, out byte[] block) && + _blockHeaderCache.TryGetValue(blockOffset, out BlockHeader blockHeader)) { sector = new byte[blockHeader.sectorSize]; Array.Copy(block, (long)(offset * blockHeader.sectorSize), sector, 0, blockHeader.sectorSize); @@ -1343,10 +1347,10 @@ namespace Aaru.DiscImages } // Read block header - imageStream.Position = (long)blockOffset; - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - blockHeader = Marshal.SpanToStructureLittleEndian(structureBytes); + _imageStream.Position = (long)blockOffset; + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + blockHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); // Decompress block AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -1355,7 +1359,7 @@ namespace Aaru.DiscImages { case CompressionType.None: block = new byte[blockHeader.length]; - imageStream.Read(block, 0, (int)blockHeader.length); + _imageStream.Read(block, 0, (int)blockHeader.length); AaruConsole.DebugWriteLine("Aaru Format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false)); @@ -1364,8 +1368,8 @@ namespace Aaru.DiscImages case CompressionType.Lzma: byte[] compressedBlock = new byte[blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; - imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); - imageStream.Read(compressedBlock, 0, compressedBlock.Length); + _imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); + _imageStream.Read(compressedBlock, 0, compressedBlock.Length); var compressedBlockMs = new MemoryStream(compressedBlock); var lzmaBlock = new LzmaStream(lzmaProperties, compressedBlockMs); block = new byte[blockHeader.length]; @@ -1379,7 +1383,7 @@ namespace Aaru.DiscImages break; case CompressionType.Flac: byte[] flacBlock = new byte[blockHeader.cmpLength]; - imageStream.Read(flacBlock, 0, flacBlock.Length); + _imageStream.Read(flacBlock, 0, flacBlock.Length); var flacMs = new MemoryStream(flacBlock); var flakeReader = new AudioDecoder(new DecoderSettings(), "", flacMs); block = new byte[blockHeader.length]; @@ -1399,17 +1403,17 @@ namespace Aaru.DiscImages } // Check if cache needs to be emptied - if(currentCacheSize + blockHeader.length >= MAX_CACHE_SIZE) + if(_currentCacheSize + blockHeader.length >= MAX_CACHE_SIZE) { - currentCacheSize = 0; - blockHeaderCache = new Dictionary(); - blockCache = new Dictionary(); + _currentCacheSize = 0; + _blockHeaderCache = new Dictionary(); + _blockCache = new Dictionary(); } // Add block to cache - currentCacheSize += blockHeader.length; - blockHeaderCache.Add(blockOffset, blockHeader); - blockCache.Add(blockOffset, block); + _currentCacheSize += blockHeader.length; + _blockHeaderCache.Add(blockOffset, blockHeader); + _blockCache.Add(blockOffset, block); sector = new byte[blockHeader.sectorSize]; Array.Copy(block, (long)(offset * blockHeader.sectorSize), sector, 0, blockHeader.sectorSize); @@ -1423,7 +1427,7 @@ namespace Aaru.DiscImages public byte[] ReadSector(ulong sectorAddress, uint track) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureNotPresentImageException("Feature not present in image"); Track trk = Tracks.FirstOrDefault(t => t.TrackSequence == track); @@ -1436,7 +1440,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureNotPresentImageException("Feature not present in image"); Track trk = Tracks.FirstOrDefault(t => t.TrackSequence == track); @@ -1449,11 +1453,11 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); @@ -1474,7 +1478,7 @@ namespace Aaru.DiscImages uint sectorSkip; byte[] dataSource; - if(imageInfo.XmlMediaType == XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType == XmlMediaType.OpticalDisc) { Track trk = Tracks.FirstOrDefault(t => sectorAddress >= t.TrackStartSector && sectorAddress <= t.TrackEndSector); @@ -1499,12 +1503,12 @@ namespace Aaru.DiscImages case SectorTagType.CdSectorSubHeader: case SectorTagType.CdSectorSync: break; case SectorTagType.CdTrackFlags: - return trackFlags.TryGetValue((byte)sectorAddress, out byte flags) ? new[] + return _trackFlags.TryGetValue((byte)sectorAddress, out byte flags) ? new[] { flags } : null; case SectorTagType.CdTrackIsrc: - return trackIsrcs.TryGetValue((byte)sectorAddress, out string isrc) + return _trackIsrcs.TryGetValue((byte)sectorAddress, out string isrc) ? Encoding.UTF8.GetBytes(isrc) : null; default: throw new ArgumentException("Unsupported tag requested", nameof(tag)); } @@ -1519,7 +1523,7 @@ namespace Aaru.DiscImages sectorOffset = 0; sectorSize = 12; sectorSkip = 4; - dataSource = sectorPrefix; + dataSource = _sectorPrefix; break; } @@ -1529,7 +1533,7 @@ namespace Aaru.DiscImages sectorOffset = 12; sectorSize = 4; sectorSkip = 2336; - dataSource = sectorPrefix; + dataSource = _sectorPrefix; break; } @@ -1541,7 +1545,7 @@ namespace Aaru.DiscImages sectorOffset = 12; sectorSize = 276; sectorSkip = 0; - dataSource = sectorSuffix; + dataSource = _sectorSuffix; break; } @@ -1551,7 +1555,7 @@ namespace Aaru.DiscImages sectorOffset = 12; sectorSize = 172; sectorSkip = 104; - dataSource = sectorSuffix; + dataSource = _sectorSuffix; break; } @@ -1561,7 +1565,7 @@ namespace Aaru.DiscImages sectorOffset = 184; sectorSize = 104; sectorSkip = 0; - dataSource = sectorSuffix; + dataSource = _sectorSuffix; break; } @@ -1571,7 +1575,7 @@ namespace Aaru.DiscImages sectorOffset = 0; sectorSize = 4; sectorSkip = 284; - dataSource = sectorSuffix; + dataSource = _sectorSuffix; break; } @@ -1581,7 +1585,7 @@ namespace Aaru.DiscImages sectorOffset = 0; sectorSize = 96; sectorSkip = 0; - dataSource = sectorSubchannel; + dataSource = _sectorSubchannel; break; } @@ -1601,7 +1605,7 @@ namespace Aaru.DiscImages sectorOffset = 0; sectorSize = 12; sectorSkip = 4; - dataSource = sectorPrefix; + dataSource = _sectorPrefix; break; } @@ -1611,7 +1615,7 @@ namespace Aaru.DiscImages sectorOffset = 12; sectorSize = 4; sectorSkip = 0; - dataSource = sectorPrefix; + dataSource = _sectorPrefix; break; } @@ -1621,7 +1625,7 @@ namespace Aaru.DiscImages sectorOffset = 0; sectorSize = 8; sectorSkip = 0; - dataSource = mode2Subheaders; + dataSource = _mode2Subheaders; break; } @@ -1637,7 +1641,7 @@ namespace Aaru.DiscImages sectorOffset = 0; sectorSize = 96; sectorSkip = 0; - dataSource = sectorSubchannel; + dataSource = _sectorSubchannel; break; } @@ -1657,7 +1661,7 @@ namespace Aaru.DiscImages sectorOffset = 0; sectorSize = 96; sectorSkip = 0; - dataSource = sectorSubchannel; + dataSource = _sectorSubchannel; break; } @@ -1696,7 +1700,7 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length, uint track) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureNotPresentImageException("Feature not present in image"); Track trk = Tracks.FirstOrDefault(t => t.TrackSequence == track); @@ -1713,7 +1717,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureNotPresentImageException("Feature not present in image"); Track trk = Tracks.FirstOrDefault(t => t.TrackSequence == track); @@ -1730,7 +1734,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorLong(ulong sectorAddress) { - switch(imageInfo.XmlMediaType) + switch(_imageInfo.XmlMediaType) { case XmlMediaType.OpticalDisc: Track trk = Tracks.FirstOrDefault(t => sectorAddress >= t.TrackStartSector && @@ -1742,8 +1746,8 @@ namespace Aaru.DiscImages throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Can't found track containing requested sector"); - if((sectorSuffix == null || sectorPrefix == null) && - (sectorSuffixMs == null || sectorPrefixMs == null)) + if((_sectorSuffix == null || _sectorPrefix == null) && + (_sectorSuffixMs == null || _sectorPrefixMs == null)) return ReadSector(sectorAddress); byte[] sector = new byte[2352]; @@ -1756,55 +1760,57 @@ namespace Aaru.DiscImages case TrackType.CdMode1: Array.Copy(data, 0, sector, 16, 2048); - if(sectorPrefix != null) - Array.Copy(sectorPrefix, (int)sectorAddress * 16, sector, 0, 16); - else if(sectorPrefixDdt != null) + if(_sectorPrefix != null) + Array.Copy(_sectorPrefix, (int)sectorAddress * 16, sector, 0, 16); + else if(_sectorPrefixDdt != null) { - if((sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) + if((_sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) ReconstructPrefix(ref sector, trk.TrackType, (long)sectorAddress); - else if((sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.NotDumped || - sectorPrefixDdt[sectorAddress] == 0) + else if((_sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == + (uint)CdFixFlags.NotDumped || + _sectorPrefixDdt[sectorAddress] == 0) { // Do nothing } else { - uint prefixPosition = ((sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16; + uint prefixPosition = ((_sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16; - if(prefixPosition > sectorPrefixMs.Length) + if(prefixPosition > _sectorPrefixMs.Length) throw new InvalidProgramException("Incorrect data found in image, please re-dump. If issue persists, please open a bug report."); - sectorPrefixMs.Position = prefixPosition; + _sectorPrefixMs.Position = prefixPosition; - sectorPrefixMs.Read(sector, 0, 16); + _sectorPrefixMs.Read(sector, 0, 16); } } else throw new InvalidProgramException("Should not have arrived here"); - if(sectorSuffix != null) - Array.Copy(sectorSuffix, (int)sectorAddress * 288, sector, 2064, 288); - else if(sectorSuffixDdt != null) + if(_sectorSuffix != null) + Array.Copy(_sectorSuffix, (int)sectorAddress * 288, sector, 2064, 288); + else if(_sectorSuffixDdt != null) { - if((sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) + if((_sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) ReconstructEcc(ref sector, trk.TrackType); - else if((sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.NotDumped || - sectorSuffixDdt[sectorAddress] == 0) + else if((_sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == + (uint)CdFixFlags.NotDumped || + _sectorSuffixDdt[sectorAddress] == 0) { // Do nothing } else { - uint suffixPosition = ((sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288; + uint suffixPosition = ((_sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288; - if(suffixPosition > sectorSuffixMs.Length) + if(suffixPosition > _sectorSuffixMs.Length) throw new InvalidProgramException("Incorrect data found in image, please re-dump. If issue persists, please open a bug report."); - sectorSuffixMs.Position = suffixPosition; + _sectorSuffixMs.Position = suffixPosition; - sectorSuffixMs.Read(sector, 2064, 288); + _sectorSuffixMs.Read(sector, 2064, 288); } } else @@ -1814,55 +1820,58 @@ namespace Aaru.DiscImages case TrackType.CdMode2Formless: case TrackType.CdMode2Form1: case TrackType.CdMode2Form2: - if(sectorPrefix != null) - Array.Copy(sectorPrefix, (int)sectorAddress * 16, sector, 0, 16); - else if(sectorPrefixMs != null) + if(_sectorPrefix != null) + Array.Copy(_sectorPrefix, (int)sectorAddress * 16, sector, 0, 16); + else if(_sectorPrefixMs != null) { - if((sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) + if((_sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) ReconstructPrefix(ref sector, trk.TrackType, (long)sectorAddress); - else if((sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.NotDumped || - sectorPrefixDdt[sectorAddress] == 0) + else if((_sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == + (uint)CdFixFlags.NotDumped || + _sectorPrefixDdt[sectorAddress] == 0) { // Do nothing } else { - uint prefixPosition = ((sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16; + uint prefixPosition = ((_sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16; - if(prefixPosition > sectorPrefixMs.Length) + if(prefixPosition > _sectorPrefixMs.Length) throw new InvalidProgramException("Incorrect data found in image, please re-dump. If issue persists, please open a bug report."); - sectorPrefixMs.Position = prefixPosition; + _sectorPrefixMs.Position = prefixPosition; - sectorPrefixMs.Read(sector, 0, 16); + _sectorPrefixMs.Read(sector, 0, 16); } } else throw new InvalidProgramException("Should not have arrived here"); - if(mode2Subheaders != null && - sectorSuffixDdt != null) + if(_mode2Subheaders != null && + _sectorSuffixDdt != null) { - Array.Copy(mode2Subheaders, (int)sectorAddress * 8, sector, 16, 8); + Array.Copy(_mode2Subheaders, (int)sectorAddress * 8, sector, 16, 8); - if((sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Mode2Form1Ok) + if((_sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Mode2Form1Ok) { Array.Copy(data, 0, sector, 24, 2048); ReconstructEcc(ref sector, TrackType.CdMode2Form1); } - else if((sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == + else if((_sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Mode2Form2Ok || - (sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == + (_sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Mode2Form2NoCrc) { Array.Copy(data, 0, sector, 24, 2324); - if((sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.Mode2Form2Ok) + if((_sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == + (uint)CdFixFlags.Mode2Form2Ok) ReconstructEcc(ref sector, TrackType.CdMode2Form2); } - else if((sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == (uint)CdFixFlags.NotDumped || - sectorSuffixDdt[sectorAddress] == 0) + else if((_sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == + (uint)CdFixFlags.NotDumped || + _sectorSuffixDdt[sectorAddress] == 0) { // Do nothing } @@ -1878,22 +1887,22 @@ namespace Aaru.DiscImages bool form2 = (sector[18] & 0x20) == 0x20 || (sector[22] & 0x20) == 0x20; uint suffixPosition = - ((sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288; + ((_sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288; - if(suffixPosition > sectorSuffixMs.Length) + if(suffixPosition > _sectorSuffixMs.Length) throw new InvalidProgramException("Incorrect data found in image, please re-dump. If issue persists, please open a bug report."); - sectorSuffixMs.Position = suffixPosition; + _sectorSuffixMs.Position = suffixPosition; - sectorSuffixMs.Read(sector, form2 ? 2348 : 2072, form2 ? 4 : 280); + _sectorSuffixMs.Read(sector, form2 ? 2348 : 2072, form2 ? 4 : 280); Array.Copy(data, 0, sector, 24, form2 ? 2324 : 2048); } } } - else if(mode2Subheaders != null) + else if(_mode2Subheaders != null) { - Array.Copy(mode2Subheaders, (int)sectorAddress * 8, sector, 16, 8); + Array.Copy(_mode2Subheaders, (int)sectorAddress * 8, sector, 16, 8); Array.Copy(data, 0, sector, 24, 2328); } else @@ -1904,7 +1913,7 @@ namespace Aaru.DiscImages break; case XmlMediaType.BlockMedia: - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.AppleFileWare: case MediaType.AppleProfile: @@ -1922,7 +1931,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorLong(ulong sectorAddress, uint track) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureNotPresentImageException("Feature not present in image"); Track trk = Tracks.FirstOrDefault(t => t.TrackSequence == track); @@ -1938,7 +1947,7 @@ namespace Aaru.DiscImages byte[] sectors; byte[] data; - switch(imageInfo.XmlMediaType) + switch(_imageInfo.XmlMediaType) { case XmlMediaType.OpticalDisc: Track trk = Tracks.FirstOrDefault(t => sectorAddress >= t.TrackStartSector && @@ -1962,27 +1971,27 @@ namespace Aaru.DiscImages // Join prefix (sync, header) with user data with suffix (edc, ecc p, ecc q) case TrackType.CdMode1: - if(sectorPrefix != null && - sectorSuffix != null) + if(_sectorPrefix != null && + _sectorSuffix != null) { sectors = new byte[2352 * length]; data = ReadSectors(sectorAddress, length); for(uint i = 0; i < length; i++) { - Array.Copy(sectorPrefix, (int)((sectorAddress + i) * 16), sectors, (int)(i * 2352), + Array.Copy(_sectorPrefix, (int)((sectorAddress + i) * 16), sectors, (int)(i * 2352), 16); Array.Copy(data, (int)(i * 2048), sectors, (int)(i * 2352) + 16, 2048); - Array.Copy(sectorSuffix, (int)((sectorAddress + i) * 288), sectors, + Array.Copy(_sectorSuffix, (int)((sectorAddress + i) * 288), sectors, (int)(i * 2352) + 2064, 288); } return sectors; } - else if(sectorPrefixDdt != null && - sectorSuffixDdt != null) + else if(_sectorPrefixDdt != null && + _sectorSuffixDdt != null) { sectors = new byte[2352 * length]; @@ -2001,15 +2010,15 @@ namespace Aaru.DiscImages case TrackType.CdMode2Formless: case TrackType.CdMode2Form1: case TrackType.CdMode2Form2: - if(sectorPrefix != null && - sectorSuffix != null) + if(_sectorPrefix != null && + _sectorSuffix != null) { sectors = new byte[2352 * length]; data = ReadSectors(sectorAddress, length); for(uint i = 0; i < length; i++) { - Array.Copy(sectorPrefix, (int)((sectorAddress + i) * 16), sectors, (int)(i * 2352), + Array.Copy(_sectorPrefix, (int)((sectorAddress + i) * 16), sectors, (int)(i * 2352), 16); Array.Copy(data, (int)(i * 2336), sectors, (int)(i * 2352) + 16, 2336); @@ -2017,8 +2026,8 @@ namespace Aaru.DiscImages return sectors; } - else if(sectorPrefixDdt != null && - sectorSuffixDdt != null) + else if(_sectorPrefixDdt != null && + _sectorSuffixDdt != null) { sectors = new byte[2352 * length]; @@ -2036,7 +2045,7 @@ namespace Aaru.DiscImages break; case XmlMediaType.BlockMedia: - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { // Join user data with tags case MediaType.AppleFileWare: @@ -2045,12 +2054,12 @@ namespace Aaru.DiscImages case MediaType.AppleSonyDS: case MediaType.AppleWidget: case MediaType.PriamDataTower: - if(sectorSubchannel == null) + if(_sectorSubchannel == null) return ReadSector(sectorAddress); uint tagSize = 0; - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.AppleFileWare: case MediaType.AppleProfile: @@ -2075,7 +2084,7 @@ namespace Aaru.DiscImages for(uint i = 0; i < length; i++) { - Array.Copy(sectorSubchannel, (int)((sectorAddress + i) * tagSize), sectors, + Array.Copy(_sectorSubchannel, (int)((sectorAddress + i) * tagSize), sectors, (int)((i * sectorSize) + 512), tagSize); Array.Copy(data, (int)((sectorAddress + i) * 512), sectors, (int)(i * 512), 512); @@ -2092,7 +2101,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureNotPresentImageException("Feature not present in image"); Track trk = Tracks.FirstOrDefault(t => t.TrackSequence == track); diff --git a/Aaru.Images/AaruFormat/Verify.cs b/Aaru.Images/AaruFormat/Verify.cs index 7409228e3..4482f28d1 100644 --- a/Aaru.Images/AaruFormat/Verify.cs +++ b/Aaru.Images/AaruFormat/Verify.cs @@ -44,12 +44,12 @@ namespace Aaru.DiscImages public bool? VerifyMediaImage() { // This will traverse all blocks and check their CRC64 without uncompressing them - AaruConsole.DebugWriteLine("Aaru Format plugin", "Checking index integrity at {0}", header.indexOffset); - imageStream.Position = (long)header.indexOffset; + AaruConsole.DebugWriteLine("Aaru Format plugin", "Checking index integrity at {0}", _header.indexOffset); + _imageStream.Position = (long)_header.indexOffset; - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - IndexHeader idxHeader = Marshal.SpanToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + IndexHeader idxHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); if(idxHeader.identifier != BlockType.Index) { @@ -58,12 +58,12 @@ namespace Aaru.DiscImages return false; } - AaruConsole.DebugWriteLine("Aaru Format plugin", "Index at {0} contains {1} entries", header.indexOffset, + AaruConsole.DebugWriteLine("Aaru Format plugin", "Index at {0} contains {1} entries", _header.indexOffset, idxHeader.entries); - structureBytes = new byte[Marshal.SizeOf() * idxHeader.entries]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - Crc64Context.Data(structureBytes, out byte[] verifyCrc); + _structureBytes = new byte[Marshal.SizeOf() * idxHeader.entries]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + Crc64Context.Data(_structureBytes, out byte[] verifyCrc); if(BitConverter.ToUInt64(verifyCrc, 0) != idxHeader.crc64) { @@ -73,15 +73,15 @@ namespace Aaru.DiscImages return false; } - imageStream.Position -= structureBytes.Length; + _imageStream.Position -= _structureBytes.Length; List vrIndex = new List(); for(ushort i = 0; i < idxHeader.entries; i++) { - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - IndexEntry entry = Marshal.SpanToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + IndexEntry entry = Marshal.SpanToStructureLittleEndian(_structureBytes); AaruConsole.DebugWriteLine("Aaru Format plugin", "Block type {0} with data type {1} is indexed to be at {2}", entry.blockType, @@ -95,7 +95,7 @@ namespace Aaru.DiscImages foreach(IndexEntry entry in vrIndex) { - imageStream.Position = (long)entry.offset; + _imageStream.Position = (long)entry.offset; Crc64Context crcVerify; ulong readBytes; byte[] verifyBytes; @@ -103,9 +103,9 @@ namespace Aaru.DiscImages switch(entry.blockType) { case BlockType.DataBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - BlockHeader blockHeader = Marshal.SpanToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + BlockHeader blockHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); crcVerify = new Crc64Context(); readBytes = 0; @@ -117,13 +117,13 @@ namespace Aaru.DiscImages while(readBytes + VERIFY_SIZE < blockHeader.cmpLength) { verifyBytes = new byte[VERIFY_SIZE]; - imageStream.Read(verifyBytes, 0, verifyBytes.Length); + _imageStream.Read(verifyBytes, 0, verifyBytes.Length); crcVerify.Update(verifyBytes); readBytes += (ulong)verifyBytes.LongLength; } verifyBytes = new byte[blockHeader.cmpLength - readBytes]; - imageStream.Read(verifyBytes, 0, verifyBytes.Length); + _imageStream.Read(verifyBytes, 0, verifyBytes.Length); crcVerify.Update(verifyBytes); verifyCrc = crcVerify.Final(); @@ -139,9 +139,9 @@ namespace Aaru.DiscImages break; case BlockType.DeDuplicationTable: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - DdtHeader ddtHeader = Marshal.SpanToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + DdtHeader ddtHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); crcVerify = new Crc64Context(); readBytes = 0; @@ -153,13 +153,13 @@ namespace Aaru.DiscImages while(readBytes + VERIFY_SIZE < ddtHeader.cmpLength) { verifyBytes = new byte[readBytes]; - imageStream.Read(verifyBytes, 0, verifyBytes.Length); + _imageStream.Read(verifyBytes, 0, verifyBytes.Length); crcVerify.Update(verifyBytes); readBytes += (ulong)verifyBytes.LongLength; } verifyBytes = new byte[ddtHeader.cmpLength - readBytes]; - imageStream.Read(verifyBytes, 0, verifyBytes.Length); + _imageStream.Read(verifyBytes, 0, verifyBytes.Length); crcVerify.Update(verifyBytes); verifyCrc = crcVerify.Final(); @@ -174,16 +174,16 @@ namespace Aaru.DiscImages break; case BlockType.TracksBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - TracksHeader trkHeader = Marshal.SpanToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + TracksHeader trkHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); AaruConsole.DebugWriteLine("Aaru Format plugin", "Track block at {0} contains {1} entries", - header.indexOffset, trkHeader.entries); + _header.indexOffset, trkHeader.entries); - structureBytes = new byte[Marshal.SizeOf() * trkHeader.entries]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - Crc64Context.Data(structureBytes, out verifyCrc); + _structureBytes = new byte[Marshal.SizeOf() * trkHeader.entries]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + Crc64Context.Data(_structureBytes, out verifyCrc); if(BitConverter.ToUInt64(verifyCrc, 0) != trkHeader.crc64) { @@ -207,7 +207,7 @@ namespace Aaru.DiscImages public bool? VerifySector(ulong sectorAddress) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) return null; byte[] buffer = ReadSectorLong(sectorAddress); @@ -222,7 +222,7 @@ namespace Aaru.DiscImages unknownLbas = new List(); // Right now only CompactDisc sectors are verifyable - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) { for(ulong i = sectorAddress; i < sectorAddress + length; i++) unknownLbas.Add(i); @@ -264,7 +264,7 @@ namespace Aaru.DiscImages out List unknownLbas) { // Right now only CompactDisc sectors are verifyable - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) { failingLbas = new List(); unknownLbas = new List(); @@ -307,7 +307,7 @@ namespace Aaru.DiscImages public bool? VerifySector(ulong sectorAddress, uint track) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) return null; byte[] buffer = ReadSectorLong(sectorAddress, track); diff --git a/Aaru.Images/AaruFormat/Write.cs b/Aaru.Images/AaruFormat/Write.cs index 245711327..a14ba3511 100644 --- a/Aaru.Images/AaruFormat/Write.cs +++ b/Aaru.Images/AaruFormat/Write.cs @@ -157,7 +157,7 @@ namespace Aaru.DiscImages if(options.TryGetValue("deduplicate", out tmpValue)) { - if(!bool.TryParse(tmpValue, out deduplicate)) + if(!bool.TryParse(tmpValue, out _deduplicate)) { ErrorMessage = "Invalid value for deduplicate option"; @@ -165,11 +165,11 @@ namespace Aaru.DiscImages } } else - deduplicate = true; + _deduplicate = true; if(options.TryGetValue("compress", out tmpValue)) { - if(!bool.TryParse(tmpValue, out compress)) + if(!bool.TryParse(tmpValue, out _compress)) { ErrorMessage = "Invalid value for compress option"; @@ -177,7 +177,7 @@ namespace Aaru.DiscImages } } else - compress = true; + _compress = true; } else { @@ -188,8 +188,8 @@ namespace Aaru.DiscImages doSha1 = false; doSha256 = false; doSpamsum = false; - deduplicate = true; - compress = true; + _deduplicate = true; + _compress = true; } // This really, cannot happen @@ -201,19 +201,19 @@ namespace Aaru.DiscImages } // Calculate shift - shift = 0; + _shift = 0; uint oldSectorsPerBlock = sectorsPerBlock; while(sectorsPerBlock > 1) { sectorsPerBlock >>= 1; - shift++; + _shift++; } - AaruConsole.DebugWriteLine("Aaru Format plugin", "Got a shift of {0} for {1} sectors per block", shift, + AaruConsole.DebugWriteLine("Aaru Format plugin", "Got a shift of {0} for {1} sectors per block", _shift, oldSectorsPerBlock); - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -223,7 +223,7 @@ namespace Aaru.DiscImages try { - imageStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _imageStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -233,68 +233,68 @@ namespace Aaru.DiscImages } // Check if appending to an existing image - if(imageStream.Length > Marshal.SizeOf()) + if(_imageStream.Length > Marshal.SizeOf()) { - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - header = Marshal.ByteArrayToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + _header = Marshal.ByteArrayToStructureLittleEndian(_structureBytes); - if(header.identifier != DIC_MAGIC && - header.identifier != AARU_MAGIC) + if(_header.identifier != DIC_MAGIC && + _header.identifier != AARU_MAGIC) { ErrorMessage = "Cannot append to a non Aaru Format image"; return false; } - if(header.imageMajorVersion > AARUFMT_VERSION) + if(_header.imageMajorVersion > AARUFMT_VERSION) { - ErrorMessage = $"Cannot append to an unknown image version {header.imageMajorVersion}"; + ErrorMessage = $"Cannot append to an unknown image version {_header.imageMajorVersion}"; return false; } - if(header.mediaType != mediaType) + if(_header.mediaType != mediaType) { ErrorMessage = - $"Cannot write a media with type {mediaType} to an image with type {header.mediaType}"; + $"Cannot write a media with type {mediaType} to an image with type {_header.mediaType}"; return false; } } else { - header = new AaruHeader + _header = new AaruHeader { identifier = AARU_MAGIC, mediaType = mediaType, creationTime = DateTime.UtcNow.ToFileTimeUtc() }; - imageStream.Write(new byte[Marshal.SizeOf()], 0, Marshal.SizeOf()); + _imageStream.Write(new byte[Marshal.SizeOf()], 0, Marshal.SizeOf()); } - header.application = "Aaru"; - header.imageMajorVersion = AARUFMT_VERSION_V1; - header.imageMinorVersion = 0; - header.applicationMajorVersion = (byte)typeof(AaruFormat).Assembly.GetName().Version.Major; - header.applicationMinorVersion = (byte)typeof(AaruFormat).Assembly.GetName().Version.Minor; + _header.application = "Aaru"; + _header.imageMajorVersion = AARUFMT_VERSION_V1; + _header.imageMinorVersion = 0; + _header.applicationMajorVersion = (byte)typeof(AaruFormat).Assembly.GetName().Version.Major; + _header.applicationMinorVersion = (byte)typeof(AaruFormat).Assembly.GetName().Version.Minor; - index = new List(); + _index = new List(); // If there exists an index, we are appending, so read index - if(header.indexOffset > 0) + if(_header.indexOffset > 0) { // Can't calculate checksum of an appended image - md5Provider = null; - sha1Provider = null; - sha256Provider = null; - spamsumProvider = null; + _md5Provider = null; + _sha1Provider = null; + _sha256Provider = null; + _spamsumProvider = null; - imageStream.Position = (long)header.indexOffset; - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - IndexHeader idxHeader = Marshal.SpanToStructureLittleEndian(structureBytes); + _imageStream.Position = (long)_header.indexOffset; + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + IndexHeader idxHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); if(idxHeader.identifier != BlockType.Index) { @@ -304,29 +304,29 @@ namespace Aaru.DiscImages } AaruConsole.DebugWriteLine("Aaru Format plugin", "Index at {0} contains {1} entries", - header.indexOffset, idxHeader.entries); + _header.indexOffset, idxHeader.entries); for(ushort i = 0; i < idxHeader.entries; i++) { - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - IndexEntry entry = Marshal.SpanToStructureLittleEndian(structureBytes); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + IndexEntry entry = Marshal.SpanToStructureLittleEndian(_structureBytes); AaruConsole.DebugWriteLine("Aaru Format plugin", "Block type {0} with data type {1} is indexed to be at {2}", entry.blockType, entry.dataType, entry.offset); - index.Add(entry); + _index.Add(entry); } // Invalidate previous checksum block - index.RemoveAll(t => t.blockType == BlockType.ChecksumBlock && t.dataType == DataType.NoData); + _index.RemoveAll(t => t.blockType == BlockType.ChecksumBlock && t.dataType == DataType.NoData); bool foundUserDataDdt = false; - foreach(IndexEntry entry in index) + foreach(IndexEntry entry in _index) { - imageStream.Position = (long)entry.offset; + _imageStream.Position = (long)entry.offset; switch(entry.blockType) { @@ -344,10 +344,10 @@ namespace Aaru.DiscImages default: continue; } - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - BlockHeader blockHeader = Marshal.SpanToStructureLittleEndian(structureBytes); - imageInfo.ImageSize += blockHeader.cmpLength; + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + BlockHeader blockHeader = Marshal.SpanToStructureLittleEndian(_structureBytes); + _imageInfo.ImageSize += blockHeader.cmpLength; if(blockHeader.identifier != entry.blockType) { @@ -377,8 +377,8 @@ namespace Aaru.DiscImages { byte[] compressedTag = new byte[blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; - imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); - imageStream.Read(compressedTag, 0, compressedTag.Length); + _imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); + _imageStream.Read(compressedTag, 0, compressedTag.Length); var compressedTagMs = new MemoryStream(compressedTag); var lzmaBlock = new LzmaStream(lzmaProperties, compressedTagMs); data = new byte[blockHeader.length]; @@ -389,7 +389,7 @@ namespace Aaru.DiscImages else if(blockHeader.compression == CompressionType.None) { data = new byte[blockHeader.length]; - imageStream.Read(data, 0, (int)blockHeader.length); + _imageStream.Read(data, 0, (int)blockHeader.length); } else { @@ -415,28 +415,28 @@ namespace Aaru.DiscImages switch(entry.dataType) { case DataType.CdSectorPrefix: - sectorPrefix = data; + _sectorPrefix = data; break; case DataType.CdSectorSuffix: - sectorSuffix = data; + _sectorSuffix = data; break; case DataType.CdSectorPrefixCorrected: - sectorPrefixMs = new NonClosableStream(); - sectorPrefixMs.Write(data, 0, data.Length); + _sectorPrefixMs = new NonClosableStream(); + _sectorPrefixMs.Write(data, 0, data.Length); break; case DataType.CdSectorSuffixCorrected: - sectorSuffixMs = new NonClosableStream(); - sectorSuffixMs.Write(data, 0, data.Length); + _sectorSuffixMs = new NonClosableStream(); + _sectorSuffixMs.Write(data, 0, data.Length); break; case DataType.CdSectorSubchannel: case DataType.AppleProfileTag: case DataType.AppleSonyTag: case DataType.PriamDataTowerTag: - sectorSubchannel = data; + _sectorSubchannel = data; break; } @@ -446,25 +446,25 @@ namespace Aaru.DiscImages // Only user data deduplication tables are used right now if(entry.dataType == DataType.UserData) { - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); DdtHeader ddtHeader = - Marshal.ByteArrayToStructureLittleEndian(structureBytes); + Marshal.ByteArrayToStructureLittleEndian(_structureBytes); if(ddtHeader.identifier != BlockType.DeDuplicationTable) break; - if(ddtHeader.entries != imageInfo.Sectors && + if(ddtHeader.entries != _imageInfo.Sectors && !IsTape) { ErrorMessage = - $"Trying to write a media with {imageInfo.Sectors} sectors to an image with {ddtHeader.entries} sectors, not continuing..."; + $"Trying to write a media with {_imageInfo.Sectors} sectors to an image with {ddtHeader.entries} sectors, not continuing..."; return false; } - shift = ddtHeader.shift; + _shift = ddtHeader.shift; switch(ddtHeader.compression) { @@ -476,17 +476,17 @@ namespace Aaru.DiscImages byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; - imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); - imageStream.Read(compressedDdt, 0, compressedDdt.Length); + _imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); + _imageStream.Read(compressedDdt, 0, compressedDdt.Length); var compressedDdtMs = new MemoryStream(compressedDdt); var lzmaDdt = new LzmaStream(lzmaProperties, compressedDdtMs); byte[] decompressedDdt = new byte[ddtHeader.length]; lzmaDdt.Read(decompressedDdt, 0, (int)ddtHeader.length); lzmaDdt.Close(); compressedDdtMs.Close(); - userDataDdt = MemoryMarshal.Cast(decompressedDdt).ToArray(); + _userDataDdt = MemoryMarshal.Cast(decompressedDdt).ToArray(); DateTime ddtEnd = DateTime.UtcNow; - inMemoryDdt = true; + _inMemoryDdt = true; AaruConsole.DebugWriteLine("Aaru Format plugin", "Took {0} seconds to decompress DDT", @@ -494,8 +494,8 @@ namespace Aaru.DiscImages break; case CompressionType.None: - inMemoryDdt = false; - outMemoryDdtPosition = (long)entry.offset; + _inMemoryDdt = false; + _outMemoryDdtPosition = (long)entry.offset; break; default: @@ -505,12 +505,12 @@ namespace Aaru.DiscImages if(IsTape) { - tapeDdt = new Dictionary(); + _tapeDdt = new Dictionary(); - for(long i = 0; i < userDataDdt.LongLength; i++) - tapeDdt.Add((ulong)i, userDataDdt[i]); + for(long i = 0; i < _userDataDdt.LongLength; i++) + _tapeDdt.Add((ulong)i, _userDataDdt[i]); - userDataDdt = null; + _userDataDdt = null; } foundUserDataDdt = true; @@ -518,19 +518,19 @@ namespace Aaru.DiscImages else if(entry.dataType == DataType.CdSectorPrefixCorrected || entry.dataType == DataType.CdSectorSuffixCorrected) { - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); DdtHeader ddtHeader = - Marshal.ByteArrayToStructureLittleEndian(structureBytes); + Marshal.ByteArrayToStructureLittleEndian(_structureBytes); if(ddtHeader.identifier != BlockType.DeDuplicationTable) break; - if(ddtHeader.entries != imageInfo.Sectors) + if(ddtHeader.entries != _imageInfo.Sectors) { ErrorMessage = - $"Trying to write a media with {imageInfo.Sectors} sectors to an image with {ddtHeader.entries} sectors, not continuing..."; + $"Trying to write a media with {_imageInfo.Sectors} sectors to an image with {ddtHeader.entries} sectors, not continuing..."; return false; } @@ -547,8 +547,8 @@ namespace Aaru.DiscImages byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; - imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); - imageStream.Read(compressedDdt, 0, compressedDdt.Length); + _imageStream.Read(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); + _imageStream.Read(compressedDdt, 0, compressedDdt.Length); var compressedDdtMs = new MemoryStream(compressedDdt); var lzmaDdt = new LzmaStream(lzmaProperties, compressedDdtMs); lzmaDdt.Read(decompressedDdt, 0, (int)ddtHeader.length); @@ -562,7 +562,7 @@ namespace Aaru.DiscImages break; case CompressionType.None: - imageStream.Read(decompressedDdt, 0, decompressedDdt.Length); + _imageStream.Read(decompressedDdt, 0, decompressedDdt.Length); break; default: @@ -575,11 +575,11 @@ namespace Aaru.DiscImages switch(entry.dataType) { case DataType.CdSectorPrefixCorrected: - sectorPrefixDdt = cdDdt; + _sectorPrefixDdt = cdDdt; break; case DataType.CdSectorSuffixCorrected: - sectorSuffixDdt = cdDdt; + _sectorSuffixDdt = cdDdt; break; } @@ -589,11 +589,11 @@ namespace Aaru.DiscImages // CICM XML metadata block case BlockType.CicmBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); CicmMetadataBlock cicmBlock = - Marshal.SpanToStructureLittleEndian(structureBytes); + Marshal.SpanToStructureLittleEndian(_structureBytes); if(cicmBlock.identifier != BlockType.CicmBlock) break; @@ -602,7 +602,7 @@ namespace Aaru.DiscImages "Found CICM XML metadata block at position {0}", entry.offset); byte[] cicmBytes = new byte[cicmBlock.length]; - imageStream.Read(cicmBytes, 0, cicmBytes.Length); + _imageStream.Read(cicmBytes, 0, cicmBytes.Length); var cicmMs = new MemoryStream(cicmBytes); var cicmXs = new XmlSerializer(typeof(CICMMetadataType)); @@ -625,11 +625,11 @@ namespace Aaru.DiscImages // Dump hardware block case BlockType.DumpHardwareBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); DumpHardwareHeader dumpBlock = - Marshal.SpanToStructureLittleEndian(structureBytes); + Marshal.SpanToStructureLittleEndian(_structureBytes); if(dumpBlock.identifier != BlockType.DumpHardwareBlock) break; @@ -637,9 +637,9 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Aaru Format plugin", "Found dump hardware block at position {0}", entry.offset); - structureBytes = new byte[dumpBlock.length]; - imageStream.Read(structureBytes, 0, structureBytes.Length); - Crc64Context.Data(structureBytes, out byte[] dumpCrc); + _structureBytes = new byte[dumpBlock.length]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); + Crc64Context.Data(_structureBytes, out byte[] dumpCrc); if(BitConverter.ToUInt64(dumpCrc, 0) != dumpBlock.crc64) { @@ -650,17 +650,17 @@ namespace Aaru.DiscImages break; } - imageStream.Position -= structureBytes.Length; + _imageStream.Position -= _structureBytes.Length; DumpHardware = new List(); for(ushort i = 0; i < dumpBlock.entries; i++) { - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); DumpHardwareEntry dumpEntry = - Marshal.SpanToStructureLittleEndian(structureBytes); + Marshal.SpanToStructureLittleEndian(_structureBytes); var dump = new DumpHardwareType { @@ -673,64 +673,64 @@ namespace Aaru.DiscImages if(dumpEntry.manufacturerLength > 0) { tmp = new byte[dumpEntry.manufacturerLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; - dump.Manufacturer = Encoding.UTF8.GetString(tmp); + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; + dump.Manufacturer = Encoding.UTF8.GetString(tmp); } if(dumpEntry.modelLength > 0) { tmp = new byte[dumpEntry.modelLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; - dump.Model = Encoding.UTF8.GetString(tmp); + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; + dump.Model = Encoding.UTF8.GetString(tmp); } if(dumpEntry.revisionLength > 0) { tmp = new byte[dumpEntry.revisionLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; - dump.Revision = Encoding.UTF8.GetString(tmp); + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; + dump.Revision = Encoding.UTF8.GetString(tmp); } if(dumpEntry.firmwareLength > 0) { tmp = new byte[dumpEntry.firmwareLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; - dump.Firmware = Encoding.UTF8.GetString(tmp); + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; + dump.Firmware = Encoding.UTF8.GetString(tmp); } if(dumpEntry.serialLength > 0) { tmp = new byte[dumpEntry.serialLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; - dump.Serial = Encoding.UTF8.GetString(tmp); + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; + dump.Serial = Encoding.UTF8.GetString(tmp); } if(dumpEntry.softwareNameLength > 0) { tmp = new byte[dumpEntry.softwareNameLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; - dump.Software.Name = Encoding.UTF8.GetString(tmp); + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; + dump.Software.Name = Encoding.UTF8.GetString(tmp); } if(dumpEntry.softwareVersionLength > 0) { tmp = new byte[dumpEntry.softwareVersionLength - 1]; - imageStream.Read(tmp, 0, tmp.Length); - imageStream.Position += 1; + _imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Position += 1; dump.Software.Version = Encoding.UTF8.GetString(tmp); } if(dumpEntry.softwareOperatingSystemLength > 0) { - tmp = new byte[dumpEntry.softwareOperatingSystemLength - 1]; - imageStream.Position += 1; - imageStream.Read(tmp, 0, tmp.Length); + tmp = new byte[dumpEntry.softwareOperatingSystemLength - 1]; + _imageStream.Position += 1; + _imageStream.Read(tmp, 0, tmp.Length); dump.Software.OperatingSystem = Encoding.UTF8.GetString(tmp); } @@ -738,7 +738,7 @@ namespace Aaru.DiscImages for(uint j = 0; j < dumpEntry.extents; j++) { - imageStream.Read(tmp, 0, tmp.Length); + _imageStream.Read(tmp, 0, tmp.Length); dump.Extents[j] = new ExtentType { @@ -760,11 +760,11 @@ namespace Aaru.DiscImages // Tape partition block case BlockType.TapePartitionBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); TapePartitionHeader partitionHeader = - Marshal.SpanToStructureLittleEndian(structureBytes); + Marshal.SpanToStructureLittleEndian(_structureBytes); if(partitionHeader.identifier != BlockType.TapePartitionBlock) break; @@ -773,7 +773,7 @@ namespace Aaru.DiscImages "Found tape partition block at position {0}", entry.offset); byte[] tapePartitionBytes = new byte[partitionHeader.length]; - imageStream.Read(tapePartitionBytes, 0, tapePartitionBytes.Length); + _imageStream.Read(tapePartitionBytes, 0, tapePartitionBytes.Length); Span tapePartitions = MemoryMarshal.Cast(tapePartitionBytes); @@ -794,11 +794,11 @@ namespace Aaru.DiscImages // Tape file block case BlockType.TapeFileBlock: - structureBytes = new byte[Marshal.SizeOf()]; - imageStream.Read(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + _imageStream.Read(_structureBytes, 0, _structureBytes.Length); TapeFileHeader fileHeader = - Marshal.SpanToStructureLittleEndian(structureBytes); + Marshal.SpanToStructureLittleEndian(_structureBytes); if(fileHeader.identifier != BlockType.TapeFileBlock) break; @@ -807,7 +807,7 @@ namespace Aaru.DiscImages entry.offset); byte[] tapeFileBytes = new byte[fileHeader.length]; - imageStream.Read(tapeFileBytes, 0, tapeFileBytes.Length); + _imageStream.Read(tapeFileBytes, 0, tapeFileBytes.Length); Span tapeFiles = MemoryMarshal.Cast(tapeFileBytes); Files = new List(); @@ -833,15 +833,15 @@ namespace Aaru.DiscImages return false; } - if(sectorSuffixMs == null || - sectorSuffixDdt == null || - sectorPrefixMs == null || - sectorPrefixDdt == null) + if(_sectorSuffixMs == null || + _sectorSuffixDdt == null || + _sectorPrefixMs == null || + _sectorPrefixDdt == null) { - sectorSuffixMs = null; - sectorSuffixDdt = null; - sectorPrefixMs = null; - sectorPrefixDdt = null; + _sectorSuffixMs = null; + _sectorSuffixDdt = null; + _sectorPrefixMs = null; + _sectorPrefixDdt = null; } } @@ -849,27 +849,27 @@ namespace Aaru.DiscImages else { // Checking that DDT is smaller than requested size - inMemoryDdt = sectors <= (maxDdtSize * 1024 * 1024) / sizeof(ulong); + _inMemoryDdt = sectors <= (maxDdtSize * 1024 * 1024) / sizeof(ulong); // If in memory, easy - if(inMemoryDdt) + if(_inMemoryDdt) { if(IsTape) - tapeDdt = new Dictionary(); + _tapeDdt = new Dictionary(); else - userDataDdt = new ulong[sectors]; + _userDataDdt = new ulong[sectors]; } // If not, create the block, add to index, and enlarge the file to allow the DDT to exist on-disk else { - outMemoryDdtPosition = imageStream.Position; + _outMemoryDdtPosition = _imageStream.Position; - index.Add(new IndexEntry + _index.Add(new IndexEntry { blockType = BlockType.DeDuplicationTable, dataType = DataType.UserData, - offset = (ulong)outMemoryDdtPosition + offset = (ulong)_outMemoryDdtPosition }); // CRC64 will be calculated later @@ -878,52 +878,52 @@ namespace Aaru.DiscImages identifier = BlockType.DeDuplicationTable, type = DataType.UserData, compression = CompressionType.None, - shift = shift, + shift = _shift, entries = sectors, cmpLength = sectors * sizeof(ulong), length = sectors * sizeof(ulong) }; - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref ddtHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); - structureBytes = null; + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref ddtHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _structureBytes = null; - imageStream.Position += (long)(sectors * sizeof(ulong)) - 1; - imageStream.WriteByte(0); + _imageStream.Position += (long)(sectors * sizeof(ulong)) - 1; + _imageStream.WriteByte(0); } if(doMd5) - md5Provider = new Md5Context(); + _md5Provider = new Md5Context(); if(doSha1) - sha1Provider = new Sha1Context(); + _sha1Provider = new Sha1Context(); if(doSha256) - sha256Provider = new Sha256Context(); + _sha256Provider = new Sha256Context(); if(doSpamsum) - spamsumProvider = new SpamSumContext(); + _spamsumProvider = new SpamSumContext(); } - AaruConsole.DebugWriteLine("Aaru Format plugin", "In memory DDT?: {0}", inMemoryDdt); + AaruConsole.DebugWriteLine("Aaru Format plugin", "In memory DDT?: {0}", _inMemoryDdt); // Initialize tables - imageStream.Seek(0, SeekOrigin.End); - mediaTags = new Dictionary(); - checksumProvider = SHA256.Create(); - deduplicationTable = new Dictionary(); - trackIsrcs = new Dictionary(); - trackFlags = new Dictionary(); + _imageStream.Seek(0, SeekOrigin.End); + _mediaTags = new Dictionary(); + _checksumProvider = SHA256.Create(); + _deduplicationTable = new Dictionary(); + _trackIsrcs = new Dictionary(); + _trackFlags = new Dictionary(); // Initialize compressors properties (all maxed) - lzmaEncoderProperties = new LzmaEncoderProperties(true, (int)dictionary, 273); + _lzmaEncoderProperties = new LzmaEncoderProperties(true, (int)dictionary, 273); - flakeWriterSettings = new EncoderSettings + _flakeWriterSettings = new EncoderSettings { PCM = AudioPCMConfig.RedBook, DoMD5 = false, - BlockSize = (1 << shift) * SAMPLES_PER_SECTOR, + BlockSize = (1 << _shift) * SAMPLES_PER_SECTOR, MinFixedOrder = 0, MaxFixedOrder = 4, MinLPCOrder = 1, @@ -942,11 +942,11 @@ namespace Aaru.DiscImages }; // Check if FLAKE's block size is bigger than what we want - if(flakeWriterSettings.BlockSize > MAX_FLAKE_BLOCK) - flakeWriterSettings.BlockSize = MAX_FLAKE_BLOCK; + if(_flakeWriterSettings.BlockSize > MAX_FLAKE_BLOCK) + _flakeWriterSettings.BlockSize = MAX_FLAKE_BLOCK; - if(flakeWriterSettings.BlockSize < MIN_FLAKE_BLOCK) - flakeWriterSettings.BlockSize = MIN_FLAKE_BLOCK; + if(_flakeWriterSettings.BlockSize < MIN_FLAKE_BLOCK) + _flakeWriterSettings.BlockSize = MIN_FLAKE_BLOCK; AudioEncoder.Vendor = "Aaru"; @@ -965,10 +965,10 @@ namespace Aaru.DiscImages return false; } - if(mediaTags.ContainsKey(tag)) - mediaTags.Remove(tag); + if(_mediaTags.ContainsKey(tag)) + _mediaTags.Remove(tag); - mediaTags.Add(tag, data); + _mediaTags.Add(tag, data); ErrorMessage = ""; @@ -992,34 +992,34 @@ namespace Aaru.DiscImages return false; } - if((imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || !writingLong) && - !rewinded) + if((_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || !_writingLong) && + !_rewinded) { - if(sectorAddress <= lastWrittenBlock && alreadyWrittenZero) + if(sectorAddress <= _lastWrittenBlock && _alreadyWrittenZero) { - rewinded = true; - md5Provider = null; - sha1Provider = null; - sha256Provider = null; - spamsumProvider = null; + _rewinded = true; + _md5Provider = null; + _sha1Provider = null; + _sha256Provider = null; + _spamsumProvider = null; } - md5Provider?.Update(data); - sha1Provider?.Update(data); - sha256Provider?.Update(data); - spamsumProvider?.Update(data); - lastWrittenBlock = sectorAddress; + _md5Provider?.Update(data); + _sha1Provider?.Update(data); + _sha256Provider?.Update(data); + _spamsumProvider?.Update(data); + _lastWrittenBlock = sectorAddress; } if(sectorAddress == 0) - alreadyWrittenZero = true; + _alreadyWrittenZero = true; byte[] hash = null; - writtenSectors++; + _writtenSectors++; // Compute hash only if asked to deduplicate, or the sector is empty (those will always be deduplicated) - if(deduplicate || ArrayHelpers.ArrayIsNullOrEmpty(data)) - hash = checksumProvider.ComputeHash(data); + if(_deduplicate || ArrayHelpers.ArrayIsNullOrEmpty(data)) + hash = _checksumProvider.ComputeHash(data); string hashString = null; @@ -1032,7 +1032,7 @@ namespace Aaru.DiscImages hashString = hashSb.ToString(); - if(deduplicationTable.TryGetValue(hashString, out ulong pointer)) + if(_deduplicationTable.TryGetValue(hashString, out ulong pointer)) { SetDdtEntry(sectorAddress, pointer); ErrorMessage = ""; @@ -1044,7 +1044,7 @@ namespace Aaru.DiscImages var trk = new Track(); // If optical disc check track - if(imageInfo.XmlMediaType == XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType == XmlMediaType.OpticalDisc) { trk = Tracks.FirstOrDefault(t => sectorAddress >= t.TrackStartSector && sectorAddress <= t.TrackEndSector); @@ -1056,27 +1056,27 @@ namespace Aaru.DiscImages } // Close current block first - if(blockStream != null && + if(_blockStream != null && // When sector siz changes - (currentBlockHeader.sectorSize != data.Length || + (_currentBlockHeader.sectorSize != data.Length || // When block if filled - currentBlockOffset == 1 << shift || + _currentBlockOffset == 1 << _shift || // When we change to/from CompactDisc audio - (currentBlockHeader.compression == CompressionType.Flac && trk.TrackType != TrackType.Audio))) + (_currentBlockHeader.compression == CompressionType.Flac && trk.TrackType != TrackType.Audio))) { - currentBlockHeader.length = currentBlockOffset * currentBlockHeader.sectorSize; - currentBlockHeader.crc64 = BitConverter.ToUInt64(crc64.Final(), 0); + _currentBlockHeader.length = _currentBlockOffset * _currentBlockHeader.sectorSize; + _currentBlockHeader.crc64 = BitConverter.ToUInt64(_crc64.Final(), 0); var cmpCrc64Context = new Crc64Context(); byte[] lzmaProperties = new byte[0]; - if(currentBlockHeader.compression == CompressionType.Flac) + if(_currentBlockHeader.compression == CompressionType.Flac) { - long remaining = (currentBlockOffset * SAMPLES_PER_SECTOR) % flakeWriter.Settings.BlockSize; + long remaining = (_currentBlockOffset * SAMPLES_PER_SECTOR) % _flakeWriter.Settings.BlockSize; // Fill FLAC block if(remaining != 0) @@ -1084,132 +1084,132 @@ namespace Aaru.DiscImages var audioBuffer = new AudioBuffer(AudioPCMConfig.RedBook, new byte[remaining * 4], (int)remaining); - flakeWriter.Write(audioBuffer); + _flakeWriter.Write(audioBuffer); } - flakeWriter.Close(); + _flakeWriter.Close(); } - else if(currentBlockHeader.compression == CompressionType.Lzma) + else if(_currentBlockHeader.compression == CompressionType.Lzma) { - lzmaProperties = lzmaBlockStream.Properties; - lzmaBlockStream.Close(); - lzmaBlockStream = null; + lzmaProperties = _lzmaBlockStream.Properties; + _lzmaBlockStream.Close(); + _lzmaBlockStream = null; cmpCrc64Context.Update(lzmaProperties); - if(blockStream.Length > decompressedStream.Length) - currentBlockHeader.compression = CompressionType.None; + if(_blockStream.Length > _decompressedStream.Length) + _currentBlockHeader.compression = CompressionType.None; } - if(currentBlockHeader.compression == CompressionType.None) + if(_currentBlockHeader.compression == CompressionType.None) { - blockStream = decompressedStream; - currentBlockHeader.cmpCrc64 = currentBlockHeader.crc64; + _blockStream = _decompressedStream; + _currentBlockHeader.cmpCrc64 = _currentBlockHeader.crc64; } else { - cmpCrc64Context.Update(blockStream.ToArray()); - currentBlockHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0); + cmpCrc64Context.Update(_blockStream.ToArray()); + _currentBlockHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0); } - currentBlockHeader.cmpLength = (uint)blockStream.Length; + _currentBlockHeader.cmpLength = (uint)_blockStream.Length; - if(currentBlockHeader.compression == CompressionType.Lzma) - currentBlockHeader.cmpLength += LZMA_PROPERTIES_LENGTH; + if(_currentBlockHeader.compression == CompressionType.Lzma) + _currentBlockHeader.cmpLength += LZMA_PROPERTIES_LENGTH; - index.Add(new IndexEntry + _index.Add(new IndexEntry { blockType = BlockType.DataBlock, dataType = DataType.UserData, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }); - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref currentBlockHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); - structureBytes = null; + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref _currentBlockHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _structureBytes = null; - if(currentBlockHeader.compression == CompressionType.Lzma) - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + if(_currentBlockHeader.compression == CompressionType.Lzma) + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); - blockStream.Close(); - blockStream = null; + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); + _blockStream.Close(); + _blockStream = null; GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized, false); - currentBlockOffset = 0; + _currentBlockOffset = 0; } // No block set - if(blockStream == null) + if(_blockStream == null) { - currentBlockHeader = new BlockHeader + _currentBlockHeader = new BlockHeader { identifier = BlockType.DataBlock, type = DataType.UserData, - compression = compress ? CompressionType.Lzma : CompressionType.None, + compression = _compress ? CompressionType.Lzma : CompressionType.None, sectorSize = (uint)data.Length }; - if(imageInfo.XmlMediaType == XmlMediaType.OpticalDisc && - trk.TrackType == TrackType.Audio && - compress) - currentBlockHeader.compression = CompressionType.Flac; + if(_imageInfo.XmlMediaType == XmlMediaType.OpticalDisc && + trk.TrackType == TrackType.Audio && + _compress) + _currentBlockHeader.compression = CompressionType.Flac; // JaguarCD stores data in audio tracks. FLAC is too inefficient, use LZMA there. // VideoNow stores video in audio tracks, and LZMA works better too. - if(((imageInfo.MediaType == MediaType.JaguarCD && trk.TrackSession > 1) || - imageInfo.MediaType == MediaType.VideoNow || imageInfo.MediaType == MediaType.VideoNowColor || - imageInfo.MediaType == MediaType.VideoNowXp) && - trk.TrackType == TrackType.Audio && - compress && - currentBlockHeader.compression == CompressionType.Flac) - currentBlockHeader.compression = CompressionType.Lzma; + if(((_imageInfo.MediaType == MediaType.JaguarCD && trk.TrackSession > 1) || + _imageInfo.MediaType == MediaType.VideoNow || _imageInfo.MediaType == MediaType.VideoNowColor || + _imageInfo.MediaType == MediaType.VideoNowXp) && + trk.TrackType == TrackType.Audio && + _compress && + _currentBlockHeader.compression == CompressionType.Flac) + _currentBlockHeader.compression = CompressionType.Lzma; - blockStream = new NonClosableStream(); - decompressedStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); + _decompressedStream = new NonClosableStream(); - switch(currentBlockHeader.compression) + switch(_currentBlockHeader.compression) { case CompressionType.Flac: - flakeWriter = new AudioEncoder(flakeWriterSettings, "", blockStream) + _flakeWriter = new AudioEncoder(_flakeWriterSettings, "", _blockStream) { DoSeekTable = false }; break; case CompressionType.Lzma: - lzmaBlockStream = new LzmaStream(lzmaEncoderProperties, false, blockStream); + _lzmaBlockStream = new LzmaStream(_lzmaEncoderProperties, false, _blockStream); break; default: - lzmaBlockStream = null; + _lzmaBlockStream = null; break; } - crc64 = new Crc64Context(); + _crc64 = new Crc64Context(); } - ulong ddtEntry = (ulong)((imageStream.Position << shift) + currentBlockOffset); + ulong ddtEntry = (ulong)((_imageStream.Position << _shift) + _currentBlockOffset); if(hash != null) - deduplicationTable.Add(hashString, ddtEntry); + _deduplicationTable.Add(hashString, ddtEntry); - if(currentBlockHeader.compression == CompressionType.Flac) + if(_currentBlockHeader.compression == CompressionType.Flac) { var audioBuffer = new AudioBuffer(AudioPCMConfig.RedBook, data, SAMPLES_PER_SECTOR); - flakeWriter.Write(audioBuffer); + _flakeWriter.Write(audioBuffer); } else { - decompressedStream.Write(data, 0, data.Length); + _decompressedStream.Write(data, 0, data.Length); - if(currentBlockHeader.compression == CompressionType.Lzma) - lzmaBlockStream.Write(data, 0, data.Length); + if(_currentBlockHeader.compression == CompressionType.Lzma) + _lzmaBlockStream.Write(data, 0, data.Length); } SetDdtEntry(sectorAddress, ddtEntry); - crc64.Update(data); - currentBlockOffset++; + _crc64.Update(data); + _currentBlockOffset++; ErrorMessage = ""; @@ -1259,7 +1259,7 @@ namespace Aaru.DiscImages byte[] sector; - switch(imageInfo.XmlMediaType) + switch(_imageInfo.XmlMediaType) { case XmlMediaType.OpticalDisc: Track track = @@ -1278,24 +1278,24 @@ namespace Aaru.DiscImages return false; } - writingLong = true; + _writingLong = true; - if(!rewinded) + if(!_rewinded) { - if(sectorAddress <= lastWrittenBlock && alreadyWrittenZero) + if(sectorAddress <= _lastWrittenBlock && _alreadyWrittenZero) { - rewinded = true; - md5Provider = null; - sha1Provider = null; - sha256Provider = null; - spamsumProvider = null; + _rewinded = true; + _md5Provider = null; + _sha1Provider = null; + _sha256Provider = null; + _spamsumProvider = null; } - md5Provider?.Update(data); - sha1Provider?.Update(data); - sha256Provider?.Update(data); - spamsumProvider?.Update(data); - lastWrittenBlock = sectorAddress; + _md5Provider?.Update(data); + _sha1Provider?.Update(data); + _sha256Provider?.Update(data); + _spamsumProvider?.Update(data); + _lastWrittenBlock = sectorAddress; } bool prefixCorrect; @@ -1310,38 +1310,38 @@ namespace Aaru.DiscImages case TrackType.Audio: case TrackType.Data: return WriteSector(data, sectorAddress); case TrackType.CdMode1: - if(sectorPrefix != null && - sectorSuffix != null) + if(_sectorPrefix != null && + _sectorSuffix != null) { sector = new byte[2048]; - Array.Copy(data, 0, sectorPrefix, (int)sectorAddress * 16, 16); + Array.Copy(data, 0, _sectorPrefix, (int)sectorAddress * 16, 16); Array.Copy(data, 16, sector, 0, 2048); - Array.Copy(data, 2064, sectorSuffix, (int)sectorAddress * 288, 288); + Array.Copy(data, 2064, _sectorSuffix, (int)sectorAddress * 288, 288); return WriteSector(sector, sectorAddress); } - if(sectorSuffixMs == null) - sectorSuffixMs = new NonClosableStream(); + if(_sectorSuffixMs == null) + _sectorSuffixMs = new NonClosableStream(); - if(sectorPrefixMs == null) - sectorPrefixMs = new NonClosableStream(); + if(_sectorPrefixMs == null) + _sectorPrefixMs = new NonClosableStream(); - if(sectorSuffixDdt == null) + if(_sectorSuffixDdt == null) { - sectorSuffixDdt = new uint[imageInfo.Sectors]; + _sectorSuffixDdt = new uint[_imageInfo.Sectors]; EccInit(); } - if(sectorPrefixDdt == null) - sectorPrefixDdt = new uint[imageInfo.Sectors]; + if(_sectorPrefixDdt == null) + _sectorPrefixDdt = new uint[_imageInfo.Sectors]; sector = new byte[2048]; if(ArrayHelpers.ArrayIsNullOrEmpty(data)) { - sectorPrefixDdt[sectorAddress] = (uint)CdFixFlags.NotDumped; - sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.NotDumped; + _sectorPrefixDdt[sectorAddress] = (uint)CdFixFlags.NotDumped; + _sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.NotDumped; return WriteSector(sector, sectorAddress); } @@ -1373,34 +1373,34 @@ namespace Aaru.DiscImages } if(prefixCorrect) - sectorPrefixDdt[sectorAddress] = (uint)CdFixFlags.Correct; + _sectorPrefixDdt[sectorAddress] = (uint)CdFixFlags.Correct; else { - if((sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) > 0) - sectorPrefixMs.Position = - ((sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16; + if((_sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) > 0) + _sectorPrefixMs.Position = + ((_sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16; else - sectorPrefixMs.Seek(0, SeekOrigin.End); + _sectorPrefixMs.Seek(0, SeekOrigin.End); - sectorPrefixDdt[sectorAddress] = (uint)((sectorPrefixMs.Position / 16) + 1); - sectorPrefixMs.Write(data, 0, 16); + _sectorPrefixDdt[sectorAddress] = (uint)((_sectorPrefixMs.Position / 16) + 1); + _sectorPrefixMs.Write(data, 0, 16); } bool correct = SuffixIsCorrect(data); if(correct) - sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.Correct; + _sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.Correct; else { - if((sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) > 0) - sectorSuffixMs.Position = - ((sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288; + if((_sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) > 0) + _sectorSuffixMs.Position = + ((_sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288; else - sectorSuffixMs.Seek(0, SeekOrigin.End); + _sectorSuffixMs.Seek(0, SeekOrigin.End); - sectorSuffixDdt[sectorAddress] = (uint)((sectorSuffixMs.Position / 288) + 1); + _sectorSuffixDdt[sectorAddress] = (uint)((_sectorSuffixMs.Position / 288) + 1); - sectorSuffixMs.Write(data, 2064, 288); + _sectorSuffixMs.Write(data, 2064, 288); } Array.Copy(data, 16, sector, 0, 2048); @@ -1409,36 +1409,36 @@ namespace Aaru.DiscImages case TrackType.CdMode2Formless: case TrackType.CdMode2Form1: case TrackType.CdMode2Form2: - if(sectorPrefix != null && - sectorSuffix != null) + if(_sectorPrefix != null && + _sectorSuffix != null) { sector = new byte[2336]; - Array.Copy(data, 0, sectorPrefix, (int)sectorAddress * 16, 16); + Array.Copy(data, 0, _sectorPrefix, (int)sectorAddress * 16, 16); Array.Copy(data, 16, sector, 0, 2336); return WriteSector(sector, sectorAddress); } - if(sectorSuffixMs == null) - sectorSuffixMs = new NonClosableStream(); + if(_sectorSuffixMs == null) + _sectorSuffixMs = new NonClosableStream(); - if(sectorPrefixMs == null) - sectorPrefixMs = new NonClosableStream(); + if(_sectorPrefixMs == null) + _sectorPrefixMs = new NonClosableStream(); - if(sectorSuffixDdt == null) + if(_sectorSuffixDdt == null) { - sectorSuffixDdt = new uint[imageInfo.Sectors]; + _sectorSuffixDdt = new uint[_imageInfo.Sectors]; EccInit(); } - if(sectorPrefixDdt == null) - sectorPrefixDdt = new uint[imageInfo.Sectors]; + if(_sectorPrefixDdt == null) + _sectorPrefixDdt = new uint[_imageInfo.Sectors]; sector = new byte[2328]; if(ArrayHelpers.ArrayIsNullOrEmpty(data)) { - sectorPrefixDdt[sectorAddress] = (uint)CdFixFlags.NotDumped; + _sectorPrefixDdt[sectorAddress] = (uint)CdFixFlags.NotDumped; return WriteSector(sector, sectorAddress); } @@ -1470,22 +1470,22 @@ namespace Aaru.DiscImages } if(prefixCorrect) - sectorPrefixDdt[sectorAddress] = (uint)CdFixFlags.Correct; + _sectorPrefixDdt[sectorAddress] = (uint)CdFixFlags.Correct; else { - if((sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) > 0) - sectorPrefixMs.Position = - ((sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16; + if((_sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) > 0) + _sectorPrefixMs.Position = + ((_sectorPrefixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 16; else - sectorPrefixMs.Seek(0, SeekOrigin.End); + _sectorPrefixMs.Seek(0, SeekOrigin.End); - sectorPrefixDdt[sectorAddress] = (uint)((sectorPrefixMs.Position / 16) + 1); + _sectorPrefixDdt[sectorAddress] = (uint)((_sectorPrefixMs.Position / 16) + 1); - sectorPrefixMs.Write(data, 0, 16); + _sectorPrefixMs.Write(data, 0, 16); } - if(mode2Subheaders == null) - mode2Subheaders = new byte[imageInfo.Sectors * 8]; + if(_mode2Subheaders == null) + _mode2Subheaders = new byte[_imageInfo.Sectors * 8]; bool form2 = (data[18] & 0x20) == 0x20 || (data[22] & 0x20) == 0x20; @@ -1498,30 +1498,30 @@ namespace Aaru.DiscImages sector = new byte[2324]; - if(sectorSuffixDdt == null) - sectorSuffixDdt = new uint[imageInfo.Sectors]; + if(_sectorSuffixDdt == null) + _sectorSuffixDdt = new uint[_imageInfo.Sectors]; Array.Copy(data, 24, sector, 0, 2324); if(correctEdc) { - sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.Mode2Form2Ok; + _sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.Mode2Form2Ok; } else if(BitConverter.ToUInt32(data, 0x92C) == 0) { - sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.Mode2Form2NoCrc; + _sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.Mode2Form2NoCrc; } else { - if((sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) > 0) - sectorSuffixMs.Position = - ((sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288; + if((_sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) > 0) + _sectorSuffixMs.Position = + ((_sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288; else - sectorSuffixMs.Seek(0, SeekOrigin.End); + _sectorSuffixMs.Seek(0, SeekOrigin.End); - sectorSuffixDdt[sectorAddress] = (uint)((sectorSuffixMs.Position / 288) + 1); + _sectorSuffixDdt[sectorAddress] = (uint)((_sectorSuffixMs.Position / 288) + 1); - sectorSuffixMs.Write(data, 2348, 4); + _sectorSuffixMs.Write(data, 2348, 4); } } else @@ -1538,33 +1538,33 @@ namespace Aaru.DiscImages if(correctEcc && correctEdc) { - if(sectorSuffixDdt == null) - sectorSuffixDdt = new uint[imageInfo.Sectors]; + if(_sectorSuffixDdt == null) + _sectorSuffixDdt = new uint[_imageInfo.Sectors]; - sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.Mode2Form1Ok; + _sectorSuffixDdt[sectorAddress] = (uint)CdFixFlags.Mode2Form1Ok; } else { - if((sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) > 0) - sectorSuffixMs.Position = - ((sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288; + if((_sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) > 0) + _sectorSuffixMs.Position = + ((_sectorSuffixDdt[sectorAddress] & CD_DFIX_MASK) - 1) * 288; else - sectorSuffixMs.Seek(0, SeekOrigin.End); + _sectorSuffixMs.Seek(0, SeekOrigin.End); - sectorSuffixDdt[sectorAddress] = (uint)((sectorSuffixMs.Position / 288) + 1); + _sectorSuffixDdt[sectorAddress] = (uint)((_sectorSuffixMs.Position / 288) + 1); - sectorSuffixMs.Write(data, 2072, 280); + _sectorSuffixMs.Write(data, 2072, 280); } } - Array.Copy(data, 16, mode2Subheaders, (int)sectorAddress * 8, 8); + Array.Copy(data, 16, _mode2Subheaders, (int)sectorAddress * 8, 8); return WriteSector(sector, sectorAddress); } break; case XmlMediaType.BlockMedia: - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { // Split user data from Apple tags case MediaType.AppleFileWare: @@ -1579,8 +1579,8 @@ namespace Aaru.DiscImages switch(data.Length - 512) { // Sony tag, convert to Profile - case 12 when imageInfo.MediaType == MediaType.AppleProfile || - imageInfo.MediaType == MediaType.AppleFileWare: + case 12 when _imageInfo.MediaType == MediaType.AppleProfile || + _imageInfo.MediaType == MediaType.AppleFileWare: oldTag = new byte[12]; Array.Copy(data, 512, oldTag, 0, 12); newTag = LisaTag.DecodeSonyTag(oldTag)?.ToProfile().GetBytes(); @@ -1588,7 +1588,7 @@ namespace Aaru.DiscImages break; // Sony tag, convert to Priam - case 12 when imageInfo.MediaType == MediaType.PriamDataTower: + case 12 when _imageInfo.MediaType == MediaType.PriamDataTower: oldTag = new byte[12]; Array.Copy(data, 512, oldTag, 0, 12); newTag = LisaTag.DecodeSonyTag(oldTag)?.ToPriam().GetBytes(); @@ -1596,23 +1596,23 @@ namespace Aaru.DiscImages break; // Sony tag, copy to Sony - case 12 when imageInfo.MediaType == MediaType.AppleSonySS || - imageInfo.MediaType == MediaType.AppleSonySS: + case 12 when _imageInfo.MediaType == MediaType.AppleSonySS || + _imageInfo.MediaType == MediaType.AppleSonySS: newTag = new byte[12]; Array.Copy(data, 512, newTag, 0, 12); break; // Profile tag, copy to Profile - case 20 when imageInfo.MediaType == MediaType.AppleProfile || - imageInfo.MediaType == MediaType.AppleFileWare: + case 20 when _imageInfo.MediaType == MediaType.AppleProfile || + _imageInfo.MediaType == MediaType.AppleFileWare: newTag = new byte[20]; Array.Copy(data, 512, newTag, 0, 20); break; // Profile tag, convert to Priam - case 20 when imageInfo.MediaType == MediaType.PriamDataTower: + case 20 when _imageInfo.MediaType == MediaType.PriamDataTower: oldTag = new byte[20]; Array.Copy(data, 512, oldTag, 0, 20); newTag = LisaTag.DecodeProfileTag(oldTag)?.ToPriam().GetBytes(); @@ -1620,8 +1620,8 @@ namespace Aaru.DiscImages break; // Profile tag, convert to Sony - case 20 when imageInfo.MediaType == MediaType.AppleSonySS || - imageInfo.MediaType == MediaType.AppleSonySS: + case 20 when _imageInfo.MediaType == MediaType.AppleSonySS || + _imageInfo.MediaType == MediaType.AppleSonySS: oldTag = new byte[20]; Array.Copy(data, 512, oldTag, 0, 20); newTag = LisaTag.DecodeProfileTag(oldTag)?.ToSony().GetBytes(); @@ -1629,8 +1629,8 @@ namespace Aaru.DiscImages break; // Priam tag, convert to Profile - case 24 when imageInfo.MediaType == MediaType.AppleProfile || - imageInfo.MediaType == MediaType.AppleFileWare: + case 24 when _imageInfo.MediaType == MediaType.AppleProfile || + _imageInfo.MediaType == MediaType.AppleFileWare: oldTag = new byte[24]; Array.Copy(data, 512, oldTag, 0, 24); newTag = LisaTag.DecodePriamTag(oldTag)?.ToProfile().GetBytes(); @@ -1638,15 +1638,15 @@ namespace Aaru.DiscImages break; // Priam tag, copy to Priam - case 12 when imageInfo.MediaType == MediaType.PriamDataTower: + case 12 when _imageInfo.MediaType == MediaType.PriamDataTower: newTag = new byte[24]; Array.Copy(data, 512, newTag, 0, 24); break; // Priam tag, convert to Sony - case 24 when imageInfo.MediaType == MediaType.AppleSonySS || - imageInfo.MediaType == MediaType.AppleSonySS: + case 24 when _imageInfo.MediaType == MediaType.AppleSonySS || + _imageInfo.MediaType == MediaType.AppleSonySS: oldTag = new byte[24]; Array.Copy(data, 512, oldTag, 0, 24); newTag = LisaTag.DecodePriamTag(oldTag)?.ToSony().GetBytes(); @@ -1668,10 +1668,10 @@ namespace Aaru.DiscImages if(newTag == null) return WriteSector(sector, sectorAddress); - if(sectorSubchannel == null) - sectorSubchannel = new byte[newTag.Length * (int)imageInfo.Sectors]; + if(_sectorSubchannel == null) + _sectorSubchannel = new byte[newTag.Length * (int)_imageInfo.Sectors]; - Array.Copy(newTag, 0, sectorSubchannel, newTag.Length * (int)sectorAddress, newTag.Length); + Array.Copy(newTag, 0, _sectorSubchannel, newTag.Length * (int)sectorAddress, newTag.Length); return WriteSector(sector, sectorAddress); } @@ -1688,7 +1688,7 @@ namespace Aaru.DiscImages { byte[] sector; - switch(imageInfo.XmlMediaType) + switch(_imageInfo.XmlMediaType) { case XmlMediaType.OpticalDisc: Track track = @@ -1727,7 +1727,7 @@ namespace Aaru.DiscImages return true; case XmlMediaType.BlockMedia: - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.AppleFileWare: case MediaType.AppleProfile: @@ -1776,7 +1776,7 @@ namespace Aaru.DiscImages public bool SetTracks(List tracks) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) { ErrorMessage = "Unsupported feature"; @@ -1806,18 +1806,18 @@ namespace Aaru.DiscImages } // Close current block first - if(blockStream != null) + if(_blockStream != null) { - currentBlockHeader.length = currentBlockOffset * currentBlockHeader.sectorSize; - currentBlockHeader.crc64 = BitConverter.ToUInt64(crc64.Final(), 0); + _currentBlockHeader.length = _currentBlockOffset * _currentBlockHeader.sectorSize; + _currentBlockHeader.crc64 = BitConverter.ToUInt64(_crc64.Final(), 0); var cmpCrc64Context = new Crc64Context(); byte[] lzmaProperties = new byte[0]; - if(currentBlockHeader.compression == CompressionType.Flac) + if(_currentBlockHeader.compression == CompressionType.Flac) { - long remaining = (currentBlockOffset * SAMPLES_PER_SECTOR) % flakeWriter.Settings.BlockSize; + long remaining = (_currentBlockOffset * SAMPLES_PER_SECTOR) % _flakeWriter.Settings.BlockSize; // Fill FLAC block if(remaining != 0) @@ -1825,67 +1825,67 @@ namespace Aaru.DiscImages var audioBuffer = new AudioBuffer(AudioPCMConfig.RedBook, new byte[remaining * 4], (int)remaining); - flakeWriter.Write(audioBuffer); + _flakeWriter.Write(audioBuffer); } - flakeWriter.Close(); + _flakeWriter.Close(); } - else if(currentBlockHeader.compression == CompressionType.Lzma) + else if(_currentBlockHeader.compression == CompressionType.Lzma) { - lzmaProperties = lzmaBlockStream.Properties; - lzmaBlockStream.Close(); - lzmaBlockStream = null; + lzmaProperties = _lzmaBlockStream.Properties; + _lzmaBlockStream.Close(); + _lzmaBlockStream = null; cmpCrc64Context.Update(lzmaProperties); - if(blockStream.Length > decompressedStream.Length) - currentBlockHeader.compression = CompressionType.None; + if(_blockStream.Length > _decompressedStream.Length) + _currentBlockHeader.compression = CompressionType.None; } - if(currentBlockHeader.compression == CompressionType.None) + if(_currentBlockHeader.compression == CompressionType.None) { - blockStream = decompressedStream; - currentBlockHeader.cmpCrc64 = currentBlockHeader.crc64; + _blockStream = _decompressedStream; + _currentBlockHeader.cmpCrc64 = _currentBlockHeader.crc64; } else { - cmpCrc64Context.Update(blockStream.ToArray()); - currentBlockHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0); + cmpCrc64Context.Update(_blockStream.ToArray()); + _currentBlockHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0); } - currentBlockHeader.cmpLength = (uint)blockStream.Length; + _currentBlockHeader.cmpLength = (uint)_blockStream.Length; - if(currentBlockHeader.compression == CompressionType.Lzma) - currentBlockHeader.cmpLength += LZMA_PROPERTIES_LENGTH; + if(_currentBlockHeader.compression == CompressionType.Lzma) + _currentBlockHeader.cmpLength += LZMA_PROPERTIES_LENGTH; - index.Add(new IndexEntry + _index.Add(new IndexEntry { blockType = BlockType.DataBlock, dataType = DataType.UserData, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }); - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref currentBlockHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); - structureBytes = null; + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref _currentBlockHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _structureBytes = null; - if(currentBlockHeader.compression == CompressionType.Lzma) - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + if(_currentBlockHeader.compression == CompressionType.Lzma) + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); - blockStream.ReallyClose(); - blockStream = null; + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); + _blockStream.ReallyClose(); + _blockStream = null; } - if(deduplicate) + if(_deduplicate) AaruConsole.DebugWriteLine("Aaru Format plugin", "Of {0} sectors written, {1} are unique ({2:P})", - writtenSectors, deduplicationTable.Count, - (double)deduplicationTable.Count / writtenSectors); + _writtenSectors, _deduplicationTable.Count, + (double)_deduplicationTable.Count / _writtenSectors); IndexEntry idxEntry; // Write media tag blocks - foreach(KeyValuePair mediaTag in mediaTags) + foreach(KeyValuePair mediaTag in _mediaTags) { DataType dataType = GetDataTypeForMediaTag(mediaTag.Key); @@ -1900,7 +1900,7 @@ namespace Aaru.DiscImages { blockType = BlockType.DataBlock, dataType = dataType, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing tag type {0} to position {1}", mediaTag.Key, @@ -1916,15 +1916,15 @@ namespace Aaru.DiscImages crc64 = BitConverter.ToUInt64(tagCrc, 0) }; - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); byte[] lzmaProperties = - CompressDataToStreamWithLZMA(mediaTag.Value, lzmaEncoderProperties, blockStream); + CompressDataToStreamWithLZMA(mediaTag.Value, _lzmaEncoderProperties, _blockStream); byte[] tagData; // Not compressible - if(blockStream.Length + LZMA_PROPERTIES_LENGTH >= mediaTag.Value.Length) + if(_blockStream.Length + LZMA_PROPERTIES_LENGTH >= mediaTag.Value.Length) { tagBlock.cmpLength = tagBlock.length; tagBlock.cmpCrc64 = tagBlock.crc64; @@ -1933,7 +1933,7 @@ namespace Aaru.DiscImages } else { - tagData = blockStream.ToArray(); + tagData = _blockStream.ToArray(); var crc64Ctx = new Crc64Context(); crc64Ctx.Update(lzmaProperties); crc64Ctx.Update(tagData); @@ -1943,43 +1943,43 @@ namespace Aaru.DiscImages tagBlock.compression = CompressionType.Lzma; } - blockStream.ReallyClose(); - blockStream = null; + _blockStream.ReallyClose(); + _blockStream = null; - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref tagBlock); - imageStream.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref tagBlock); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); if(tagBlock.compression == CompressionType.Lzma) - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(tagData, 0, tagData.Length); + _imageStream.Write(tagData, 0, tagData.Length); - index.RemoveAll(t => t.blockType == BlockType.DataBlock && t.dataType == dataType); + _index.RemoveAll(t => t.blockType == BlockType.DataBlock && t.dataType == dataType); - index.Add(idxEntry); + _index.Add(idxEntry); } // If we have set the geometry block, write it - if(geometryBlock.identifier == BlockType.GeometryBlock) + if(_geometryBlock.identifier == BlockType.GeometryBlock) { idxEntry = new IndexEntry { blockType = BlockType.GeometryBlock, dataType = DataType.NoData, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing geometry block to position {0}", idxEntry.offset); - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref geometryBlock); - imageStream.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref _geometryBlock); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); - index.RemoveAll(t => t.blockType == BlockType.GeometryBlock && t.dataType == DataType.NoData); + _index.RemoveAll(t => t.blockType == BlockType.GeometryBlock && t.dataType == DataType.NoData); - index.Add(idxEntry); + _index.Add(idxEntry); } // If we have dump hardware, write it @@ -2038,9 +2038,9 @@ namespace Aaru.DiscImages extents = (uint)dump.Extents.Length }; - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref dumpEntry); - dumpMs.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref dumpEntry); + dumpMs.Write(_structureBytes, 0, _structureBytes.Length); if(dumpManufacturer != null) { @@ -2101,7 +2101,7 @@ namespace Aaru.DiscImages { blockType = BlockType.DumpHardwareBlock, dataType = DataType.NoData, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing dump hardware block to position {0}", @@ -2117,14 +2117,14 @@ namespace Aaru.DiscImages length = (uint)dumpMs.Length }; - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref dumpBlock); - imageStream.Write(structureBytes, 0, structureBytes.Length); - imageStream.Write(dumpMs.ToArray(), 0, (int)dumpMs.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref dumpBlock); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _imageStream.Write(dumpMs.ToArray(), 0, (int)dumpMs.Length); - index.RemoveAll(t => t.blockType == BlockType.DumpHardwareBlock && t.dataType == DataType.NoData); + _index.RemoveAll(t => t.blockType == BlockType.DumpHardwareBlock && t.dataType == DataType.NoData); - index.Add(idxEntry); + _index.Add(idxEntry); } // If we have CICM XML metadata, write it @@ -2138,7 +2138,7 @@ namespace Aaru.DiscImages { blockType = BlockType.CicmBlock, dataType = DataType.NoData, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing CICM XML block to position {0}", @@ -2150,21 +2150,21 @@ namespace Aaru.DiscImages length = (uint)cicmMs.Length }; - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref cicmBlock); - imageStream.Write(structureBytes, 0, structureBytes.Length); - imageStream.Write(cicmMs.ToArray(), 0, (int)cicmMs.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref cicmBlock); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _imageStream.Write(cicmMs.ToArray(), 0, (int)cicmMs.Length); - index.RemoveAll(t => t.blockType == BlockType.CicmBlock && t.dataType == DataType.NoData); + _index.RemoveAll(t => t.blockType == BlockType.CicmBlock && t.dataType == DataType.NoData); - index.Add(idxEntry); + _index.Add(idxEntry); } // If we have checksums, write it to disk - if(md5Provider != null || - sha1Provider != null || - sha256Provider != null || - spamsumProvider != null) + if(_md5Provider != null || + _sha1Provider != null || + _sha256Provider != null || + _spamsumProvider != null) { var chkMs = new MemoryStream(); @@ -2173,9 +2173,9 @@ namespace Aaru.DiscImages identifier = BlockType.ChecksumBlock }; - if(md5Provider != null) + if(_md5Provider != null) { - byte[] md5 = md5Provider.Final(); + byte[] md5 = _md5Provider.Final(); var md5Entry = new ChecksumEntry { @@ -2183,16 +2183,16 @@ namespace Aaru.DiscImages length = (uint)md5.Length }; - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref md5Entry); - chkMs.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref md5Entry); + chkMs.Write(_structureBytes, 0, _structureBytes.Length); chkMs.Write(md5, 0, md5.Length); chkHeader.entries++; } - if(sha1Provider != null) + if(_sha1Provider != null) { - byte[] sha1 = sha1Provider.Final(); + byte[] sha1 = _sha1Provider.Final(); var sha1Entry = new ChecksumEntry { @@ -2200,16 +2200,16 @@ namespace Aaru.DiscImages length = (uint)sha1.Length }; - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref sha1Entry); - chkMs.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref sha1Entry); + chkMs.Write(_structureBytes, 0, _structureBytes.Length); chkMs.Write(sha1, 0, sha1.Length); chkHeader.entries++; } - if(sha256Provider != null) + if(_sha256Provider != null) { - byte[] sha256 = sha256Provider.Final(); + byte[] sha256 = _sha256Provider.Final(); var sha256Entry = new ChecksumEntry { @@ -2217,16 +2217,16 @@ namespace Aaru.DiscImages length = (uint)sha256.Length }; - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref sha256Entry); - chkMs.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref sha256Entry); + chkMs.Write(_structureBytes, 0, _structureBytes.Length); chkMs.Write(sha256, 0, sha256.Length); chkHeader.entries++; } - if(spamsumProvider != null) + if(_spamsumProvider != null) { - byte[] spamsum = Encoding.ASCII.GetBytes(spamsumProvider.End()); + byte[] spamsum = Encoding.ASCII.GetBytes(_spamsumProvider.End()); var spamsumEntry = new ChecksumEntry { @@ -2234,9 +2234,9 @@ namespace Aaru.DiscImages length = (uint)spamsum.Length }; - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref spamsumEntry); - chkMs.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref spamsumEntry); + chkMs.Write(_structureBytes, 0, _structureBytes.Length); chkMs.Write(spamsum, 0, spamsum.Length); chkHeader.entries++; } @@ -2249,40 +2249,40 @@ namespace Aaru.DiscImages { blockType = BlockType.ChecksumBlock, dataType = DataType.NoData, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing checksum block to position {0}", idxEntry.offset); - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref chkHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); - imageStream.Write(chkMs.ToArray(), 0, (int)chkMs.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref chkHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _imageStream.Write(chkMs.ToArray(), 0, (int)chkMs.Length); - index.RemoveAll(t => t.blockType == BlockType.ChecksumBlock && t.dataType == DataType.NoData); + _index.RemoveAll(t => t.blockType == BlockType.ChecksumBlock && t.dataType == DataType.NoData); - index.Add(idxEntry); + _index.Add(idxEntry); } } if(IsTape) { - ulong latestBlock = tapeDdt.Max(b => b.Key); + ulong latestBlock = _tapeDdt.Max(b => b.Key); - userDataDdt = new ulong[latestBlock + 1]; + _userDataDdt = new ulong[latestBlock + 1]; - foreach(KeyValuePair block in tapeDdt) - userDataDdt[block.Key] = block.Value; + foreach(KeyValuePair block in _tapeDdt) + _userDataDdt[block.Key] = block.Value; - inMemoryDdt = true; - tapeDdt.Clear(); + _inMemoryDdt = true; + _tapeDdt.Clear(); idxEntry = new IndexEntry { blockType = BlockType.TapePartitionBlock, dataType = DataType.UserData, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing tape partitions to position {0}", @@ -2306,24 +2306,24 @@ namespace Aaru.DiscImages tapePartitionHeader.entries = (byte)tapePartitionEntries.Length; tapePartitionHeader.length = (ulong)tapePartitionEntriesData.Length; - crc64 = new Crc64Context(); - crc64.Update(tapePartitionEntriesData); - tapePartitionHeader.crc64 = BitConverter.ToUInt64(crc64.Final(), 0); + _crc64 = new Crc64Context(); + _crc64.Update(tapePartitionEntriesData); + tapePartitionHeader.crc64 = BitConverter.ToUInt64(_crc64.Final(), 0); - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref tapePartitionHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); - structureBytes = null; - imageStream.Write(tapePartitionEntriesData, 0, tapePartitionEntriesData.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref tapePartitionHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _structureBytes = null; + _imageStream.Write(tapePartitionEntriesData, 0, tapePartitionEntriesData.Length); - index.RemoveAll(t => t.blockType == BlockType.TapePartitionBlock && t.dataType == DataType.UserData); - index.Add(idxEntry); + _index.RemoveAll(t => t.blockType == BlockType.TapePartitionBlock && t.dataType == DataType.UserData); + _index.Add(idxEntry); idxEntry = new IndexEntry { blockType = BlockType.TapeFileBlock, dataType = DataType.UserData, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing tape files to position {0}", idxEntry.offset); @@ -2347,28 +2347,28 @@ namespace Aaru.DiscImages length = (ulong)tapeFileEntriesData.Length }; - crc64 = new Crc64Context(); - crc64.Update(tapeFileEntriesData); - tapeFileHeader.crc64 = BitConverter.ToUInt64(crc64.Final(), 0); + _crc64 = new Crc64Context(); + _crc64.Update(tapeFileEntriesData); + tapeFileHeader.crc64 = BitConverter.ToUInt64(_crc64.Final(), 0); - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref tapeFileHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); - structureBytes = null; - imageStream.Write(tapeFileEntriesData, 0, tapeFileEntriesData.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref tapeFileHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _structureBytes = null; + _imageStream.Write(tapeFileEntriesData, 0, tapeFileEntriesData.Length); - index.RemoveAll(t => t.blockType == BlockType.TapeFileBlock && t.dataType == DataType.UserData); - index.Add(idxEntry); + _index.RemoveAll(t => t.blockType == BlockType.TapeFileBlock && t.dataType == DataType.UserData); + _index.Add(idxEntry); } // If the DDT is in-memory, write it to disk - if(inMemoryDdt) + if(_inMemoryDdt) { idxEntry = new IndexEntry { blockType = BlockType.DeDuplicationTable, dataType = DataType.UserData, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing user data DDT to position {0}", @@ -2379,96 +2379,96 @@ namespace Aaru.DiscImages identifier = BlockType.DeDuplicationTable, type = DataType.UserData, compression = CompressionType.Lzma, - shift = shift, - entries = (ulong)userDataDdt.LongLength, - length = (ulong)(userDataDdt.LongLength * sizeof(ulong)) + shift = _shift, + entries = (ulong)_userDataDdt.LongLength, + length = (ulong)(_userDataDdt.LongLength * sizeof(ulong)) }; - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); var userDataDdtStream = new MemoryStream(); - crc64 = new Crc64Context(); - byte[] ddtEntries = MemoryMarshal.Cast(userDataDdt).ToArray(); - crc64.Update(ddtEntries); + _crc64 = new Crc64Context(); + byte[] ddtEntries = MemoryMarshal.Cast(_userDataDdt).ToArray(); + _crc64.Update(ddtEntries); userDataDdtStream.Write(ddtEntries, 0, ddtEntries.Length); byte[] lzmaProperties = - CompressDataToStreamWithLZMA(userDataDdtStream.ToArray(), lzmaEncoderProperties, blockStream); + CompressDataToStreamWithLZMA(userDataDdtStream.ToArray(), _lzmaEncoderProperties, _blockStream); userDataDdtStream.Close(); - ddtHeader.cmpLength = (uint)blockStream.Length + LZMA_PROPERTIES_LENGTH; + ddtHeader.cmpLength = (uint)_blockStream.Length + LZMA_PROPERTIES_LENGTH; var cmpCrc64Context = new Crc64Context(); cmpCrc64Context.Update(lzmaProperties); - cmpCrc64Context.Update(blockStream.ToArray()); + cmpCrc64Context.Update(_blockStream.ToArray()); ddtHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0); - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref ddtHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); - structureBytes = null; - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); - blockStream.ReallyClose(); - blockStream = null; + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref ddtHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _structureBytes = null; + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); + _blockStream.ReallyClose(); + _blockStream = null; - index.RemoveAll(t => t.blockType == BlockType.DeDuplicationTable && t.dataType == DataType.UserData); + _index.RemoveAll(t => t.blockType == BlockType.DeDuplicationTable && t.dataType == DataType.UserData); - index.Add(idxEntry); + _index.Add(idxEntry); } // Write the sector prefix, suffix and subchannels if present - switch(imageInfo.XmlMediaType) + switch(_imageInfo.XmlMediaType) { case XmlMediaType.OpticalDisc when Tracks != null && Tracks.Count > 0: DateTime startCompress; DateTime endCompress; // Old format - if(sectorPrefix != null && - sectorSuffix != null) + if(_sectorPrefix != null && + _sectorSuffix != null) { idxEntry = new IndexEntry { blockType = BlockType.DataBlock, dataType = DataType.CdSectorPrefix, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing CD sector prefix block to position {0}", idxEntry.offset); - Crc64Context.Data(sectorPrefix, out byte[] blockCrc); + Crc64Context.Data(_sectorPrefix, out byte[] blockCrc); var prefixBlock = new BlockHeader { identifier = BlockType.DataBlock, type = DataType.CdSectorPrefix, - length = (uint)sectorPrefix.Length, + length = (uint)_sectorPrefix.Length, crc64 = BitConverter.ToUInt64(blockCrc, 0), sectorSize = 16 }; byte[] lzmaProperties = null; - if(!compress) + if(!_compress) { prefixBlock.compression = CompressionType.None; prefixBlock.cmpCrc64 = prefixBlock.crc64; prefixBlock.cmpLength = prefixBlock.length; - blockStream = new NonClosableStream(sectorPrefix); + _blockStream = new NonClosableStream(_sectorPrefix); } else { startCompress = DateTime.Now; - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); lzmaProperties = - CompressDataToStreamWithLZMA(sectorPrefix, lzmaEncoderProperties, blockStream); + CompressDataToStreamWithLZMA(_sectorPrefix, _lzmaEncoderProperties, _blockStream); var cmpCrc = new Crc64Context(); cmpCrc.Update(lzmaProperties); - cmpCrc.Update(blockStream.ToArray()); + cmpCrc.Update(_blockStream.ToArray()); blockCrc = cmpCrc.Final(); - prefixBlock.cmpLength = (uint)blockStream.Length + LZMA_PROPERTIES_LENGTH; + prefixBlock.cmpLength = (uint)_blockStream.Length + LZMA_PROPERTIES_LENGTH; prefixBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); prefixBlock.compression = CompressionType.Lzma; @@ -2478,63 +2478,63 @@ namespace Aaru.DiscImages (endCompress - startCompress).TotalSeconds); } - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref prefixBlock); - imageStream.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref prefixBlock); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); if(prefixBlock.compression == CompressionType.Lzma) - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); - blockStream.ReallyClose(); - blockStream = null; + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); + _blockStream.ReallyClose(); + _blockStream = null; - index.RemoveAll(t => t.blockType == BlockType.DataBlock && - t.dataType == DataType.CdSectorPrefix); + _index.RemoveAll(t => t.blockType == BlockType.DataBlock && + t.dataType == DataType.CdSectorPrefix); - index.Add(idxEntry); + _index.Add(idxEntry); idxEntry = new IndexEntry { blockType = BlockType.DataBlock, dataType = DataType.CdSectorSuffix, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing CD sector suffix block to position {0}", idxEntry.offset); - Crc64Context.Data(sectorSuffix, out blockCrc); + Crc64Context.Data(_sectorSuffix, out blockCrc); prefixBlock = new BlockHeader { identifier = BlockType.DataBlock, type = DataType.CdSectorSuffix, - length = (uint)sectorSuffix.Length, + length = (uint)_sectorSuffix.Length, crc64 = BitConverter.ToUInt64(blockCrc, 0), sectorSize = 288 }; - if(!compress) + if(!_compress) { prefixBlock.compression = CompressionType.None; prefixBlock.cmpCrc64 = prefixBlock.crc64; prefixBlock.cmpLength = prefixBlock.length; - blockStream = new NonClosableStream(sectorSuffix); + _blockStream = new NonClosableStream(_sectorSuffix); } else { startCompress = DateTime.Now; - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); lzmaProperties = - CompressDataToStreamWithLZMA(sectorSuffix, lzmaEncoderProperties, blockStream); + CompressDataToStreamWithLZMA(_sectorSuffix, _lzmaEncoderProperties, _blockStream); var cmpCrc = new Crc64Context(); cmpCrc.Update(lzmaProperties); - cmpCrc.Update(blockStream.ToArray()); + cmpCrc.Update(_blockStream.ToArray()); blockCrc = cmpCrc.Final(); - prefixBlock.cmpLength = (uint)blockStream.Length + LZMA_PROPERTIES_LENGTH; + prefixBlock.cmpLength = (uint)_blockStream.Length + LZMA_PROPERTIES_LENGTH; prefixBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); prefixBlock.compression = CompressionType.Lzma; @@ -2544,26 +2544,26 @@ namespace Aaru.DiscImages (endCompress - startCompress).TotalSeconds); } - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref prefixBlock); - imageStream.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref prefixBlock); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); if(prefixBlock.compression == CompressionType.Lzma) - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); - index.RemoveAll(t => t.blockType == BlockType.DataBlock && - t.dataType == DataType.CdSectorSuffix); + _index.RemoveAll(t => t.blockType == BlockType.DataBlock && + t.dataType == DataType.CdSectorSuffix); - index.Add(idxEntry); - blockStream.ReallyClose(); - blockStream = null; + _index.Add(idxEntry); + _blockStream.ReallyClose(); + _blockStream = null; } - else if(sectorSuffixMs != null && - sectorSuffixDdt != null && - sectorPrefixMs != null && - sectorPrefixDdt != null) + else if(_sectorSuffixMs != null && + _sectorSuffixDdt != null && + _sectorPrefixMs != null && + _sectorPrefixDdt != null) { #if DEBUG uint notDumpedPrefixes = 0; @@ -2576,52 +2576,52 @@ namespace Aaru.DiscImages uint correctMode2Form2 = 0; uint emptyMode2Form1 = 0; - for(long i = 0; i < sectorPrefixDdt.LongLength; i++) - if((sectorPrefixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.NotDumped) + for(long i = 0; i < _sectorPrefixDdt.LongLength; i++) + if((_sectorPrefixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.NotDumped) notDumpedPrefixes++; - else if((sectorPrefixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) + else if((_sectorPrefixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) correctPrefixes++; - else if((sectorPrefixDdt[i] & CD_DFIX_MASK) > 0) + else if((_sectorPrefixDdt[i] & CD_DFIX_MASK) > 0) writtenPrefixes++; - for(long i = 0; i < sectorPrefixDdt.LongLength; i++) - if((sectorSuffixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.NotDumped) + for(long i = 0; i < _sectorPrefixDdt.LongLength; i++) + if((_sectorSuffixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.NotDumped) notDumpedSuffixes++; - else if((sectorSuffixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) + else if((_sectorSuffixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.Correct) correctSuffixes++; - else if((sectorSuffixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.Mode2Form1Ok) + else if((_sectorSuffixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.Mode2Form1Ok) correctMode2Form1++; - else if((sectorSuffixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.Mode2Form2Ok) + else if((_sectorSuffixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.Mode2Form2Ok) correctMode2Form2++; - else if((sectorSuffixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.Mode2Form2NoCrc) + else if((_sectorSuffixDdt[i] & CD_XFIX_MASK) == (uint)CdFixFlags.Mode2Form2NoCrc) emptyMode2Form1++; - else if((sectorSuffixDdt[i] & CD_DFIX_MASK) > 0) + else if((_sectorSuffixDdt[i] & CD_DFIX_MASK) > 0) writtenSuffixes++; AaruConsole.DebugWriteLine("Aaru Format plugin", "{0} ({1:P}% prefixes are correct, {2} ({3:P}%) prefixes have not been dumped, {4} ({5:P}%) prefixes have been written to image", - correctPrefixes, correctPrefixes / imageInfo.Sectors, - notDumpedPrefixes, notDumpedPrefixes / imageInfo.Sectors, - writtenPrefixes, writtenPrefixes / imageInfo.Sectors); + correctPrefixes, correctPrefixes / _imageInfo.Sectors, + notDumpedPrefixes, notDumpedPrefixes / _imageInfo.Sectors, + writtenPrefixes, writtenPrefixes / _imageInfo.Sectors); AaruConsole.DebugWriteLine("Aaru Format plugin", "{0} ({1:P}% suffixes are correct, {2} ({3:P}%) suffixes have not been dumped, {4} ({5:P}%) suffixes have been written to image", - correctSuffixes, correctSuffixes / imageInfo.Sectors, - notDumpedSuffixes, notDumpedSuffixes / imageInfo.Sectors, - writtenSuffixes, writtenSuffixes / imageInfo.Sectors); + correctSuffixes, correctSuffixes / _imageInfo.Sectors, + notDumpedSuffixes, notDumpedSuffixes / _imageInfo.Sectors, + writtenSuffixes, writtenSuffixes / _imageInfo.Sectors); AaruConsole.DebugWriteLine("Aaru Format plugin", "{0} ({1:P}% MODE 2 Form 1 are correct, {2} ({3:P}%) MODE 2 Form 2 are correct, {4} ({5:P}%) MODE 2 Form 2 have empty CRC", - correctMode2Form1, correctMode2Form1 / imageInfo.Sectors, - correctMode2Form2, correctMode2Form2 / imageInfo.Sectors, - emptyMode2Form1, emptyMode2Form1 / imageInfo.Sectors); + correctMode2Form1, correctMode2Form1 / _imageInfo.Sectors, + correctMode2Form2, correctMode2Form2 / _imageInfo.Sectors, + emptyMode2Form1, emptyMode2Form1 / _imageInfo.Sectors); #endif idxEntry = new IndexEntry { blockType = BlockType.DeDuplicationTable, dataType = DataType.CdSectorPrefixCorrected, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", @@ -2633,47 +2633,47 @@ namespace Aaru.DiscImages identifier = BlockType.DeDuplicationTable, type = DataType.CdSectorPrefixCorrected, compression = CompressionType.Lzma, - entries = (ulong)sectorPrefixDdt.LongLength, - length = (ulong)(sectorPrefixDdt.LongLength * sizeof(uint)) + entries = (ulong)_sectorPrefixDdt.LongLength, + length = (ulong)(_sectorPrefixDdt.LongLength * sizeof(uint)) }; - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); var sectorPrefixDdtStream = new MemoryStream(); - crc64 = new Crc64Context(); - byte[] ddtEntries = MemoryMarshal.Cast(sectorPrefixDdt).ToArray(); - crc64.Update(ddtEntries); + _crc64 = new Crc64Context(); + byte[] ddtEntries = MemoryMarshal.Cast(_sectorPrefixDdt).ToArray(); + _crc64.Update(ddtEntries); sectorPrefixDdtStream.Write(ddtEntries, 0, ddtEntries.Length); byte[] lzmaProperties = - CompressDataToStreamWithLZMA(sectorPrefixDdtStream.ToArray(), lzmaEncoderProperties, - blockStream); + CompressDataToStreamWithLZMA(sectorPrefixDdtStream.ToArray(), _lzmaEncoderProperties, + _blockStream); sectorPrefixDdtStream.Close(); - ddtHeader.cmpLength = (uint)blockStream.Length + LZMA_PROPERTIES_LENGTH; + ddtHeader.cmpLength = (uint)_blockStream.Length + LZMA_PROPERTIES_LENGTH; var cmpCrc64Context = new Crc64Context(); cmpCrc64Context.Update(lzmaProperties); - cmpCrc64Context.Update(blockStream.ToArray()); + cmpCrc64Context.Update(_blockStream.ToArray()); ddtHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0); - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref ddtHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); - structureBytes = null; - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); - blockStream.ReallyClose(); - blockStream = null; + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref ddtHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _structureBytes = null; + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); + _blockStream.ReallyClose(); + _blockStream = null; - index.RemoveAll(t => t.blockType == BlockType.DeDuplicationTable && - t.dataType == DataType.CdSectorPrefixCorrected); + _index.RemoveAll(t => t.blockType == BlockType.DeDuplicationTable && + t.dataType == DataType.CdSectorPrefixCorrected); - index.Add(idxEntry); + _index.Add(idxEntry); idxEntry = new IndexEntry { blockType = BlockType.DeDuplicationTable, dataType = DataType.CdSectorSuffixCorrected, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", @@ -2685,86 +2685,87 @@ namespace Aaru.DiscImages identifier = BlockType.DeDuplicationTable, type = DataType.CdSectorSuffixCorrected, compression = CompressionType.Lzma, - entries = (ulong)sectorSuffixDdt.LongLength, - length = (ulong)(sectorSuffixDdt.LongLength * sizeof(uint)) + entries = (ulong)_sectorSuffixDdt.LongLength, + length = (ulong)(_sectorSuffixDdt.LongLength * sizeof(uint)) }; - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); var sectorSuffixDdtStream = new MemoryStream(); - crc64 = new Crc64Context(); - ddtEntries = MemoryMarshal.Cast(sectorSuffixDdt).ToArray(); - crc64.Update(ddtEntries); + _crc64 = new Crc64Context(); + ddtEntries = MemoryMarshal.Cast(_sectorSuffixDdt).ToArray(); + _crc64.Update(ddtEntries); sectorSuffixDdtStream.Write(ddtEntries, 0, ddtEntries.Length); lzmaProperties = - CompressDataToStreamWithLZMA(sectorSuffixDdtStream.ToArray(), lzmaEncoderProperties, - blockStream); + CompressDataToStreamWithLZMA(sectorSuffixDdtStream.ToArray(), _lzmaEncoderProperties, + _blockStream); - ddtHeader.cmpLength = (uint)blockStream.Length + LZMA_PROPERTIES_LENGTH; + ddtHeader.cmpLength = (uint)_blockStream.Length + LZMA_PROPERTIES_LENGTH; cmpCrc64Context = new Crc64Context(); cmpCrc64Context.Update(lzmaProperties); - cmpCrc64Context.Update(blockStream.ToArray()); + cmpCrc64Context.Update(_blockStream.ToArray()); ddtHeader.cmpCrc64 = BitConverter.ToUInt64(cmpCrc64Context.Final(), 0); - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref ddtHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); - structureBytes = null; - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); - blockStream.ReallyClose(); - blockStream = null; + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref ddtHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _structureBytes = null; + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); + _blockStream.ReallyClose(); + _blockStream = null; - index.RemoveAll(t => t.blockType == BlockType.DeDuplicationTable && - t.dataType == DataType.CdSectorSuffixCorrected); + _index.RemoveAll(t => t.blockType == BlockType.DeDuplicationTable && + t.dataType == DataType.CdSectorSuffixCorrected); - index.Add(idxEntry); + _index.Add(idxEntry); idxEntry = new IndexEntry { blockType = BlockType.DataBlock, dataType = DataType.CdSectorPrefixCorrected, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing CD sector corrected prefix block to position {0}", idxEntry.offset); - Crc64Context.Data(sectorPrefixMs.GetBuffer(), (uint)sectorPrefixMs.Length, out byte[] blockCrc); + Crc64Context.Data(_sectorPrefixMs.GetBuffer(), (uint)_sectorPrefixMs.Length, + out byte[] blockCrc); var prefixBlock = new BlockHeader { identifier = BlockType.DataBlock, type = DataType.CdSectorPrefixCorrected, - length = (uint)sectorPrefixMs.Length, + length = (uint)_sectorPrefixMs.Length, crc64 = BitConverter.ToUInt64(blockCrc, 0), sectorSize = 16 }; lzmaProperties = null; - if(!compress) + if(!_compress) { prefixBlock.compression = CompressionType.None; prefixBlock.cmpCrc64 = prefixBlock.crc64; prefixBlock.cmpLength = prefixBlock.length; - blockStream = sectorPrefixMs; + _blockStream = _sectorPrefixMs; } else { startCompress = DateTime.Now; - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); lzmaProperties = - CompressDataToStreamWithLZMA(sectorPrefixMs.ToArray(), lzmaEncoderProperties, - blockStream); + CompressDataToStreamWithLZMA(_sectorPrefixMs.ToArray(), _lzmaEncoderProperties, + _blockStream); var cmpCrc = new Crc64Context(); cmpCrc.Update(lzmaProperties); - cmpCrc.Update(blockStream.ToArray()); + cmpCrc.Update(_blockStream.ToArray()); blockCrc = cmpCrc.Final(); - prefixBlock.cmpLength = (uint)blockStream.Length + LZMA_PROPERTIES_LENGTH; + prefixBlock.cmpLength = (uint)_blockStream.Length + LZMA_PROPERTIES_LENGTH; prefixBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); prefixBlock.compression = CompressionType.Lzma; @@ -2774,67 +2775,67 @@ namespace Aaru.DiscImages (endCompress - startCompress).TotalSeconds); } - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref prefixBlock); - imageStream.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref prefixBlock); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); if(prefixBlock.compression == CompressionType.Lzma) - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); - blockStream.ReallyClose(); - blockStream = null; + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); + _blockStream.ReallyClose(); + _blockStream = null; - index.RemoveAll(t => t.blockType == BlockType.DataBlock && - t.dataType == DataType.CdSectorPrefixCorrected); + _index.RemoveAll(t => t.blockType == BlockType.DataBlock && + t.dataType == DataType.CdSectorPrefixCorrected); - index.Add(idxEntry); + _index.Add(idxEntry); idxEntry = new IndexEntry { blockType = BlockType.DataBlock, dataType = DataType.CdSectorSuffixCorrected, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing CD sector corrected suffix block to position {0}", idxEntry.offset); - Crc64Context.Data(sectorSuffixMs.GetBuffer(), (uint)sectorSuffixMs.Length, out blockCrc); + Crc64Context.Data(_sectorSuffixMs.GetBuffer(), (uint)_sectorSuffixMs.Length, out blockCrc); var suffixBlock = new BlockHeader { identifier = BlockType.DataBlock, type = DataType.CdSectorSuffixCorrected, - length = (uint)sectorSuffixMs.Length, + length = (uint)_sectorSuffixMs.Length, crc64 = BitConverter.ToUInt64(blockCrc, 0), sectorSize = 288 }; lzmaProperties = null; - if(!compress) + if(!_compress) { suffixBlock.compression = CompressionType.None; suffixBlock.cmpCrc64 = suffixBlock.crc64; suffixBlock.cmpLength = suffixBlock.length; - blockStream = sectorSuffixMs; + _blockStream = _sectorSuffixMs; } else { startCompress = DateTime.Now; - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); lzmaProperties = - CompressDataToStreamWithLZMA(sectorSuffixMs.ToArray(), lzmaEncoderProperties, - blockStream); + CompressDataToStreamWithLZMA(_sectorSuffixMs.ToArray(), _lzmaEncoderProperties, + _blockStream); var cmpCrc = new Crc64Context(); cmpCrc.Update(lzmaProperties); - cmpCrc.Update(blockStream.ToArray()); + cmpCrc.Update(_blockStream.ToArray()); blockCrc = cmpCrc.Final(); - suffixBlock.cmpLength = (uint)blockStream.Length + LZMA_PROPERTIES_LENGTH; + suffixBlock.cmpLength = (uint)_blockStream.Length + LZMA_PROPERTIES_LENGTH; suffixBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); suffixBlock.compression = CompressionType.Lzma; @@ -2844,69 +2845,69 @@ namespace Aaru.DiscImages (endCompress - startCompress).TotalSeconds); } - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref suffixBlock); - imageStream.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref suffixBlock); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); if(suffixBlock.compression == CompressionType.Lzma) - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); - blockStream.ReallyClose(); - blockStream = null; + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); + _blockStream.ReallyClose(); + _blockStream = null; - index.RemoveAll(t => t.blockType == BlockType.DataBlock && - t.dataType == DataType.CdSectorSuffixCorrected); + _index.RemoveAll(t => t.blockType == BlockType.DataBlock && + t.dataType == DataType.CdSectorSuffixCorrected); - index.Add(idxEntry); + _index.Add(idxEntry); } - if(mode2Subheaders != null) + if(_mode2Subheaders != null) { idxEntry = new IndexEntry { blockType = BlockType.DataBlock, dataType = DataType.CompactDiscMode2Subheader, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing CD MODE2 subheaders block to position {0}", idxEntry.offset); - Crc64Context.Data(mode2Subheaders, out byte[] blockCrc); + Crc64Context.Data(_mode2Subheaders, out byte[] blockCrc); var subheaderBlock = new BlockHeader { identifier = BlockType.DataBlock, type = DataType.CompactDiscMode2Subheader, - length = (uint)mode2Subheaders.Length, + length = (uint)_mode2Subheaders.Length, crc64 = BitConverter.ToUInt64(blockCrc, 0), sectorSize = 8 }; byte[] lzmaProperties = null; - if(!compress) + if(!_compress) { subheaderBlock.compression = CompressionType.None; subheaderBlock.cmpCrc64 = subheaderBlock.crc64; subheaderBlock.cmpLength = subheaderBlock.length; - blockStream = new NonClosableStream(mode2Subheaders); + _blockStream = new NonClosableStream(_mode2Subheaders); } else { startCompress = DateTime.Now; - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); lzmaProperties = - CompressDataToStreamWithLZMA(mode2Subheaders, lzmaEncoderProperties, blockStream); + CompressDataToStreamWithLZMA(_mode2Subheaders, _lzmaEncoderProperties, _blockStream); var cmpCrc = new Crc64Context(); cmpCrc.Update(lzmaProperties); - cmpCrc.Update(blockStream.ToArray()); + cmpCrc.Update(_blockStream.ToArray()); blockCrc = cmpCrc.Final(); - subheaderBlock.cmpLength = (uint)blockStream.Length + LZMA_PROPERTIES_LENGTH; + subheaderBlock.cmpLength = (uint)_blockStream.Length + LZMA_PROPERTIES_LENGTH; subheaderBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); subheaderBlock.compression = CompressionType.Lzma; @@ -2917,69 +2918,70 @@ namespace Aaru.DiscImages (endCompress - startCompress).TotalSeconds); } - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref subheaderBlock); - imageStream.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref subheaderBlock); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); if(subheaderBlock.compression == CompressionType.Lzma) - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); - index.RemoveAll(t => t.blockType == BlockType.DataBlock && - t.dataType == DataType.CompactDiscMode2Subheader); + _index.RemoveAll(t => t.blockType == BlockType.DataBlock && + t.dataType == DataType.CompactDiscMode2Subheader); - index.Add(idxEntry); - blockStream.ReallyClose(); - blockStream = null; + _index.Add(idxEntry); + _blockStream.ReallyClose(); + _blockStream = null; } - if(sectorSubchannel != null) + if(_sectorSubchannel != null) { idxEntry = new IndexEntry { blockType = BlockType.DataBlock, dataType = DataType.CdSectorSubchannel, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing CD subchannel block to position {0}", idxEntry.offset); - Crc64Context.Data(sectorSubchannel, out byte[] blockCrc); + Crc64Context.Data(_sectorSubchannel, out byte[] blockCrc); var subchannelBlock = new BlockHeader { identifier = BlockType.DataBlock, type = DataType.CdSectorSubchannel, - length = (uint)sectorSubchannel.Length, + length = (uint)_sectorSubchannel.Length, crc64 = BitConverter.ToUInt64(blockCrc, 0), sectorSize = 96 }; byte[] lzmaProperties = null; - if(!compress) + if(!_compress) { subchannelBlock.compression = CompressionType.None; subchannelBlock.cmpCrc64 = subchannelBlock.crc64; subchannelBlock.cmpLength = subchannelBlock.length; - blockStream = new NonClosableStream(sectorSubchannel); + _blockStream = new NonClosableStream(_sectorSubchannel); } else { startCompress = DateTime.Now; - byte[] transformedSubchannel = ClauniaSubchannelTransform(sectorSubchannel); - blockStream = new NonClosableStream(); + byte[] transformedSubchannel = ClauniaSubchannelTransform(_sectorSubchannel); + _blockStream = new NonClosableStream(); lzmaProperties = - CompressDataToStreamWithLZMA(transformedSubchannel, lzmaEncoderProperties, blockStream); + CompressDataToStreamWithLZMA(transformedSubchannel, _lzmaEncoderProperties, + _blockStream); var cmpCrc = new Crc64Context(); cmpCrc.Update(lzmaProperties); - cmpCrc.Update(blockStream.ToArray()); + cmpCrc.Update(_blockStream.ToArray()); blockCrc = cmpCrc.Final(); - subchannelBlock.cmpLength = (uint)blockStream.Length + LZMA_PROPERTIES_LENGTH; + subchannelBlock.cmpLength = (uint)_blockStream.Length + LZMA_PROPERTIES_LENGTH; subchannelBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); subchannelBlock.compression = CompressionType.LzmaClauniaSubchannelTransform; @@ -2989,22 +2991,22 @@ namespace Aaru.DiscImages (endCompress - startCompress).TotalSeconds); } - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref subchannelBlock); - imageStream.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref subchannelBlock); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); if(subchannelBlock.compression == CompressionType.Lzma || subchannelBlock.compression == CompressionType.LzmaClauniaSubchannelTransform) - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); - index.RemoveAll(t => t.blockType == BlockType.DataBlock && - t.dataType == DataType.CdSectorSubchannel); + _index.RemoveAll(t => t.blockType == BlockType.DataBlock && + t.dataType == DataType.CdSectorSubchannel); - index.Add(idxEntry); - blockStream.ReallyClose(); - blockStream = null; + _index.Add(idxEntry); + _blockStream.ReallyClose(); + _blockStream = null; } List trackEntries = new List(); @@ -3012,8 +3014,8 @@ namespace Aaru.DiscImages foreach(Track track in Tracks) { - trackFlags.TryGetValue((byte)track.TrackSequence, out byte flags); - trackIsrcs.TryGetValue((byte)track.TrackSequence, out string isrc); + _trackFlags.TryGetValue((byte)track.TrackSequence, out byte flags); + _trackIsrcs.TryGetValue((byte)track.TrackSequence, out string isrc); if((flags & (int)CdFlags.DataTrack) == 0 && track.TrackType != TrackType.Audio) @@ -3052,24 +3054,24 @@ namespace Aaru.DiscImages // If there are tracks build the tracks block if(trackEntries.Count > 0) { - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); foreach(TrackEntry entry in trackEntries) { - structurePointer = + _structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); - structureBytes = new byte[Marshal.SizeOf()]; - System.Runtime.InteropServices.Marshal.StructureToPtr(entry, structurePointer, true); + _structureBytes = new byte[Marshal.SizeOf()]; + System.Runtime.InteropServices.Marshal.StructureToPtr(entry, _structurePointer, true); - System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, - structureBytes.Length); + System.Runtime.InteropServices.Marshal.Copy(_structurePointer, _structureBytes, 0, + _structureBytes.Length); - System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer); - blockStream.Write(structureBytes, 0, structureBytes.Length); + System.Runtime.InteropServices.Marshal.FreeHGlobal(_structurePointer); + _blockStream.Write(_structureBytes, 0, _structureBytes.Length); } - Crc64Context.Data(blockStream.ToArray(), out byte[] trksCrc); + Crc64Context.Data(_blockStream.ToArray(), out byte[] trksCrc); var trkHeader = new TracksHeader { @@ -3079,48 +3081,48 @@ namespace Aaru.DiscImages }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing tracks to position {0}", - imageStream.Position); + _imageStream.Position); - index.RemoveAll(t => t.blockType == BlockType.TracksBlock && t.dataType == DataType.NoData); + _index.RemoveAll(t => t.blockType == BlockType.TracksBlock && t.dataType == DataType.NoData); - index.Add(new IndexEntry + _index.Add(new IndexEntry { blockType = BlockType.TracksBlock, dataType = DataType.NoData, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }); - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref trkHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); - blockStream.ReallyClose(); - blockStream = null; + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref trkHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); + _blockStream.ReallyClose(); + _blockStream = null; } // If there are track indexes bigger than 1 if(compactDiscIndexEntries.Any(i => i.Index > 1)) { - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); foreach(CompactDiscIndexEntry entry in compactDiscIndexEntries) { - structurePointer = + _structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal. SizeOf()); - structureBytes = new byte[Marshal.SizeOf()]; - System.Runtime.InteropServices.Marshal.StructureToPtr(entry, structurePointer, true); + _structureBytes = new byte[Marshal.SizeOf()]; + System.Runtime.InteropServices.Marshal.StructureToPtr(entry, _structurePointer, true); - System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, - structureBytes.Length); + System.Runtime.InteropServices.Marshal.Copy(_structurePointer, _structureBytes, 0, + _structureBytes.Length); - System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer); - blockStream.Write(structureBytes, 0, structureBytes.Length); + System.Runtime.InteropServices.Marshal.FreeHGlobal(_structurePointer); + _blockStream.Write(_structureBytes, 0, _structureBytes.Length); } - Crc64Context.Data(blockStream.ToArray(), out byte[] cdixCrc); + Crc64Context.Data(_blockStream.ToArray(), out byte[] cdixCrc); var cdixHeader = new CompactDiscIndexesHeader { @@ -3130,37 +3132,39 @@ namespace Aaru.DiscImages }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing compact disc indexes to position {0}", - imageStream.Position); + _imageStream.Position); - index.RemoveAll(t => t.blockType == BlockType.CompactDiscIndexesBlock && - t.dataType == DataType.NoData); + _index.RemoveAll(t => t.blockType == BlockType.CompactDiscIndexesBlock && + t.dataType == DataType.NoData); - index.Add(new IndexEntry + _index.Add(new IndexEntry { blockType = BlockType.CompactDiscIndexesBlock, dataType = DataType.NoData, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }); - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref cdixHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); - blockStream.ReallyClose(); - blockStream = null; + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref cdixHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); + _blockStream.ReallyClose(); + _blockStream = null; } break; case XmlMediaType.BlockMedia: - if(sectorSubchannel != null && - (imageInfo.MediaType == MediaType.AppleFileWare || - imageInfo.MediaType == MediaType.AppleSonySS || imageInfo.MediaType == MediaType.AppleSonyDS || - imageInfo.MediaType == MediaType.AppleProfile || imageInfo.MediaType == MediaType.AppleWidget || - imageInfo.MediaType == MediaType.PriamDataTower)) + if(_sectorSubchannel != null && + (_imageInfo.MediaType == MediaType.AppleFileWare || + _imageInfo.MediaType == MediaType.AppleSonySS || + _imageInfo.MediaType == MediaType.AppleSonyDS || + _imageInfo.MediaType == MediaType.AppleProfile || + _imageInfo.MediaType == MediaType.AppleWidget || + _imageInfo.MediaType == MediaType.PriamDataTower)) { DataType tagType = DataType.NoData; - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.AppleSonySS: case MediaType.AppleSonyDS: @@ -3183,23 +3187,23 @@ namespace Aaru.DiscImages { blockType = BlockType.DataBlock, dataType = tagType, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing apple sector tag block to position {0}", idxEntry.offset); - Crc64Context.Data(sectorSubchannel, out byte[] blockCrc); + Crc64Context.Data(_sectorSubchannel, out byte[] blockCrc); var subchannelBlock = new BlockHeader { identifier = BlockType.DataBlock, type = tagType, - length = (uint)sectorSubchannel.Length, + length = (uint)_sectorSubchannel.Length, crc64 = BitConverter.ToUInt64(blockCrc, 0) }; - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.AppleSonySS: case MediaType.AppleSonyDS: @@ -3220,43 +3224,43 @@ namespace Aaru.DiscImages byte[] lzmaProperties = null; - if(!compress) + if(!_compress) { subchannelBlock.compression = CompressionType.None; subchannelBlock.cmpCrc64 = subchannelBlock.crc64; subchannelBlock.cmpLength = subchannelBlock.length; - blockStream = new NonClosableStream(sectorSubchannel); + _blockStream = new NonClosableStream(_sectorSubchannel); } else { - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); lzmaProperties = - CompressDataToStreamWithLZMA(sectorSubchannel, lzmaEncoderProperties, blockStream); + CompressDataToStreamWithLZMA(_sectorSubchannel, _lzmaEncoderProperties, _blockStream); var cmpCrc = new Crc64Context(); cmpCrc.Update(lzmaProperties); - cmpCrc.Update(blockStream.ToArray()); + cmpCrc.Update(_blockStream.ToArray()); blockCrc = cmpCrc.Final(); - subchannelBlock.cmpLength = (uint)blockStream.Length + LZMA_PROPERTIES_LENGTH; + subchannelBlock.cmpLength = (uint)_blockStream.Length + LZMA_PROPERTIES_LENGTH; subchannelBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); subchannelBlock.compression = CompressionType.Lzma; } - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref subchannelBlock); - imageStream.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref subchannelBlock); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); if(subchannelBlock.compression == CompressionType.Lzma) - imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); + _imageStream.Write(lzmaProperties, 0, lzmaProperties.Length); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); - index.RemoveAll(t => t.blockType == BlockType.DataBlock && t.dataType == tagType); + _index.RemoveAll(t => t.blockType == BlockType.DataBlock && t.dataType == tagType); - index.Add(idxEntry); - blockStream.ReallyClose(); - blockStream = null; + _index.Add(idxEntry); + _blockStream.ReallyClose(); + _blockStream = null; } break; @@ -3265,181 +3269,181 @@ namespace Aaru.DiscImages // Write metadata if present SetMetadataFromTags(); var metadataBlock = new MetadataBlock(); - blockStream = new NonClosableStream(); - blockStream.Write(new byte[Marshal.SizeOf()], 0, Marshal.SizeOf()); + _blockStream = new NonClosableStream(); + _blockStream.Write(new byte[Marshal.SizeOf()], 0, Marshal.SizeOf()); byte[] tmpUtf16Le; - if(imageInfo.MediaSequence > 0 && - imageInfo.LastMediaSequence > 0) + if(_imageInfo.MediaSequence > 0 && + _imageInfo.LastMediaSequence > 0) { metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.mediaSequence = imageInfo.MediaSequence; - metadataBlock.lastMediaSequence = imageInfo.LastMediaSequence; + metadataBlock.mediaSequence = _imageInfo.MediaSequence; + metadataBlock.lastMediaSequence = _imageInfo.LastMediaSequence; } - if(!string.IsNullOrWhiteSpace(imageInfo.Creator)) + if(!string.IsNullOrWhiteSpace(_imageInfo.Creator)) { - tmpUtf16Le = Encoding.Unicode.GetBytes(imageInfo.Creator); + tmpUtf16Le = Encoding.Unicode.GetBytes(_imageInfo.Creator); metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.creatorOffset = (uint)blockStream.Position; + metadataBlock.creatorOffset = (uint)_blockStream.Position; metadataBlock.creatorLength = (uint)(tmpUtf16Le.Length + 2); - blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); + _blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); - blockStream.Write(new byte[] + _blockStream.Write(new byte[] { 0, 0 }, 0, 2); } - if(!string.IsNullOrWhiteSpace(imageInfo.Comments)) + if(!string.IsNullOrWhiteSpace(_imageInfo.Comments)) { - tmpUtf16Le = Encoding.Unicode.GetBytes(imageInfo.Comments); + tmpUtf16Le = Encoding.Unicode.GetBytes(_imageInfo.Comments); metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.commentsOffset = (uint)blockStream.Position; + metadataBlock.commentsOffset = (uint)_blockStream.Position; metadataBlock.commentsLength = (uint)(tmpUtf16Le.Length + 2); - blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); + _blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); - blockStream.Write(new byte[] + _blockStream.Write(new byte[] { 0, 0 }, 0, 2); } - if(!string.IsNullOrWhiteSpace(imageInfo.MediaTitle)) + if(!string.IsNullOrWhiteSpace(_imageInfo.MediaTitle)) { - tmpUtf16Le = Encoding.Unicode.GetBytes(imageInfo.MediaTitle); + tmpUtf16Le = Encoding.Unicode.GetBytes(_imageInfo.MediaTitle); metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.mediaTitleOffset = (uint)blockStream.Position; + metadataBlock.mediaTitleOffset = (uint)_blockStream.Position; metadataBlock.mediaTitleLength = (uint)(tmpUtf16Le.Length + 2); - blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); + _blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); - blockStream.Write(new byte[] + _blockStream.Write(new byte[] { 0, 0 }, 0, 2); } - if(!string.IsNullOrWhiteSpace(imageInfo.MediaManufacturer)) + if(!string.IsNullOrWhiteSpace(_imageInfo.MediaManufacturer)) { - tmpUtf16Le = Encoding.Unicode.GetBytes(imageInfo.MediaManufacturer); + tmpUtf16Le = Encoding.Unicode.GetBytes(_imageInfo.MediaManufacturer); metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.mediaManufacturerOffset = (uint)blockStream.Position; + metadataBlock.mediaManufacturerOffset = (uint)_blockStream.Position; metadataBlock.mediaManufacturerLength = (uint)(tmpUtf16Le.Length + 2); - blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); + _blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); - blockStream.Write(new byte[] + _blockStream.Write(new byte[] { 0, 0 }, 0, 2); } - if(!string.IsNullOrWhiteSpace(imageInfo.MediaModel)) + if(!string.IsNullOrWhiteSpace(_imageInfo.MediaModel)) { - tmpUtf16Le = Encoding.Unicode.GetBytes(imageInfo.MediaModel); + tmpUtf16Le = Encoding.Unicode.GetBytes(_imageInfo.MediaModel); metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.mediaModelOffset = (uint)blockStream.Position; + metadataBlock.mediaModelOffset = (uint)_blockStream.Position; metadataBlock.mediaModelLength = (uint)(tmpUtf16Le.Length + 2); - blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); + _blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); - blockStream.Write(new byte[] + _blockStream.Write(new byte[] { 0, 0 }, 0, 2); } - if(!string.IsNullOrWhiteSpace(imageInfo.MediaSerialNumber)) + if(!string.IsNullOrWhiteSpace(_imageInfo.MediaSerialNumber)) { - tmpUtf16Le = Encoding.Unicode.GetBytes(imageInfo.MediaSerialNumber); + tmpUtf16Le = Encoding.Unicode.GetBytes(_imageInfo.MediaSerialNumber); metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.mediaSerialNumberOffset = (uint)blockStream.Position; + metadataBlock.mediaSerialNumberOffset = (uint)_blockStream.Position; metadataBlock.mediaSerialNumberLength = (uint)(tmpUtf16Le.Length + 2); - blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); + _blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); - blockStream.Write(new byte[] + _blockStream.Write(new byte[] { 0, 0 }, 0, 2); } - if(!string.IsNullOrWhiteSpace(imageInfo.MediaBarcode)) + if(!string.IsNullOrWhiteSpace(_imageInfo.MediaBarcode)) { - tmpUtf16Le = Encoding.Unicode.GetBytes(imageInfo.MediaBarcode); + tmpUtf16Le = Encoding.Unicode.GetBytes(_imageInfo.MediaBarcode); metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.mediaBarcodeOffset = (uint)blockStream.Position; + metadataBlock.mediaBarcodeOffset = (uint)_blockStream.Position; metadataBlock.mediaBarcodeLength = (uint)(tmpUtf16Le.Length + 2); - blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); + _blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); - blockStream.Write(new byte[] + _blockStream.Write(new byte[] { 0, 0 }, 0, 2); } - if(!string.IsNullOrWhiteSpace(imageInfo.MediaPartNumber)) + if(!string.IsNullOrWhiteSpace(_imageInfo.MediaPartNumber)) { - tmpUtf16Le = Encoding.Unicode.GetBytes(imageInfo.MediaPartNumber); + tmpUtf16Le = Encoding.Unicode.GetBytes(_imageInfo.MediaPartNumber); metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.mediaPartNumberOffset = (uint)blockStream.Position; + metadataBlock.mediaPartNumberOffset = (uint)_blockStream.Position; metadataBlock.mediaPartNumberLength = (uint)(tmpUtf16Le.Length + 2); - blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); + _blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); - blockStream.Write(new byte[] + _blockStream.Write(new byte[] { 0, 0 }, 0, 2); } - if(!string.IsNullOrWhiteSpace(imageInfo.DriveManufacturer)) + if(!string.IsNullOrWhiteSpace(_imageInfo.DriveManufacturer)) { - tmpUtf16Le = Encoding.Unicode.GetBytes(imageInfo.DriveManufacturer); + tmpUtf16Le = Encoding.Unicode.GetBytes(_imageInfo.DriveManufacturer); metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.driveManufacturerOffset = (uint)blockStream.Position; + metadataBlock.driveManufacturerOffset = (uint)_blockStream.Position; metadataBlock.driveManufacturerLength = (uint)(tmpUtf16Le.Length + 2); - blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); + _blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); - blockStream.Write(new byte[] + _blockStream.Write(new byte[] { 0, 0 }, 0, 2); } - if(!string.IsNullOrWhiteSpace(imageInfo.DriveModel)) + if(!string.IsNullOrWhiteSpace(_imageInfo.DriveModel)) { - tmpUtf16Le = Encoding.Unicode.GetBytes(imageInfo.DriveModel); + tmpUtf16Le = Encoding.Unicode.GetBytes(_imageInfo.DriveModel); metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.driveModelOffset = (uint)blockStream.Position; + metadataBlock.driveModelOffset = (uint)_blockStream.Position; metadataBlock.driveModelLength = (uint)(tmpUtf16Le.Length + 2); - blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); + _blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); - blockStream.Write(new byte[] + _blockStream.Write(new byte[] { 0, 0 }, 0, 2); } - if(!string.IsNullOrWhiteSpace(imageInfo.DriveSerialNumber)) + if(!string.IsNullOrWhiteSpace(_imageInfo.DriveSerialNumber)) { - tmpUtf16Le = Encoding.Unicode.GetBytes(imageInfo.DriveSerialNumber); + tmpUtf16Le = Encoding.Unicode.GetBytes(_imageInfo.DriveSerialNumber); metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.driveSerialNumberOffset = (uint)blockStream.Position; + metadataBlock.driveSerialNumberOffset = (uint)_blockStream.Position; metadataBlock.driveSerialNumberLength = (uint)(tmpUtf16Le.Length + 2); - blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); + _blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); - blockStream.Write(new byte[] + _blockStream.Write(new byte[] { 0, 0 }, 0, 2); } - if(!string.IsNullOrWhiteSpace(imageInfo.DriveFirmwareRevision)) + if(!string.IsNullOrWhiteSpace(_imageInfo.DriveFirmwareRevision)) { - tmpUtf16Le = Encoding.Unicode.GetBytes(imageInfo.DriveFirmwareRevision); + tmpUtf16Le = Encoding.Unicode.GetBytes(_imageInfo.DriveFirmwareRevision); metadataBlock.identifier = BlockType.MetadataBlock; - metadataBlock.driveFirmwareRevisionOffset = (uint)blockStream.Position; + metadataBlock.driveFirmwareRevisionOffset = (uint)_blockStream.Position; metadataBlock.driveFirmwareRevisionLength = (uint)(tmpUtf16Le.Length + 2); - blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); + _blockStream.Write(tmpUtf16Le, 0, tmpUtf16Le.Length); - blockStream.Write(new byte[] + _blockStream.Write(new byte[] { 0, 0 }, 0, 2); @@ -3449,92 +3453,92 @@ namespace Aaru.DiscImages if(metadataBlock.identifier == BlockType.MetadataBlock) { AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing metadata to position {0}", - imageStream.Position); + _imageStream.Position); - metadataBlock.blockSize = (uint)blockStream.Length; - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref metadataBlock); - blockStream.Position = 0; - blockStream.Write(structureBytes, 0, structureBytes.Length); - index.RemoveAll(t => t.blockType == BlockType.MetadataBlock && t.dataType == DataType.NoData); + metadataBlock.blockSize = (uint)_blockStream.Length; + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref metadataBlock); + _blockStream.Position = 0; + _blockStream.Write(_structureBytes, 0, _structureBytes.Length); + _index.RemoveAll(t => t.blockType == BlockType.MetadataBlock && t.dataType == DataType.NoData); - index.Add(new IndexEntry + _index.Add(new IndexEntry { blockType = BlockType.MetadataBlock, dataType = DataType.NoData, - offset = (ulong)imageStream.Position + offset = (ulong)_imageStream.Position }); - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); - blockStream.ReallyClose(); - blockStream = null; + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); + _blockStream.ReallyClose(); + _blockStream = null; } - header.indexOffset = (ulong)imageStream.Position; + _header.indexOffset = (ulong)_imageStream.Position; - AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing index to position {0}", header.indexOffset); + AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing index to position {0}", _header.indexOffset); - blockStream = new NonClosableStream(); + _blockStream = new NonClosableStream(); // Write index to memory - foreach(IndexEntry entry in index) + foreach(IndexEntry entry in _index) { - structureBytes = new byte[Marshal.SizeOf()]; + _structureBytes = new byte[Marshal.SizeOf()]; IndexEntry indexEntry = entry; - MemoryMarshal.Write(structureBytes, ref indexEntry); - blockStream.Write(structureBytes, 0, structureBytes.Length); + MemoryMarshal.Write(_structureBytes, ref indexEntry); + _blockStream.Write(_structureBytes, 0, _structureBytes.Length); } - Crc64Context.Data(blockStream.ToArray(), out byte[] idxCrc); + Crc64Context.Data(_blockStream.ToArray(), out byte[] idxCrc); - if(index.Count > ushort.MaxValue) + if(_index.Count > ushort.MaxValue) { - header.imageMajorVersion = AARUFMT_VERSION; + _header.imageMajorVersion = AARUFMT_VERSION; var idxHeader = new IndexHeader2 { identifier = BlockType.Index2, - entries = (ulong)index.Count, + entries = (ulong)_index.Count, crc64 = BitConverter.ToUInt64(idxCrc, 0) }; // Write index header to disk - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref idxHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref idxHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); } else { var idxHeader = new IndexHeader { identifier = BlockType.Index, - entries = (ushort)index.Count, + entries = (ushort)_index.Count, crc64 = BitConverter.ToUInt64(idxCrc, 0) }; // Write index header to disk - structureBytes = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(structureBytes, ref idxHeader); - imageStream.Write(structureBytes, 0, structureBytes.Length); + _structureBytes = new byte[Marshal.SizeOf()]; + MemoryMarshal.Write(_structureBytes, ref idxHeader); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); } // Write index to disk - imageStream.Write(blockStream.ToArray(), 0, (int)blockStream.Length); - blockStream.ReallyClose(); - blockStream = null; + _imageStream.Write(_blockStream.ToArray(), 0, (int)_blockStream.Length); + _blockStream.ReallyClose(); + _blockStream = null; AaruConsole.DebugWriteLine("Aaru Format plugin", "Writing header"); - header.lastWrittenTime = DateTime.UtcNow.ToFileTimeUtc(); - imageStream.Position = 0; - structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); - structureBytes = new byte[Marshal.SizeOf()]; - System.Runtime.InteropServices.Marshal.StructureToPtr(header, structurePointer, true); - System.Runtime.InteropServices.Marshal.Copy(structurePointer, structureBytes, 0, structureBytes.Length); - System.Runtime.InteropServices.Marshal.FreeHGlobal(structurePointer); - imageStream.Write(structureBytes, 0, structureBytes.Length); + _header.lastWrittenTime = DateTime.UtcNow.ToFileTimeUtc(); + _imageStream.Position = 0; + _structurePointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); + _structureBytes = new byte[Marshal.SizeOf()]; + System.Runtime.InteropServices.Marshal.StructureToPtr(_header, _structurePointer, true); + System.Runtime.InteropServices.Marshal.Copy(_structurePointer, _structureBytes, 0, _structureBytes.Length); + System.Runtime.InteropServices.Marshal.FreeHGlobal(_structurePointer); + _imageStream.Write(_structureBytes, 0, _structureBytes.Length); - imageStream.Flush(); - imageStream.Close(); + _imageStream.Flush(); + _imageStream.Close(); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true, true); IsWriting = false; @@ -3545,20 +3549,20 @@ namespace Aaru.DiscImages public bool SetMetadata(ImageInfo metadata) { - imageInfo.Creator = metadata.Creator; - imageInfo.Comments = metadata.Comments; - imageInfo.MediaManufacturer = metadata.MediaManufacturer; - imageInfo.MediaModel = metadata.MediaModel; - imageInfo.MediaSerialNumber = metadata.MediaSerialNumber; - imageInfo.MediaBarcode = metadata.MediaBarcode; - imageInfo.MediaPartNumber = metadata.MediaPartNumber; - imageInfo.MediaSequence = metadata.MediaSequence; - imageInfo.LastMediaSequence = metadata.LastMediaSequence; - imageInfo.DriveManufacturer = metadata.DriveManufacturer; - imageInfo.DriveModel = metadata.DriveModel; - imageInfo.DriveSerialNumber = metadata.DriveSerialNumber; - imageInfo.DriveFirmwareRevision = metadata.DriveFirmwareRevision; - imageInfo.MediaTitle = metadata.MediaTitle; + _imageInfo.Creator = metadata.Creator; + _imageInfo.Comments = metadata.Comments; + _imageInfo.MediaManufacturer = metadata.MediaManufacturer; + _imageInfo.MediaModel = metadata.MediaModel; + _imageInfo.MediaSerialNumber = metadata.MediaSerialNumber; + _imageInfo.MediaBarcode = metadata.MediaBarcode; + _imageInfo.MediaPartNumber = metadata.MediaPartNumber; + _imageInfo.MediaSequence = metadata.MediaSequence; + _imageInfo.LastMediaSequence = metadata.LastMediaSequence; + _imageInfo.DriveManufacturer = metadata.DriveManufacturer; + _imageInfo.DriveModel = metadata.DriveModel; + _imageInfo.DriveSerialNumber = metadata.DriveSerialNumber; + _imageInfo.DriveFirmwareRevision = metadata.DriveFirmwareRevision; + _imageInfo.MediaTitle = metadata.MediaTitle; return true; } @@ -3572,14 +3576,14 @@ namespace Aaru.DiscImages return false; } - if(imageInfo.XmlMediaType != XmlMediaType.BlockMedia) + if(_imageInfo.XmlMediaType != XmlMediaType.BlockMedia) { ErrorMessage = "Tried to set geometry on a media that doesn't suppport it"; return false; } - geometryBlock = new GeometryBlock + _geometryBlock = new GeometryBlock { identifier = BlockType.GeometryBlock, cylinders = cylinders, @@ -3601,7 +3605,7 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -3614,7 +3618,7 @@ namespace Aaru.DiscImages { case SectorTagType.CdTrackFlags: case SectorTagType.CdTrackIsrc: - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) { ErrorMessage = "Incorrect tag for disk type"; @@ -3634,7 +3638,7 @@ namespace Aaru.DiscImages break; case SectorTagType.CdSectorSubchannel: - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) { ErrorMessage = "Incorrect tag for disk type"; @@ -3663,7 +3667,7 @@ namespace Aaru.DiscImages return false; } - trackFlags[(byte)sectorAddress] = data[0]; + _trackFlags[(byte)sectorAddress] = data[0]; return true; } @@ -3671,7 +3675,7 @@ namespace Aaru.DiscImages case SectorTagType.CdTrackIsrc: { if(data != null) - trackIsrcs[(byte)sectorAddress] = Encoding.UTF8.GetString(data); + _trackIsrcs[(byte)sectorAddress] = Encoding.UTF8.GetString(data); return true; } @@ -3685,10 +3689,10 @@ namespace Aaru.DiscImages return false; } - if(sectorSubchannel == null) - sectorSubchannel = new byte[imageInfo.Sectors * 96]; + if(_sectorSubchannel == null) + _sectorSubchannel = new byte[_imageInfo.Sectors * 96]; - Array.Copy(data, 0, sectorSubchannel, (int)(96 * sectorAddress), 96); + Array.Copy(data, 0, _sectorSubchannel, (int)(96 * sectorAddress), 96); return true; } @@ -3709,7 +3713,7 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -3729,17 +3733,17 @@ namespace Aaru.DiscImages return false; } - if(sectorSubchannel == null) - sectorSubchannel = new byte[imageInfo.Sectors * 96]; + if(_sectorSubchannel == null) + _sectorSubchannel = new byte[_imageInfo.Sectors * 96]; - if((sectorAddress * 96) + (length * 96) > (ulong)sectorSubchannel.LongLength) + if((sectorAddress * 96) + (length * 96) > (ulong)_sectorSubchannel.LongLength) { ErrorMessage = "Tried to write more data than possible"; return false; } - Array.Copy(data, 0, sectorSubchannel, (int)(96 * sectorAddress), 96 * length); + Array.Copy(data, 0, _sectorSubchannel, (int)(96 * sectorAddress), 96 * length); return true; } diff --git a/Aaru.Images/Alcohol120/Alcohol120.cs b/Aaru.Images/Alcohol120/Alcohol120.cs index e79c51204..dc733d58e 100644 --- a/Aaru.Images/Alcohol120/Alcohol120.cs +++ b/Aaru.Images/Alcohol120/Alcohol120.cs @@ -40,26 +40,26 @@ namespace Aaru.DiscImages { public partial class Alcohol120 : IWritableOpticalImage { - AlcoholFooter alcFooter; - IFilter alcImage; - Dictionary alcSessions; - Dictionary> alcToc; - Dictionary alcTrackExtras; - Dictionary alcTracks; - byte[] bca; - FileStream descriptorStream; - byte[] dmi; - byte[] fullToc; - AlcoholHeader header; - ImageInfo imageInfo; - Stream imageStream; - bool isDvd; - Dictionary offsetmap; - byte[] pfi; - Dictionary trackFlags; - List writingTracks; + AlcoholFooter _alcFooter; + IFilter _alcImage; + Dictionary _alcSessions; + Dictionary> _alcToc; + Dictionary _alcTrackExtras; + Dictionary _alcTracks; + byte[] _bca; + FileStream _descriptorStream; + byte[] _dmi; + byte[] _fullToc; + AlcoholHeader _header; + ImageInfo _imageInfo; + Stream _imageStream; + bool _isDvd; + Dictionary _offsetmap; + byte[] _pfi; + Dictionary _trackFlags; + List _writingTracks; - public Alcohol120() => imageInfo = new ImageInfo + public Alcohol120() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/Alcohol120/Constants.cs b/Aaru.Images/Alcohol120/Constants.cs index 9af1942ec..b23604bc7 100644 --- a/Aaru.Images/Alcohol120/Constants.cs +++ b/Aaru.Images/Alcohol120/Constants.cs @@ -35,7 +35,7 @@ namespace Aaru.DiscImages public partial class Alcohol120 { const byte _maximumSupportedVersion = 1; - readonly byte[] alcoholSignature = + readonly byte[] _alcoholSignature = { 0x4d, 0x45, 0x44, 0x49, 0x41, 0x20, 0x44, 0x45, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x4f, 0x52 }; diff --git a/Aaru.Images/Alcohol120/Identify.cs b/Aaru.Images/Alcohol120/Identify.cs index 9c378eaa5..6b56dedb1 100644 --- a/Aaru.Images/Alcohol120/Identify.cs +++ b/Aaru.Images/Alcohol120/Identify.cs @@ -51,7 +51,7 @@ namespace Aaru.DiscImages stream.Read(hdr, 0, 88); AlcoholHeader header = Marshal.ByteArrayToStructureLittleEndian(hdr); - return header.signature.SequenceEqual(alcoholSignature) && header.version[0] <= _maximumSupportedVersion; + return header.signature.SequenceEqual(_alcoholSignature) && header.version[0] <= _maximumSupportedVersion; } } } \ No newline at end of file diff --git a/Aaru.Images/Alcohol120/Properties.cs b/Aaru.Images/Alcohol120/Properties.cs index cd9c53718..73bd8d0bf 100644 --- a/Aaru.Images/Alcohol120/Properties.cs +++ b/Aaru.Images/Alcohol120/Properties.cs @@ -52,7 +52,7 @@ namespace Aaru.DiscImages OpticalImageCapabilities.CanStoreRawData | OpticalImageCapabilities.CanStoreCookedData | OpticalImageCapabilities.CanStoreMultipleTracks; - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Alcohol 120% Media Descriptor Structure"; public Guid Id => new Guid("A78FBEBA-0307-4915-BDE3-B8A3B57F843F"); public string Author => "Natalia Portillo"; @@ -67,14 +67,14 @@ namespace Aaru.DiscImages { List tracks = new List(); - foreach(AlcoholTrack alcTrack in alcTracks.Values) + foreach(AlcoholTrack alcTrack in _alcTracks.Values) { ushort sessionNo = (from session in Sessions where alcTrack.point >= session.StartTrack || alcTrack.point <= session.EndTrack select session.SessionSequence).FirstOrDefault(); - if(!alcTrackExtras.TryGetValue(alcTrack.point, out AlcoholTrackExtra alcExtra)) + if(!_alcTrackExtras.TryGetValue(alcTrack.point, out AlcoholTrackExtra alcExtra)) continue; var aaruTrack = new Track @@ -85,8 +85,8 @@ namespace Aaru.DiscImages TrackSession = sessionNo, TrackSequence = alcTrack.point, TrackType = AlcoholTrackTypeToTrackType(alcTrack.mode), - TrackFilter = alcImage, - TrackFile = alcImage.GetFilename(), + TrackFilter = _alcImage, + TrackFile = _alcImage.GetFilename(), TrackFileOffset = alcTrack.startOffset, TrackFileType = "BINARY", TrackRawBytesPerSector = alcTrack.sectorSize, @@ -101,8 +101,8 @@ namespace Aaru.DiscImages switch(alcTrack.subMode) { case AlcoholSubchannelMode.Interleaved: - aaruTrack.TrackSubchannelFilter = alcImage; - aaruTrack.TrackSubchannelFile = alcImage.GetFilename(); + aaruTrack.TrackSubchannelFilter = _alcImage; + aaruTrack.TrackSubchannelFile = _alcImage.GetFilename(); aaruTrack.TrackSubchannelOffset = alcTrack.startOffset; aaruTrack.TrackSubchannelType = TrackSubchannelType.RawInterleaved; @@ -113,9 +113,9 @@ namespace Aaru.DiscImages break; } - if(header.type != AlcoholMediumType.CD && - header.type != AlcoholMediumType.CDR && - header.type != AlcoholMediumType.CDRW) + if(_header.type != AlcoholMediumType.CD && + _header.type != AlcoholMediumType.CDR && + _header.type != AlcoholMediumType.CDRW) { aaruTrack.TrackPregap = 0; aaruTrack.Indexes?.Clear(); diff --git a/Aaru.Images/Alcohol120/Read.cs b/Aaru.Images/Alcohol120/Read.cs index 92e3a1560..e925cf2ce 100644 --- a/Aaru.Images/Alcohol120/Read.cs +++ b/Aaru.Images/Alcohol120/Read.cs @@ -59,52 +59,53 @@ namespace Aaru.DiscImages if(stream.Length < 88) return false; - isDvd = false; + _isDvd = false; byte[] hdr = new byte[88]; stream.Read(hdr, 0, 88); - header = Marshal.ByteArrayToStructureLittleEndian(hdr); + _header = Marshal.ByteArrayToStructureLittleEndian(hdr); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.signature = {0}", - Encoding.ASCII.GetString(header.signature)); + Encoding.ASCII.GetString(_header.signature)); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.version = {0}.{1}", header.version[0], - header.version[1]); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.version = {0}.{1}", _header.version[0], + _header.version[1]); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.type = {0}", header.type); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.sessions = {0}", header.sessions); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.type = {0}", _header.type); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.sessions = {0}", _header.sessions); - for(int i = 0; i < header.unknown1.Length; i++) - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown1[{1}] = 0x{0:X4}", header.unknown1[i], - i); + for(int i = 0; i < _header.unknown1.Length; i++) + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown1[{1}] = 0x{0:X4}", + _header.unknown1[i], i); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.bcaLength = {0}", header.bcaLength); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.bcaLength = {0}", _header.bcaLength); - for(int i = 0; i < header.unknown2.Length; i++) - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown2[{1}] = 0x{0:X8}", header.unknown2[i], - i); + for(int i = 0; i < _header.unknown2.Length; i++) + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown2[{1}] = 0x{0:X8}", + _header.unknown2[i], i); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.bcaOffset = {0}", header.bcaOffset); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.bcaOffset = {0}", _header.bcaOffset); - for(int i = 0; i < header.unknown3.Length; i++) - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown3[{1}] = 0x{0:X8}", header.unknown3[i], - i); + for(int i = 0; i < _header.unknown3.Length; i++) + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown3[{1}] = 0x{0:X8}", + _header.unknown3[i], i); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.structuresOffset = {0}", header.structuresOffset); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.structuresOffset = {0}", + _header.structuresOffset); - for(int i = 0; i < header.unknown4.Length; i++) - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown4[{1}] = 0x{0:X8}", header.unknown4[i], - i); + for(int i = 0; i < _header.unknown4.Length; i++) + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.unknown4[{1}] = 0x{0:X8}", + _header.unknown4[i], i); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.sessionOffset = {0}", header.sessionOffset); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.dpmOffset = {0}", header.dpmOffset); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.sessionOffset = {0}", _header.sessionOffset); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "header.dpmOffset = {0}", _header.dpmOffset); - if(header.version[0] > _maximumSupportedVersion) + if(_header.version[0] > _maximumSupportedVersion) return false; - stream.Seek(header.sessionOffset, SeekOrigin.Begin); - alcSessions = new Dictionary(); + stream.Seek(_header.sessionOffset, SeekOrigin.Begin); + _alcSessions = new Dictionary(); - for(int i = 0; i < header.sessions; i++) + for(int i = 0; i < _header.sessions; i++) { byte[] sesHdr = new byte[24]; stream.Read(sesHdr, 0, 24); @@ -135,16 +136,16 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Alcohol 120% plugin", "session[{1}].trackOffset = {0}", session.trackOffset, i); - alcSessions.Add(session.sessionSequence, session); + _alcSessions.Add(session.sessionSequence, session); } long footerOff = 0; bool oldIncorrectImage = false; - alcTracks = new Dictionary(); - alcToc = new Dictionary>(); + _alcTracks = new Dictionary(); + _alcToc = new Dictionary>(); - foreach(AlcoholSession session in alcSessions.Values) + foreach(AlcoholSession session in _alcSessions.Values) { stream.Seek(session.trackOffset, SeekOrigin.Begin); Dictionary sesToc = new Dictionary(); @@ -235,22 +236,22 @@ namespace Aaru.DiscImages sesToc.Add(track.point, track); if(track.point < 0xA0) - alcTracks.Add(track.point, track); + _alcTracks.Add(track.point, track); if(footerOff == 0) footerOff = track.footerOffset; - isDvd |= track.mode == AlcoholTrackMode.DVD; + _isDvd |= track.mode == AlcoholTrackMode.DVD; } - alcToc.Add(session.sessionSequence, sesToc); + _alcToc.Add(session.sessionSequence, sesToc); } - alcTrackExtras = new Dictionary(); + _alcTrackExtras = new Dictionary(); - foreach(AlcoholTrack track in alcTracks.Values) + foreach(AlcoholTrack track in _alcTracks.Values) if(track.extraOffset > 0 && - !isDvd) + !_isDvd) { byte[] extHdr = new byte[8]; stream.Seek(track.extraOffset, SeekOrigin.Begin); @@ -263,16 +264,16 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Alcohol 120% plugin", "track[{1}].extra.sectors = {0}", extra.sectors, track.point); - alcTrackExtras.Add(track.point, extra); + _alcTrackExtras.Add(track.point, extra); } - else if(isDvd) + else if(_isDvd) { var extra = new AlcoholTrackExtra { sectors = track.extraOffset }; - alcTrackExtras.Add(track.point, extra); + _alcTrackExtras.Add(track.point, extra); } if(footerOff > 0) @@ -280,71 +281,71 @@ namespace Aaru.DiscImages byte[] footer = new byte[16]; stream.Seek(footerOff, SeekOrigin.Begin); stream.Read(footer, 0, 16); - alcFooter = Marshal.SpanToStructureLittleEndian(footer); + _alcFooter = Marshal.SpanToStructureLittleEndian(footer); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.filenameOffset = {0}", - alcFooter.filenameOffset); + _alcFooter.filenameOffset); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.widechar = {0}", alcFooter.widechar); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.unknown1 = 0x{0:X8}", alcFooter.unknown1); - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.unknown2 = 0x{0:X8}", alcFooter.unknown2); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.widechar = {0}", _alcFooter.widechar); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.unknown1 = 0x{0:X8}", _alcFooter.unknown1); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.unknown2 = 0x{0:X8}", _alcFooter.unknown2); } string alcFile = "*.mdf"; - if(alcFooter.filenameOffset > 0) + if(_alcFooter.filenameOffset > 0) { - stream.Seek(alcFooter.filenameOffset, SeekOrigin.Begin); + stream.Seek(_alcFooter.filenameOffset, SeekOrigin.Begin); - byte[] filename = header.dpmOffset == 0 ? new byte[stream.Length - stream.Position] - : new byte[header.dpmOffset - stream.Position]; + byte[] filename = _header.dpmOffset == 0 ? new byte[stream.Length - stream.Position] + : new byte[_header.dpmOffset - stream.Position]; stream.Read(filename, 0, filename.Length); - alcFile = alcFooter.widechar == 1 ? Encoding.Unicode.GetString(filename) + alcFile = _alcFooter.widechar == 1 ? Encoding.Unicode.GetString(filename) : Encoding.Default.GetString(filename); AaruConsole.DebugWriteLine("Alcohol 120% plugin", "footer.filename = {0}", alcFile); } - if(alcFooter.filenameOffset == 0 || + if(_alcFooter.filenameOffset == 0 || string.Compare(alcFile, "*.mdf", StringComparison.InvariantCultureIgnoreCase) == 0) alcFile = Path.GetFileNameWithoutExtension(imageFilter.GetBasePath()) + ".mdf"; - if(header.bcaLength > 0 && - header.bcaOffset > 0 && - isDvd) + if(_header.bcaLength > 0 && + _header.bcaOffset > 0 && + _isDvd) { - bca = new byte[header.bcaLength]; - stream.Seek(header.bcaOffset, SeekOrigin.Begin); - int readBytes = stream.Read(bca, 0, bca.Length); + _bca = new byte[_header.bcaLength]; + stream.Seek(_header.bcaOffset, SeekOrigin.Begin); + int readBytes = stream.Read(_bca, 0, _bca.Length); - if(readBytes == bca.Length) - switch(header.type) + if(readBytes == _bca.Length) + switch(_header.type) { case AlcoholMediumType.DVD: case AlcoholMediumType.DVDR: - imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_BCA); + _imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_BCA); break; } } - imageInfo.MediaType = AlcoholMediumTypeToMediaType(header.type); + _imageInfo.MediaType = AlcoholMediumTypeToMediaType(_header.type); Sessions = new List(); - foreach(AlcoholSession alcSes in alcSessions.Values) + foreach(AlcoholSession alcSes in _alcSessions.Values) { var session = new Session(); - if(!alcTracks.TryGetValue(alcSes.firstTrack, out AlcoholTrack startingTrack)) + if(!_alcTracks.TryGetValue(alcSes.firstTrack, out AlcoholTrack startingTrack)) break; - if(!alcTracks.TryGetValue(alcSes.lastTrack, out AlcoholTrack endingTrack)) + if(!_alcTracks.TryGetValue(alcSes.lastTrack, out AlcoholTrack endingTrack)) break; - if(!alcTrackExtras.TryGetValue(alcSes.lastTrack, out AlcoholTrackExtra endingTrackExtra)) + if(!_alcTrackExtras.TryGetValue(alcSes.lastTrack, out AlcoholTrackExtra endingTrackExtra)) break; session.StartSector = startingTrack.startLba; @@ -355,31 +356,31 @@ namespace Aaru.DiscImages Sessions.Add(session); - if(session.EndSector > imageInfo.Sectors) - imageInfo.Sectors = session.EndSector + 1; + if(session.EndSector > _imageInfo.Sectors) + _imageInfo.Sectors = session.EndSector + 1; } - if(isDvd) + if(_isDvd) { // TODO: Second layer - if(header.structuresOffset > 0) + if(_header.structuresOffset > 0) { byte[] structures = new byte[4100]; - stream.Seek(header.structuresOffset, SeekOrigin.Begin); + stream.Seek(_header.structuresOffset, SeekOrigin.Begin); stream.Read(structures, 0, 4100); - dmi = new byte[2052]; - pfi = new byte[2052]; + _dmi = new byte[2052]; + _pfi = new byte[2052]; // TODO: CMI - Array.Copy(structures, 4, dmi, 4, 2048); - Array.Copy(structures, 0x804, pfi, 4, 2048); + Array.Copy(structures, 4, _dmi, 4, 2048); + Array.Copy(structures, 0x804, _pfi, 4, 2048); - pfi[0] = 0x08; - pfi[1] = 0x02; - dmi[0] = 0x08; - dmi[1] = 0x02; + _pfi[0] = 0x08; + _pfi[1] = 0x02; + _dmi[0] = 0x08; + _dmi[1] = 0x02; - PFI.PhysicalFormatInformation? pfi0 = PFI.Decode(pfi); + PFI.PhysicalFormatInformation? pfi0 = PFI.Decode(_pfi); // All discs I tested the disk category and part version (as well as the start PSN for DVD-RAM) where modified by Alcohol // So much for archival value @@ -388,82 +389,83 @@ namespace Aaru.DiscImages switch(pfi0.Value.DiskCategory) { case DiskCategory.DVDPR: - imageInfo.MediaType = MediaType.DVDPR; + _imageInfo.MediaType = MediaType.DVDPR; break; case DiskCategory.DVDPRDL: - imageInfo.MediaType = MediaType.DVDPRDL; + _imageInfo.MediaType = MediaType.DVDPRDL; break; case DiskCategory.DVDPRW: - imageInfo.MediaType = MediaType.DVDPRW; + _imageInfo.MediaType = MediaType.DVDPRW; break; case DiskCategory.DVDPRWDL: - imageInfo.MediaType = MediaType.DVDPRWDL; + _imageInfo.MediaType = MediaType.DVDPRWDL; break; case DiskCategory.DVDR: - imageInfo.MediaType = pfi0.Value.PartVersion == 6 ? MediaType.DVDRDL : MediaType.DVDR; + _imageInfo.MediaType = pfi0.Value.PartVersion == 6 ? MediaType.DVDRDL : MediaType.DVDR; break; case DiskCategory.DVDRAM: - imageInfo.MediaType = MediaType.DVDRAM; + _imageInfo.MediaType = MediaType.DVDRAM; break; default: - imageInfo.MediaType = MediaType.DVDROM; + _imageInfo.MediaType = MediaType.DVDROM; break; case DiskCategory.DVDRW: - imageInfo.MediaType = pfi0.Value.PartVersion == 3 ? MediaType.DVDRWDL : MediaType.DVDRW; + _imageInfo.MediaType = + pfi0.Value.PartVersion == 3 ? MediaType.DVDRWDL : MediaType.DVDRW; break; case DiskCategory.HDDVDR: - imageInfo.MediaType = MediaType.HDDVDR; + _imageInfo.MediaType = MediaType.HDDVDR; break; case DiskCategory.HDDVDRAM: - imageInfo.MediaType = MediaType.HDDVDRAM; + _imageInfo.MediaType = MediaType.HDDVDRAM; break; case DiskCategory.HDDVDROM: - imageInfo.MediaType = MediaType.HDDVDROM; + _imageInfo.MediaType = MediaType.HDDVDROM; break; case DiskCategory.HDDVDRW: - imageInfo.MediaType = MediaType.HDDVDRW; + _imageInfo.MediaType = MediaType.HDDVDRW; break; case DiskCategory.Nintendo: - imageInfo.MediaType = + _imageInfo.MediaType = pfi0.Value.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD; break; case DiskCategory.UMD: - imageInfo.MediaType = MediaType.UMD; + _imageInfo.MediaType = MediaType.UMD; break; } - if(DMI.IsXbox(dmi)) - imageInfo.MediaType = MediaType.XGD; - else if(DMI.IsXbox360(dmi)) - imageInfo.MediaType = MediaType.XGD2; + if(DMI.IsXbox(_dmi)) + _imageInfo.MediaType = MediaType.XGD; + else if(DMI.IsXbox360(_dmi)) + _imageInfo.MediaType = MediaType.XGD2; byte[] tmp = new byte[2048]; - Array.Copy(dmi, 4, tmp, 0, 2048); - dmi = tmp; - tmp = new byte[2048]; - Array.Copy(pfi, 4, tmp, 0, 2048); - pfi = tmp; + Array.Copy(_dmi, 4, tmp, 0, 2048); + _dmi = tmp; + tmp = new byte[2048]; + Array.Copy(_pfi, 4, tmp, 0, 2048); + _pfi = tmp; - imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_PFI); - imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_DMI); + _imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_PFI); + _imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_DMI); } } } - else if(header.type == AlcoholMediumType.CD) + else if(_header.type == AlcoholMediumType.CD) { bool data = false; bool mode2 = false; @@ -471,7 +473,7 @@ namespace Aaru.DiscImages bool firstdata = false; bool audio = false; - foreach(AlcoholTrack alcoholTrack in alcTracks.Values) + foreach(AlcoholTrack alcoholTrack in _alcTracks.Values) { // First track is audio firstaudio |= alcoholTrack.point == 1 && alcoholTrack.mode == AlcoholTrackMode.Audio; @@ -500,29 +502,29 @@ namespace Aaru.DiscImages if(!data && !firstdata) - imageInfo.MediaType = MediaType.CDDA; + _imageInfo.MediaType = MediaType.CDDA; else if(firstaudio && data && Sessions.Count > 1 && mode2) - imageInfo.MediaType = MediaType.CDPLUS; + _imageInfo.MediaType = MediaType.CDPLUS; else if((firstdata && audio) || mode2) - imageInfo.MediaType = MediaType.CDROMXA; + _imageInfo.MediaType = MediaType.CDROMXA; else if(!audio) - imageInfo.MediaType = MediaType.CDROM; + _imageInfo.MediaType = MediaType.CDROM; else - imageInfo.MediaType = MediaType.CD; + _imageInfo.MediaType = MediaType.CD; } - AaruConsole.DebugWriteLine("Alcohol 120% plugin", "ImageInfo.mediaType = {0}", imageInfo.MediaType); + AaruConsole.DebugWriteLine("Alcohol 120% plugin", "ImageInfo.mediaType = {0}", _imageInfo.MediaType); Partitions = new List(); - offsetmap = new Dictionary(); + _offsetmap = new Dictionary(); ulong byteOffset = 0; - foreach(AlcoholTrack trk in alcTracks.Values) + foreach(AlcoholTrack trk in _alcTracks.Values) { - if(alcTrackExtras.TryGetValue(trk.point, out AlcoholTrackExtra extra)) + if(_alcTrackExtras.TryGetValue(trk.point, out AlcoholTrackExtra extra)) { var partition = new Partition { @@ -539,84 +541,84 @@ namespace Aaru.DiscImages byteOffset += partition.Size; } - if(!offsetmap.ContainsKey(trk.point)) - offsetmap.Add(trk.point, trk.startLba); + if(!_offsetmap.ContainsKey(trk.point)) + _offsetmap.Add(trk.point, trk.startLba); switch(trk.mode) { case AlcoholTrackMode.Mode1: case AlcoholTrackMode.Mode2F1: case AlcoholTrackMode.Mode2F1Alt: - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - if(imageInfo.SectorSize < 2048) - imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) + _imageInfo.SectorSize = 2048; break; case AlcoholTrackMode.Mode2: - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(imageInfo.SectorSize < 2336) - imageInfo.SectorSize = 2336; + if(_imageInfo.SectorSize < 2336) + _imageInfo.SectorSize = 2336; break; case AlcoholTrackMode.Mode2F2: case AlcoholTrackMode.Mode2F2Alt: - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - if(imageInfo.SectorSize < 2324) - imageInfo.SectorSize = 2324; + if(_imageInfo.SectorSize < 2324) + _imageInfo.SectorSize = 2324; break; case AlcoholTrackMode.DVD: - imageInfo.SectorSize = 2048; + _imageInfo.SectorSize = 2048; break; default: - imageInfo.SectorSize = 2352; + _imageInfo.SectorSize = 2352; break; } if(trk.subMode != AlcoholSubchannelMode.None && - !imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); + !_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); } AaruConsole.DebugWriteLine("Alcohol 120% plugin", "printing partition map"); @@ -636,23 +638,23 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Alcohol 120% plugin", "\tPartition size in bytes: {0}", partition.Size); } - imageInfo.Application = "Alcohol 120%"; + _imageInfo.Application = "Alcohol 120%"; AaruConsole.DebugWriteLine("Alcohol 120% plugin", "Data filename: {0}", alcFile); var filtersList = new FiltersList(); - alcImage = filtersList.GetFilter(alcFile); + _alcImage = filtersList.GetFilter(alcFile); - if(alcImage == null) + if(_alcImage == null) throw new Exception("Cannot open data file"); - imageInfo.ImageSize = (ulong)alcImage.GetDataForkLength(); - imageInfo.CreationTime = alcImage.GetCreationTime(); - imageInfo.LastModificationTime = alcImage.GetLastWriteTime(); - imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; - imageInfo.Version = $"{header.version[0]}.{header.version[1]}"; + _imageInfo.ImageSize = (ulong)_alcImage.GetDataForkLength(); + _imageInfo.CreationTime = _alcImage.GetCreationTime(); + _imageInfo.LastModificationTime = _alcImage.GetLastWriteTime(); + _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; + _imageInfo.Version = $"{_header.version[0]}.{_header.version[1]}"; - if(!isDvd) + if(!_isDvd) { AaruConsole.DebugWriteLine("Alcohol 120% plugin", "Rebuilding TOC"); byte firstSession = byte.MaxValue; @@ -664,7 +666,7 @@ namespace Aaru.DiscImages 0, 0 }, 0, 2); // Reserved for TOC session numbers - foreach(KeyValuePair> sessionToc in alcToc) + foreach(KeyValuePair> sessionToc in _alcToc) { if(sessionToc.Key < firstSession) firstSession = (byte)sessionToc.Key; @@ -688,21 +690,21 @@ namespace Aaru.DiscImages } } - fullToc = tocMs.ToArray(); - fullToc[0] = firstSession; - fullToc[1] = lastSession; + _fullToc = tocMs.ToArray(); + _fullToc[0] = firstSession; + _fullToc[1] = lastSession; - imageInfo.ReadableMediaTags.Add(MediaTagType.CD_FullTOC); - imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); + _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_FullTOC); + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); } - if(imageInfo.MediaType == MediaType.XGD2) - if(imageInfo.Sectors == 25063 || // Locked (or non compatible drive) - imageInfo.Sectors == 4229664 || // Xtreme unlock - imageInfo.Sectors == 4246304) // Wxripper unlock - imageInfo.MediaType = MediaType.XGD3; + if(_imageInfo.MediaType == MediaType.XGD2) + if(_imageInfo.Sectors == 25063 || // Locked (or non compatible drive) + _imageInfo.Sectors == 4229664 || // Xtreme unlock + _imageInfo.Sectors == 4246304) // Wxripper unlock + _imageInfo.MediaType = MediaType.XGD3; - AaruConsole.VerboseWriteLine("Alcohol 120% image describes a disc of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("Alcohol 120% image describes a disc of type {0}", _imageInfo.MediaType); if(oldIncorrectImage) AaruConsole. @@ -717,32 +719,32 @@ namespace Aaru.DiscImages { case MediaTagType.DVD_BCA: { - if(bca != null) - return (byte[])bca.Clone(); + if(_bca != null) + return (byte[])_bca.Clone(); throw new FeatureNotPresentImageException("Image does not contain BCA information."); } case MediaTagType.DVD_PFI: { - if(pfi != null) - return (byte[])pfi.Clone(); + if(_pfi != null) + return (byte[])_pfi.Clone(); throw new FeatureNotPresentImageException("Image does not contain PFI."); } case MediaTagType.DVD_DMI: { - if(dmi != null) - return (byte[])dmi.Clone(); + if(_dmi != null) + return (byte[])_dmi.Clone(); throw new FeatureNotPresentImageException("Image does not contain DMI."); } case MediaTagType.CD_FullTOC: { - if(fullToc != null) - return (byte[])fullToc.Clone(); + if(_fullToc != null) + return (byte[])_fullToc.Clone(); throw new FeatureNotPresentImageException("Image does not contain TOC information."); } @@ -763,12 +765,12 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in offsetmap) + foreach(KeyValuePair kvp in _offsetmap) if(sectorAddress >= kvp.Value) - foreach(AlcoholTrack track in alcTracks.Values) + foreach(AlcoholTrack track in _alcTracks.Values) { if(track.point != kvp.Key || - !alcTrackExtras.TryGetValue(track.point, out AlcoholTrackExtra extra)) + !_alcTrackExtras.TryGetValue(track.point, out AlcoholTrackExtra extra)) continue; if(sectorAddress - kvp.Value < extra.sectors) @@ -780,12 +782,12 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { - foreach(KeyValuePair kvp in offsetmap) + foreach(KeyValuePair kvp in _offsetmap) if(sectorAddress >= kvp.Value) - foreach(AlcoholTrack track in alcTracks.Values) + foreach(AlcoholTrack track in _alcTracks.Values) { if(track.point != kvp.Key || - !alcTrackExtras.TryGetValue(track.point, out AlcoholTrackExtra extra)) + !_alcTrackExtras.TryGetValue(track.point, out AlcoholTrackExtra extra)) continue; if(sectorAddress - kvp.Value < extra.sectors) @@ -797,8 +799,8 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length, uint track) { - if(!alcTracks.TryGetValue((int)track, out AlcoholTrack alcTrack) || - !alcTrackExtras.TryGetValue((int)track, out AlcoholTrackExtra alcExtra)) + if(!_alcTracks.TryGetValue((int)track, out AlcoholTrack alcTrack) || + !_alcTrackExtras.TryGetValue((int)track, out AlcoholTrackExtra alcExtra)) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); if(length + sectorAddress > alcExtra.sectors) @@ -871,8 +873,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = alcImage.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = _alcImage.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)alcTrack.startOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), @@ -914,8 +916,8 @@ namespace Aaru.DiscImages if(tag == SectorTagType.CdTrackFlags) track = (uint)sectorAddress; - if(!alcTracks.TryGetValue((int)track, out AlcoholTrack alcTrack) || - !alcTrackExtras.TryGetValue((int)track, out AlcoholTrackExtra alcExtra)) + if(!_alcTracks.TryGetValue((int)track, out AlcoholTrack alcTrack) || + !_alcTrackExtras.TryGetValue((int)track, out AlcoholTrackExtra alcExtra)) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); if(length + sectorAddress > alcExtra.sectors) @@ -1275,8 +1277,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = alcImage.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = _alcImage.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)alcTrack.startOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), @@ -1303,12 +1305,12 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in offsetmap) + foreach(KeyValuePair kvp in _offsetmap) if(sectorAddress >= kvp.Value) - foreach(AlcoholTrack alcTrack in alcTracks.Values) + foreach(AlcoholTrack alcTrack in _alcTracks.Values) { if(alcTrack.point != kvp.Key || - !alcTrackExtras.TryGetValue(alcTrack.point, out AlcoholTrackExtra alcExtra)) + !_alcTrackExtras.TryGetValue(alcTrack.point, out AlcoholTrackExtra alcExtra)) continue; if(sectorAddress - kvp.Value < alcExtra.sectors) @@ -1320,8 +1322,8 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track) { - if(!alcTracks.TryGetValue((int)track, out AlcoholTrack alcTrack) || - !alcTrackExtras.TryGetValue((int)track, out AlcoholTrackExtra alcExtra)) + if(!_alcTracks.TryGetValue((int)track, out AlcoholTrack alcTrack) || + !_alcTrackExtras.TryGetValue((int)track, out AlcoholTrackExtra alcExtra)) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); if(length + sectorAddress > alcExtra.sectors) @@ -1358,8 +1360,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = alcImage.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = _alcImage.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)alcTrack.startOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), @@ -1393,13 +1395,13 @@ namespace Aaru.DiscImages { List tracks = new List(); - foreach(AlcoholTrack alcTrack in alcTracks.Values) + foreach(AlcoholTrack alcTrack in _alcTracks.Values) { ushort sessionNo = (from ses in Sessions where alcTrack.point >= ses.StartTrack || alcTrack.point <= ses.EndTrack select ses.SessionSequence).FirstOrDefault(); - if(!alcTrackExtras.TryGetValue(alcTrack.point, out AlcoholTrackExtra alcExtra) || + if(!_alcTrackExtras.TryGetValue(alcTrack.point, out AlcoholTrackExtra alcExtra) || session != sessionNo) continue; @@ -1411,8 +1413,8 @@ namespace Aaru.DiscImages TrackSession = sessionNo, TrackSequence = alcTrack.point, TrackType = AlcoholTrackTypeToTrackType(alcTrack.mode), - TrackFilter = alcImage, - TrackFile = alcImage.GetFilename(), + TrackFilter = _alcImage, + TrackFile = _alcImage.GetFilename(), TrackFileOffset = alcTrack.startOffset, TrackFileType = "BINARY", TrackRawBytesPerSector = alcTrack.sectorSize, @@ -1427,8 +1429,8 @@ namespace Aaru.DiscImages switch(alcTrack.subMode) { case AlcoholSubchannelMode.Interleaved: - aaruTrack.TrackSubchannelFilter = alcImage; - aaruTrack.TrackSubchannelFile = alcImage.GetFilename(); + aaruTrack.TrackSubchannelFilter = _alcImage; + aaruTrack.TrackSubchannelFile = _alcImage.GetFilename(); aaruTrack.TrackSubchannelOffset = alcTrack.startOffset; aaruTrack.TrackSubchannelType = TrackSubchannelType.RawInterleaved; diff --git a/Aaru.Images/Alcohol120/Write.cs b/Aaru.Images/Alcohol120/Write.cs index 265bdf518..9f3012493 100644 --- a/Aaru.Images/Alcohol120/Write.cs +++ b/Aaru.Images/Alcohol120/Write.cs @@ -57,7 +57,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -66,9 +66,9 @@ namespace Aaru.DiscImages try { - descriptorStream = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None); + _descriptorStream = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None); - imageStream = + _imageStream = new FileStream(Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)) + ".mdf", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); @@ -80,7 +80,7 @@ namespace Aaru.DiscImages return false; } - imageInfo.MediaType = mediaType; + _imageInfo.MediaType = mediaType; switch(mediaType) { @@ -121,16 +121,16 @@ namespace Aaru.DiscImages case MediaType.VideoNowColor: case MediaType.VideoNowXp: case MediaType.CVD: - isDvd = false; + _isDvd = false; break; default: - isDvd = true; + _isDvd = true; break; } - trackFlags = new Dictionary(); + _trackFlags = new Dictionary(); IsWriting = true; ErrorMessage = null; @@ -150,47 +150,47 @@ namespace Aaru.DiscImages switch(tag) { case MediaTagType.CD_FullTOC: - if(isDvd) + if(_isDvd) { - ErrorMessage = $"Unsupported media tag {tag} for medium type {imageInfo.MediaType}"; + ErrorMessage = $"Unsupported media tag {tag} for medium type {_imageInfo.MediaType}"; return false; } - fullToc = data; + _fullToc = data; return true; case MediaTagType.DVD_PFI: - if(!isDvd) + if(!_isDvd) { - ErrorMessage = $"Unsupported media tag {tag} for medium type {imageInfo.MediaType}"; + ErrorMessage = $"Unsupported media tag {tag} for medium type {_imageInfo.MediaType}"; return false; } - pfi = data; + _pfi = data; return true; case MediaTagType.DVD_DMI: - if(!isDvd) + if(!_isDvd) { - ErrorMessage = $"Unsupported media tag {tag} for medium type {imageInfo.MediaType}"; + ErrorMessage = $"Unsupported media tag {tag} for medium type {_imageInfo.MediaType}"; return false; } - dmi = data; + _dmi = data; return true; case MediaTagType.DVD_BCA: - if(!isDvd) + if(!_isDvd) { - ErrorMessage = $"Unsupported media tag {tag} for medium type {imageInfo.MediaType}"; + ErrorMessage = $"Unsupported media tag {tag} for medium type {_imageInfo.MediaType}"; return false; } - bca = data; + _bca = data; return true; default: @@ -210,8 +210,8 @@ namespace Aaru.DiscImages } Track track = - writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && - sectorAddress <= trk.TrackEndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && + sectorAddress <= trk.TrackEndSector); if(track is null) { @@ -234,11 +234,11 @@ namespace Aaru.DiscImages return false; } - imageStream. + _imageStream. Seek((long)(track.TrackFileOffset + ((sectorAddress - track.TrackStartSector) * (ulong)track.TrackRawBytesPerSector)), SeekOrigin.Begin); - imageStream.Write(data, 0, data.Length); + _imageStream.Write(data, 0, data.Length); return true; } @@ -253,8 +253,8 @@ namespace Aaru.DiscImages } Track track = - writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && - sectorAddress <= trk.TrackEndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && + sectorAddress <= trk.TrackEndSector); if(track is null) { @@ -287,25 +287,25 @@ namespace Aaru.DiscImages switch(track.TrackSubchannelType) { case TrackSubchannelType.None: - imageStream. + _imageStream. Seek((long)(track.TrackFileOffset + ((sectorAddress - track.TrackStartSector) * (ulong)track.TrackRawBytesPerSector)), SeekOrigin.Begin); - imageStream.Write(data, 0, data.Length); + _imageStream.Write(data, 0, data.Length); ErrorMessage = ""; return true; case TrackSubchannelType.Raw: case TrackSubchannelType.RawInterleaved: - imageStream. + _imageStream. Seek((long)(track.TrackFileOffset + ((sectorAddress - track.TrackStartSector) * (ulong)(track.TrackRawBytesPerSector + 96))), SeekOrigin.Begin); for(uint i = 0; i < length; i++) { - imageStream.Write(data, (int)(i * track.TrackRawBytesPerSector), track.TrackRawBytesPerSector); - imageStream.Position += 96; + _imageStream.Write(data, (int)(i * track.TrackRawBytesPerSector), track.TrackRawBytesPerSector); + _imageStream.Position += 96; } ErrorMessage = ""; @@ -328,8 +328,8 @@ namespace Aaru.DiscImages } Track track = - writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && - sectorAddress <= trk.TrackEndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && + sectorAddress <= trk.TrackEndSector); if(track is null) { @@ -347,11 +347,11 @@ namespace Aaru.DiscImages uint subchannelSize = (uint)(track.TrackSubchannelType != TrackSubchannelType.None ? 96 : 0); - imageStream. + _imageStream. Seek((long)(track.TrackFileOffset + ((sectorAddress - track.TrackStartSector) * (ulong)(track.TrackRawBytesPerSector + subchannelSize))), SeekOrigin.Begin); - imageStream.Write(data, 0, data.Length); + _imageStream.Write(data, 0, data.Length); return true; } @@ -366,8 +366,8 @@ namespace Aaru.DiscImages } Track track = - writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && - sectorAddress <= trk.TrackEndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && + sectorAddress <= trk.TrackEndSector); if(track is null) { @@ -394,11 +394,11 @@ namespace Aaru.DiscImages for(uint i = 0; i < length; i++) { - imageStream. + _imageStream. Seek((long)(track.TrackFileOffset + (((i + sectorAddress) - track.TrackStartSector) * (ulong)(track.TrackRawBytesPerSector + subchannelSize))), SeekOrigin.Begin); - imageStream.Write(data, (int)(i * track.TrackRawBytesPerSector), track.TrackRawBytesPerSector); + _imageStream.Write(data, (int)(i * track.TrackRawBytesPerSector), track.TrackRawBytesPerSector); } return true; @@ -408,9 +408,9 @@ namespace Aaru.DiscImages { ulong currentDataOffset = 0; - writingTracks = new List(); + _writingTracks = new List(); - if(!isDvd) + if(!_isDvd) { Track[] tmpTracks = tracks.OrderBy(t => t.TrackSequence).ToArray(); @@ -461,7 +461,7 @@ namespace Aaru.DiscImages currentDataOffset += (ulong)(newTrack.TrackRawBytesPerSector + subchannelSize) * ((newTrack.TrackEndSector - newTrack.TrackStartSector) + 1); - writingTracks.Add(newTrack); + _writingTracks.Add(newTrack); } return true; @@ -478,21 +478,21 @@ namespace Aaru.DiscImages byte sessions = byte.MinValue; - foreach(Track t in writingTracks) + foreach(Track t in _writingTracks) if(t.TrackSession > byte.MinValue) sessions = (byte)t.TrackSession; var header = new AlcoholHeader { - signature = alcoholSignature, + signature = _alcoholSignature, version = new byte[] { 1, 5 }, - type = MediaTypeToAlcohol(imageInfo.MediaType), + type = MediaTypeToAlcohol(_imageInfo.MediaType), sessions = sessions, - structuresOffset = (uint)(pfi == null ? 0 : 96), - sessionOffset = (uint)(pfi == null ? 96 : 4196), + structuresOffset = (uint)(_pfi == null ? 0 : 96), + sessionOffset = (uint)(_pfi == null ? 96 : 4196), unknown1 = new ushort[2], unknown2 = new uint[2], unknown3 = new uint[6], @@ -502,20 +502,20 @@ namespace Aaru.DiscImages // Alcohol sets this always, Daemon Tool expects this header.unknown1[0] = 2; - alcSessions = new Dictionary(); - alcTracks = new Dictionary(); - alcToc = new Dictionary>(); - writingTracks = writingTracks.OrderBy(t => t.TrackSession).ThenBy(t => t.TrackSequence).ToList(); - alcTrackExtras = new Dictionary(); + _alcSessions = new Dictionary(); + _alcTracks = new Dictionary(); + _alcToc = new Dictionary>(); + _writingTracks = _writingTracks.OrderBy(t => t.TrackSession).ThenBy(t => t.TrackSequence).ToList(); + _alcTrackExtras = new Dictionary(); long currentTrackOffset = header.sessionOffset + (Marshal.SizeOf() * sessions); byte[] tmpToc = null; - if(fullToc != null) + if(_fullToc != null) { - byte[] fullTocSize = BigEndianBitConverter.GetBytes((short)fullToc.Length); - tmpToc = new byte[fullToc.Length + 2]; - Array.Copy(fullToc, 0, tmpToc, 2, fullToc.Length); + byte[] fullTocSize = BigEndianBitConverter.GetBytes((short)_fullToc.Length); + tmpToc = new byte[_fullToc.Length + 2]; + Array.Copy(_fullToc, 0, tmpToc, 2, _fullToc.Length); tmpToc[0] = fullTocSize[0]; tmpToc[1] = fullTocSize[1]; } @@ -539,9 +539,9 @@ namespace Aaru.DiscImages extraCount += 3; currentExtraOffset += Marshal.SizeOf() * - writingTracks.Count(t => t.TrackSession == i); + _writingTracks.Count(t => t.TrackSession == i); - extraCount += writingTracks.Count(t => t.TrackSession == i); + extraCount += _writingTracks.Count(t => t.TrackSession == i); if(i < sessions) { @@ -552,36 +552,36 @@ namespace Aaru.DiscImages long footerOffset = currentExtraOffset + (Marshal.SizeOf() * extraCount); - if(bca != null) + if(_bca != null) { header.bcaOffset = (uint)footerOffset; - footerOffset += bca.Length; + footerOffset += _bca.Length; } - if(isDvd) + if(_isDvd) { - alcSessions.Add(1, new AlcoholSession + _alcSessions.Add(1, new AlcoholSession { - sessionEnd = (int)((writingTracks[0].TrackEndSector - writingTracks[0].TrackStartSector) + 1), + sessionEnd = (int)((_writingTracks[0].TrackEndSector - _writingTracks[0].TrackStartSector) + 1), sessionSequence = 1, - allBlocks = 1, - nonTrackBlocks = 3, - firstTrack = 1, - lastTrack = 1, - trackOffset = 4220 + allBlocks = 1, + nonTrackBlocks = 3, + firstTrack = 1, + lastTrack = 1, + trackOffset = 4220 }); footerOffset = 4300; - if(bca != null) - footerOffset += bca.Length; + if(_bca != null) + footerOffset += _bca.Length; - alcTracks.Add(1, new AlcoholTrack + _alcTracks.Add(1, new AlcoholTrack { mode = AlcoholTrackMode.DVD, adrCtl = 20, point = 1, - extraOffset = (uint)((writingTracks[0].TrackEndSector - writingTracks[0].TrackStartSector) + 1), + extraOffset = (uint)((_writingTracks[0].TrackEndSector - _writingTracks[0].TrackStartSector) + 1), sectorSize = 2048, files = 1, footerOffset = (uint)footerOffset, @@ -589,21 +589,21 @@ namespace Aaru.DiscImages unknown2 = new byte[24] }); - alcToc.Add(1, alcTracks); + _alcToc.Add(1, _alcTracks); } else for(int i = 1; i <= sessions; i++) { - Track firstTrack = writingTracks.First(t => t.TrackSession == i); - Track lastTrack = writingTracks.Last(t => t.TrackSession == i); + Track firstTrack = _writingTracks.First(t => t.TrackSession == i); + Track lastTrack = _writingTracks.Last(t => t.TrackSession == i); - alcSessions.Add(i, new AlcoholSession + _alcSessions.Add(i, new AlcoholSession { sessionStart = (int)firstTrack.TrackStartSector - 150, sessionEnd = (int)lastTrack.TrackEndSector + 1, sessionSequence = (ushort)i, allBlocks = (byte)(decodedToc?.TrackDescriptors.Count(t => t.SessionNumber == i) ?? - writingTracks.Count(t => t.TrackSession == i) + 3), + _writingTracks.Count(t => t.TrackSession == i) + 3), nonTrackBlocks = (byte)(decodedToc?.TrackDescriptors.Count(t => t.SessionNumber == i && t.POINT >= 0xA0 && t.POINT <= 0xAF) ?? 3), @@ -613,8 +613,8 @@ namespace Aaru.DiscImages }); Dictionary thisSessionTracks = new Dictionary(); - trackFlags.TryGetValue((byte)firstTrack.TrackSequence, out byte firstTrackControl); - trackFlags.TryGetValue((byte)lastTrack.TrackSequence, out byte lastTrackControl); + _trackFlags.TryGetValue((byte)firstTrack.TrackSequence, out byte firstTrackControl); + _trackFlags.TryGetValue((byte)lastTrack.TrackSequence, out byte lastTrackControl); if(firstTrackControl == 0 && firstTrack.TrackType != TrackType.Audio) @@ -664,11 +664,11 @@ namespace Aaru.DiscImages point = 0xA0, unknown = new byte[18], unknown2 = new byte[24], - psec = (byte)(imageInfo.MediaType == MediaType.CDI + psec = (byte)(_imageInfo.MediaType == MediaType.CDI ? 0x10 - : writingTracks.Any(t => t.TrackType == TrackType.CdMode2Form1 || - t.TrackType == TrackType.CdMode2Form2 || - t.TrackType == TrackType.CdMode2Formless) + : _writingTracks.Any(t => t.TrackType == TrackType.CdMode2Form1 || + t.TrackType == TrackType.CdMode2Form2 || + t.TrackType == TrackType.CdMode2Formless) ? 0x20 : 0), extraOffset = (uint)currentExtraOffset @@ -703,7 +703,7 @@ namespace Aaru.DiscImages currentTrackOffset += Marshal.SizeOf() * 3; } - foreach(Track track in writingTracks.Where(t => t.TrackSession == i).OrderBy(t => t.TrackSequence)) + foreach(Track track in _writingTracks.Where(t => t.TrackSession == i).OrderBy(t => t.TrackSequence)) { var alcTrk = new AlcoholTrack(); @@ -729,7 +729,7 @@ namespace Aaru.DiscImages else { (byte minute, byte second, byte frame) msf = LbaToMsf(track.TrackStartSector); - trackFlags.TryGetValue((byte)track.TrackSequence, out byte trackControl); + _trackFlags.TryGetValue((byte)track.TrackSequence, out byte trackControl); if(trackControl == 0 && track.TrackType != TrackType.Audio) @@ -790,19 +790,19 @@ namespace Aaru.DiscImages // When track mode changes there's a mandatory gap, Alcohol needs it else if(thisSessionTracks.TryGetValue((int)(track.TrackSequence - 1), out AlcoholTrack previousTrack) && - alcTrackExtras.TryGetValue((int)(track.TrackSequence - 1), - out AlcoholTrackExtra previousExtra) && + _alcTrackExtras.TryGetValue((int)(track.TrackSequence - 1), + out AlcoholTrackExtra previousExtra) && previousTrack.mode != alcTrk.mode) { previousExtra.sectors -= 150; trkExtra.pregap = 150; - alcTrackExtras.Remove((int)(track.TrackSequence - 1)); - alcTrackExtras.Add((int)(track.TrackSequence - 1), previousExtra); + _alcTrackExtras.Remove((int)(track.TrackSequence - 1)); + _alcTrackExtras.Add((int)(track.TrackSequence - 1), previousExtra); } else trkExtra.pregap = 0; - alcTrackExtras.Add((int)track.TrackSequence, trkExtra); + _alcTrackExtras.Add((int)track.TrackSequence, trkExtra); } if(decodedToc.HasValue && @@ -834,11 +834,11 @@ namespace Aaru.DiscImages else if(i < sessions) { (byte minute, byte second, byte frame) leadoutAmsf = - LbaToMsf(writingTracks.First(t => t.TrackSession == i + 1).TrackStartSector - 150); + LbaToMsf(_writingTracks.First(t => t.TrackSession == i + 1).TrackStartSector - 150); (byte minute, byte second, byte frame) leadoutPmsf = - LbaToMsf(writingTracks.OrderBy(t => t.TrackSession).ThenBy(t => t.TrackSequence).Last(). - TrackStartSector); + LbaToMsf(_writingTracks.OrderBy(t => t.TrackSession).ThenBy(t => t.TrackSequence).Last(). + TrackStartSector); thisSessionTracks.Add(0xB0, new AlcoholTrack { @@ -869,10 +869,10 @@ namespace Aaru.DiscImages currentTrackOffset += Marshal.SizeOf() * 2; } - alcToc.Add(i, thisSessionTracks); + _alcToc.Add(i, thisSessionTracks); } - alcFooter = new AlcoholFooter + _alcFooter = new AlcoholFooter { filenameOffset = (uint)(footerOffset + Marshal.SizeOf()), widechar = 1 @@ -883,73 +883,73 @@ namespace Aaru.DiscImages IntPtr blockPtr; // Write header - descriptorStream.Seek(0, SeekOrigin.Begin); + _descriptorStream.Seek(0, SeekOrigin.Begin); byte[] block = new byte[Marshal.SizeOf()]; blockPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); System.Runtime.InteropServices.Marshal.StructureToPtr(header, blockPtr, true); System.Runtime.InteropServices.Marshal.Copy(blockPtr, block, 0, block.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(blockPtr); - descriptorStream.Write(block, 0, block.Length); + _descriptorStream.Write(block, 0, block.Length); // Write DVD structures if pressent if(header.structuresOffset != 0) { - if(dmi != null) + if(_dmi != null) { - descriptorStream.Seek(header.structuresOffset, SeekOrigin.Begin); + _descriptorStream.Seek(header.structuresOffset, SeekOrigin.Begin); - if(dmi.Length == 2052) - descriptorStream.Write(dmi, 0, 2052); - else if(dmi.Length == 2048) + if(_dmi.Length == 2052) + _descriptorStream.Write(_dmi, 0, 2052); + else if(_dmi.Length == 2048) { - descriptorStream.Write(new byte[] + _descriptorStream.Write(new byte[] { 0x08, 0x02, 0x00, 0x00 }, 0, 4); - descriptorStream.Write(dmi, 0, 2048); + _descriptorStream.Write(_dmi, 0, 2048); } } // TODO: Create fake PFI if none present - if(pfi != null) + if(_pfi != null) { - descriptorStream.Seek(header.structuresOffset + 2052, SeekOrigin.Begin); - descriptorStream.Write(pfi, pfi.Length - 2048, 2048); + _descriptorStream.Seek(header.structuresOffset + 2052, SeekOrigin.Begin); + _descriptorStream.Write(_pfi, _pfi.Length - 2048, 2048); } } // Write sessions - descriptorStream.Seek(header.sessionOffset, SeekOrigin.Begin); + _descriptorStream.Seek(header.sessionOffset, SeekOrigin.Begin); - foreach(AlcoholSession session in alcSessions.Values) + foreach(AlcoholSession session in _alcSessions.Values) { block = new byte[Marshal.SizeOf()]; blockPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); System.Runtime.InteropServices.Marshal.StructureToPtr(session, blockPtr, true); System.Runtime.InteropServices.Marshal.Copy(blockPtr, block, 0, block.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(blockPtr); - descriptorStream.Write(block, 0, block.Length); + _descriptorStream.Write(block, 0, block.Length); } // Write tracks - foreach(KeyValuePair> kvp in alcToc) + foreach(KeyValuePair> kvp in _alcToc) { - descriptorStream.Seek(alcSessions.First(t => t.Key == kvp.Key).Value.trackOffset, SeekOrigin.Begin); + _descriptorStream.Seek(_alcSessions.First(t => t.Key == kvp.Key).Value.trackOffset, SeekOrigin.Begin); foreach(AlcoholTrack track in kvp.Value.Values) { AlcoholTrack alcoholTrack = track; // Write extra - if(!isDvd) + if(!_isDvd) { - long position = descriptorStream.Position; - descriptorStream.Seek(alcoholTrack.extraOffset, SeekOrigin.Begin); + long position = _descriptorStream.Position; + _descriptorStream.Seek(alcoholTrack.extraOffset, SeekOrigin.Begin); block = new byte[Marshal.SizeOf()]; - if(alcTrackExtras.TryGetValue(alcoholTrack.point, out AlcoholTrackExtra extra)) + if(_alcTrackExtras.TryGetValue(alcoholTrack.point, out AlcoholTrackExtra extra)) { blockPtr = System.Runtime.InteropServices.Marshal. @@ -962,9 +962,9 @@ namespace Aaru.DiscImages else alcoholTrack.extraOffset = 0; - descriptorStream.Write(block, 0, block.Length); + _descriptorStream.Write(block, 0, block.Length); - descriptorStream.Seek(position, SeekOrigin.Begin); + _descriptorStream.Seek(position, SeekOrigin.Begin); } block = new byte[Marshal.SizeOf()]; @@ -972,39 +972,39 @@ namespace Aaru.DiscImages System.Runtime.InteropServices.Marshal.StructureToPtr(alcoholTrack, blockPtr, true); System.Runtime.InteropServices.Marshal.Copy(blockPtr, block, 0, block.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(blockPtr); - descriptorStream.Write(block, 0, block.Length); + _descriptorStream.Write(block, 0, block.Length); } } // Write BCA - if(bca != null) + if(_bca != null) { - descriptorStream.Seek(header.bcaOffset, SeekOrigin.Begin); - descriptorStream.Write(bca, 0, bca.Length); + _descriptorStream.Seek(header.bcaOffset, SeekOrigin.Begin); + _descriptorStream.Write(_bca, 0, _bca.Length); } // Write footer - descriptorStream.Seek(footerOffset, SeekOrigin.Begin); + _descriptorStream.Seek(footerOffset, SeekOrigin.Begin); block = new byte[Marshal.SizeOf()]; blockPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); - System.Runtime.InteropServices.Marshal.StructureToPtr(alcFooter, blockPtr, true); + System.Runtime.InteropServices.Marshal.StructureToPtr(_alcFooter, blockPtr, true); System.Runtime.InteropServices.Marshal.Copy(blockPtr, block, 0, block.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(blockPtr); - descriptorStream.Write(block, 0, block.Length); + _descriptorStream.Write(block, 0, block.Length); // Write filename - descriptorStream.Write(filename, 0, filename.Length); + _descriptorStream.Write(filename, 0, filename.Length); // Write filename null termination - descriptorStream.Write(new byte[] + _descriptorStream.Write(new byte[] { 0, 0 }, 0, 2); - descriptorStream.Flush(); - descriptorStream.Close(); - imageStream.Flush(); - imageStream.Close(); + _descriptorStream.Flush(); + _descriptorStream.Close(); + _imageStream.Flush(); + _imageStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -1031,8 +1031,8 @@ namespace Aaru.DiscImages } Track track = - writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && - sectorAddress <= trk.TrackEndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && + sectorAddress <= trk.TrackEndSector); if(track is null) { @@ -1052,7 +1052,7 @@ namespace Aaru.DiscImages return false; } - trackFlags[(byte)sectorAddress] = data[0]; + _trackFlags[(byte)sectorAddress] = data[0]; return true; } @@ -1073,11 +1073,11 @@ namespace Aaru.DiscImages return false; } - imageStream. + _imageStream. Seek((long)(track.TrackFileOffset + ((sectorAddress - track.TrackStartSector) * (ulong)(track.TrackRawBytesPerSector + 96))) + track.TrackRawBytesPerSector, SeekOrigin.Begin); - imageStream.Write(data, 0, data.Length); + _imageStream.Write(data, 0, data.Length); return true; } @@ -1098,8 +1098,8 @@ namespace Aaru.DiscImages } Track track = - writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && - sectorAddress <= trk.TrackEndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && + sectorAddress <= trk.TrackEndSector); if(track is null) { @@ -1130,11 +1130,11 @@ namespace Aaru.DiscImages for(uint i = 0; i < length; i++) { - imageStream. + _imageStream. Seek((long)(track.TrackFileOffset + (((i + sectorAddress) - track.TrackStartSector) * (ulong)(track.TrackRawBytesPerSector + 96))) + track.TrackRawBytesPerSector, SeekOrigin.Begin); - imageStream.Write(data, (int)(i * 96), 96); + _imageStream.Write(data, (int)(i * 96), 96); } return true; diff --git a/Aaru.Images/Anex86/Anex86.cs b/Aaru.Images/Anex86/Anex86.cs index 59987890f..6e0624ecf 100644 --- a/Aaru.Images/Anex86/Anex86.cs +++ b/Aaru.Images/Anex86/Anex86.cs @@ -40,12 +40,12 @@ namespace Aaru.DiscImages { public partial class Anex86 : IWritableImage { - IFilter anexImageFilter; - Anex86Header fdihdr; - ImageInfo imageInfo; - FileStream writingStream; + IFilter _anexImageFilter; + Anex86Header _fdihdr; + ImageInfo _imageInfo; + FileStream _writingStream; - public Anex86() => imageInfo = new ImageInfo + public Anex86() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/Anex86/Identify.cs b/Aaru.Images/Anex86/Identify.cs index 67f0e28bc..609a8dde7 100644 --- a/Aaru.Images/Anex86/Identify.cs +++ b/Aaru.Images/Anex86/Identify.cs @@ -50,19 +50,19 @@ namespace Aaru.DiscImages byte[] hdrB = new byte[Marshal.SizeOf()]; stream.Read(hdrB, 0, hdrB.Length); - fdihdr = Marshal.SpanToStructureLittleEndian(hdrB); + _fdihdr = Marshal.SpanToStructureLittleEndian(hdrB); - AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.unknown = {0}", fdihdr.unknown); - AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.hddtype = {0}", fdihdr.hddtype); - AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.hdrSize = {0}", fdihdr.hdrSize); - AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.dskSize = {0}", fdihdr.dskSize); - AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.bps = {0}", fdihdr.bps); - AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.spt = {0}", fdihdr.spt); - AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.heads = {0}", fdihdr.heads); - AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.cylinders = {0}", fdihdr.cylinders); + AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.unknown = {0}", _fdihdr.unknown); + AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.hddtype = {0}", _fdihdr.hddtype); + AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.hdrSize = {0}", _fdihdr.hdrSize); + AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.dskSize = {0}", _fdihdr.dskSize); + AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.bps = {0}", _fdihdr.bps); + AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.spt = {0}", _fdihdr.spt); + AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.heads = {0}", _fdihdr.heads); + AaruConsole.DebugWriteLine("Anex86 plugin", "fdihdr.cylinders = {0}", _fdihdr.cylinders); - return stream.Length == fdihdr.hdrSize + fdihdr.dskSize && - fdihdr.dskSize == fdihdr.bps * fdihdr.spt * fdihdr.heads * fdihdr.cylinders; + return stream.Length == _fdihdr.hdrSize + _fdihdr.dskSize && + _fdihdr.dskSize == _fdihdr.bps * _fdihdr.spt * _fdihdr.heads * _fdihdr.cylinders; } } } \ No newline at end of file diff --git a/Aaru.Images/Anex86/Properties.cs b/Aaru.Images/Anex86/Properties.cs index bc90b284c..23c57b8b0 100644 --- a/Aaru.Images/Anex86/Properties.cs +++ b/Aaru.Images/Anex86/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class Anex86 { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Anex86 Disk Image"; public Guid Id => new Guid("0410003E-6E7B-40E6-9328-BA5651ADF6B7"); diff --git a/Aaru.Images/Anex86/Read.cs b/Aaru.Images/Anex86/Read.cs index bfb1c5d5d..b1a5bce41 100644 --- a/Aaru.Images/Anex86/Read.cs +++ b/Aaru.Images/Anex86/Read.cs @@ -53,29 +53,29 @@ namespace Aaru.DiscImages byte[] hdrB = new byte[Marshal.SizeOf()]; stream.Read(hdrB, 0, hdrB.Length); - fdihdr = Marshal.SpanToStructureLittleEndian(hdrB); + _fdihdr = Marshal.SpanToStructureLittleEndian(hdrB); - imageInfo.MediaType = Geometry.GetMediaType(((ushort)fdihdr.cylinders, (byte)fdihdr.heads, - (ushort)fdihdr.spt, (uint)fdihdr.bps, MediaEncoding.MFM, - false)); + _imageInfo.MediaType = Geometry.GetMediaType(((ushort)_fdihdr.cylinders, (byte)_fdihdr.heads, + (ushort)_fdihdr.spt, (uint)_fdihdr.bps, MediaEncoding.MFM, + false)); - if(imageInfo.MediaType == MediaType.Unknown) - imageInfo.MediaType = MediaType.GENERIC_HDD; + if(_imageInfo.MediaType == MediaType.Unknown) + _imageInfo.MediaType = MediaType.GENERIC_HDD; - AaruConsole.DebugWriteLine("Anex86 plugin", "MediaType: {0}", imageInfo.MediaType); + AaruConsole.DebugWriteLine("Anex86 plugin", "MediaType: {0}", _imageInfo.MediaType); - imageInfo.ImageSize = (ulong)fdihdr.dskSize; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = (ulong)(fdihdr.cylinders * fdihdr.heads * fdihdr.spt); - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.SectorSize = (uint)fdihdr.bps; - imageInfo.Cylinders = (uint)fdihdr.cylinders; - imageInfo.Heads = (uint)fdihdr.heads; - imageInfo.SectorsPerTrack = (uint)fdihdr.spt; + _imageInfo.ImageSize = (ulong)_fdihdr.dskSize; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = (ulong)(_fdihdr.cylinders * _fdihdr.heads * _fdihdr.spt); + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.SectorSize = (uint)_fdihdr.bps; + _imageInfo.Cylinders = (uint)_fdihdr.cylinders; + _imageInfo.Heads = (uint)_fdihdr.heads; + _imageInfo.SectorsPerTrack = (uint)_fdihdr.spt; - anexImageFilter = imageFilter; + _anexImageFilter = imageFilter; return true; } @@ -84,19 +84,19 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Stream stream = anexImageFilter.GetDataForkStream(); + Stream stream = _anexImageFilter.GetDataForkStream(); - stream.Seek((long)((ulong)fdihdr.hdrSize + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)((ulong)_fdihdr.hdrSize + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); - stream.Read(buffer, 0, (int)(length * imageInfo.SectorSize)); + stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); return buffer; } diff --git a/Aaru.Images/Anex86/Write.cs b/Aaru.Images/Anex86/Write.cs index e2b78cfb3..ca1185eb9 100644 --- a/Aaru.Images/Anex86/Write.cs +++ b/Aaru.Images/Anex86/Write.cs @@ -69,7 +69,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -78,7 +78,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -87,7 +87,7 @@ namespace Aaru.DiscImages return false; } - fdihdr = new Anex86Header + _fdihdr = new Anex86Header { hdrSize = 4096, dskSize = (int)(sectors * sectorSize), @@ -116,22 +116,22 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(4096 + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(4096 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -147,22 +147,22 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(4096 + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(4096 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -192,44 +192,44 @@ namespace Aaru.DiscImages return false; } - if((imageInfo.MediaType == MediaType.Unknown || imageInfo.MediaType == MediaType.GENERIC_HDD || - imageInfo.MediaType == MediaType.FlashDrive || imageInfo.MediaType == MediaType.CompactFlash || - imageInfo.MediaType == MediaType.CompactFlashType2 || imageInfo.MediaType == MediaType.PCCardTypeI || - imageInfo.MediaType == MediaType.PCCardTypeII || imageInfo.MediaType == MediaType.PCCardTypeIII || - imageInfo.MediaType == MediaType.PCCardTypeIV) && - fdihdr.cylinders == 0) + if((_imageInfo.MediaType == MediaType.Unknown || _imageInfo.MediaType == MediaType.GENERIC_HDD || + _imageInfo.MediaType == MediaType.FlashDrive || _imageInfo.MediaType == MediaType.CompactFlash || + _imageInfo.MediaType == MediaType.CompactFlashType2 || _imageInfo.MediaType == MediaType.PCCardTypeI || + _imageInfo.MediaType == MediaType.PCCardTypeII || _imageInfo.MediaType == MediaType.PCCardTypeIII || + _imageInfo.MediaType == MediaType.PCCardTypeIV) && + _fdihdr.cylinders == 0) { - fdihdr.cylinders = (int)(imageInfo.Sectors / 8 / 33); - fdihdr.heads = 8; - fdihdr.spt = 33; + _fdihdr.cylinders = (int)(_imageInfo.Sectors / 8 / 33); + _fdihdr.heads = 8; + _fdihdr.spt = 33; - while(fdihdr.cylinders == 0) + while(_fdihdr.cylinders == 0) { - fdihdr.heads--; + _fdihdr.heads--; - if(fdihdr.heads == 0) + if(_fdihdr.heads == 0) { - fdihdr.spt--; - fdihdr.heads = 8; + _fdihdr.spt--; + _fdihdr.heads = 8; } - fdihdr.cylinders = (int)imageInfo.Sectors / fdihdr.heads / fdihdr.spt; + _fdihdr.cylinders = (int)_imageInfo.Sectors / _fdihdr.heads / _fdihdr.spt; - if(fdihdr.cylinders == 0 && - fdihdr.heads == 0 && - fdihdr.spt == 0) + if(_fdihdr.cylinders == 0 && + _fdihdr.heads == 0 && + _fdihdr.spt == 0) break; } } byte[] hdr = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(hdr, ref fdihdr); + MemoryMarshal.Write(hdr, ref _fdihdr); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(hdr, 0, hdr.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -262,9 +262,9 @@ namespace Aaru.DiscImages return false; } - fdihdr.spt = (int)sectorsPerTrack; - fdihdr.heads = (int)heads; - fdihdr.cylinders = (int)cylinders; + _fdihdr.spt = (int)sectorsPerTrack; + _fdihdr.heads = (int)heads; + _fdihdr.cylinders = (int)cylinders; return true; } diff --git a/Aaru.Images/Apple2MG/Apple2MG.cs b/Aaru.Images/Apple2MG/Apple2MG.cs index 079f82ce0..9fef64818 100644 --- a/Aaru.Images/Apple2MG/Apple2MG.cs +++ b/Aaru.Images/Apple2MG/Apple2MG.cs @@ -40,13 +40,13 @@ namespace Aaru.DiscImages { public partial class Apple2Mg : IWritableImage { - IFilter a2MgImageFilter; - byte[] decodedImage; - A2ImgHeader imageHeader; - ImageInfo imageInfo; - FileStream writingStream; + IFilter _a2MgImageFilter; + byte[] _decodedImage; + A2ImgHeader _imageHeader; + ImageInfo _imageInfo; + FileStream _writingStream; - public Apple2Mg() => imageInfo = new ImageInfo + public Apple2Mg() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/Apple2MG/Constants.cs b/Aaru.Images/Apple2MG/Constants.cs index 919e93dd1..58e78d49f 100644 --- a/Aaru.Images/Apple2MG/Constants.cs +++ b/Aaru.Images/Apple2MG/Constants.cs @@ -61,11 +61,11 @@ namespace Aaru.DiscImages const uint LOCKED_DISK = 0x80000000; const uint VALID_VOLUME_NUMBER = 0x00000100; const uint VOLUME_NUMBER_MASK = 0x000000FF; - readonly int[] deinterleave = + readonly int[] _deinterleave = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; - readonly int[] interleave = + readonly int[] _interleave = { 0, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15 }; diff --git a/Aaru.Images/Apple2MG/Helpers.cs b/Aaru.Images/Apple2MG/Helpers.cs index f2223105f..3062fffee 100644 --- a/Aaru.Images/Apple2MG/Helpers.cs +++ b/Aaru.Images/Apple2MG/Helpers.cs @@ -38,7 +38,7 @@ namespace Aaru.DiscImages { MediaType GetMediaType() { - switch(imageInfo.Sectors) + switch(_imageInfo.Sectors) { case 455: return MediaType.Apple32SS; case 910: return MediaType.Apple32DS; diff --git a/Aaru.Images/Apple2MG/Properties.cs b/Aaru.Images/Apple2MG/Properties.cs index 33b49b84d..e312d2ded 100644 --- a/Aaru.Images/Apple2MG/Properties.cs +++ b/Aaru.Images/Apple2MG/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class Apple2Mg { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Apple 2IMG"; public Guid Id => new Guid("CBAF8824-BA5F-415F-953A-19A03519B2D1"); diff --git a/Aaru.Images/Apple2MG/Read.cs b/Aaru.Images/Apple2MG/Read.cs index 5024bb33e..23a30fc62 100644 --- a/Aaru.Images/Apple2MG/Read.cs +++ b/Aaru.Images/Apple2MG/Read.cs @@ -49,7 +49,7 @@ namespace Aaru.DiscImages Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - imageHeader = new A2ImgHeader(); + _imageHeader = new A2ImgHeader(); byte[] header = new byte[64]; stream.Read(header, 0, 64); @@ -59,11 +59,11 @@ namespace Aaru.DiscImages Array.Copy(header, 0, magic, 0, 4); Array.Copy(header, 4, creator, 0, 4); - imageHeader = Marshal.SpanToStructureLittleEndian(header); + _imageHeader = Marshal.SpanToStructureLittleEndian(header); - if(imageHeader.DataSize == 0x00800C00) + if(_imageHeader.DataSize == 0x00800C00) { - imageHeader.DataSize = 0x000C8000; + _imageHeader.DataSize = 0x000C8000; AaruConsole.DebugWriteLine("2MG plugin", "Detected incorrect endian on data size field, correcting."); } @@ -72,224 +72,227 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.creator = \"{0}\"", Encoding.ASCII.GetString(creator)); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.headerSize = {0}", imageHeader.HeaderSize); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.version = {0}", imageHeader.Version); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.imageFormat = {0}", imageHeader.ImageFormat); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.flags = 0x{0:X8}", imageHeader.Flags); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.blocks = {0}", imageHeader.Blocks); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.dataOffset = 0x{0:X8}", imageHeader.DataOffset); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.dataSize = {0}", imageHeader.DataSize); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.commentOffset = 0x{0:X8}", imageHeader.CommentOffset); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.commentSize = {0}", imageHeader.CommentSize); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.headerSize = {0}", _imageHeader.HeaderSize); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.version = {0}", _imageHeader.Version); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.imageFormat = {0}", _imageHeader.ImageFormat); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.flags = 0x{0:X8}", _imageHeader.Flags); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.blocks = {0}", _imageHeader.Blocks); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.dataOffset = 0x{0:X8}", _imageHeader.DataOffset); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.dataSize = {0}", _imageHeader.DataSize); + + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.commentOffset = 0x{0:X8}", + _imageHeader.CommentOffset); + + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.commentSize = {0}", _imageHeader.CommentSize); AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.creatorSpecificOffset = 0x{0:X8}", - imageHeader.CreatorSpecificOffset); + _imageHeader.CreatorSpecificOffset); AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.creatorSpecificSize = {0}", - imageHeader.CreatorSpecificSize); + _imageHeader.CreatorSpecificSize); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.reserved1 = 0x{0:X8}", imageHeader.Reserved1); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.reserved2 = 0x{0:X8}", imageHeader.Reserved2); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.reserved3 = 0x{0:X8}", imageHeader.Reserved3); - AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.reserved4 = 0x{0:X8}", imageHeader.Reserved4); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.reserved1 = 0x{0:X8}", _imageHeader.Reserved1); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.reserved2 = 0x{0:X8}", _imageHeader.Reserved2); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.reserved3 = 0x{0:X8}", _imageHeader.Reserved3); + AaruConsole.DebugWriteLine("2MG plugin", "ImageHeader.reserved4 = 0x{0:X8}", _imageHeader.Reserved4); - if(imageHeader.DataSize == 0 && - imageHeader.Blocks == 0 && - imageHeader.ImageFormat != SectorOrder.ProDos) + if(_imageHeader.DataSize == 0 && + _imageHeader.Blocks == 0 && + _imageHeader.ImageFormat != SectorOrder.ProDos) return false; byte[] tmp; int[] offsets; - switch(imageHeader.ImageFormat) + switch(_imageHeader.ImageFormat) { case SectorOrder.Nibbles: - tmp = new byte[imageHeader.DataSize]; - stream.Seek(imageHeader.DataOffset, SeekOrigin.Begin); + tmp = new byte[_imageHeader.DataSize]; + stream.Seek(_imageHeader.DataOffset, SeekOrigin.Begin); stream.Read(tmp, 0, tmp.Length); var nibPlugin = new AppleNib(); var noFilter = new ZZZNoFilter(); noFilter.Open(tmp); nibPlugin.Open(noFilter); - decodedImage = nibPlugin.ReadSectors(0, (uint)nibPlugin.Info.Sectors); - imageInfo.Sectors = nibPlugin.Info.Sectors; - imageInfo.SectorSize = nibPlugin.Info.SectorSize; + _decodedImage = nibPlugin.ReadSectors(0, (uint)nibPlugin.Info.Sectors); + _imageInfo.Sectors = nibPlugin.Info.Sectors; + _imageInfo.SectorSize = nibPlugin.Info.SectorSize; break; - case SectorOrder.Dos when imageHeader.DataSize == 143360: - case SectorOrder.ProDos when imageHeader.DataSize == 143360: - stream.Seek(imageHeader.DataOffset, SeekOrigin.Begin); - tmp = new byte[imageHeader.DataSize]; + case SectorOrder.Dos when _imageHeader.DataSize == 143360: + case SectorOrder.ProDos when _imageHeader.DataSize == 143360: + stream.Seek(_imageHeader.DataOffset, SeekOrigin.Begin); + tmp = new byte[_imageHeader.DataSize]; stream.Read(tmp, 0, tmp.Length); bool isDos = tmp[0x11001] == 17 && tmp[0x11002] < 16 && tmp[0x11027] <= 122 && tmp[0x11034] == 35 && tmp[0x11035] == 16 && tmp[0x11036] == 0 && tmp[0x11037] == 1; - decodedImage = new byte[imageHeader.DataSize]; + _decodedImage = new byte[_imageHeader.DataSize]; - offsets = imageHeader.ImageFormat == SectorOrder.Dos + offsets = _imageHeader.ImageFormat == SectorOrder.Dos ? isDos - ? deinterleave - : interleave + ? _deinterleave + : _interleave : isDos - ? interleave - : deinterleave; + ? _interleave + : _deinterleave; for(int t = 0; t < 35; t++) { for(int s = 0; s < 16; s++) - Array.Copy(tmp, (t * 16 * 256) + (s * 256), decodedImage, + Array.Copy(tmp, (t * 16 * 256) + (s * 256), _decodedImage, (t * 16 * 256) + (offsets[s] * 256), 256); } - imageInfo.Sectors = 560; - imageInfo.SectorSize = 256; + _imageInfo.Sectors = 560; + _imageInfo.SectorSize = 256; break; - case SectorOrder.Dos when imageHeader.DataSize == 819200: - stream.Seek(imageHeader.DataOffset, SeekOrigin.Begin); - tmp = new byte[imageHeader.DataSize]; + case SectorOrder.Dos when _imageHeader.DataSize == 819200: + stream.Seek(_imageHeader.DataOffset, SeekOrigin.Begin); + tmp = new byte[_imageHeader.DataSize]; stream.Read(tmp, 0, tmp.Length); - decodedImage = new byte[imageHeader.DataSize]; - offsets = interleave; + _decodedImage = new byte[_imageHeader.DataSize]; + offsets = _interleave; for(int t = 0; t < 200; t++) { for(int s = 0; s < 16; s++) - Array.Copy(tmp, (t * 16 * 256) + (s * 256), decodedImage, + Array.Copy(tmp, (t * 16 * 256) + (s * 256), _decodedImage, (t * 16 * 256) + (offsets[s] * 256), 256); } - imageInfo.Sectors = 1600; - imageInfo.SectorSize = 512; + _imageInfo.Sectors = 1600; + _imageInfo.SectorSize = 512; break; default: - decodedImage = null; - imageInfo.SectorSize = 512; - imageInfo.Sectors = imageHeader.DataSize / 512; + _decodedImage = null; + _imageInfo.SectorSize = 512; + _imageInfo.Sectors = _imageHeader.DataSize / 512; break; } - imageInfo.ImageSize = imageHeader.DataSize; + _imageInfo.ImageSize = _imageHeader.DataSize; - switch(imageHeader.Creator) + switch(_imageHeader.Creator) { case CREATOR_ASIMOV: - imageInfo.Application = "ASIMOV2"; + _imageInfo.Application = "ASIMOV2"; break; case CREATOR_BERNIE: - imageInfo.Application = "Bernie ][ the Rescue"; + _imageInfo.Application = "Bernie ][ the Rescue"; break; case CREATOR_CATAKIG: - imageInfo.Application = "Catakig"; + _imageInfo.Application = "Catakig"; break; case CREATOR_SHEPPY: - imageInfo.Application = "Sheppy's ImageMaker"; + _imageInfo.Application = "Sheppy's ImageMaker"; break; case CREATOR_SWEET: - imageInfo.Application = "Sweet16"; + _imageInfo.Application = "Sweet16"; break; case CREATOR_XGS: - imageInfo.Application = "XGS"; + _imageInfo.Application = "XGS"; break; case CREATOR_CIDER: - imageInfo.Application = "CiderPress"; + _imageInfo.Application = "CiderPress"; break; case CREATOR_DIC: - imageInfo.Application = "DiscImageChef"; + _imageInfo.Application = "DiscImageChef"; break; case CREATOR_AARU: - imageInfo.Application = "Aaru"; + _imageInfo.Application = "Aaru"; break; default: - imageInfo.Application = $"Unknown creator code \"{Encoding.ASCII.GetString(creator)}\""; + _imageInfo.Application = $"Unknown creator code \"{Encoding.ASCII.GetString(creator)}\""; break; } - imageInfo.Version = imageHeader.Version.ToString(); + _imageInfo.Version = _imageHeader.Version.ToString(); - if(imageHeader.CommentOffset != 0 && - imageHeader.CommentSize != 0) + if(_imageHeader.CommentOffset != 0 && + _imageHeader.CommentSize != 0) { - stream.Seek(imageHeader.CommentOffset, SeekOrigin.Begin); + stream.Seek(_imageHeader.CommentOffset, SeekOrigin.Begin); - byte[] comments = new byte[imageHeader.CommentSize]; - stream.Read(comments, 0, (int)imageHeader.CommentSize); - imageInfo.Comments = Encoding.ASCII.GetString(comments); + byte[] comments = new byte[_imageHeader.CommentSize]; + stream.Read(comments, 0, (int)_imageHeader.CommentSize); + _imageInfo.Comments = Encoding.ASCII.GetString(comments); } - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.MediaType = GetMediaType(); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.MediaType = GetMediaType(); - a2MgImageFilter = imageFilter; + _a2MgImageFilter = imageFilter; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - AaruConsole.VerboseWriteLine("2MG image contains a disk of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("2MG image contains a disk of type {0}", _imageInfo.MediaType); - if(!string.IsNullOrEmpty(imageInfo.Comments)) - AaruConsole.VerboseWriteLine("2MG comments: {0}", imageInfo.Comments); + if(!string.IsNullOrEmpty(_imageInfo.Comments)) + AaruConsole.VerboseWriteLine("2MG comments: {0}", _imageInfo.Comments); - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.Apple32SS: - imageInfo.Cylinders = 35; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 13; + _imageInfo.Cylinders = 35; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 13; break; case MediaType.Apple32DS: - imageInfo.Cylinders = 35; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 13; + _imageInfo.Cylinders = 35; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 13; break; case MediaType.Apple33SS: - imageInfo.Cylinders = 35; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 35; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 16; break; case MediaType.Apple33DS: - imageInfo.Cylinders = 35; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 35; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 16; break; case MediaType.AppleSonySS: - imageInfo.Cylinders = 80; - imageInfo.Heads = 1; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 1; // Variable sectors per track, this suffices - imageInfo.SectorsPerTrack = 10; + _imageInfo.SectorsPerTrack = 10; break; case MediaType.AppleSonyDS: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; // Variable sectors per track, this suffices - imageInfo.SectorsPerTrack = 10; + _imageInfo.SectorsPerTrack = 10; break; case MediaType.DOS_35_HD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 18; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 18; break; } @@ -301,22 +304,25 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - if(decodedImage != null) - Array.Copy(decodedImage, (long)(sectorAddress * imageInfo.SectorSize), buffer, 0, - length * imageInfo.SectorSize); + if(_decodedImage != null) + Array.Copy(_decodedImage, (long)(sectorAddress * _imageInfo.SectorSize), buffer, 0, + length * _imageInfo.SectorSize); else { - Stream stream = a2MgImageFilter.GetDataForkStream(); - stream.Seek((long)(imageHeader.DataOffset + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); - stream.Read(buffer, 0, (int)(length * imageInfo.SectorSize)); + Stream stream = _a2MgImageFilter.GetDataForkStream(); + + stream.Seek((long)(_imageHeader.DataOffset + (sectorAddress * _imageInfo.SectorSize)), + SeekOrigin.Begin); + + stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); } return buffer; diff --git a/Aaru.Images/Apple2MG/Write.cs b/Aaru.Images/Apple2MG/Write.cs index 88ca96941..d2edede19 100644 --- a/Aaru.Images/Apple2MG/Write.cs +++ b/Aaru.Images/Apple2MG/Write.cs @@ -71,7 +71,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -80,7 +80,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -111,22 +111,22 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(0x40 + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(0x40 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -142,22 +142,22 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(0x40 + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(0x40 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -187,48 +187,48 @@ namespace Aaru.DiscImages return false; } - writingStream.Seek(0x40 + (17 * 16 * 256), SeekOrigin.Begin); + _writingStream.Seek(0x40 + (17 * 16 * 256), SeekOrigin.Begin); byte[] tmp = new byte[256]; - writingStream.Read(tmp, 0, tmp.Length); + _writingStream.Read(tmp, 0, tmp.Length); bool isDos = tmp[0x01] == 17 && tmp[0x02] < 16 && tmp[0x27] <= 122 && tmp[0x34] == 35 && tmp[0x35] == 16 && tmp[0x36] == 0 && tmp[0x37] == 1; - imageHeader = new A2ImgHeader + _imageHeader = new A2ImgHeader { - Blocks = (uint)(imageInfo.Sectors * imageInfo.SectorSize) / 512, + Blocks = (uint)(_imageInfo.Sectors * _imageInfo.SectorSize) / 512, Creator = CREATOR_AARU, DataOffset = 0x40, - DataSize = (uint)(imageInfo.Sectors * imageInfo.SectorSize), - Flags = (uint)(imageInfo.LastMediaSequence != 0 ? VALID_VOLUME_NUMBER + (imageInfo.MediaSequence & 0xFF) - : 0), + DataSize = (uint)(_imageInfo.Sectors * _imageInfo.SectorSize), + Flags = (uint)(_imageInfo.LastMediaSequence != 0 + ? VALID_VOLUME_NUMBER + (_imageInfo.MediaSequence & 0xFF) : 0), HeaderSize = 0x40, ImageFormat = isDos ? SectorOrder.Dos : SectorOrder.ProDos, Magic = MAGIC, Version = 1 }; - if(!string.IsNullOrEmpty(imageInfo.Comments)) + if(!string.IsNullOrEmpty(_imageInfo.Comments)) { - writingStream.Seek(0, SeekOrigin.End); - tmp = Encoding.UTF8.GetBytes(imageInfo.Comments); - imageHeader.CommentOffset = (uint)writingStream.Position; - imageHeader.CommentSize = (uint)(tmp.Length + 1); - writingStream.Write(tmp, 0, tmp.Length); - writingStream.WriteByte(0); + _writingStream.Seek(0, SeekOrigin.End); + tmp = Encoding.UTF8.GetBytes(_imageInfo.Comments); + _imageHeader.CommentOffset = (uint)_writingStream.Position; + _imageHeader.CommentSize = (uint)(tmp.Length + 1); + _writingStream.Write(tmp, 0, tmp.Length); + _writingStream.WriteByte(0); } byte[] hdr = new byte[Marshal.SizeOf()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); - System.Runtime.InteropServices.Marshal.StructureToPtr(imageHeader, hdrPtr, true); + System.Runtime.InteropServices.Marshal.StructureToPtr(_imageHeader, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(hdr, 0, hdr.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -238,9 +238,9 @@ namespace Aaru.DiscImages public bool SetMetadata(ImageInfo metadata) { - imageInfo.Comments = metadata.Comments; - imageInfo.LastMediaSequence = metadata.LastMediaSequence; - imageInfo.MediaSequence = metadata.MediaSequence; + _imageInfo.Comments = metadata.Comments; + _imageInfo.LastMediaSequence = metadata.LastMediaSequence; + _imageInfo.MediaSequence = metadata.MediaSequence; return true; } diff --git a/Aaru.Images/AppleDOS/AppleDOS.cs b/Aaru.Images/AppleDOS/AppleDOS.cs index 3b3218906..63886529c 100644 --- a/Aaru.Images/AppleDOS/AppleDOS.cs +++ b/Aaru.Images/AppleDOS/AppleDOS.cs @@ -40,12 +40,12 @@ namespace Aaru.DiscImages { public partial class AppleDos : IWritableImage { - byte[] deinterleaved; - string extension; - ImageInfo imageInfo; - FileStream writingStream; + byte[] _deinterleaved; + string _extension; + ImageInfo _imageInfo; + FileStream _writingStream; - public AppleDos() => imageInfo = new ImageInfo + public AppleDos() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/AppleDOS/Constants.cs b/Aaru.Images/AppleDOS/Constants.cs index eddf04cdb..f83063c1a 100644 --- a/Aaru.Images/AppleDOS/Constants.cs +++ b/Aaru.Images/AppleDOS/Constants.cs @@ -34,11 +34,11 @@ namespace Aaru.DiscImages { public partial class AppleDos { - readonly int[] deinterleave = + readonly int[] _deinterleave = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; - readonly int[] interleave = + readonly int[] _interleave = { 0, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15 }; diff --git a/Aaru.Images/AppleDOS/Identify.cs b/Aaru.Images/AppleDOS/Identify.cs index 1cb729a42..972fb994c 100644 --- a/Aaru.Images/AppleDOS/Identify.cs +++ b/Aaru.Images/AppleDOS/Identify.cs @@ -39,9 +39,9 @@ namespace Aaru.DiscImages { public bool Identify(IFilter imageFilter) { - extension = Path.GetExtension(imageFilter.GetFilename())?.ToLower(); + _extension = Path.GetExtension(imageFilter.GetFilename())?.ToLower(); - return imageFilter.GetDataForkLength() == 143360 && (extension == ".po" || extension == ".do"); + return imageFilter.GetDataForkLength() == 143360 && (_extension == ".po" || _extension == ".do"); } } } \ No newline at end of file diff --git a/Aaru.Images/AppleDOS/Properties.cs b/Aaru.Images/AppleDOS/Properties.cs index 48a40069d..5dbd76c86 100644 --- a/Aaru.Images/AppleDOS/Properties.cs +++ b/Aaru.Images/AppleDOS/Properties.cs @@ -41,12 +41,12 @@ namespace Aaru.DiscImages { public partial class AppleDos { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Apple ][ Interleaved Disk Image"; public Guid Id => new Guid("A5828AC0-62C9-4304-81D4-EFD4AAE47360"); public string Author => "Natalia Portillo"; - public string Format => extension == ".po" ? "Apple ][ Interleaved Disk Image (ProDOS order)" + public string Format => _extension == ".po" ? "Apple ][ Interleaved Disk Image (ProDOS order)" : "Apple ][ Interleaved Disk Image (DOS order)"; public List DumpHardware => null; diff --git a/Aaru.Images/AppleDOS/Read.cs b/Aaru.Images/AppleDOS/Read.cs index 351de6c08..606b6daea 100644 --- a/Aaru.Images/AppleDOS/Read.cs +++ b/Aaru.Images/AppleDOS/Read.cs @@ -51,36 +51,36 @@ namespace Aaru.DiscImages bool isDos = tmp[0x11001] == 17 && tmp[0x11002] < 16 && tmp[0x11027] <= 122 && tmp[0x11034] == 35 && tmp[0x11035] == 16 && tmp[0x11036] == 0 && tmp[0x11037] == 1; - deinterleaved = new byte[tmp.Length]; + _deinterleaved = new byte[tmp.Length]; - extension = Path.GetExtension(imageFilter.GetFilename())?.ToLower(); + _extension = Path.GetExtension(imageFilter.GetFilename())?.ToLower(); - int[] offsets = extension == ".do" + int[] offsets = _extension == ".do" ? isDos - ? deinterleave - : interleave + ? _deinterleave + : _interleave : isDos - ? interleave - : deinterleave; + ? _interleave + : _deinterleave; for(int t = 0; t < 35; t++) { for(int s = 0; s < 16; s++) - Array.Copy(tmp, (t * 16 * 256) + (s * 256), deinterleaved, (t * 16 * 256) + (offsets[s] * 256), + Array.Copy(tmp, (t * 16 * 256) + (s * 256), _deinterleaved, (t * 16 * 256) + (offsets[s] * 256), 256); } - imageInfo.SectorSize = 256; - imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = 560; - imageInfo.MediaType = MediaType.Apple33SS; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.Cylinders = 35; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 16; + _imageInfo.SectorSize = 256; + _imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = 560; + _imageInfo.MediaType = MediaType.Apple33SS; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.Cylinders = 35; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 16; return true; } @@ -89,15 +89,15 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Array.Copy(deinterleaved, (int)(sectorAddress * imageInfo.SectorSize), buffer, 0, buffer.Length); + Array.Copy(_deinterleaved, (int)(sectorAddress * _imageInfo.SectorSize), buffer, 0, buffer.Length); return buffer; } diff --git a/Aaru.Images/AppleDOS/Write.cs b/Aaru.Images/AppleDOS/Write.cs index 9b8e399f2..5d787cae5 100644 --- a/Aaru.Images/AppleDOS/Write.cs +++ b/Aaru.Images/AppleDOS/Write.cs @@ -66,7 +66,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -75,7 +75,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -84,8 +84,8 @@ namespace Aaru.DiscImages return false; } - deinterleaved = new byte[35 * 16 * 256]; - extension = Path.GetExtension(path); + _deinterleaved = new byte[35 * 16 * 256]; + _extension = Path.GetExtension(path); IsWriting = true; ErrorMessage = null; @@ -111,21 +111,21 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - Array.Copy(data, 0, deinterleaved, (int)(sectorAddress * imageInfo.SectorSize), data.Length); + Array.Copy(data, 0, _deinterleaved, (int)(sectorAddress * _imageInfo.SectorSize), data.Length); ErrorMessage = ""; @@ -155,32 +155,32 @@ namespace Aaru.DiscImages return false; } - bool isDos = deinterleaved[0x11001] == 17 && deinterleaved[0x11002] < 16 && deinterleaved[0x11027] <= 122 && - deinterleaved[0x11034] == 35 && deinterleaved[0x11035] == 16 && deinterleaved[0x11036] == 0 && - deinterleaved[0x11037] == 1; + bool isDos = _deinterleaved[0x11001] == 17 && _deinterleaved[0x11002] < 16 && + _deinterleaved[0x11027] <= 122 && _deinterleaved[0x11034] == 35 && + _deinterleaved[0x11035] == 16 && _deinterleaved[0x11036] == 0 && _deinterleaved[0x11037] == 1; - byte[] tmp = new byte[deinterleaved.Length]; + byte[] tmp = new byte[_deinterleaved.Length]; - int[] offsets = extension == ".do" + int[] offsets = _extension == ".do" ? isDos - ? deinterleave - : interleave + ? _deinterleave + : _interleave : isDos - ? interleave - : deinterleave; + ? _interleave + : _deinterleave; for(int t = 0; t < 35; t++) { for(int s = 0; s < 16; s++) - Array.Copy(deinterleaved, (t * 16 * 256) + (offsets[s] * 256), tmp, (t * 16 * 256) + (s * 256), + Array.Copy(_deinterleaved, (t * 16 * 256) + (offsets[s] * 256), tmp, (t * 16 * 256) + (s * 256), 256); } - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(tmp, 0, tmp.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(tmp, 0, tmp.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; diff --git a/Aaru.Images/AppleNIB/AppleNIB.cs b/Aaru.Images/AppleNIB/AppleNIB.cs index 45b821b12..1baed3630 100644 --- a/Aaru.Images/AppleNIB/AppleNIB.cs +++ b/Aaru.Images/AppleNIB/AppleNIB.cs @@ -40,12 +40,12 @@ namespace Aaru.DiscImages // TODO: Checksum sectors public partial class AppleNib : IMediaImage { - Dictionary addressFields; - Dictionary cookedSectors; - ImageInfo imageInfo; - Dictionary longSectors; + Dictionary _addressFields; + Dictionary _cookedSectors; + ImageInfo _imageInfo; + Dictionary _longSectors; - public AppleNib() => imageInfo = new ImageInfo + public AppleNib() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/AppleNIB/Constants.cs b/Aaru.Images/AppleNIB/Constants.cs index bbe18d7e5..adaca46c4 100644 --- a/Aaru.Images/AppleNIB/Constants.cs +++ b/Aaru.Images/AppleNIB/Constants.cs @@ -37,48 +37,48 @@ namespace Aaru.DiscImages [SuppressMessage("ReSharper", "UnusedMember.Local")] public partial class AppleNib { - readonly byte[] apple3_sign = + readonly byte[] _apple3Sign = { 0x8D, 0xD0, 0x03, 0x4C, 0xC7, 0xA4 }; - readonly byte[] cpm_sign = + readonly byte[] _cpmSign = { 0xA2, 0x55, 0xA9, 0x00, 0x9D, 0x00, 0x0D, 0xCA }; - readonly byte[] dos_sign = + readonly byte[] _dosSign = { 0xA2, 0x02, 0x8E, 0x52 }; - readonly ulong[] dosSkewing = + readonly ulong[] _dosSkewing = { 0, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 15 }; - readonly byte[] dri_string = + readonly byte[] _driString = { 0x43, 0x4F, 0x50, 0x59, 0x52, 0x49, 0x47, 0x48, 0x54, 0x20, 0x28, 0x43, 0x29, 0x20, 0x31, 0x39, 0x37, 0x39, 0x2C, 0x20, 0x44, 0x49, 0x47, 0x49, 0x54, 0x41, 0x4C, 0x20, 0x52, 0x45, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48 }; - readonly byte[] pascal_sign = + readonly byte[] _pascalSign = { 0x08, 0xA5, 0x0F, 0x29 }; - readonly byte[] pascal_string = + readonly byte[] _pascalString = { 0x53, 0x59, 0x53, 0x54, 0x45, 0x2E, 0x41, 0x50, 0x50, 0x4C, 0x45 }; - readonly byte[] pascal2_sign = + readonly byte[] _pascal2Sign = { 0xFF, 0xA2, 0x00, 0x8E }; - readonly byte[] prodos_string = + readonly byte[] _prodosString = { 0x50, 0x52, 0x4F, 0x44, 0x4F, 0x53 }; - readonly ulong[] proDosSkewing = + readonly ulong[] _proDosSkewing = { 0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15 }; - readonly byte[] sos_sign = + readonly byte[] _sosSign = { 0xC9, 0x20, 0xF0, 0x3E }; diff --git a/Aaru.Images/AppleNIB/Helpers.cs b/Aaru.Images/AppleNIB/Helpers.cs index 2e880e4e4..48a130c7a 100644 --- a/Aaru.Images/AppleNIB/Helpers.cs +++ b/Aaru.Images/AppleNIB/Helpers.cs @@ -38,7 +38,7 @@ namespace Aaru.DiscImages { MediaType GetMediaType() { - switch(imageInfo.Sectors) + switch(_imageInfo.Sectors) { case 455: return MediaType.Apple32SS; case 560: return MediaType.Apple33SS; diff --git a/Aaru.Images/AppleNIB/Properties.cs b/Aaru.Images/AppleNIB/Properties.cs index c3b82e217..32a296499 100644 --- a/Aaru.Images/AppleNIB/Properties.cs +++ b/Aaru.Images/AppleNIB/Properties.cs @@ -39,7 +39,7 @@ namespace Aaru.DiscImages { public partial class AppleNib { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Apple NIB"; public Guid Id => new Guid("AE171AE8-6747-49CC-B861-9D450B7CD42E"); diff --git a/Aaru.Images/AppleNIB/Read.cs b/Aaru.Images/AppleNIB/Read.cs index 6253b292b..7fb5e893f 100644 --- a/Aaru.Images/AppleNIB/Read.cs +++ b/Aaru.Images/AppleNIB/Read.cs @@ -72,7 +72,7 @@ namespace Aaru.DiscImages spt = tracks[0].sectors.Length; bool skewed = spt == 16; - ulong[] skewing = proDosSkewing; + ulong[] skewing = _proDosSkewing; // Detect ProDOS skewed disks if(skewed) @@ -93,10 +93,10 @@ namespace Aaru.DiscImages sector0[0x34] == 35 && sector0[0x35] == 16 && sector0[0x36] == 0 && sector0[0x37] == 1; if(isDos) - skewing = dosSkewing; + skewing = _dosSkewing; AaruConsole.DebugWriteLine("Apple NIB Plugin", "Using {0}DOS skewing", - skewing.SequenceEqual(dosSkewing) ? "" : "Pro"); + skewing.SequenceEqual(_dosSkewing) ? "" : "Pro"); } for(int i = 0; i < tracks.Count; i++) @@ -111,60 +111,60 @@ namespace Aaru.DiscImages sectorNo, i, skewing[sectorNo] + (ulong)(i * spt)); rawSectors.Add(skewing[sectorNo] + (ulong)(i * spt), sector); - imageInfo.Sectors++; + _imageInfo.Sectors++; } else { - rawSectors.Add(imageInfo.Sectors, sector); - imageInfo.Sectors++; + rawSectors.Add(_imageInfo.Sectors, sector); + _imageInfo.Sectors++; } - AaruConsole.DebugWriteLine("Apple NIB Plugin", "Got {0} sectors", imageInfo.Sectors); + AaruConsole.DebugWriteLine("Apple NIB Plugin", "Got {0} sectors", _imageInfo.Sectors); AaruConsole.DebugWriteLine("Apple NIB Plugin", "Cooking sectors"); - longSectors = new Dictionary(); - cookedSectors = new Dictionary(); - addressFields = new Dictionary(); + _longSectors = new Dictionary(); + _cookedSectors = new Dictionary(); + _addressFields = new Dictionary(); foreach(KeyValuePair kvp in rawSectors) { byte[] cooked = Apple2.DecodeSector(kvp.Value); byte[] raw = Apple2.MarshalSector(kvp.Value); byte[] addr = Apple2.MarshalAddressField(kvp.Value.addressField); - longSectors.Add(kvp.Key, raw); - cookedSectors.Add(kvp.Key, cooked); - addressFields.Add(kvp.Key, addr); + _longSectors.Add(kvp.Key, raw); + _cookedSectors.Add(kvp.Key, cooked); + _addressFields.Add(kvp.Key, addr); } - imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - if(imageInfo.Sectors == 455) - imageInfo.MediaType = MediaType.Apple32SS; - else if(imageInfo.Sectors == 560) - imageInfo.MediaType = MediaType.Apple33SS; + if(_imageInfo.Sectors == 455) + _imageInfo.MediaType = MediaType.Apple32SS; + else if(_imageInfo.Sectors == 560) + _imageInfo.MediaType = MediaType.Apple33SS; else - imageInfo.MediaType = MediaType.Unknown; + _imageInfo.MediaType = MediaType.Unknown; - imageInfo.SectorSize = 256; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.ReadableSectorTags.Add(SectorTagType.FloppyAddressMark); + _imageInfo.SectorSize = 256; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.ReadableSectorTags.Add(SectorTagType.FloppyAddressMark); - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.Apple32SS: - imageInfo.Cylinders = 35; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 13; + _imageInfo.Cylinders = 35; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 13; break; case MediaType.Apple33SS: - imageInfo.Cylinders = 35; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 35; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 16; break; } @@ -174,22 +174,22 @@ namespace Aaru.DiscImages public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - cookedSectors.TryGetValue(sectorAddress, out byte[] temp); + _cookedSectors.TryGetValue(sectorAddress, out byte[] temp); return temp; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); @@ -205,25 +205,25 @@ namespace Aaru.DiscImages public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); if(tag != SectorTagType.FloppyAddressMark) throw new FeatureUnsupportedImageException($"Tag {tag} not supported by image format"); - addressFields.TryGetValue(sectorAddress, out byte[] temp); + _addressFields.TryGetValue(sectorAddress, out byte[] temp); return temp; } public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); if(tag != SectorTagType.FloppyAddressMark) @@ -242,22 +242,22 @@ namespace Aaru.DiscImages public byte[] ReadSectorLong(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - longSectors.TryGetValue(sectorAddress, out byte[] temp); + _longSectors.TryGetValue(sectorAddress, out byte[] temp); return temp; } public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); diff --git a/Aaru.Images/Apridisk/Apridisk.cs b/Aaru.Images/Apridisk/Apridisk.cs index f9c96b655..53fc9ebee 100644 --- a/Aaru.Images/Apridisk/Apridisk.cs +++ b/Aaru.Images/Apridisk/Apridisk.cs @@ -41,13 +41,13 @@ namespace Aaru.DiscImages // TODO: Check writing public partial class Apridisk : IWritableImage { - ImageInfo imageInfo; + ImageInfo _imageInfo; // Cylinder by head, sector data matrix - byte[][][][] sectorsData; - FileStream writingStream; + byte[][][][] _sectorsData; + FileStream _writingStream; - public Apridisk() => imageInfo = new ImageInfo + public Apridisk() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/Apridisk/Constants.cs b/Aaru.Images/Apridisk/Constants.cs index 2ee87f556..518f8a3a3 100644 --- a/Aaru.Images/Apridisk/Constants.cs +++ b/Aaru.Images/Apridisk/Constants.cs @@ -34,7 +34,7 @@ namespace Aaru.DiscImages { public partial class Apridisk { - readonly byte[] signature = + readonly byte[] _signature = { 0x41, 0x43, 0x54, 0x20, 0x41, 0x70, 0x72, 0x69, 0x63, 0x6F, 0x74, 0x20, 0x64, 0x69, 0x73, 0x6B, 0x20, 0x69, 0x6D, 0x61, 0x67, 0x65, 0x1A, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/Aaru.Images/Apridisk/Helpers.cs b/Aaru.Images/Apridisk/Helpers.cs index 8d6c14b2d..dbb016e4c 100644 --- a/Aaru.Images/Apridisk/Helpers.cs +++ b/Aaru.Images/Apridisk/Helpers.cs @@ -36,9 +36,9 @@ namespace Aaru.DiscImages { (ushort cylinder, byte head, byte sector) LbaToChs(ulong lba) { - ushort cylinder = (ushort)(lba / (imageInfo.Heads * imageInfo.SectorsPerTrack)); - byte head = (byte)((lba / imageInfo.SectorsPerTrack) % imageInfo.Heads); - byte sector = (byte)((lba % imageInfo.SectorsPerTrack) + 1); + ushort cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack)); + byte head = (byte)((lba / _imageInfo.SectorsPerTrack) % _imageInfo.Heads); + byte sector = (byte)((lba % _imageInfo.SectorsPerTrack) + 1); return (cylinder, head, sector); } diff --git a/Aaru.Images/Apridisk/Identify.cs b/Aaru.Images/Apridisk/Identify.cs index 9b31e3d57..933463472 100644 --- a/Aaru.Images/Apridisk/Identify.cs +++ b/Aaru.Images/Apridisk/Identify.cs @@ -43,13 +43,13 @@ namespace Aaru.DiscImages Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - if(stream.Length < signature.Length) + if(stream.Length < _signature.Length) return false; - byte[] sigB = new byte[signature.Length]; - stream.Read(sigB, 0, signature.Length); + byte[] sigB = new byte[_signature.Length]; + stream.Read(sigB, 0, _signature.Length); - return sigB.SequenceEqual(signature); + return sigB.SequenceEqual(_signature); } } } \ No newline at end of file diff --git a/Aaru.Images/Apridisk/Properties.cs b/Aaru.Images/Apridisk/Properties.cs index 036758d0e..f5a06a81e 100644 --- a/Aaru.Images/Apridisk/Properties.cs +++ b/Aaru.Images/Apridisk/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class Apridisk { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "ACT Apricot Disk Image"; public Guid Id => new Guid("43408CF3-6DB3-449F-A779-2B0E497C5B14"); diff --git a/Aaru.Images/Apridisk/Read.cs b/Aaru.Images/Apridisk/Read.cs index 65e785aca..1e1fc95e0 100644 --- a/Aaru.Images/Apridisk/Read.cs +++ b/Aaru.Images/Apridisk/Read.cs @@ -49,7 +49,7 @@ namespace Aaru.DiscImages stream.Seek(0, SeekOrigin.Begin); // Skip signature - stream.Seek(signature.Length, SeekOrigin.Begin); + stream.Seek(_signature.Length, SeekOrigin.Begin); int totalCylinders = -1; int totalHeads = -1; @@ -77,8 +77,8 @@ namespace Aaru.DiscImages stream.Seek(record.headerSize - recordSize, SeekOrigin.Current); byte[] commentB = new byte[record.dataSize]; stream.Read(commentB, 0, commentB.Length); - imageInfo.Comments = StringHandlers.CToString(commentB); - AaruConsole.DebugWriteLine("Apridisk plugin", "Comment: \"{0}\"", imageInfo.Comments); + _imageInfo.Comments = StringHandlers.CToString(commentB); + AaruConsole.DebugWriteLine("Apridisk plugin", "Comment: \"{0}\"", _imageInfo.Comments); break; case RecordType.Creator: @@ -86,8 +86,8 @@ namespace Aaru.DiscImages stream.Seek(record.headerSize - recordSize, SeekOrigin.Current); byte[] creatorB = new byte[record.dataSize]; stream.Read(creatorB, 0, creatorB.Length); - imageInfo.Creator = StringHandlers.CToString(creatorB); - AaruConsole.DebugWriteLine("Apridisk plugin", "Creator: \"{0}\"", imageInfo.Creator); + _imageInfo.Creator = StringHandlers.CToString(creatorB); + AaruConsole.DebugWriteLine("Apridisk plugin", "Creator: \"{0}\"", _imageInfo.Creator); break; case RecordType.Sector: @@ -127,13 +127,13 @@ namespace Aaru.DiscImages totalHeads <= 0) throw new ImageNotSupportedException("No cylinders or heads found"); - sectorsData = new byte[totalCylinders][][][]; + _sectorsData = new byte[totalCylinders][][][]; // Total sectors per track uint[][] spts = new uint[totalCylinders][]; - imageInfo.Cylinders = (ushort)totalCylinders; - imageInfo.Heads = (byte)totalHeads; + _imageInfo.Cylinders = (ushort)totalCylinders; + _imageInfo.Heads = (byte)totalHeads; AaruConsole.DebugWriteLine("Apridisk plugin", "Found {0} cylinders and {1} heads with a maximum sector number of {2}", @@ -142,19 +142,19 @@ namespace Aaru.DiscImages // Create heads for(int i = 0; i < totalCylinders; i++) { - sectorsData[i] = new byte[totalHeads][][]; - spts[i] = new uint[totalHeads]; + _sectorsData[i] = new byte[totalHeads][][]; + spts[i] = new uint[totalHeads]; for(int j = 0; j < totalHeads; j++) - sectorsData[i][j] = new byte[maxSector + 1][]; + _sectorsData[i][j] = new byte[maxSector + 1][]; } - imageInfo.SectorSize = uint.MaxValue; + _imageInfo.SectorSize = uint.MaxValue; ulong headersizes = 0; // Read sectors - stream.Seek(signature.Length, SeekOrigin.Begin); + stream.Seek(_signature.Length, SeekOrigin.Begin); while(stream.Position < stream.Length) { @@ -183,12 +183,13 @@ namespace Aaru.DiscImages uint realLength = record.dataSize; if(record.compression == CompressType.Compressed) - realLength = Decompress(data, out sectorsData[record.cylinder][record.head][record.sector]); + realLength = + Decompress(data, out _sectorsData[record.cylinder][record.head][record.sector]); else - sectorsData[record.cylinder][record.head][record.sector] = data; + _sectorsData[record.cylinder][record.head][record.sector] = data; - if(realLength < imageInfo.SectorSize) - imageInfo.SectorSize = realLength; + if(realLength < _imageInfo.SectorSize) + _imageInfo.SectorSize = realLength; headersizes += record.headerSize + record.dataSize; @@ -197,33 +198,33 @@ namespace Aaru.DiscImages } AaruConsole.DebugWriteLine("Apridisk plugin", "Found a minimum of {0} bytes per sector", - imageInfo.SectorSize); + _imageInfo.SectorSize); // Count sectors per track uint spt = uint.MaxValue; - for(ushort cyl = 0; cyl < imageInfo.Cylinders; cyl++) + for(ushort cyl = 0; cyl < _imageInfo.Cylinders; cyl++) { - for(ushort head = 0; head < imageInfo.Heads; head++) + for(ushort head = 0; head < _imageInfo.Heads; head++) if(spts[cyl][head] < spt) spt = spts[cyl][head]; } - imageInfo.SectorsPerTrack = spt; + _imageInfo.SectorsPerTrack = spt; AaruConsole.DebugWriteLine("Apridisk plugin", "Found a minimum of {0} sectors per track", - imageInfo.SectorsPerTrack); + _imageInfo.SectorsPerTrack); - imageInfo.MediaType = Geometry.GetMediaType(((ushort)imageInfo.Cylinders, (byte)imageInfo.Heads, - (ushort)imageInfo.SectorsPerTrack, 512, MediaEncoding.MFM, - false)); + _imageInfo.MediaType = Geometry.GetMediaType(((ushort)_imageInfo.Cylinders, (byte)_imageInfo.Heads, + (ushort)_imageInfo.SectorsPerTrack, 512, MediaEncoding.MFM, + false)); - imageInfo.ImageSize = (ulong)stream.Length - headersizes; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = imageInfo.Cylinders * imageInfo.Heads * imageInfo.SectorsPerTrack; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.ImageSize = (ulong)stream.Length - headersizes; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = _imageInfo.Cylinders * _imageInfo.Heads * _imageInfo.SectorsPerTrack; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; return true; } @@ -232,24 +233,24 @@ namespace Aaru.DiscImages { (ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress); - if(cylinder >= sectorsData.Length) + if(cylinder >= _sectorsData.Length) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(head >= sectorsData[cylinder].Length) + if(head >= _sectorsData[cylinder].Length) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sector > sectorsData[cylinder][head].Length) + if(sector > _sectorsData[cylinder][head].Length) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - return sectorsData[cylinder][head][sector]; + return _sectorsData[cylinder][head][sector]; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var buffer = new MemoryStream(); diff --git a/Aaru.Images/Apridisk/Write.cs b/Aaru.Images/Apridisk/Write.cs index c993615cc..d44396ddd 100644 --- a/Aaru.Images/Apridisk/Write.cs +++ b/Aaru.Images/Apridisk/Write.cs @@ -55,7 +55,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -64,7 +64,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -90,28 +90,28 @@ namespace Aaru.DiscImages { (ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress); - if(cylinder >= sectorsData.Length) + if(cylinder >= _sectorsData.Length) { ErrorMessage = "Sector address not found"; return false; } - if(head >= sectorsData[cylinder].Length) + if(head >= _sectorsData[cylinder].Length) { ErrorMessage = "Sector address not found"; return false; } - if(sector > sectorsData[cylinder][head].Length) + if(sector > _sectorsData[cylinder][head].Length) { ErrorMessage = "Sector address not found"; return false; } - sectorsData[cylinder][head][sector] = data; + _sectorsData[cylinder][head][sector] = data; return true; } @@ -122,28 +122,28 @@ namespace Aaru.DiscImages { (ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress); - if(cylinder >= sectorsData.Length) + if(cylinder >= _sectorsData.Length) { ErrorMessage = "Sector address not found"; return false; } - if(head >= sectorsData[cylinder].Length) + if(head >= _sectorsData[cylinder].Length) { ErrorMessage = "Sector address not found"; return false; } - if(sector > sectorsData[cylinder][head].Length) + if(sector > _sectorsData[cylinder][head].Length) { ErrorMessage = "Sector address not found"; return false; } - sectorsData[cylinder][head][sector] = data; + _sectorsData[cylinder][head][sector] = data; } return true; @@ -166,19 +166,19 @@ namespace Aaru.DiscImages // TODO: Try if apridisk software supports finding other chunks, to extend metadata support public bool Close() { - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(signature, 0, signature.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(_signature, 0, _signature.Length); byte[] hdr = new byte[Marshal.SizeOf()]; - for(ushort c = 0; c < imageInfo.Cylinders; c++) + for(ushort c = 0; c < _imageInfo.Cylinders; c++) { - for(byte h = 0; h < imageInfo.Heads; h++) + for(byte h = 0; h < _imageInfo.Heads; h++) { - for(byte s = 0; s < imageInfo.SectorsPerTrack; s++) + for(byte s = 0; s < _imageInfo.SectorsPerTrack; s++) { - if(sectorsData[c][h][s] == null || - sectorsData[c][h][s].Length == 0) + if(_sectorsData[c][h][s] == null || + _sectorsData[c][h][s].Length == 0) continue; var record = new ApridiskRecord @@ -186,7 +186,7 @@ namespace Aaru.DiscImages type = RecordType.Sector, compression = CompressType.Uncompresed, headerSize = (ushort)Marshal.SizeOf(), - dataSize = (uint)sectorsData[c][h][s].Length, + dataSize = (uint)_sectorsData[c][h][s].Length, head = h, sector = s, cylinder = c @@ -194,15 +194,15 @@ namespace Aaru.DiscImages MemoryMarshal.Write(hdr, ref record); - writingStream.Write(hdr, 0, hdr.Length); - writingStream.Write(sectorsData[c][h][s], 0, sectorsData[c][h][s].Length); + _writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Write(_sectorsData[c][h][s], 0, _sectorsData[c][h][s].Length); } } } - if(!string.IsNullOrEmpty(imageInfo.Creator)) + if(!string.IsNullOrEmpty(_imageInfo.Creator)) { - byte[] creatorBytes = Encoding.UTF8.GetBytes(imageInfo.Creator); + byte[] creatorBytes = Encoding.UTF8.GetBytes(_imageInfo.Creator); var creatorRecord = new ApridiskRecord { @@ -217,14 +217,14 @@ namespace Aaru.DiscImages MemoryMarshal.Write(hdr, ref creatorRecord); - writingStream.Write(hdr, 0, hdr.Length); - writingStream.Write(creatorBytes, 0, creatorBytes.Length); - writingStream.WriteByte(0); // Termination + _writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Write(creatorBytes, 0, creatorBytes.Length); + _writingStream.WriteByte(0); // Termination } - if(!string.IsNullOrEmpty(imageInfo.Comments)) + if(!string.IsNullOrEmpty(_imageInfo.Comments)) { - byte[] commentBytes = Encoding.UTF8.GetBytes(imageInfo.Comments); + byte[] commentBytes = Encoding.UTF8.GetBytes(_imageInfo.Comments); var commentRecord = new ApridiskRecord { @@ -239,13 +239,13 @@ namespace Aaru.DiscImages MemoryMarshal.Write(hdr, ref commentRecord); - writingStream.Write(hdr, 0, hdr.Length); - writingStream.Write(commentBytes, 0, commentBytes.Length); - writingStream.WriteByte(0); // Termination + _writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Write(commentBytes, 0, commentBytes.Length); + _writingStream.WriteByte(0); // Termination } - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -255,8 +255,8 @@ namespace Aaru.DiscImages public bool SetMetadata(ImageInfo metadata) { - imageInfo.Comments = metadata.Comments; - imageInfo.Creator = metadata.Creator; + _imageInfo.Comments = metadata.Comments; + _imageInfo.Creator = metadata.Creator; return true; } @@ -284,19 +284,19 @@ namespace Aaru.DiscImages return false; } - sectorsData = new byte[cylinders][][][]; + _sectorsData = new byte[cylinders][][][]; for(ushort c = 0; c < cylinders; c++) { - sectorsData[c] = new byte[heads][][]; + _sectorsData[c] = new byte[heads][][]; for(byte h = 0; h < heads; h++) - sectorsData[c][h] = new byte[sectorsPerTrack][]; + _sectorsData[c][h] = new byte[sectorsPerTrack][]; } - imageInfo.Cylinders = cylinders; - imageInfo.Heads = heads; - imageInfo.SectorsPerTrack = sectorsPerTrack; + _imageInfo.Cylinders = cylinders; + _imageInfo.Heads = heads; + _imageInfo.SectorsPerTrack = sectorsPerTrack; return true; } diff --git a/Aaru.Images/BLU/BLU.cs b/Aaru.Images/BLU/BLU.cs index 02beb7664..072d02e42 100644 --- a/Aaru.Images/BLU/BLU.cs +++ b/Aaru.Images/BLU/BLU.cs @@ -40,13 +40,13 @@ namespace Aaru.DiscImages { public partial class Blu : IWritableImage, IVerifiableSectorsImage { - IFilter bluImageFilter; - int bptag; - BluHeader imageHeader; - ImageInfo imageInfo; - FileStream writingStream; + IFilter _bluImageFilter; + int _bptag; + BluHeader _imageHeader; + ImageInfo _imageInfo; + FileStream _writingStream; - public Blu() => imageInfo = new ImageInfo + public Blu() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/BLU/Properties.cs b/Aaru.Images/BLU/Properties.cs index 08249ff63..90ee5e319 100644 --- a/Aaru.Images/BLU/Properties.cs +++ b/Aaru.Images/BLU/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class Blu { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Basic Lisa Utility"; public Guid Id => new Guid("A153E2F8-4235-432D-9A7F-20807B0BCD74"); public string Author => "Natalia Portillo"; diff --git a/Aaru.Images/BLU/Read.cs b/Aaru.Images/BLU/Read.cs index 8d6e12a7a..ae2f85dff 100644 --- a/Aaru.Images/BLU/Read.cs +++ b/Aaru.Images/BLU/Read.cs @@ -48,103 +48,105 @@ namespace Aaru.DiscImages Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - imageHeader = new BluHeader + _imageHeader = new BluHeader { DeviceName = new byte[0x0D] }; byte[] header = new byte[0x17]; stream.Read(header, 0, 0x17); - Array.Copy(header, 0, imageHeader.DeviceName, 0, 0x0D); - imageHeader.DeviceType = BigEndianBitConverter.ToUInt32(header, 0x0C) & 0x00FFFFFF; - imageHeader.DeviceBlocks = BigEndianBitConverter.ToUInt32(header, 0x11) & 0x00FFFFFF; - imageHeader.BytesPerBlock = BigEndianBitConverter.ToUInt16(header, 0x15); + Array.Copy(header, 0, _imageHeader.DeviceName, 0, 0x0D); + _imageHeader.DeviceType = BigEndianBitConverter.ToUInt32(header, 0x0C) & 0x00FFFFFF; + _imageHeader.DeviceBlocks = BigEndianBitConverter.ToUInt32(header, 0x11) & 0x00FFFFFF; + _imageHeader.BytesPerBlock = BigEndianBitConverter.ToUInt16(header, 0x15); AaruConsole.DebugWriteLine("BLU plugin", "ImageHeader.deviceName = \"{0}\"", - StringHandlers.CToString(imageHeader.DeviceName)); + StringHandlers.CToString(_imageHeader.DeviceName)); - AaruConsole.DebugWriteLine("BLU plugin", "ImageHeader.deviceType = {0}", imageHeader.DeviceType); - AaruConsole.DebugWriteLine("BLU plugin", "ImageHeader.deviceBlock = {0}", imageHeader.DeviceBlocks); - AaruConsole.DebugWriteLine("BLU plugin", "ImageHeader.bytesPerBlock = {0}", imageHeader.BytesPerBlock); + AaruConsole.DebugWriteLine("BLU plugin", "ImageHeader.deviceType = {0}", _imageHeader.DeviceType); + AaruConsole.DebugWriteLine("BLU plugin", "ImageHeader.deviceBlock = {0}", _imageHeader.DeviceBlocks); + AaruConsole.DebugWriteLine("BLU plugin", "ImageHeader.bytesPerBlock = {0}", _imageHeader.BytesPerBlock); for(int i = 0; i < 0xD; i++) - if(imageHeader.DeviceName[i] < 0x20) + if(_imageHeader.DeviceName[i] < 0x20) return false; - if((imageHeader.BytesPerBlock & 0xFE00) != 0x200) + if((_imageHeader.BytesPerBlock & 0xFE00) != 0x200) return false; stream.Seek(0, SeekOrigin.Begin); - header = new byte[imageHeader.BytesPerBlock]; - stream.Read(header, 0, imageHeader.BytesPerBlock); + header = new byte[_imageHeader.BytesPerBlock]; + stream.Read(header, 0, _imageHeader.BytesPerBlock); - imageInfo.SectorSize = 0x200; + _imageInfo.SectorSize = 0x200; - imageInfo.Sectors = imageHeader.DeviceBlocks; - imageInfo.ImageSize = imageHeader.DeviceBlocks * imageHeader.BytesPerBlock; - bptag = imageHeader.BytesPerBlock - 0x200; - byte[] hdrTag = new byte[bptag]; - Array.Copy(header, 0x200, hdrTag, 0, bptag); + _imageInfo.Sectors = _imageHeader.DeviceBlocks; + _imageInfo.ImageSize = _imageHeader.DeviceBlocks * _imageHeader.BytesPerBlock; + _bptag = _imageHeader.BytesPerBlock - 0x200; + byte[] hdrTag = new byte[_bptag]; + Array.Copy(header, 0x200, hdrTag, 0, _bptag); - switch(StringHandlers.CToString(imageHeader.DeviceName)) + switch(StringHandlers.CToString(_imageHeader.DeviceName)) { case PROFILE_NAME: - imageInfo.MediaType = imageInfo.Sectors == 0x2600 ? MediaType.AppleProfile : MediaType.GENERIC_HDD; + _imageInfo.MediaType = + _imageInfo.Sectors == 0x2600 ? MediaType.AppleProfile : MediaType.GENERIC_HDD; - imageInfo.Cylinders = 152; - imageInfo.Heads = 4; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 152; + _imageInfo.Heads = 4; + _imageInfo.SectorsPerTrack = 16; break; case PROFILE10_NAME: - imageInfo.MediaType = imageInfo.Sectors == 0x4C00 ? MediaType.AppleProfile : MediaType.GENERIC_HDD; + _imageInfo.MediaType = + _imageInfo.Sectors == 0x4C00 ? MediaType.AppleProfile : MediaType.GENERIC_HDD; - imageInfo.Cylinders = 304; - imageInfo.Heads = 4; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 304; + _imageInfo.Heads = 4; + _imageInfo.SectorsPerTrack = 16; break; case WIDGET_NAME: - imageInfo.MediaType = imageInfo.Sectors == 0x4C00 ? MediaType.AppleWidget : MediaType.GENERIC_HDD; + _imageInfo.MediaType = _imageInfo.Sectors == 0x4C00 ? MediaType.AppleWidget : MediaType.GENERIC_HDD; - imageInfo.Cylinders = 304; - imageInfo.Heads = 4; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 304; + _imageInfo.Heads = 4; + _imageInfo.SectorsPerTrack = 16; break; case PRIAM_NAME: - imageInfo.MediaType = - imageInfo.Sectors == 0x022C7C ? MediaType.PriamDataTower : MediaType.GENERIC_HDD; + _imageInfo.MediaType = _imageInfo.Sectors == 0x022C7C ? MediaType.PriamDataTower + : MediaType.GENERIC_HDD; // This values are invented... - imageInfo.Cylinders = 419; - imageInfo.Heads = 4; - imageInfo.SectorsPerTrack = 85; + _imageInfo.Cylinders = 419; + _imageInfo.Heads = 4; + _imageInfo.SectorsPerTrack = 85; break; default: - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; break; } - imageInfo.Application = StringHandlers.CToString(hdrTag); + _imageInfo.Application = StringHandlers.CToString(hdrTag); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - bluImageFilter = imageFilter; + _bluImageFilter = imageFilter; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - if(bptag > 0) - imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag); + if(_bptag > 0) + _imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag); - AaruConsole.VerboseWriteLine("BLU image contains a disk of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("BLU image contains a disk of type {0}", _imageInfo.MediaType); return true; } @@ -155,19 +157,19 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var buffer = new MemoryStream(); int seek = 0; int read = 0x200; - int skip = bptag; + int skip = _bptag; - Stream stream = bluImageFilter.GetDataForkStream(); - stream.Seek((long)((sectorAddress + 1) * imageHeader.BytesPerBlock), SeekOrigin.Begin); + Stream stream = _bluImageFilter.GetDataForkStream(); + stream.Seek((long)((sectorAddress + 1) * _imageHeader.BytesPerBlock), SeekOrigin.Begin); for(int i = 0; i < length; i++) { @@ -186,22 +188,22 @@ namespace Aaru.DiscImages if(tag != SectorTagType.AppleSectorTag) throw new FeatureUnsupportedImageException($"Tag {tag} not supported by image format"); - if(bptag == 0) + if(_bptag == 0) throw new FeatureNotPresentImageException("Disk image does not have tags"); - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var buffer = new MemoryStream(); int seek = 0x200; - int read = bptag; + int read = _bptag; int skip = 0; - Stream stream = bluImageFilter.GetDataForkStream(); - stream.Seek((long)((sectorAddress + 1) * imageHeader.BytesPerBlock), SeekOrigin.Begin); + Stream stream = _bluImageFilter.GetDataForkStream(); + stream.Seek((long)((sectorAddress + 1) * _imageHeader.BytesPerBlock), SeekOrigin.Begin); for(int i = 0; i < length; i++) { @@ -219,15 +221,15 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageHeader.BytesPerBlock]; - Stream stream = bluImageFilter.GetDataForkStream(); - stream.Seek((long)((sectorAddress + 1) * imageHeader.BytesPerBlock), SeekOrigin.Begin); + byte[] buffer = new byte[length * _imageHeader.BytesPerBlock]; + Stream stream = _bluImageFilter.GetDataForkStream(); + stream.Seek((long)((sectorAddress + 1) * _imageHeader.BytesPerBlock), SeekOrigin.Begin); stream.Read(buffer, 0, buffer.Length); return buffer; diff --git a/Aaru.Images/BLU/Write.cs b/Aaru.Images/BLU/Write.cs index 3f783b628..b149ce9ec 100644 --- a/Aaru.Images/BLU/Write.cs +++ b/Aaru.Images/BLU/Write.cs @@ -71,7 +71,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -80,7 +80,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -104,7 +104,7 @@ namespace Aaru.DiscImages public bool WriteSector(byte[] data, ulong sectorAddress) { - int longSectorSize = imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; + int longSectorSize = _imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; if(!IsWriting) { @@ -120,15 +120,15 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -137,7 +137,7 @@ namespace Aaru.DiscImages public bool WriteSectors(byte[] data, ulong sectorAddress, uint length) { - int longSectorSize = imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; + int longSectorSize = _imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; if(!IsWriting) { @@ -153,15 +153,15 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -177,14 +177,14 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - int longSectorSize = imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; + int longSectorSize = _imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; byte[] oldTag; byte[] newTag; @@ -249,9 +249,9 @@ namespace Aaru.DiscImages if(newTag == null) newTag = new byte[longSectorSize - 512]; - writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin); - writingStream.Write(data, 0, 512); - writingStream.Write(newTag, 0, newTag.Length); + _writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin); + _writingStream.Write(data, 0, 512); + _writingStream.Write(newTag, 0, newTag.Length); ErrorMessage = ""; @@ -267,14 +267,14 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - int longSectorSize = imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; + int longSectorSize = _imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; long givenSectorSize = data.Length / length; switch(givenSectorSize) @@ -354,9 +354,9 @@ namespace Aaru.DiscImages if(newTag == null) newTag = new byte[longSectorSize - 512]; - writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin); - writingStream.Write(data, (int)(givenSectorSize * i), 512); - writingStream.Write(newTag, 0, newTag.Length); + _writingStream.Seek(longSectorSize + ((long)sectorAddress * longSectorSize), SeekOrigin.Begin); + _writingStream.Write(data, (int)(givenSectorSize * i), 512); + _writingStream.Write(newTag, 0, newTag.Length); } ErrorMessage = ""; @@ -376,22 +376,22 @@ namespace Aaru.DiscImages byte[] markerTag = Encoding.UTF8.GetBytes("Aaru " + Version.GetVersion()); byte[] driveName; byte[] driveType = new byte[3]; - byte[] driveBlocks = BigEndianBitConverter.GetBytes((uint)imageInfo.Sectors); - int longSectorSize = imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; + byte[] driveBlocks = BigEndianBitConverter.GetBytes((uint)_imageInfo.Sectors); + int longSectorSize = _imageInfo.MediaType == MediaType.PriamDataTower ? 536 : 532; byte[] blockSize = BigEndianBitConverter.GetBytes((ushort)longSectorSize); - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { - case MediaType.AppleProfile when imageInfo.Sectors == 0x4C00: + case MediaType.AppleProfile when _imageInfo.Sectors == 0x4C00: driveName = Encoding.ASCII.GetBytes(PROFILE10_NAME); break; - case MediaType.AppleWidget when imageInfo.Sectors == 0x4C00: + case MediaType.AppleWidget when _imageInfo.Sectors == 0x4C00: driveType[1] = 0x01; driveName = Encoding.ASCII.GetBytes(PROFILE10_NAME); break; - case MediaType.PriamDataTower when imageInfo.Sectors == 0x22C7C: + case MediaType.PriamDataTower when _imageInfo.Sectors == 0x22C7C: driveType[1] = 0xFF; driveName = Encoding.ASCII.GetBytes(PRIAM_NAME); @@ -402,21 +402,21 @@ namespace Aaru.DiscImages break; } - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(driveName, 0, driveName.Length >= 0xD ? 0xD : driveName.Length); - writingStream.Seek(0xD, SeekOrigin.Begin); - writingStream.Write(driveType, 0, 3); - writingStream.Seek(0x12, SeekOrigin.Begin); - writingStream.Write(driveBlocks, 1, 3); - writingStream.Seek(0x15, SeekOrigin.Begin); - writingStream.Write(blockSize, 1, 2); - writingStream.Seek(512, SeekOrigin.Begin); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(driveName, 0, driveName.Length >= 0xD ? 0xD : driveName.Length); + _writingStream.Seek(0xD, SeekOrigin.Begin); + _writingStream.Write(driveType, 0, 3); + _writingStream.Seek(0x12, SeekOrigin.Begin); + _writingStream.Write(driveBlocks, 1, 3); + _writingStream.Seek(0x15, SeekOrigin.Begin); + _writingStream.Write(blockSize, 1, 2); + _writingStream.Seek(512, SeekOrigin.Begin); - writingStream.Write(markerTag, 0, - markerTag.Length >= longSectorSize - 512 ? longSectorSize - 512 : markerTag.Length); + _writingStream.Write(markerTag, 0, + markerTag.Length >= longSectorSize - 512 ? longSectorSize - 512 : markerTag.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; diff --git a/Aaru.Images/BlindWrite4/BlindWrite4.cs b/Aaru.Images/BlindWrite4/BlindWrite4.cs index 6708028f4..991c6599d 100644 --- a/Aaru.Images/BlindWrite4/BlindWrite4.cs +++ b/Aaru.Images/BlindWrite4/BlindWrite4.cs @@ -41,16 +41,16 @@ namespace Aaru.DiscImages // TODO: Too many unknowns, plus a completely unknown footer, to make this writable public partial class BlindWrite4 : IOpticalMediaImage { - List bwTracks; - IFilter dataFilter, subFilter; + List _bwTracks; + IFilter _dataFilter, _subFilter; - Bw4Header header; - ImageInfo imageInfo; - Stream imageStream; - Dictionary offsetmap; - Dictionary trackFlags; + Bw4Header _header; + ImageInfo _imageInfo; + Stream _imageStream; + Dictionary _offsetmap; + Dictionary _trackFlags; - public BlindWrite4() => imageInfo = new ImageInfo + public BlindWrite4() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/BlindWrite4/Constants.cs b/Aaru.Images/BlindWrite4/Constants.cs index 099d212cb..352d3f46e 100644 --- a/Aaru.Images/BlindWrite4/Constants.cs +++ b/Aaru.Images/BlindWrite4/Constants.cs @@ -35,7 +35,7 @@ namespace Aaru.DiscImages public partial class BlindWrite4 { /// "BLINDWRITE TOC FILE" - readonly byte[] bw4Signature = + readonly byte[] _bw4Signature = { 0x42, 0x4C, 0x49, 0x4E, 0x44, 0x57, 0x52, 0x49, 0x54, 0x45, 0x20, 0x54, 0x4F, 0x43, 0x20, 0x46, 0x49, 0x4C, 0x45 diff --git a/Aaru.Images/BlindWrite4/Identify.cs b/Aaru.Images/BlindWrite4/Identify.cs index cd706a6f7..8f5e5bafe 100644 --- a/Aaru.Images/BlindWrite4/Identify.cs +++ b/Aaru.Images/BlindWrite4/Identify.cs @@ -49,7 +49,7 @@ namespace Aaru.DiscImages byte[] signature = new byte[19]; stream.Read(signature, 0, 19); - return bw4Signature.SequenceEqual(signature); + return _bw4Signature.SequenceEqual(signature); } } } \ No newline at end of file diff --git a/Aaru.Images/BlindWrite4/Properties.cs b/Aaru.Images/BlindWrite4/Properties.cs index 1cba758e6..546a43b88 100644 --- a/Aaru.Images/BlindWrite4/Properties.cs +++ b/Aaru.Images/BlindWrite4/Properties.cs @@ -40,7 +40,7 @@ namespace Aaru.DiscImages { public partial class BlindWrite4 { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "BlindWrite 4"; public Guid Id => new Guid("664568B2-15D4-4E64-8A7A-20BDA8B8386F"); diff --git a/Aaru.Images/BlindWrite4/Read.cs b/Aaru.Images/BlindWrite4/Read.cs index cce4d3640..36268c7e9 100644 --- a/Aaru.Images/BlindWrite4/Read.cs +++ b/Aaru.Images/BlindWrite4/Read.cs @@ -65,95 +65,95 @@ namespace Aaru.DiscImages stream.Read(tmpArray, 0, 19); - if(!bw4Signature.SequenceEqual(tmpArray)) + if(!_bw4Signature.SequenceEqual(tmpArray)) return false; - header = new Bw4Header + _header = new Bw4Header { Signature = tmpArray }; // Seems to always be 2 stream.Read(tmpUInt, 0, 4); - header.Unknown1 = BitConverter.ToUInt32(tmpUInt, 0); + _header.Unknown1 = BitConverter.ToUInt32(tmpUInt, 0); // Seems to be a timetamp stream.Read(tmpULong, 0, 8); - header.Timestamp = BitConverter.ToUInt64(tmpULong, 0); + _header.Timestamp = BitConverter.ToUInt64(tmpULong, 0); stream.Read(tmpUInt, 0, 4); - header.VolumeIdLength = BitConverter.ToUInt32(tmpUInt, 0); - tmpArray = new byte[header.VolumeIdLength]; + _header.VolumeIdLength = BitConverter.ToUInt32(tmpUInt, 0); + tmpArray = new byte[_header.VolumeIdLength]; stream.Read(tmpArray, 0, tmpArray.Length); - header.VolumeIdBytes = tmpArray; - header.VolumeIdentifier = StringHandlers.CToString(header.VolumeIdBytes, Encoding.Default); + _header.VolumeIdBytes = tmpArray; + _header.VolumeIdentifier = StringHandlers.CToString(_header.VolumeIdBytes, Encoding.Default); stream.Read(tmpUInt, 0, 4); - header.SysIdLength = BitConverter.ToUInt32(tmpUInt, 0); - tmpArray = new byte[header.SysIdLength]; + _header.SysIdLength = BitConverter.ToUInt32(tmpUInt, 0); + tmpArray = new byte[_header.SysIdLength]; stream.Read(tmpArray, 0, tmpArray.Length); - header.SysIdBytes = tmpArray; - header.SystemIdentifier = StringHandlers.CToString(header.SysIdBytes, Encoding.Default); + _header.SysIdBytes = tmpArray; + _header.SystemIdentifier = StringHandlers.CToString(_header.SysIdBytes, Encoding.Default); stream.Read(tmpUInt, 0, 4); - header.CommentsLength = BitConverter.ToUInt32(tmpUInt, 0); - tmpArray = new byte[header.CommentsLength]; + _header.CommentsLength = BitConverter.ToUInt32(tmpUInt, 0); + tmpArray = new byte[_header.CommentsLength]; stream.Read(tmpArray, 0, tmpArray.Length); - header.CommentsBytes = tmpArray; - header.Comments = StringHandlers.CToString(header.CommentsBytes, Encoding.Default); + _header.CommentsBytes = tmpArray; + _header.Comments = StringHandlers.CToString(_header.CommentsBytes, Encoding.Default); stream.Read(tmpUInt, 0, 4); - header.TrackDescriptors = BitConverter.ToUInt32(tmpUInt, 0); + _header.TrackDescriptors = BitConverter.ToUInt32(tmpUInt, 0); stream.Read(tmpUInt, 0, 4); - header.DataFileLength = BitConverter.ToUInt32(tmpUInt, 0); - tmpArray = new byte[header.DataFileLength]; + _header.DataFileLength = BitConverter.ToUInt32(tmpUInt, 0); + tmpArray = new byte[_header.DataFileLength]; stream.Read(tmpArray, 0, tmpArray.Length); - header.DataFileBytes = tmpArray; - header.DataFile = StringHandlers.CToString(header.DataFileBytes, Encoding.Default); + _header.DataFileBytes = tmpArray; + _header.DataFile = StringHandlers.CToString(_header.DataFileBytes, Encoding.Default); stream.Read(tmpUInt, 0, 4); - header.SubchannelFileLength = BitConverter.ToUInt32(tmpUInt, 0); - tmpArray = new byte[header.SubchannelFileLength]; + _header.SubchannelFileLength = BitConverter.ToUInt32(tmpUInt, 0); + tmpArray = new byte[_header.SubchannelFileLength]; stream.Read(tmpArray, 0, tmpArray.Length); - header.SubchannelFileBytes = tmpArray; - header.SubchannelFile = StringHandlers.CToString(header.SubchannelFileBytes, Encoding.Default); + _header.SubchannelFileBytes = tmpArray; + _header.SubchannelFile = StringHandlers.CToString(_header.SubchannelFileBytes, Encoding.Default); stream.Read(tmpUInt, 0, 4); - header.Unknown2 = BitConverter.ToUInt32(tmpUInt, 0); - header.Unknown3 = (byte)stream.ReadByte(); - tmpArray = new byte[header.Unknown3]; - stream.Read(tmpArray, 0, header.Unknown3); - header.Unknown4 = tmpArray; + _header.Unknown2 = BitConverter.ToUInt32(tmpUInt, 0); + _header.Unknown3 = (byte)stream.ReadByte(); + tmpArray = new byte[_header.Unknown3]; + stream.Read(tmpArray, 0, _header.Unknown3); + _header.Unknown4 = tmpArray; AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.signature = {0}", - StringHandlers.CToString(header.Signature)); + StringHandlers.CToString(_header.Signature)); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.unknown1 = {0}", header.Unknown1); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.timestamp = {0}", header.Timestamp); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.volumeIdLength = {0}", header.VolumeIdLength); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.volumeIdentifier = {0}", header.VolumeIdentifier); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.sysIdLength = {0}", header.SysIdLength); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.systemIdentifier = {0}", header.SystemIdentifier); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.commentsLength = {0}", header.CommentsLength); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.comments = {0}", header.Comments); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.trackDescriptors = {0}", header.TrackDescriptors); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.dataFileLength = {0}", header.DataFileLength); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.dataFilter = {0}", header.DataFilter); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.dataFile = {0}", header.DataFile); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.unknown1 = {0}", _header.Unknown1); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.timestamp = {0}", _header.Timestamp); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.volumeIdLength = {0}", _header.VolumeIdLength); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.volumeIdentifier = {0}", _header.VolumeIdentifier); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.sysIdLength = {0}", _header.SysIdLength); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.systemIdentifier = {0}", _header.SystemIdentifier); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.commentsLength = {0}", _header.CommentsLength); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.comments = {0}", _header.Comments); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.trackDescriptors = {0}", _header.TrackDescriptors); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.dataFileLength = {0}", _header.DataFileLength); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.dataFilter = {0}", _header.DataFilter); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.dataFile = {0}", _header.DataFile); AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.subchannelFileLength = {0}", - header.SubchannelFileLength); + _header.SubchannelFileLength); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.subchannelFilter = {0}", header.SubchannelFilter); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.subchannelFile = {0}", header.SubchannelFile); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.unknown2 = {0}", header.Unknown2); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.unknown3 = {0}", header.Unknown3); - AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.unknown4.Length = {0}", header.Unknown4.Length); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.subchannelFilter = {0}", _header.SubchannelFilter); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.subchannelFile = {0}", _header.SubchannelFile); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.unknown2 = {0}", _header.Unknown2); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.unknown3 = {0}", _header.Unknown3); + AaruConsole.DebugWriteLine("BlindWrite4 plugin", "header.unknown4.Length = {0}", _header.Unknown4.Length); - bwTracks = new List(); + _bwTracks = new List(); - for(int i = 0; i < header.TrackDescriptors; i++) + for(int i = 0; i < _header.TrackDescriptors; i++) { AaruConsole.DebugWriteLine("BlindWrite4 plugin", "stream.Position = {0}", stream.Position); @@ -381,90 +381,90 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.isrcLen = {0}", track.isrcLen); AaruConsole.DebugWriteLine("BlindWrite4 plugin", "track.isrcUpc = {0}", track.isrcUpc); - bwTracks.Add(track); + _bwTracks.Add(track); } var filtersList = new FiltersList(); - if(!string.IsNullOrEmpty(header.DataFile)) + if(!string.IsNullOrEmpty(_header.DataFile)) while(true) { - dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), header.DataFile)); + _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), _header.DataFile)); - if(dataFilter != null) + if(_dataFilter != null) break; - dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), - header.DataFile.ToLower(CultureInfo. - CurrentCulture))); + _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), + _header.DataFile.ToLower(CultureInfo. + CurrentCulture))); - if(dataFilter != null) + if(_dataFilter != null) break; - dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), - header.DataFile.ToUpper(CultureInfo. - CurrentCulture))); + _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), + _header.DataFile.ToUpper(CultureInfo. + CurrentCulture))); - if(dataFilter != null) + if(_dataFilter != null) break; - dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), header. - DataFile.Split(new[] - { - '\\' - }, - StringSplitOptions. - RemoveEmptyEntries). - Last())); + _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), _header. + DataFile.Split(new[] + { + '\\' + }, + StringSplitOptions. + RemoveEmptyEntries). + Last())); - if(dataFilter != null) + if(_dataFilter != null) break; - dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), header. - DataFile.Split(new[] - { - '\\' - }, - StringSplitOptions. - RemoveEmptyEntries). - Last(). - ToLower(CultureInfo. - CurrentCulture))); + _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), _header. + DataFile.Split(new[] + { + '\\' + }, + StringSplitOptions. + RemoveEmptyEntries). + Last(). + ToLower(CultureInfo. + CurrentCulture))); - if(dataFilter != null) + if(_dataFilter != null) break; - dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), header. - DataFile.Split(new[] - { - '\\' - }, - StringSplitOptions. - RemoveEmptyEntries). - Last(). - ToUpper(CultureInfo. - CurrentCulture))); + _dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), _header. + DataFile.Split(new[] + { + '\\' + }, + StringSplitOptions. + RemoveEmptyEntries). + Last(). + ToUpper(CultureInfo. + CurrentCulture))); - if(dataFilter != null) + if(_dataFilter != null) break; - throw new ArgumentException($"Data file {header.DataFile} not found"); + throw new ArgumentException($"Data file {_header.DataFile} not found"); } else throw new ArgumentException("Unable to find data file"); - if(!string.IsNullOrEmpty(header.SubchannelFile)) + if(!string.IsNullOrEmpty(_header.SubchannelFile)) { filtersList = new FiltersList(); - subFilter = - ((((filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), header.SubchannelFile)) ?? + _subFilter = + ((((filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), _header.SubchannelFile)) ?? filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), - header.SubchannelFile.ToLower(CultureInfo.CurrentCulture))) + _header.SubchannelFile.ToLower(CultureInfo.CurrentCulture))) ) ?? filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), - header.SubchannelFile. - ToUpper(CultureInfo.CurrentCulture)))) ?? - filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), header. + _header.SubchannelFile. + ToUpper(CultureInfo.CurrentCulture)))) ?? + filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), _header. SubchannelFile.Split(new[] { '\\' @@ -472,7 +472,7 @@ namespace Aaru.DiscImages StringSplitOptions. RemoveEmptyEntries). Last())) - ) ?? filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), header. + ) ?? filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), _header. SubchannelFile.Split(new[] { '\\' @@ -481,7 +481,7 @@ namespace Aaru.DiscImages RemoveEmptyEntries). Last().ToLower(CultureInfo. CurrentCulture))) - ) ?? filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), header. + ) ?? filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), _header. SubchannelFile.Split(new[] { '\\' @@ -492,14 +492,14 @@ namespace Aaru.DiscImages CurrentCulture))); } - Tracks = new List(); - Partitions = new List(); - offsetmap = new Dictionary(); - trackFlags = new Dictionary(); + Tracks = new List(); + Partitions = new List(); + _offsetmap = new Dictionary(); + _trackFlags = new Dictionary(); ushort maxSession = 0; ulong currentPos = 0; - foreach(Bw4TrackDescriptor bwTrack in bwTracks) + foreach(Bw4TrackDescriptor bwTrack in _bwTracks) if(bwTrack.point < 0xA0) { var track = new Track @@ -570,12 +570,12 @@ namespace Aaru.DiscImages ToUpper(CultureInfo. CurrentCulture))); - track.TrackFilter = dataFilter; + track.TrackFilter = _dataFilter; } while(true); else - track.TrackFilter = dataFilter; + track.TrackFilter = _dataFilter; - track.TrackFile = dataFilter.GetFilename(); + track.TrackFile = _dataFilter.GetFilename(); track.TrackFileOffset = currentPos * 2352; track.TrackSubchannelOffset = currentPos * 96; @@ -601,16 +601,16 @@ namespace Aaru.DiscImages if(track.TrackSession > maxSession) maxSession = track.TrackSession; - track.TrackSubchannelFilter = subFilter; - track.TrackSubchannelFile = subFilter?.GetFilename(); + track.TrackSubchannelFilter = _subFilter; + track.TrackSubchannelFile = _subFilter?.GetFilename(); - if(subFilter != null && + if(_subFilter != null && bwTrack.subchannel > 0) { track.TrackSubchannelType = TrackSubchannelType.Packed; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); } else track.TrackSubchannelType = TrackSubchannelType.None; @@ -619,36 +619,36 @@ namespace Aaru.DiscImages { case Bw4TrackType.Audio: track.TrackType = TrackType.Audio; - imageInfo.SectorSize = 2352; + _imageInfo.SectorSize = 2352; track.TrackBytesPerSector = 2352; break; case Bw4TrackType.Mode1: track.TrackType = TrackType.CdMode1; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - if(imageInfo.SectorSize < 2048) - imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) + _imageInfo.SectorSize = 2048; track.TrackBytesPerSector = 2048; @@ -656,14 +656,14 @@ namespace Aaru.DiscImages case Bw4TrackType.Mode2: track.TrackType = TrackType.CdMode2Formless; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(imageInfo.SectorSize < 2336) - imageInfo.SectorSize = 2336; + if(_imageInfo.SectorSize < 2336) + _imageInfo.SectorSize = 2336; track.TrackBytesPerSector = 2336; @@ -671,7 +671,7 @@ namespace Aaru.DiscImages default: track.TrackType = TrackType.Data; track.TrackRawBytesPerSector = 2048; - imageInfo.SectorSize = 2048; + _imageInfo.SectorSize = 2048; track.TrackBytesPerSector = 2048; break; @@ -697,23 +697,23 @@ namespace Aaru.DiscImages Partitions.Add(partition); Tracks.Add(track); - if(!offsetmap.ContainsKey(track.TrackSequence)) - offsetmap.Add(track.TrackSequence, track.TrackStartSector); + if(!_offsetmap.ContainsKey(track.TrackSequence)) + _offsetmap.Add(track.TrackSequence, track.TrackStartSector); - if(!trackFlags.ContainsKey(track.TrackSequence)) - trackFlags.Add(track.TrackSequence, (byte)(bwTrack.adrCtl & 0x0F)); + if(!_trackFlags.ContainsKey(track.TrackSequence)) + _trackFlags.Add(track.TrackSequence, (byte)(bwTrack.adrCtl & 0x0F)); - imageInfo.Sectors += (ulong)((bwTrack.lastSector - bwTrack.startSector) + 1); + _imageInfo.Sectors += (ulong)((bwTrack.lastSector - bwTrack.startSector) + 1); } else { - imageInfo.MediaBarcode = bwTrack.isrcUpc; - imageInfo.MediaSerialNumber = bwTrack.discId; - imageInfo.MediaTitle = bwTrack.title; + _imageInfo.MediaBarcode = bwTrack.isrcUpc; + _imageInfo.MediaSerialNumber = bwTrack.discId; + _imageInfo.MediaTitle = bwTrack.title; if(!string.IsNullOrEmpty(bwTrack.isrcUpc) && - !imageInfo.ReadableMediaTags.Contains(MediaTagType.CD_MCN)) - imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); + !_imageInfo.ReadableMediaTags.Contains(MediaTagType.CD_MCN)) + _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); } Sessions = new List(); @@ -745,16 +745,16 @@ namespace Aaru.DiscImages Sessions.Add(session); } - imageInfo.MediaType = MediaType.CD; + _imageInfo.MediaType = MediaType.CD; - imageInfo.Application = "BlindWrite"; - imageInfo.ApplicationVersion = "4"; - imageInfo.Version = "4"; + _imageInfo.Application = "BlindWrite"; + _imageInfo.ApplicationVersion = "4"; + _imageInfo.Version = "4"; - imageInfo.ImageSize = (ulong)dataFilter.GetDataForkLength(); - imageInfo.CreationTime = dataFilter.GetCreationTime(); - imageInfo.LastModificationTime = dataFilter.GetLastWriteTime(); - imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; + _imageInfo.ImageSize = (ulong)_dataFilter.GetDataForkLength(); + _imageInfo.CreationTime = _dataFilter.GetCreationTime(); + _imageInfo.LastModificationTime = _dataFilter.GetLastWriteTime(); + _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; bool data = false; bool mode2 = false; @@ -787,25 +787,25 @@ namespace Aaru.DiscImages if(!data && !firstdata) - imageInfo.MediaType = MediaType.CDDA; + _imageInfo.MediaType = MediaType.CDDA; else if(firstaudio && data && Sessions.Count > 1 && mode2) - imageInfo.MediaType = MediaType.CDPLUS; + _imageInfo.MediaType = MediaType.CDPLUS; else if((firstdata && audio) || mode2) - imageInfo.MediaType = MediaType.CDROMXA; + _imageInfo.MediaType = MediaType.CDROMXA; else if(!audio) - imageInfo.MediaType = MediaType.CDROM; + _imageInfo.MediaType = MediaType.CDROM; else - imageInfo.MediaType = MediaType.CD; + _imageInfo.MediaType = MediaType.CD; - imageInfo.Comments = header.Comments; + _imageInfo.Comments = _header.Comments; - AaruConsole.VerboseWriteLine("BlindWrite image describes a disc of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("BlindWrite image describes a disc of type {0}", _imageInfo.MediaType); - if(!string.IsNullOrEmpty(imageInfo.Comments)) - AaruConsole.VerboseWriteLine("BlindrWrite comments: {0}", imageInfo.Comments); + if(!string.IsNullOrEmpty(_imageInfo.Comments)) + AaruConsole.VerboseWriteLine("BlindrWrite comments: {0}", _imageInfo.Comments); return true; } @@ -816,8 +816,8 @@ namespace Aaru.DiscImages { case MediaTagType.CD_MCN: { - if(imageInfo.MediaSerialNumber != null) - return Encoding.ASCII.GetBytes(imageInfo.MediaSerialNumber); + if(_imageInfo.MediaSerialNumber != null) + return Encoding.ASCII.GetBytes(_imageInfo.MediaSerialNumber); throw new FeatureNotPresentImageException("Image does not contain MCN information."); } @@ -837,7 +837,7 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value < (track.TrackEndSector - track.TrackStartSector) + 1 @@ -849,7 +849,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value < (track.TrackEndSector - track.TrackStartSector) + 1 @@ -925,8 +925,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = aaruTrack.TrackFilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = aaruTrack.TrackFilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)aaruTrack.TrackFileOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), @@ -1002,7 +1002,7 @@ namespace Aaru.DiscImages case SectorTagType.CdSectorSubHeader: case SectorTagType.CdSectorSync: break; case SectorTagType.CdTrackFlags: - if(trackFlags.TryGetValue((uint)sectorAddress, out byte flag)) + if(_trackFlags.TryGetValue((uint)sectorAddress, out byte flag)) return new[] { flag @@ -1140,10 +1140,10 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = tag == SectorTagType.CdSectorSubchannel ? aaruTrack.TrackSubchannelFilter.GetDataForkStream() - : aaruTrack.TrackFilter.GetDataForkStream(); + _imageStream = tag == SectorTagType.CdSectorSubchannel ? aaruTrack.TrackSubchannelFilter.GetDataForkStream() + : aaruTrack.TrackFilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)(tag == SectorTagType.CdSectorSubchannel ? aaruTrack.TrackSubchannelOffset : aaruTrack.TrackFileOffset) + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), @@ -1170,7 +1170,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value < (track.TrackEndSector - track.TrackStartSector) + 1 @@ -1221,8 +1221,8 @@ namespace Aaru.DiscImages default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type"); } - imageStream = aaruTrack.TrackFilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = aaruTrack.TrackFilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)aaruTrack.TrackFileOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), diff --git a/Aaru.Images/BlindWrite5/BlindWrite5.cs b/Aaru.Images/BlindWrite5/BlindWrite5.cs index 7531453a3..60cfdd339 100644 --- a/Aaru.Images/BlindWrite5/BlindWrite5.cs +++ b/Aaru.Images/BlindWrite5/BlindWrite5.cs @@ -41,29 +41,29 @@ namespace Aaru.DiscImages // TODO: Too many unknowns to make this writable public partial class BlindWrite5 : IOpticalMediaImage { - byte[] atip; - byte[] bca; - List bwSessions; - byte[] cdtext; - List dataFiles; - string dataPath; - byte[] discInformation; - byte[] dmi; - byte[] dpm; - List filePaths; - byte[] fullToc; + byte[] _atip; + byte[] _bca; + List _bwSessions; + byte[] _cdtext; + List _dataFiles; + string _dataPath; + byte[] _discInformation; + byte[] _dmi; + byte[] _dpm; + List _filePaths; + byte[] _fullToc; - Bw5Header header; - ImageInfo imageInfo; - Stream imageStream; - byte[] mode2A; - Dictionary offsetmap; - byte[] pfi; - byte[] pma; - Dictionary trackFlags; - byte[] unkBlock; + Bw5Header _header; + ImageInfo _imageInfo; + Stream _imageStream; + byte[] _mode2A; + Dictionary _offsetmap; + byte[] _pfi; + byte[] _pma; + Dictionary _trackFlags; + byte[] _unkBlock; - public BlindWrite5() => imageInfo = new ImageInfo + public BlindWrite5() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/BlindWrite5/Constants.cs b/Aaru.Images/BlindWrite5/Constants.cs index 5491c5fe3..c74762ce1 100644 --- a/Aaru.Images/BlindWrite5/Constants.cs +++ b/Aaru.Images/BlindWrite5/Constants.cs @@ -35,12 +35,12 @@ namespace Aaru.DiscImages public partial class BlindWrite5 { /// "BWT5 STREAM FOOT" - readonly byte[] bw5Footer = + readonly byte[] _bw5Footer = { 0x42, 0x57, 0x54, 0x35, 0x20, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4D, 0x20, 0x46, 0x4F, 0x4F, 0x54 }; /// "BWT5 STREAM SIGN" - readonly byte[] bw5Signature = + readonly byte[] _bw5Signature = { 0x42, 0x57, 0x54, 0x35, 0x20, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4D, 0x20, 0x53, 0x49, 0x47, 0x4E }; diff --git a/Aaru.Images/BlindWrite5/Identify.cs b/Aaru.Images/BlindWrite5/Identify.cs index d06b13792..4536cf6fb 100644 --- a/Aaru.Images/BlindWrite5/Identify.cs +++ b/Aaru.Images/BlindWrite5/Identify.cs @@ -53,7 +53,7 @@ namespace Aaru.DiscImages stream.Seek(-16, SeekOrigin.End); stream.Read(footer, 0, 16); - return bw5Signature.SequenceEqual(signature) && bw5Footer.SequenceEqual(footer); + return _bw5Signature.SequenceEqual(signature) && _bw5Footer.SequenceEqual(footer); } } } \ No newline at end of file diff --git a/Aaru.Images/BlindWrite5/Properties.cs b/Aaru.Images/BlindWrite5/Properties.cs index 74df8abc2..33e2baa9f 100644 --- a/Aaru.Images/BlindWrite5/Properties.cs +++ b/Aaru.Images/BlindWrite5/Properties.cs @@ -40,7 +40,7 @@ namespace Aaru.DiscImages { public partial class BlindWrite5 { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "BlindWrite 5"; public Guid Id => new Guid("9CB7A381-0509-4F9F-B801-3F65434BC3EE"); diff --git a/Aaru.Images/BlindWrite5/Read.cs b/Aaru.Images/BlindWrite5/Read.cs index a73c3b179..0c88a63cd 100644 --- a/Aaru.Images/BlindWrite5/Read.cs +++ b/Aaru.Images/BlindWrite5/Read.cs @@ -65,157 +65,157 @@ namespace Aaru.DiscImages byte[] hdr = new byte[260]; stream.Read(hdr, 0, 260); - header = Marshal.ByteArrayToStructureLittleEndian(hdr); + _header = Marshal.ByteArrayToStructureLittleEndian(hdr); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.signature = {0}", - StringHandlers.CToString(header.signature)); + StringHandlers.CToString(_header.signature)); - for(int i = 0; i < header.unknown1.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown1[{1}] = 0x{0:X8}", header.unknown1[i], + for(int i = 0; i < _header.unknown1.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown1[{1}] = 0x{0:X8}", _header.unknown1[i], i); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.profile = {0}", header.profile); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.sessions = {0}", header.sessions); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.profile = {0}", _header.profile); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.sessions = {0}", _header.sessions); - for(int i = 0; i < header.unknown2.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown2[{1}] = 0x{0:X8}", header.unknown2[i], + for(int i = 0; i < _header.unknown2.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown2[{1}] = 0x{0:X8}", _header.unknown2[i], i); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.mcnIsValid = {0}", header.mcnIsValid); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.mcn = {0}", StringHandlers.CToString(header.mcn)); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown3 = 0x{0:X4}", header.unknown3); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.mcnIsValid = {0}", _header.mcnIsValid); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.mcn = {0}", StringHandlers.CToString(_header.mcn)); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown3 = 0x{0:X4}", _header.unknown3); - for(int i = 0; i < header.unknown4.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown4[{1}] = 0x{0:X8}", header.unknown4[i], + for(int i = 0; i < _header.unknown4.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown4[{1}] = 0x{0:X8}", _header.unknown4[i], i); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.pmaLen = {0}", header.pmaLen); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.atipLen = {0}", header.atipLen); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.cdtLen = {0}", header.cdtLen); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.cdInfoLen = {0}", header.cdInfoLen); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.bcaLen = {0}", header.bcaLen); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.pmaLen = {0}", _header.pmaLen); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.atipLen = {0}", _header.atipLen); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.cdtLen = {0}", _header.cdtLen); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.cdInfoLen = {0}", _header.cdInfoLen); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.bcaLen = {0}", _header.bcaLen); - for(int i = 0; i < header.unknown5.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown5[{1}] = 0x{0:X8}", header.unknown5[i], + for(int i = 0; i < _header.unknown5.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown5[{1}] = 0x{0:X8}", _header.unknown5[i], i); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.dvdStrLen = {0}", header.dvdStrLen); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.dvdInfoLen = {0}", header.dvdInfoLen); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.dvdStrLen = {0}", _header.dvdStrLen); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.dvdInfoLen = {0}", _header.dvdInfoLen); - for(int i = 0; i < header.unknown6.Length; i++) - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown6[{1}] = 0x{0:X2}", header.unknown6[i], + for(int i = 0; i < _header.unknown6.Length; i++) + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unknown6[{1}] = 0x{0:X2}", _header.unknown6[i], i); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.manufacturer = {0}", - StringHandlers.CToString(header.manufacturer)); + StringHandlers.CToString(_header.manufacturer)); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.product = {0}", - StringHandlers.CToString(header.product)); + StringHandlers.CToString(_header.product)); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.revision = {0}", - StringHandlers.CToString(header.revision)); + StringHandlers.CToString(_header.revision)); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.vendor = {0}", - StringHandlers.CToString(header.vendor)); + StringHandlers.CToString(_header.vendor)); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.volumeId = {0}", - StringHandlers.CToString(header.volumeId)); + StringHandlers.CToString(_header.volumeId)); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.mode2ALen = {0}", header.mode2ALen); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unkBlkLen = {0}", header.unkBlkLen); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.dataLen = {0}", header.dataLen); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.sessionsLen = {0}", header.sessionsLen); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.dpmLen = {0}", header.dpmLen); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.mode2ALen = {0}", _header.mode2ALen); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.unkBlkLen = {0}", _header.unkBlkLen); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.dataLen = {0}", _header.dataLen); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.sessionsLen = {0}", _header.sessionsLen); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "header.dpmLen = {0}", _header.dpmLen); - mode2A = new byte[header.mode2ALen]; + _mode2A = new byte[_header.mode2ALen]; - if(mode2A.Length > 0) + if(_mode2A.Length > 0) { - stream.Read(mode2A, 0, mode2A.Length); - mode2A[1] -= 2; - var decoded2A = ModePage_2A.Decode(mode2A); + stream.Read(_mode2A, 0, _mode2A.Length); + _mode2A[1] -= 2; + var decoded2A = ModePage_2A.Decode(_mode2A); if(!(decoded2A is null)) AaruConsole.DebugWriteLine("BlindWrite5 plugin", "mode page 2A: {0}", Modes.PrettifyModePage_2A(decoded2A)); else - mode2A = null; + _mode2A = null; } - unkBlock = new byte[header.unkBlkLen]; + _unkBlock = new byte[_header.unkBlkLen]; - if(unkBlock.Length > 0) - stream.Read(unkBlock, 0, unkBlock.Length); + if(_unkBlock.Length > 0) + stream.Read(_unkBlock, 0, _unkBlock.Length); - byte[] temp = new byte[header.pmaLen]; + byte[] temp = new byte[_header.pmaLen]; if(temp.Length > 0) { byte[] tushort = BitConverter.GetBytes((ushort)(temp.Length + 2)); stream.Read(temp, 0, temp.Length); - pma = new byte[temp.Length + 4]; - pma[0] = tushort[1]; - pma[1] = tushort[0]; - Array.Copy(temp, 0, pma, 4, temp.Length); + _pma = new byte[temp.Length + 4]; + _pma[0] = tushort[1]; + _pma[1] = tushort[0]; + Array.Copy(temp, 0, _pma, 4, temp.Length); - PMA.CDPMA? decodedPma = PMA.Decode(pma); + PMA.CDPMA? decodedPma = PMA.Decode(_pma); if(decodedPma.HasValue) AaruConsole.DebugWriteLine("BlindWrite5 plugin", "PMA: {0}", PMA.Prettify(decodedPma)); else - pma = null; + _pma = null; } - atip = new byte[header.atipLen]; + _atip = new byte[_header.atipLen]; - if(atip.Length > 0) - stream.Read(atip, 0, atip.Length); + if(_atip.Length > 0) + stream.Read(_atip, 0, _atip.Length); else - atip = null; + _atip = null; - cdtext = new byte[header.cdtLen]; + _cdtext = new byte[_header.cdtLen]; - if(cdtext.Length > 0) - stream.Read(cdtext, 0, cdtext.Length); + if(_cdtext.Length > 0) + stream.Read(_cdtext, 0, _cdtext.Length); else - cdtext = null; + _cdtext = null; - bca = new byte[header.bcaLen]; + _bca = new byte[_header.bcaLen]; - if(bca.Length > 0) - stream.Read(bca, 0, bca.Length); + if(_bca.Length > 0) + stream.Read(_bca, 0, _bca.Length); else - bca = null; + _bca = null; - temp = new byte[header.dvdStrLen]; + temp = new byte[_header.dvdStrLen]; if(temp.Length > 0) { stream.Read(temp, 0, temp.Length); - dmi = new byte[2052]; - pfi = new byte[2052]; + _dmi = new byte[2052]; + _pfi = new byte[2052]; // TODO: CMI - Array.Copy(temp, 2, dmi, 4, 2048); - Array.Copy(temp, 0x802, pfi, 4, 2048); + Array.Copy(temp, 2, _dmi, 4, 2048); + Array.Copy(temp, 0x802, _pfi, 4, 2048); - pfi[0] = 0x08; - pfi[1] = 0x02; - dmi[0] = 0x08; - dmi[1] = 0x02; + _pfi[0] = 0x08; + _pfi[1] = 0x02; + _dmi[0] = 0x08; + _dmi[1] = 0x02; - PFI.PhysicalFormatInformation? decodedPfi = PFI.Decode(pfi); + PFI.PhysicalFormatInformation? decodedPfi = PFI.Decode(_pfi); if(decodedPfi.HasValue) AaruConsole.DebugWriteLine("BlindWrite5 plugin", "PFI: {0}", PFI.Prettify(decodedPfi)); else { - pfi = null; - dmi = null; + _pfi = null; + _dmi = null; } } - switch(header.profile) + switch(_header.profile) { case ProfileNumber.CDR: case ProfileNumber.CDROM: @@ -226,24 +226,24 @@ namespace Aaru.DiscImages case ProfileNumber.HDBURNROM: case ProfileNumber.HDBURNR: case ProfileNumber.HDBURNRW: - discInformation = new byte[header.cdInfoLen]; + _discInformation = new byte[_header.cdInfoLen]; break; default: - discInformation = new byte[header.dvdInfoLen]; + _discInformation = new byte[_header.dvdInfoLen]; break; } - if(discInformation.Length > 0) + if(_discInformation.Length > 0) { - stream.Read(discInformation, 0, discInformation.Length); + stream.Read(_discInformation, 0, _discInformation.Length); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "Disc information: {0}", - PrintHex.ByteArrayToHexArrayString(discInformation, 40)); + PrintHex.ByteArrayToHexArrayString(_discInformation, 40)); } else - discInformation = null; + _discInformation = null; // How many data blocks byte[] tmpArray = new byte[4]; @@ -254,10 +254,10 @@ namespace Aaru.DiscImages uint dataPathLen = BitConverter.ToUInt32(tmpArray, 0); byte[] dataPathBytes = new byte[dataPathLen]; stream.Read(dataPathBytes, 0, dataPathBytes.Length); - dataPath = Encoding.Unicode.GetString(dataPathBytes); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "Data path: {0}", dataPath); + _dataPath = Encoding.Unicode.GetString(dataPathBytes); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "Data path: {0}", _dataPath); - dataFiles = new List(); + _dataFiles = new List(); for(int cD = 0; cD < dataBlockCount; cD++) { @@ -293,7 +293,7 @@ namespace Aaru.DiscImages dataFile.Unknown3 = BitConverter.ToUInt32(tmpArray, 0); dataFile.Filename = Encoding.Unicode.GetString(dataFile.FilenameBytes); - dataFiles.Add(dataFile); + _dataFiles.Add(dataFile); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "dataFile.type = 0x{0:X8}", dataFile.Type); AaruConsole.DebugWriteLine("BlindWrite5 plugin", "dataFile.length = {0}", dataFile.Length); @@ -315,9 +315,9 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("BlindWrite5 plugin", "dataFile.unknown3 = {0}", dataFile.Unknown3); } - bwSessions = new List(); + _bwSessions = new List(); - for(int ses = 0; ses < header.sessions; ses++) + for(int ses = 0; ses < _header.sessions; ses++) { var session = new Bw5SessionDescriptor(); tmpArray = new byte[16]; @@ -447,11 +447,11 @@ namespace Aaru.DiscImages } } - bwSessions.Add(session); + _bwSessions.Add(session); } - dpm = new byte[header.dpmLen]; - stream.Read(dpm, 0, dpm.Length); + _dpm = new byte[_header.dpmLen]; + stream.Read(_dpm, 0, _dpm.Length); // Unused tmpArray = new byte[4]; @@ -460,18 +460,18 @@ namespace Aaru.DiscImages byte[] footer = new byte[16]; stream.Read(footer, 0, footer.Length); - if(bw5Footer.SequenceEqual(footer)) + if(_bw5Footer.SequenceEqual(footer)) AaruConsole.DebugWriteLine("BlindWrite5 plugin", "Correctly arrived end of image"); else AaruConsole. ErrorWriteLine("BlindWrite5 image ends after expected position. Probably new version with different data. Errors may occur."); - filePaths = new List(); + _filePaths = new List(); - foreach(Bw5DataFile dataFile in dataFiles) + foreach(Bw5DataFile dataFile in _dataFiles) { var chars = new DataFileCharacteristics(); - string path = Path.Combine(dataPath, dataFile.Filename); + string path = Path.Combine(_dataPath, dataFile.Filename); var filtersList = new FiltersList(); if(filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), path)) != null) @@ -481,7 +481,7 @@ namespace Aaru.DiscImages } else { - path = Path.Combine(dataPath, dataFile.Filename.ToLower(CultureInfo.CurrentCulture)); + path = Path.Combine(_dataPath, dataFile.Filename.ToLower(CultureInfo.CurrentCulture)); if(filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), path)) != null) { @@ -490,7 +490,7 @@ namespace Aaru.DiscImages } else { - path = Path.Combine(dataPath, dataFile.Filename.ToUpper(CultureInfo.CurrentCulture)); + path = Path.Combine(_dataPath, dataFile.Filename.ToUpper(CultureInfo.CurrentCulture)); if(filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), path)) != null) { @@ -499,7 +499,7 @@ namespace Aaru.DiscImages } else { - path = Path.Combine(dataPath.ToLower(CultureInfo.CurrentCulture), dataFile.Filename); + path = Path.Combine(_dataPath.ToLower(CultureInfo.CurrentCulture), dataFile.Filename); if(filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), path)) != null) { @@ -510,7 +510,7 @@ namespace Aaru.DiscImages } else { - path = Path.Combine(dataPath.ToUpper(CultureInfo.CurrentCulture), dataFile.Filename); + path = Path.Combine(_dataPath.ToUpper(CultureInfo.CurrentCulture), dataFile.Filename); if(filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), path)) != null) { @@ -521,7 +521,7 @@ namespace Aaru.DiscImages } else { - path = Path.Combine(dataPath, dataFile.Filename); + path = Path.Combine(_dataPath, dataFile.Filename); if(filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), path.ToLower(CultureInfo.CurrentCulture))) != @@ -618,7 +618,7 @@ namespace Aaru.DiscImages chars.Sectors = dataFile.Sectors; chars.Offset = dataFile.Offset; - filePaths.Add(chars); + _filePaths.Add(chars); } Sessions = new List(); @@ -632,16 +632,16 @@ namespace Aaru.DiscImages }, 0, 2); ulong offsetBytes = 0; - offsetmap = new Dictionary(); + _offsetmap = new Dictionary(); bool isDvd = false; byte firstSession = byte.MaxValue; byte lastSession = 0; - trackFlags = new Dictionary(); - imageInfo.Sectors = 0; + _trackFlags = new Dictionary(); + _imageInfo.Sectors = 0; AaruConsole.DebugWriteLine("BlindWrite5 plugin", "Building maps"); - foreach(Bw5SessionDescriptor ses in bwSessions) + foreach(Bw5SessionDescriptor ses in _bwSessions) { // TODO: This does nothing, should it? /* @@ -680,7 +680,7 @@ namespace Aaru.DiscImages var track = new Track(); var partition = new Partition(); - trackFlags.Add(trk.point, trk.ctl); + _trackFlags.Add(trk.point, trk.ctl); switch(trk.type) { @@ -688,80 +688,80 @@ namespace Aaru.DiscImages track.TrackBytesPerSector = 2352; track.TrackRawBytesPerSector = 2352; - if(imageInfo.SectorSize < 2352) - imageInfo.SectorSize = 2352; + if(_imageInfo.SectorSize < 2352) + _imageInfo.SectorSize = 2352; break; case Bw5TrackType.Mode1: case Bw5TrackType.Mode2F1: - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); track.TrackBytesPerSector = 2048; track.TrackRawBytesPerSector = 2352; - if(imageInfo.SectorSize < 2048) - imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) + _imageInfo.SectorSize = 2048; break; case Bw5TrackType.Mode2: - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); track.TrackBytesPerSector = 2336; track.TrackRawBytesPerSector = 2352; - if(imageInfo.SectorSize < 2336) - imageInfo.SectorSize = 2336; + if(_imageInfo.SectorSize < 2336) + _imageInfo.SectorSize = 2336; break; case Bw5TrackType.Mode2F2: - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); track.TrackBytesPerSector = 2336; track.TrackRawBytesPerSector = 2352; - if(imageInfo.SectorSize < 2324) - imageInfo.SectorSize = 2324; + if(_imageInfo.SectorSize < 2324) + _imageInfo.SectorSize = 2324; break; case Bw5TrackType.Dvd: track.TrackBytesPerSector = 2048; track.TrackRawBytesPerSector = 2048; - if(imageInfo.SectorSize < 2048) - imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) + _imageInfo.SectorSize = 2048; isDvd = true; @@ -772,9 +772,9 @@ namespace Aaru.DiscImages track.TrackStartSector = (ulong)(trk.startLba + trk.pregap); track.TrackEndSector = (ulong)(trk.sectors + trk.startLba); - foreach(DataFileCharacteristics chars in filePaths.Where(chars => trk.startLba >= chars.StartLba && - trk.startLba + trk.sectors <= - chars.StartLba + chars.Sectors)) + foreach(DataFileCharacteristics chars in _filePaths.Where(chars => trk.startLba >= chars.StartLba && + trk.startLba + trk.sectors <= + chars.StartLba + chars.Sectors)) { track.TrackFilter = chars.FileFilter; track.TrackFile = chars.FileFilter.GetFilename(); @@ -795,8 +795,8 @@ namespace Aaru.DiscImages track.TrackSubchannelOffset = track.TrackFileOffset; if(chars.Subchannel == TrackSubchannelType.PackedInterleaved) - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); } break; @@ -836,8 +836,8 @@ namespace Aaru.DiscImages Tracks.Add(track); Partitions.Add(partition); - offsetmap.Add(track.TrackSequence, track.TrackStartSector); - imageInfo.Sectors += partition.Length; + _offsetmap.Add(track.TrackSequence, track.TrackStartSector); + _imageInfo.Sectors += partition.Length; } } @@ -877,21 +877,21 @@ namespace Aaru.DiscImages { AaruConsole.DebugWriteLine("BlindWrite5 plugin", "Rebuilding TOC"); - fullToc = fullTocStream.ToArray(); - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "TOC len {0}", fullToc.Length); + _fullToc = fullTocStream.ToArray(); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "TOC len {0}", _fullToc.Length); - fullToc[0] = firstSession; - fullToc[1] = lastSession; + _fullToc[0] = firstSession; + _fullToc[1] = lastSession; - imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); } - imageInfo.MediaType = BlindWriteProfileToMediaType(header.profile); + _imageInfo.MediaType = BlindWriteProfileToMediaType(_header.profile); - if(dmi != null && - pfi != null) + if(_dmi != null && + _pfi != null) { - PFI.PhysicalFormatInformation? pfi0 = PFI.Decode(pfi); + PFI.PhysicalFormatInformation? pfi0 = PFI.Decode(_pfi); // All discs I tested the disk category and part version (as well as the start PSN for DVD-RAM) where modified by Alcohol // So much for archival value @@ -900,71 +900,72 @@ namespace Aaru.DiscImages switch(pfi0.Value.DiskCategory) { case DiskCategory.DVDPR: - imageInfo.MediaType = MediaType.DVDPR; + _imageInfo.MediaType = MediaType.DVDPR; break; case DiskCategory.DVDPRDL: - imageInfo.MediaType = MediaType.DVDPRDL; + _imageInfo.MediaType = MediaType.DVDPRDL; break; case DiskCategory.DVDPRW: - imageInfo.MediaType = MediaType.DVDPRW; + _imageInfo.MediaType = MediaType.DVDPRW; break; case DiskCategory.DVDPRWDL: - imageInfo.MediaType = MediaType.DVDPRWDL; + _imageInfo.MediaType = MediaType.DVDPRWDL; break; case DiskCategory.DVDR: - imageInfo.MediaType = pfi0.Value.PartVersion == 6 ? MediaType.DVDRDL : MediaType.DVDR; + _imageInfo.MediaType = pfi0.Value.PartVersion == 6 ? MediaType.DVDRDL : MediaType.DVDR; break; case DiskCategory.DVDRAM: - imageInfo.MediaType = MediaType.DVDRAM; + _imageInfo.MediaType = MediaType.DVDRAM; break; default: - imageInfo.MediaType = MediaType.DVDROM; + _imageInfo.MediaType = MediaType.DVDROM; break; case DiskCategory.DVDRW: - imageInfo.MediaType = pfi0.Value.PartVersion == 3 ? MediaType.DVDRWDL : MediaType.DVDRW; + _imageInfo.MediaType = pfi0.Value.PartVersion == 3 ? MediaType.DVDRWDL : MediaType.DVDRW; break; case DiskCategory.HDDVDR: - imageInfo.MediaType = MediaType.HDDVDR; + _imageInfo.MediaType = MediaType.HDDVDR; break; case DiskCategory.HDDVDRAM: - imageInfo.MediaType = MediaType.HDDVDRAM; + _imageInfo.MediaType = MediaType.HDDVDRAM; break; case DiskCategory.HDDVDROM: - imageInfo.MediaType = MediaType.HDDVDROM; + _imageInfo.MediaType = MediaType.HDDVDROM; break; case DiskCategory.HDDVDRW: - imageInfo.MediaType = MediaType.HDDVDRW; + _imageInfo.MediaType = MediaType.HDDVDRW; break; case DiskCategory.Nintendo: - imageInfo.MediaType = pfi0.Value.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD; + _imageInfo.MediaType = + pfi0.Value.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD; break; case DiskCategory.UMD: - imageInfo.MediaType = MediaType.UMD; + _imageInfo.MediaType = MediaType.UMD; break; } - if(DMI.IsXbox(dmi)) - imageInfo.MediaType = MediaType.XGD; - else if(DMI.IsXbox360(dmi)) - imageInfo.MediaType = MediaType.XGD2; + if(DMI.IsXbox(_dmi)) + _imageInfo.MediaType = MediaType.XGD; + else if(DMI.IsXbox360(_dmi)) + _imageInfo.MediaType = MediaType.XGD2; } } - else if(imageInfo.MediaType == MediaType.CD || - imageInfo.MediaType == MediaType.CDROM) + else if(_imageInfo.MediaType == MediaType.CD || + _imageInfo.MediaType == MediaType.CDROM) { bool data = false; bool mode2 = false; @@ -999,142 +1000,142 @@ namespace Aaru.DiscImages if(!data && !firstdata) - imageInfo.MediaType = MediaType.CDDA; + _imageInfo.MediaType = MediaType.CDDA; else if(firstaudio && data && Sessions.Count > 1 && mode2) - imageInfo.MediaType = MediaType.CDPLUS; + _imageInfo.MediaType = MediaType.CDPLUS; else if((firstdata && audio) || mode2) - imageInfo.MediaType = MediaType.CDROMXA; + _imageInfo.MediaType = MediaType.CDROMXA; else if(!audio) - imageInfo.MediaType = MediaType.CDROM; + _imageInfo.MediaType = MediaType.CDROM; else - imageInfo.MediaType = MediaType.CD; + _imageInfo.MediaType = MediaType.CD; } - imageInfo.DriveManufacturer = StringHandlers.CToString(header.manufacturer); - imageInfo.DriveModel = StringHandlers.CToString(header.product); - imageInfo.DriveFirmwareRevision = StringHandlers.CToString(header.revision); - imageInfo.Application = "BlindWrite"; + _imageInfo.DriveManufacturer = StringHandlers.CToString(_header.manufacturer); + _imageInfo.DriveModel = StringHandlers.CToString(_header.product); + _imageInfo.DriveFirmwareRevision = StringHandlers.CToString(_header.revision); + _imageInfo.Application = "BlindWrite"; if(string.Compare(Path.GetExtension(imageFilter.GetFilename()), ".B5T", StringComparison.OrdinalIgnoreCase) == 0) - imageInfo.ApplicationVersion = "5"; + _imageInfo.ApplicationVersion = "5"; else if(string.Compare(Path.GetExtension(imageFilter.GetFilename()), ".B6T", StringComparison.OrdinalIgnoreCase) == 0) - imageInfo.ApplicationVersion = "6"; + _imageInfo.ApplicationVersion = "6"; - imageInfo.Version = "5"; + _imageInfo.Version = "5"; - imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; + _imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; - if(pma != null) + if(_pma != null) { - PMA.CDPMA pma0 = PMA.Decode(pma).Value; + PMA.CDPMA pma0 = PMA.Decode(_pma).Value; foreach(uint id in from descriptor in pma0.PMADescriptors where descriptor.ADR == 2 select (uint)((descriptor.Min << 16) + (descriptor.Sec << 8) + descriptor.Frame)) - imageInfo.MediaSerialNumber = $"{id & 0x00FFFFFF:X6}"; + _imageInfo.MediaSerialNumber = $"{id & 0x00FFFFFF:X6}"; } - if(atip != null) + if(_atip != null) { - byte[] atipTmp = new byte[atip.Length + 4]; - Array.Copy(atip, 0, atipTmp, 4, atip.Length); - atipTmp[0] = (byte)((atip.Length & 0xFF00) >> 8); - atipTmp[1] = (byte)(atip.Length & 0xFF); + byte[] atipTmp = new byte[_atip.Length + 4]; + Array.Copy(_atip, 0, atipTmp, 4, _atip.Length); + atipTmp[0] = (byte)((_atip.Length & 0xFF00) >> 8); + atipTmp[1] = (byte)(_atip.Length & 0xFF); ATIP.CDATIP atip0 = ATIP.Decode(atipTmp).Value; - imageInfo.MediaType = atip0.DiscType ? MediaType.CDRW : MediaType.CDR; + _imageInfo.MediaType = atip0.DiscType ? MediaType.CDRW : MediaType.CDR; if(atip0.LeadInStartMin == 97) { int type = atip0.LeadInStartFrame % 10; int frm = atip0.LeadInStartFrame - type; - imageInfo.MediaManufacturer = ATIP.ManufacturerFromATIP(atip0.LeadInStartSec, frm); + _imageInfo.MediaManufacturer = ATIP.ManufacturerFromATIP(atip0.LeadInStartSec, frm); } } bool isBd = false; - if(imageInfo.MediaType == MediaType.BDR || - imageInfo.MediaType == MediaType.BDRE || - imageInfo.MediaType == MediaType.BDROM) + if(_imageInfo.MediaType == MediaType.BDR || + _imageInfo.MediaType == MediaType.BDRE || + _imageInfo.MediaType == MediaType.BDROM) { isDvd = false; isBd = true; } - if(isBd && imageInfo.Sectors > 24438784) - switch(imageInfo.MediaType) + if(isBd && _imageInfo.Sectors > 24438784) + switch(_imageInfo.MediaType) { case MediaType.BDR: - imageInfo.MediaType = MediaType.BDRXL; + _imageInfo.MediaType = MediaType.BDRXL; break; case MediaType.BDRE: - imageInfo.MediaType = MediaType.BDREXL; + _imageInfo.MediaType = MediaType.BDREXL; break; } - AaruConsole.DebugWriteLine("BlindWrite5 plugin", "ImageInfo.mediaType = {0}", imageInfo.MediaType); + AaruConsole.DebugWriteLine("BlindWrite5 plugin", "ImageInfo.mediaType = {0}", _imageInfo.MediaType); - if(mode2A != null) - imageInfo.ReadableMediaTags.Add(MediaTagType.SCSI_MODEPAGE_2A); + if(_mode2A != null) + _imageInfo.ReadableMediaTags.Add(MediaTagType.SCSI_MODEPAGE_2A); - if(pma != null) - imageInfo.ReadableMediaTags.Add(MediaTagType.CD_PMA); + if(_pma != null) + _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_PMA); - if(atip != null) - imageInfo.ReadableMediaTags.Add(MediaTagType.CD_ATIP); + if(_atip != null) + _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_ATIP); - if(cdtext != null) - imageInfo.ReadableMediaTags.Add(MediaTagType.CD_TEXT); + if(_cdtext != null) + _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_TEXT); - if(bca != null) + if(_bca != null) if(isDvd) - imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_BCA); + _imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_BCA); else if(isBd) - imageInfo.ReadableMediaTags.Add(MediaTagType.BD_BCA); + _imageInfo.ReadableMediaTags.Add(MediaTagType.BD_BCA); byte[] tmp; - if(dmi != null) + if(_dmi != null) { tmp = new byte[2048]; - Array.Copy(dmi, 4, tmp, 0, 2048); - dmi = tmp; - imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_DMI); + Array.Copy(_dmi, 4, tmp, 0, 2048); + _dmi = tmp; + _imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_DMI); } - if(pfi != null) + if(_pfi != null) { tmp = new byte[2048]; - Array.Copy(pfi, 4, tmp, 0, 2048); - pfi = tmp; - imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_PFI); + Array.Copy(_pfi, 4, tmp, 0, 2048); + _pfi = tmp; + _imageInfo.ReadableMediaTags.Add(MediaTagType.DVD_PFI); } - if(fullToc != null) - imageInfo.ReadableMediaTags.Add(MediaTagType.CD_FullTOC); + if(_fullToc != null) + _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_FullTOC); - if(imageInfo.MediaType == MediaType.XGD2) - if(imageInfo.Sectors == 25063 || // Locked (or non compatible drive) - imageInfo.Sectors == 4229664 || // Xtreme unlock - imageInfo.Sectors == 4246304) // Wxripper unlock - imageInfo.MediaType = MediaType.XGD3; + if(_imageInfo.MediaType == MediaType.XGD2) + if(_imageInfo.Sectors == 25063 || // Locked (or non compatible drive) + _imageInfo.Sectors == 4229664 || // Xtreme unlock + _imageInfo.Sectors == 4246304) // Wxripper unlock + _imageInfo.MediaType = MediaType.XGD3; - AaruConsole.VerboseWriteLine("BlindWrite image describes a disc of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("BlindWrite image describes a disc of type {0}", _imageInfo.MediaType); - if(header.profile != ProfileNumber.CDR && - header.profile != ProfileNumber.CDRW && - header.profile != ProfileNumber.CDROM) + if(_header.profile != ProfileNumber.CDR && + _header.profile != ProfileNumber.CDRW && + _header.profile != ProfileNumber.CDROM) foreach(Track track in Tracks) { track.TrackPregap = 0; @@ -1150,58 +1151,58 @@ namespace Aaru.DiscImages { case MediaTagType.SCSI_MODEPAGE_2A: { - if(mode2A != null) - return (byte[])mode2A.Clone(); + if(_mode2A != null) + return (byte[])_mode2A.Clone(); throw new FeatureNotPresentImageException("Image does not contain SCSI MODE PAGE 2Ah."); } case MediaTagType.CD_PMA: { - if(pma != null) - return (byte[])pma.Clone(); + if(_pma != null) + return (byte[])_pma.Clone(); throw new FeatureNotPresentImageException("Image does not contain PMA information."); } case MediaTagType.CD_ATIP: { - if(atip != null) - return (byte[])atip.Clone(); + if(_atip != null) + return (byte[])_atip.Clone(); throw new FeatureNotPresentImageException("Image does not contain ATIP information."); } case MediaTagType.CD_TEXT: { - if(cdtext != null) - return (byte[])cdtext.Clone(); + if(_cdtext != null) + return (byte[])_cdtext.Clone(); throw new FeatureNotPresentImageException("Image does not contain CD-Text information."); } case MediaTagType.DVD_BCA: case MediaTagType.BD_BCA: { - if(bca != null) - return (byte[])bca.Clone(); + if(_bca != null) + return (byte[])_bca.Clone(); throw new FeatureNotPresentImageException("Image does not contain BCA information."); } case MediaTagType.DVD_PFI: { - if(pfi != null) - return (byte[])pfi.Clone(); + if(_pfi != null) + return (byte[])_pfi.Clone(); throw new FeatureNotPresentImageException("Image does not contain PFI."); } case MediaTagType.DVD_DMI: { - if(dmi != null) - return (byte[])dmi.Clone(); + if(_dmi != null) + return (byte[])_dmi.Clone(); throw new FeatureNotPresentImageException("Image does not contain DMI."); } case MediaTagType.CD_FullTOC: { - if(fullToc != null) - return (byte[])fullToc.Clone(); + if(_fullToc != null) + return (byte[])_fullToc.Clone(); throw new FeatureNotPresentImageException("Image does not contain TOC information."); } @@ -1221,7 +1222,7 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector select kvp) @@ -1232,7 +1233,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector select kvp) @@ -1262,7 +1263,7 @@ namespace Aaru.DiscImages throw new ArgumentOutOfRangeException(nameof(length), $"Requested more sectors ({length + sectorAddress}) than present in track ({aaruTrack.TrackEndSector}), won't cross tracks"); - DataFileCharacteristics chars = (from characteristics in filePaths let firstSector = + DataFileCharacteristics chars = (from characteristics in _filePaths let firstSector = characteristics.StartLba let lastSector = (firstSector + characteristics.Sectors) - 1 let wantedSector = (int)(sectorAddress + aaruTrack.TrackStartSector) @@ -1337,8 +1338,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = chars.FileFilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = chars.FileFilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)aaruTrack.TrackFileOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), @@ -1396,7 +1397,7 @@ namespace Aaru.DiscImages throw new ArgumentOutOfRangeException(nameof(length), $"Requested more sectors ({length + sectorAddress}) than present in track ({aaruTrack.TrackEndSector}), won't cross tracks"); - DataFileCharacteristics chars = (from characteristics in filePaths let firstSector = + DataFileCharacteristics chars = (from characteristics in _filePaths let firstSector = characteristics.StartLba let lastSector = (firstSector + characteristics.Sectors) - 1 let wantedSector = (int)(sectorAddress + aaruTrack.TrackStartSector) @@ -1421,7 +1422,7 @@ namespace Aaru.DiscImages case SectorTagType.CdSectorSubHeader: case SectorTagType.CdSectorSync: break; case SectorTagType.CdTrackFlags: - if(trackFlags.TryGetValue((uint)sectorAddress, out byte flag)) + if(_trackFlags.TryGetValue((uint)sectorAddress, out byte flag)) return new[] { flag @@ -1769,8 +1770,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = aaruTrack.TrackFilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = aaruTrack.TrackFilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)aaruTrack.TrackFileOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), @@ -1805,7 +1806,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector select kvp) @@ -1835,7 +1836,7 @@ namespace Aaru.DiscImages throw new ArgumentOutOfRangeException(nameof(length), $"Requested more sectors ({length + sectorAddress}) than present in track ({aaruTrack.TrackEndSector}), won't cross tracks"); - DataFileCharacteristics chars = (from characteristics in filePaths let firstSector = + DataFileCharacteristics chars = (from characteristics in _filePaths let firstSector = characteristics.StartLba let lastSector = (firstSector + characteristics.Sectors) - 1 let wantedSector = (int)(sectorAddress + aaruTrack.TrackStartSector) @@ -1894,8 +1895,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = aaruTrack.TrackFilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = aaruTrack.TrackFilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)aaruTrack.TrackFileOffset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), diff --git a/Aaru.Images/CDRDAO/CDRDAO.cs b/Aaru.Images/CDRDAO/CDRDAO.cs index ae2449dfa..48e23d376 100644 --- a/Aaru.Images/CDRDAO/CDRDAO.cs +++ b/Aaru.Images/CDRDAO/CDRDAO.cs @@ -43,23 +43,23 @@ namespace Aaru.DiscImages // TODO: Doesn't support silences that are not in files public partial class Cdrdao : IWritableOpticalImage { - SectorBuilder _sectorBuilder; - IFilter cdrdaoFilter; - StreamWriter descriptorStream; - CdrdaoDisc discimage; - ImageInfo imageInfo; - Stream imageStream; + IFilter _cdrdaoFilter; + StreamWriter _descriptorStream; + CdrdaoDisc _discimage; + ImageInfo _imageInfo; + Stream _imageStream; /// Dictionary, index is track #, value is TrackFile - Dictionary offsetmap; - bool separateTracksWriting; - StreamReader tocStream; - Dictionary trackFlags; - Dictionary trackIsrcs; - string writingBaseName; - Dictionary writingStreams; - List writingTracks; + Dictionary _offsetmap; + SectorBuilder _sectorBuilder; + bool _separateTracksWriting; + StreamReader _tocStream; + Dictionary _trackFlags; + Dictionary _trackIsrcs; + string _writingBaseName; + Dictionary _writingStreams; + List _writingTracks; - public Cdrdao() => imageInfo = new ImageInfo + public Cdrdao() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/CDRDAO/Identify.cs b/Aaru.Images/CDRDAO/Identify.cs index 9b33aee0d..e75d4b86e 100644 --- a/Aaru.Images/CDRDAO/Identify.cs +++ b/Aaru.Images/CDRDAO/Identify.cs @@ -74,14 +74,14 @@ namespace Aaru.DiscImages return false; } - tocStream = new StreamReader(imageFilter.GetDataForkStream()); + _tocStream = new StreamReader(imageFilter.GetDataForkStream()); var cr = new Regex(REGEX_COMMENT); var dr = new Regex(REGEX_DISCTYPE); - while(tocStream.Peek() >= 0) + while(_tocStream.Peek() >= 0) { - string line = tocStream.ReadLine(); + string line = _tocStream.ReadLine(); Match dm = dr.Match(line ?? throw new InvalidOperationException()); Match cm = cr.Match(line); @@ -97,7 +97,7 @@ namespace Aaru.DiscImages } catch(Exception ex) { - AaruConsole.ErrorWriteLine("Exception trying to identify image file {0}", cdrdaoFilter.GetFilename()); + AaruConsole.ErrorWriteLine("Exception trying to identify image file {0}", _cdrdaoFilter.GetFilename()); AaruConsole.ErrorWriteLine("Exception: {0}", ex.Message); AaruConsole.ErrorWriteLine("Stack trace: {0}", ex.StackTrace); diff --git a/Aaru.Images/CDRDAO/Properties.cs b/Aaru.Images/CDRDAO/Properties.cs index b62442412..b4625df20 100644 --- a/Aaru.Images/CDRDAO/Properties.cs +++ b/Aaru.Images/CDRDAO/Properties.cs @@ -52,7 +52,7 @@ namespace Aaru.DiscImages OpticalImageCapabilities.CanStoreCookedData | OpticalImageCapabilities.CanStoreMultipleTracks | OpticalImageCapabilities.CanStoreIndexes; - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "CDRDAO tocfile"; public Guid Id => new Guid("04D7BA12-1BE8-44D4-97A4-1B48A505463E"); public string Format => "CDRDAO tocfile"; @@ -66,7 +66,7 @@ namespace Aaru.DiscImages { List tracks = new List(); - foreach(CdrdaoTrack cdrTrack in discimage.Tracks) + foreach(CdrdaoTrack cdrTrack in _discimage.Tracks) { var aaruTrack = new Track { diff --git a/Aaru.Images/CDRDAO/Read.cs b/Aaru.Images/CDRDAO/Read.cs index 2b01b3451..242edb911 100644 --- a/Aaru.Images/CDRDAO/Read.cs +++ b/Aaru.Images/CDRDAO/Read.cs @@ -54,12 +54,12 @@ namespace Aaru.DiscImages if(imageFilter == null) return false; - cdrdaoFilter = imageFilter; + _cdrdaoFilter = imageFilter; try { imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); - tocStream = new StreamReader(imageFilter.GetDataForkStream()); + _tocStream = new StreamReader(imageFilter.GetDataForkStream()); bool intrack = false; // Initialize all RegExs @@ -97,7 +97,7 @@ namespace Aaru.DiscImages Match matchDiskType; // Initialize disc - discimage = new CdrdaoDisc + _discimage = new CdrdaoDisc { Tracks = new List(), Comment = "" @@ -111,14 +111,14 @@ namespace Aaru.DiscImages int nextindex = 2; var commentBuilder = new StringBuilder(); - tocStream = new StreamReader(cdrdaoFilter.GetDataForkStream()); + _tocStream = new StreamReader(_cdrdaoFilter.GetDataForkStream()); string line; int lineNumber = 0; - while(tocStream.Peek() >= 0) + while(_tocStream.Peek() >= 0) { lineNumber++; - line = tocStream.ReadLine(); + line = _tocStream.ReadLine(); matchDiskType = regexDiskType.Match(line ?? throw new InvalidOperationException()); matchComment = regexComment.Match(line); @@ -138,15 +138,15 @@ namespace Aaru.DiscImages break; } - tocStream = new StreamReader(cdrdaoFilter.GetDataForkStream()); + _tocStream = new StreamReader(_cdrdaoFilter.GetDataForkStream()); lineNumber = 0; - tocStream.BaseStream.Position = 0; + _tocStream.BaseStream.Position = 0; - while(tocStream.Peek() >= 0) + while(_tocStream.Peek() >= 0) { lineNumber++; - line = tocStream.ReadLine(); + line = _tocStream.ReadLine(); matchComment = regexComment.Match(line ?? throw new InvalidOperationException()); matchDiskType = regexDiskType.Match(line); @@ -193,28 +193,28 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CDRDAO plugin", "Found {1} at line {0}", lineNumber, matchDiskType.Groups["type"].Value); - discimage.Disktypestr = matchDiskType.Groups["type"].Value; + _discimage.Disktypestr = matchDiskType.Groups["type"].Value; switch(matchDiskType.Groups["type"].Value) { case "CD_DA": - discimage.Disktype = MediaType.CDDA; + _discimage.Disktype = MediaType.CDDA; break; case "CD_ROM": - discimage.Disktype = MediaType.CDROM; + _discimage.Disktype = MediaType.CDROM; break; case "CD_ROM_XA": - discimage.Disktype = MediaType.CDROMXA; + _discimage.Disktype = MediaType.CDROMXA; break; case "CD_I": - discimage.Disktype = MediaType.CDI; + _discimage.Disktype = MediaType.CDI; break; default: - discimage.Disktype = MediaType.CD; + _discimage.Disktype = MediaType.CD; break; } @@ -224,7 +224,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CDRDAO plugin", "Found CATALOG \"{1}\" at line {0}", lineNumber, matchMcn.Groups["catalog"].Value); - discimage.Mcn = matchMcn.Groups["catalog"].Value; + _discimage.Mcn = matchMcn.Groups["catalog"].Value; } else if(matchTrack.Success) { @@ -246,7 +246,7 @@ namespace Aaru.DiscImages !currenttrack.Indexes.ContainsKey(1)) currenttrack.Indexes.Add(1, currenttrack.StartSector + currenttrack.Pregap); - discimage.Tracks.Add(currenttrack); + _discimage.Tracks.Add(currenttrack); currenttrack = new CdrdaoTrack { @@ -471,7 +471,7 @@ namespace Aaru.DiscImages if(intrack) currenttrack.Title = matchTitle.Groups["title"].Value; else - discimage.Title = matchTitle.Groups["title"].Value; + _discimage.Title = matchTitle.Groups["title"].Value; } else if(matchPerformer.Success) { @@ -481,7 +481,7 @@ namespace Aaru.DiscImages if(intrack) currenttrack.Performer = matchPerformer.Groups["performer"].Value; else - discimage.Performer = matchPerformer.Groups["performer"].Value; + _discimage.Performer = matchPerformer.Groups["performer"].Value; } else if(matchSongwriter.Success) { @@ -491,7 +491,7 @@ namespace Aaru.DiscImages if(intrack) currenttrack.Songwriter = matchSongwriter.Groups["songwriter"].Value; else - discimage.Songwriter = matchSongwriter.Groups["songwriter"].Value; + _discimage.Songwriter = matchSongwriter.Groups["songwriter"].Value; } else if(matchComposer.Success) { @@ -501,7 +501,7 @@ namespace Aaru.DiscImages if(intrack) currenttrack.Composer = matchComposer.Groups["composer"].Value; else - discimage.Composer = matchComposer.Groups["composer"].Value; + _discimage.Composer = matchComposer.Groups["composer"].Value; } else if(matchArranger.Success) { @@ -511,7 +511,7 @@ namespace Aaru.DiscImages if(intrack) currenttrack.Arranger = matchArranger.Groups["arranger"].Value; else - discimage.Arranger = matchArranger.Groups["arranger"].Value; + _discimage.Arranger = matchArranger.Groups["arranger"].Value; } else if(matchMessage.Success) { @@ -521,7 +521,7 @@ namespace Aaru.DiscImages if(intrack) currenttrack.Message = matchMessage.Groups["message"].Value; else - discimage.Message = matchMessage.Groups["message"].Value; + _discimage.Message = matchMessage.Groups["message"].Value; } else if(matchDiscId.Success) { @@ -529,7 +529,7 @@ namespace Aaru.DiscImages matchDiscId.Groups["discid"].Value); if(!intrack) - discimage.DiskId = matchDiscId.Groups["discid"].Value; + _discimage.DiskId = matchDiscId.Groups["discid"].Value; } else if(matchUpc.Success) { @@ -537,7 +537,7 @@ namespace Aaru.DiscImages matchUpc.Groups["catalog"].Value); if(!intrack) - discimage.Barcode = matchUpc.Groups["catalog"].Value; + _discimage.Barcode = matchUpc.Groups["catalog"].Value; } // Ignored fields @@ -565,176 +565,176 @@ namespace Aaru.DiscImages !currenttrack.Indexes.ContainsKey(1)) currenttrack.Indexes.Add(1, currenttrack.StartSector + currenttrack.Pregap); - discimage.Tracks.Add(currenttrack); + _discimage.Tracks.Add(currenttrack); } - discimage.Comment = commentBuilder.ToString(); + _discimage.Comment = commentBuilder.ToString(); // DEBUG information AaruConsole.DebugWriteLine("CDRDAO plugin", "Disc image parsing results"); AaruConsole.DebugWriteLine("CDRDAO plugin", "Disc CD-TEXT:"); - if(discimage.Arranger == null) + if(_discimage.Arranger == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\tArranger is not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\tArranger: {0}", discimage.Arranger); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\tArranger: {0}", _discimage.Arranger); - if(discimage.Composer == null) + if(_discimage.Composer == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\tComposer is not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\tComposer: {0}", discimage.Composer); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\tComposer: {0}", _discimage.Composer); - if(discimage.Performer == null) + if(_discimage.Performer == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\tPerformer is not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\tPerformer: {0}", discimage.Performer); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\tPerformer: {0}", _discimage.Performer); - if(discimage.Songwriter == null) + if(_discimage.Songwriter == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\tSongwriter is not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\tSongwriter: {0}", discimage.Songwriter); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\tSongwriter: {0}", _discimage.Songwriter); - if(discimage.Title == null) + if(_discimage.Title == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\tTitle is not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\tTitle: {0}", discimage.Title); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\tTitle: {0}", _discimage.Title); AaruConsole.DebugWriteLine("CDRDAO plugin", "Disc information:"); - AaruConsole.DebugWriteLine("CDRDAO plugin", "\tGuessed disk type: {0}", discimage.Disktype); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\tGuessed disk type: {0}", _discimage.Disktype); - if(discimage.Barcode == null) + if(_discimage.Barcode == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\tBarcode not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\tBarcode: {0}", discimage.Barcode); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\tBarcode: {0}", _discimage.Barcode); - if(discimage.DiskId == null) + if(_discimage.DiskId == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\tDisc ID not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\tDisc ID: {0}", discimage.DiskId); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\tDisc ID: {0}", _discimage.DiskId); - if(discimage.Mcn == null) + if(_discimage.Mcn == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\tMCN not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\tMCN: {0}", discimage.Mcn); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\tMCN: {0}", _discimage.Mcn); - if(string.IsNullOrEmpty(discimage.Comment)) + if(string.IsNullOrEmpty(_discimage.Comment)) AaruConsole.DebugWriteLine("CDRDAO plugin", "\tComment not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\tComment: \"{0}\"", discimage.Comment); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\tComment: \"{0}\"", _discimage.Comment); AaruConsole.DebugWriteLine("CDRDAO plugin", "Track information:"); - AaruConsole.DebugWriteLine("CDRDAO plugin", "\tDisc contains {0} tracks", discimage.Tracks.Count); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\tDisc contains {0} tracks", _discimage.Tracks.Count); - for(int i = 0; i < discimage.Tracks.Count; i++) + for(int i = 0; i < _discimage.Tracks.Count; i++) { AaruConsole.DebugWriteLine("CDRDAO plugin", "\tTrack {0} information:", - discimage.Tracks[i].Sequence); + _discimage.Tracks[i].Sequence); - AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\t{0} bytes per sector", discimage.Tracks[i].Bps); - AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tPregap: {0} sectors", discimage.Tracks[i].Pregap); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\t{0} bytes per sector", _discimage.Tracks[i].Bps); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tPregap: {0} sectors", _discimage.Tracks[i].Pregap); AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tData: {0} sectors starting at sector {1}", - discimage.Tracks[i].Sectors, discimage.Tracks[i].StartSector); + _discimage.Tracks[i].Sectors, _discimage.Tracks[i].StartSector); AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tPostgap: {0} sectors", - discimage.Tracks[i].Postgap); + _discimage.Tracks[i].Postgap); - if(discimage.Tracks[i].Flag_4Ch) + if(_discimage.Tracks[i].Flag_4Ch) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tTrack is flagged as quadraphonic"); - if(discimage.Tracks[i].FlagDcp) + if(_discimage.Tracks[i].FlagDcp) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tTrack allows digital copy"); - if(discimage.Tracks[i].FlagPre) + if(_discimage.Tracks[i].FlagPre) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tTrack has pre-emphasis applied"); AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tTrack resides in file {0}, type defined as {1}, starting at byte {2}", - discimage.Tracks[i].Trackfile.Datafilter.GetFilename(), - discimage.Tracks[i].Trackfile.Filetype, - discimage.Tracks[i].Trackfile.Offset); + _discimage.Tracks[i].Trackfile.Datafilter.GetFilename(), + _discimage.Tracks[i].Trackfile.Filetype, + _discimage.Tracks[i].Trackfile.Offset); AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tIndexes:"); - foreach(KeyValuePair kvp in discimage.Tracks[i].Indexes) + foreach(KeyValuePair kvp in _discimage.Tracks[i].Indexes) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\t\tIndex {0} starts at sector {1}", kvp.Key, kvp.Value); - if(discimage.Tracks[i].Isrc == null) + if(_discimage.Tracks[i].Isrc == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tISRC is not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tISRC: {0}", discimage.Tracks[i].Isrc); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tISRC: {0}", _discimage.Tracks[i].Isrc); - if(discimage.Tracks[i].Arranger == null) + if(_discimage.Tracks[i].Arranger == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tArranger is not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tArranger: {0}", discimage.Tracks[i].Arranger); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tArranger: {0}", _discimage.Tracks[i].Arranger); - if(discimage.Tracks[i].Composer == null) + if(_discimage.Tracks[i].Composer == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tComposer is not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tComposer: {0}", discimage.Tracks[i].Composer); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tComposer: {0}", _discimage.Tracks[i].Composer); - if(discimage.Tracks[i].Performer == null) + if(_discimage.Tracks[i].Performer == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tPerformer is not set."); else AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tPerformer: {0}", - discimage.Tracks[i].Performer); + _discimage.Tracks[i].Performer); - if(discimage.Tracks[i].Songwriter == null) + if(_discimage.Tracks[i].Songwriter == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tSongwriter is not set."); else AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tSongwriter: {0}", - discimage.Tracks[i].Songwriter); + _discimage.Tracks[i].Songwriter); - if(discimage.Tracks[i].Title == null) + if(_discimage.Tracks[i].Title == null) AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tTitle is not set."); else - AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tTitle: {0}", discimage.Tracks[i].Title); + AaruConsole.DebugWriteLine("CDRDAO plugin", "\t\tTitle: {0}", _discimage.Tracks[i].Title); } AaruConsole.DebugWriteLine("CDRDAO plugin", "Building offset map"); Partitions = new List(); - offsetmap = new Dictionary(); + _offsetmap = new Dictionary(); ulong byteOffset = 0; ulong partitionSequence = 0; - for(int i = 0; i < discimage.Tracks.Count; i++) + for(int i = 0; i < _discimage.Tracks.Count; i++) { ulong index0Len = 0; - if(discimage.Tracks[i].Sequence == 1 && - i != 0) + if(_discimage.Tracks[i].Sequence == 1 && + i != 0) throw new ImageNotSupportedException("Unordered tracks"); // Index 01 var partition = new Partition { - Description = $"Track {discimage.Tracks[i].Sequence}.", - Name = discimage.Tracks[i].Title, - Start = discimage.Tracks[i].StartSector, - Size = (discimage.Tracks[i].Sectors - index0Len) * discimage.Tracks[i].Bps, - Length = discimage.Tracks[i].Sectors - index0Len, + Description = $"Track {_discimage.Tracks[i].Sequence}.", + Name = _discimage.Tracks[i].Title, + Start = _discimage.Tracks[i].StartSector, + Size = (_discimage.Tracks[i].Sectors - index0Len) * _discimage.Tracks[i].Bps, + Length = _discimage.Tracks[i].Sectors - index0Len, Sequence = partitionSequence, Offset = byteOffset, - Type = discimage.Tracks[i].Tracktype + Type = _discimage.Tracks[i].Tracktype }; byteOffset += partition.Size; partitionSequence++; - if(!offsetmap.ContainsKey(discimage.Tracks[i].Sequence)) - offsetmap.Add(discimage.Tracks[i].Sequence, partition.Start); + if(!_offsetmap.ContainsKey(_discimage.Tracks[i].Sequence)) + _offsetmap.Add(_discimage.Tracks[i].Sequence, partition.Start); else { - offsetmap.TryGetValue(discimage.Tracks[i].Sequence, out ulong oldStart); + _offsetmap.TryGetValue(_discimage.Tracks[i].Sequence, out ulong oldStart); if(partition.Start < oldStart) { - offsetmap.Remove(discimage.Tracks[i].Sequence); - offsetmap.Add(discimage.Tracks[i].Sequence, partition.Start); + _offsetmap.Remove(_discimage.Tracks[i].Sequence); + _offsetmap.Add(_discimage.Tracks[i].Sequence, partition.Start); } } @@ -756,114 +756,114 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CDRDAO plugin", "\tPartition size in bytes: {0}", partition.Size); } - foreach(CdrdaoTrack track in discimage.Tracks) + foreach(CdrdaoTrack track in _discimage.Tracks) { - imageInfo.ImageSize += track.Bps * track.Sectors; - imageInfo.Sectors += track.Sectors; + _imageInfo.ImageSize += track.Bps * track.Sectors; + _imageInfo.Sectors += track.Sectors; } - if(discimage.Disktype != MediaType.CDG && - discimage.Disktype != MediaType.CDEG && - discimage.Disktype != MediaType.CDMIDI && - discimage.Disktype != MediaType.CDROMXA && - discimage.Disktype != MediaType.CDDA && - discimage.Disktype != MediaType.CDI && - discimage.Disktype != MediaType.CDPLUS) - imageInfo.SectorSize = 2048; // Only data tracks + if(_discimage.Disktype != MediaType.CDG && + _discimage.Disktype != MediaType.CDEG && + _discimage.Disktype != MediaType.CDMIDI && + _discimage.Disktype != MediaType.CDROMXA && + _discimage.Disktype != MediaType.CDDA && + _discimage.Disktype != MediaType.CDI && + _discimage.Disktype != MediaType.CDPLUS) + _imageInfo.SectorSize = 2048; // Only data tracks else - imageInfo.SectorSize = 2352; // All others + _imageInfo.SectorSize = 2352; // All others - if(discimage.Mcn != null) - imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); + if(_discimage.Mcn != null) + _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); - imageInfo.Application = "CDRDAO"; + _imageInfo.Application = "CDRDAO"; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.Comments = discimage.Comment; - imageInfo.MediaSerialNumber = discimage.Mcn; - imageInfo.MediaBarcode = discimage.Barcode; - imageInfo.MediaType = discimage.Disktype; + _imageInfo.Comments = _discimage.Comment; + _imageInfo.MediaSerialNumber = _discimage.Mcn; + _imageInfo.MediaBarcode = _discimage.Barcode; + _imageInfo.MediaType = _discimage.Disktype; - imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); - foreach(CdrdaoTrack track in discimage.Tracks) + foreach(CdrdaoTrack track in _discimage.Tracks) { if(track.Subchannel) - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); switch(track.Tracktype) { case CDRDAO_TRACK_TYPE_AUDIO: { - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc); break; } case CDRDAO_TRACK_TYPE_MODE2: case CDRDAO_TRACK_TYPE_MODE2_MIX: { - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); break; } case CDRDAO_TRACK_TYPE_MODE2_RAW: { - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); break; } case CDRDAO_TRACK_TYPE_MODE1_RAW: { - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); break; } } } - imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; + _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; - AaruConsole.VerboseWriteLine("CDRDAO image describes a disc of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("CDRDAO image describes a disc of type {0}", _imageInfo.MediaType); - if(!string.IsNullOrEmpty(imageInfo.Comments)) - AaruConsole.VerboseWriteLine("CDRDAO comments: {0}", imageInfo.Comments); + if(!string.IsNullOrEmpty(_imageInfo.Comments)) + AaruConsole.VerboseWriteLine("CDRDAO comments: {0}", _imageInfo.Comments); _sectorBuilder = new SectorBuilder(); @@ -885,8 +885,8 @@ namespace Aaru.DiscImages { case MediaTagType.CD_MCN: { - if(discimage.Mcn != null) - return Encoding.ASCII.GetBytes(discimage.Mcn); + if(_discimage.Mcn != null) + return Encoding.ASCII.GetBytes(_discimage.Mcn); throw new FeatureNotPresentImageException("Image does not contain MCN information."); } @@ -906,8 +906,8 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value - from cdrdaoTrack in discimage.Tracks + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value + from cdrdaoTrack in _discimage.Tracks where cdrdaoTrack.Sequence == kvp.Key where sectorAddress - kvp.Value < cdrdaoTrack.Sectors select kvp) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); @@ -917,8 +917,8 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value - from cdrdaoTrack in discimage.Tracks + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value + from cdrdaoTrack in _discimage.Tracks where cdrdaoTrack.Sequence == kvp.Key where sectorAddress - kvp.Value < cdrdaoTrack.Sectors select kvp) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); @@ -933,7 +933,7 @@ namespace Aaru.DiscImages Sequence = 0 }; - foreach(CdrdaoTrack cdrdaoTrack in discimage.Tracks.Where(cdrdaoTrack => cdrdaoTrack.Sequence == track)) + foreach(CdrdaoTrack cdrdaoTrack in _discimage.Tracks.Where(cdrdaoTrack => cdrdaoTrack.Sequence == track)) { aaruTrack = cdrdaoTrack; @@ -1014,8 +1014,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = aaruTrack.Trackfile.Datafilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = aaruTrack.Trackfile.Datafilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)aaruTrack.Trackfile.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), @@ -1075,7 +1075,7 @@ namespace Aaru.DiscImages Sequence = 0 }; - foreach(CdrdaoTrack cdrdaoTrack in discimage.Tracks.Where(cdrdaoTrack => cdrdaoTrack.Sequence == track)) + foreach(CdrdaoTrack cdrdaoTrack in _discimage.Tracks.Where(cdrdaoTrack => cdrdaoTrack.Sequence == track)) { aaruTrack = cdrdaoTrack; @@ -1243,8 +1243,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = aaruTrack.Trackfile.Datafilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = aaruTrack.Trackfile.Datafilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)aaruTrack.Trackfile.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), @@ -1271,8 +1271,8 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value - from cdrdaoTrack in discimage.Tracks + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value + from cdrdaoTrack in _discimage.Tracks where cdrdaoTrack.Sequence == kvp.Key where sectorAddress - kvp.Value < cdrdaoTrack.Sectors select kvp) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); @@ -1287,7 +1287,7 @@ namespace Aaru.DiscImages Sequence = 0 }; - foreach(CdrdaoTrack cdrdaoTrack in discimage.Tracks.Where(cdrdaoTrack => cdrdaoTrack.Sequence == track)) + foreach(CdrdaoTrack cdrdaoTrack in _discimage.Tracks.Where(cdrdaoTrack => cdrdaoTrack.Sequence == track)) { aaruTrack = cdrdaoTrack; @@ -1351,8 +1351,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = aaruTrack.Trackfile.Datafilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = aaruTrack.Trackfile.Datafilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)aaruTrack.Trackfile.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), diff --git a/Aaru.Images/CDRDAO/Write.cs b/Aaru.Images/CDRDAO/Write.cs index 0ee8564a0..d2170fecc 100644 --- a/Aaru.Images/CDRDAO/Write.cs +++ b/Aaru.Images/CDRDAO/Write.cs @@ -52,14 +52,14 @@ namespace Aaru.DiscImages { if(options.TryGetValue("separate", out string tmpValue)) { - if(!bool.TryParse(tmpValue, out separateTracksWriting)) + if(!bool.TryParse(tmpValue, out _separateTracksWriting)) { ErrorMessage = "Invalid value for split option"; return false; } - if(separateTracksWriting) + if(_separateTracksWriting) { ErrorMessage = "Separate tracksnot yet implemented"; @@ -68,7 +68,7 @@ namespace Aaru.DiscImages } } else - separateTracksWriting = false; + _separateTracksWriting = false; if(!SupportedMediaTypes.Contains(mediaType)) { @@ -77,7 +77,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -87,8 +87,8 @@ namespace Aaru.DiscImages // TODO: Separate tracks try { - writingBaseName = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)); - descriptorStream = new StreamWriter(path, false, Encoding.ASCII); + _writingBaseName = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)); + _descriptorStream = new StreamWriter(path, false, Encoding.ASCII); } catch(IOException e) { @@ -97,14 +97,14 @@ namespace Aaru.DiscImages return false; } - discimage = new CdrdaoDisc + _discimage = new CdrdaoDisc { Disktype = mediaType, Tracks = new List() }; - trackFlags = new Dictionary(); - trackIsrcs = new Dictionary(); + _trackFlags = new Dictionary(); + _trackIsrcs = new Dictionary(); IsWriting = true; ErrorMessage = null; @@ -124,7 +124,7 @@ namespace Aaru.DiscImages switch(tag) { case MediaTagType.CD_MCN: - discimage.Mcn = Encoding.ASCII.GetString(data); + _discimage.Mcn = Encoding.ASCII.GetString(data); return true; default: @@ -144,8 +144,8 @@ namespace Aaru.DiscImages } Track track = - writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && - sectorAddress <= trk.TrackEndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && + sectorAddress <= trk.TrackEndSector); if(track is null) { @@ -154,7 +154,7 @@ namespace Aaru.DiscImages return false; } - FileStream trackStream = writingStreams.FirstOrDefault(kvp => kvp.Key == track.TrackSequence).Value; + FileStream trackStream = _writingStreams.FirstOrDefault(kvp => kvp.Key == track.TrackSequence).Value; if(trackStream == null) { @@ -210,8 +210,8 @@ namespace Aaru.DiscImages } Track track = - writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && - sectorAddress <= trk.TrackEndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && + sectorAddress <= trk.TrackEndSector); if(track is null) { @@ -220,7 +220,7 @@ namespace Aaru.DiscImages return false; } - FileStream trackStream = writingStreams.FirstOrDefault(kvp => kvp.Key == track.TrackSequence).Value; + FileStream trackStream = _writingStreams.FirstOrDefault(kvp => kvp.Key == track.TrackSequence).Value; if(trackStream == null) { @@ -308,8 +308,8 @@ namespace Aaru.DiscImages } Track track = - writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && - sectorAddress <= trk.TrackEndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && + sectorAddress <= trk.TrackEndSector); if(track is null) { @@ -318,7 +318,7 @@ namespace Aaru.DiscImages return false; } - FileStream trackStream = writingStreams.FirstOrDefault(kvp => kvp.Key == track.TrackSequence).Value; + FileStream trackStream = _writingStreams.FirstOrDefault(kvp => kvp.Key == track.TrackSequence).Value; if(trackStream == null) { @@ -369,8 +369,8 @@ namespace Aaru.DiscImages } Track track = - writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && - sectorAddress <= trk.TrackEndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && + sectorAddress <= trk.TrackEndSector); if(track is null) { @@ -379,7 +379,7 @@ namespace Aaru.DiscImages return false; } - FileStream trackStream = writingStreams.FirstOrDefault(kvp => kvp.Key == track.TrackSequence).Value; + FileStream trackStream = _writingStreams.FirstOrDefault(kvp => kvp.Key == track.TrackSequence).Value; if(trackStream == null) { @@ -447,13 +447,13 @@ namespace Aaru.DiscImages return false; } - if(writingTracks != null && - writingStreams != null) - foreach(FileStream oldTrack in writingStreams.Select(t => t.Value).Distinct()) + if(_writingTracks != null && + _writingStreams != null) + foreach(FileStream oldTrack in _writingStreams.Select(t => t.Value).Distinct()) oldTrack.Close(); ulong currentOffset = 0; - writingTracks = new List(); + _writingTracks = new List(); foreach(Track track in tracks.OrderBy(t => t.TrackSequence)) { @@ -468,11 +468,11 @@ namespace Aaru.DiscImages Track newTrack = track; - newTrack.TrackFile = separateTracksWriting ? writingBaseName + $"_track{track.TrackSequence:D2}.bin" - : writingBaseName + ".bin"; + newTrack.TrackFile = _separateTracksWriting ? _writingBaseName + $"_track{track.TrackSequence:D2}.bin" + : _writingBaseName + ".bin"; - newTrack.TrackFileOffset = separateTracksWriting ? 0 : currentOffset; - writingTracks.Add(newTrack); + newTrack.TrackFileOffset = _separateTracksWriting ? 0 : currentOffset; + _writingTracks.Add(newTrack); currentOffset += (ulong)newTrack.TrackRawBytesPerSector * ((newTrack.TrackEndSector - newTrack.TrackStartSector) + 1); @@ -481,20 +481,20 @@ namespace Aaru.DiscImages currentOffset += 96 * ((newTrack.TrackEndSector - newTrack.TrackStartSector) + 1); } - writingStreams = new Dictionary(); + _writingStreams = new Dictionary(); - if(separateTracksWriting) - foreach(Track track in writingTracks) - writingStreams.Add(track.TrackSequence, - new FileStream(track.TrackFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, - FileShare.None)); + if(_separateTracksWriting) + foreach(Track track in _writingTracks) + _writingStreams.Add(track.TrackSequence, + new FileStream(track.TrackFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, + FileShare.None)); else { - var jointstream = new FileStream(writingBaseName + ".bin", FileMode.OpenOrCreate, FileAccess.ReadWrite, + var jointstream = new FileStream(_writingBaseName + ".bin", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); - foreach(Track track in writingTracks) - writingStreams.Add(track.TrackSequence, jointstream); + foreach(Track track in _writingTracks) + _writingStreams.Add(track.TrackSequence, jointstream); } return true; @@ -509,51 +509,51 @@ namespace Aaru.DiscImages return false; } - if(separateTracksWriting) - foreach(FileStream writingStream in writingStreams.Values) + if(_separateTracksWriting) + foreach(FileStream writingStream in _writingStreams.Values) { writingStream.Flush(); writingStream.Close(); } else { - writingStreams.First().Value.Flush(); - writingStreams.First().Value.Close(); + _writingStreams.First().Value.Flush(); + _writingStreams.First().Value.Close(); } - bool data = writingTracks.Count(t => t.TrackType != TrackType.Audio) > 0; + bool data = _writingTracks.Count(t => t.TrackType != TrackType.Audio) > 0; - bool mode2 = writingTracks.Count(t => t.TrackType == TrackType.CdMode2Form1 || - t.TrackType == TrackType.CdMode2Form2 || - t.TrackType == TrackType.CdMode2Formless) > 0; + bool mode2 = _writingTracks.Count(t => t.TrackType == TrackType.CdMode2Form1 || + t.TrackType == TrackType.CdMode2Form2 || + t.TrackType == TrackType.CdMode2Formless) > 0; if(mode2) - descriptorStream.WriteLine("CD_ROM_XA"); + _descriptorStream.WriteLine("CD_ROM_XA"); else if(data) - descriptorStream.WriteLine("CD_ROM"); + _descriptorStream.WriteLine("CD_ROM"); else - descriptorStream.WriteLine("CD_DA"); + _descriptorStream.WriteLine("CD_DA"); - if(!string.IsNullOrWhiteSpace(discimage.Comment)) + if(!string.IsNullOrWhiteSpace(_discimage.Comment)) { - string[] commentLines = discimage.Comment.Split(new[] + string[] commentLines = _discimage.Comment.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach(string line in commentLines) - descriptorStream.WriteLine("// {0}", line); + _descriptorStream.WriteLine("// {0}", line); } - descriptorStream.WriteLine(); + _descriptorStream.WriteLine(); - if(!string.IsNullOrEmpty(discimage.Mcn)) - descriptorStream.WriteLine("CATALOG {0}", discimage.Mcn); + if(!string.IsNullOrEmpty(_discimage.Mcn)) + _descriptorStream.WriteLine("CATALOG {0}", _discimage.Mcn); - foreach(Track track in writingTracks) + foreach(Track track in _writingTracks) { - descriptorStream.WriteLine(); - descriptorStream.WriteLine("// Track {0}", track.TrackSequence); + _descriptorStream.WriteLine(); + _descriptorStream.WriteLine("// Track {0}", track.TrackSequence); string subchannelType; @@ -575,47 +575,47 @@ namespace Aaru.DiscImages break; } - descriptorStream.WriteLine("TRACK {0}{1}", GetTrackMode(track), subchannelType); + _descriptorStream.WriteLine("TRACK {0}{1}", GetTrackMode(track), subchannelType); - trackFlags.TryGetValue((byte)track.TrackSequence, out byte flagsByte); + _trackFlags.TryGetValue((byte)track.TrackSequence, out byte flagsByte); var flags = (CdFlags)flagsByte; - descriptorStream.WriteLine("{0}COPY", flags.HasFlag(CdFlags.CopyPermitted) ? "" : "NO "); + _descriptorStream.WriteLine("{0}COPY", flags.HasFlag(CdFlags.CopyPermitted) ? "" : "NO "); if(track.TrackType == TrackType.Audio) { - descriptorStream.WriteLine("{0}PRE_EMPHASIS", flags.HasFlag(CdFlags.PreEmphasis) ? "" : "NO "); + _descriptorStream.WriteLine("{0}PRE_EMPHASIS", flags.HasFlag(CdFlags.PreEmphasis) ? "" : "NO "); - descriptorStream.WriteLine("{0}_CHANNEL_AUDIO", - flags.HasFlag(CdFlags.FourChannel) ? "FOUR" : "TWO"); + _descriptorStream.WriteLine("{0}_CHANNEL_AUDIO", + flags.HasFlag(CdFlags.FourChannel) ? "FOUR" : "TWO"); } - if(trackIsrcs.TryGetValue((byte)track.TrackSequence, out string isrc)) - descriptorStream.WriteLine("ISRC {0}", isrc); + if(_trackIsrcs.TryGetValue((byte)track.TrackSequence, out string isrc)) + _descriptorStream.WriteLine("ISRC {0}", isrc); (byte minute, byte second, byte frame) msf = LbaToMsf((track.TrackEndSector - track.TrackStartSector) + 1); - descriptorStream.WriteLine("DATAFILE \"{0}\" #{1} {2:D2}:{3:D2}:{4:D2} // length in bytes: {5}", - Path.GetFileName(track.TrackFile), track.TrackFileOffset, msf.minute, - msf.second, msf.frame, - ((track.TrackEndSector - track.TrackStartSector) + 1) * - (ulong)(track.TrackRawBytesPerSector + - (track.TrackSubchannelType != TrackSubchannelType.None ? 96 : 0))); + _descriptorStream.WriteLine("DATAFILE \"{0}\" #{1} {2:D2}:{3:D2}:{4:D2} // length in bytes: {5}", + Path.GetFileName(track.TrackFile), track.TrackFileOffset, msf.minute, + msf.second, msf.frame, + ((track.TrackEndSector - track.TrackStartSector) + 1) * + (ulong)(track.TrackRawBytesPerSector + + (track.TrackSubchannelType != TrackSubchannelType.None ? 96 : 0))); foreach(KeyValuePair index in track.Indexes.OrderBy(i => i.Key).Where(i => i.Key > 1)) { msf = LbaToMsf((ulong)index.Value - (track.TrackPregap + track.TrackStartSector)); - descriptorStream.WriteLine("INDEX {0:D2}:{1:D2}:{2:D2}", msf.minute, msf.second, msf.frame); + _descriptorStream.WriteLine("INDEX {0:D2}:{1:D2}:{2:D2}", msf.minute, msf.second, msf.frame); } - descriptorStream.WriteLine(); + _descriptorStream.WriteLine(); } - descriptorStream.Flush(); - descriptorStream.Close(); + _descriptorStream.Flush(); + _descriptorStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -625,8 +625,8 @@ namespace Aaru.DiscImages public bool SetMetadata(ImageInfo metadata) { - discimage.Barcode = metadata.MediaBarcode; - discimage.Comment = metadata.Comments; + _discimage.Barcode = metadata.MediaBarcode; + _discimage.Comment = metadata.Comments; return true; } @@ -648,8 +648,8 @@ namespace Aaru.DiscImages } Track track = - writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && - sectorAddress <= trk.TrackEndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && + sectorAddress <= trk.TrackEndSector); if(track is null) { @@ -669,14 +669,14 @@ namespace Aaru.DiscImages return false; } - trackFlags[(byte)sectorAddress] = data[0]; + _trackFlags[(byte)sectorAddress] = data[0]; return true; } case SectorTagType.CdTrackIsrc: { if(data != null) - trackIsrcs[(byte)sectorAddress] = Encoding.UTF8.GetString(data); + _trackIsrcs[(byte)sectorAddress] = Encoding.UTF8.GetString(data); return true; } @@ -697,7 +697,8 @@ namespace Aaru.DiscImages return false; } - FileStream trackStream = writingStreams.FirstOrDefault(kvp => kvp.Key == track.TrackSequence).Value; + FileStream trackStream = + _writingStreams.FirstOrDefault(kvp => kvp.Key == track.TrackSequence).Value; if(trackStream == null) { @@ -731,8 +732,8 @@ namespace Aaru.DiscImages } Track track = - writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && - sectorAddress <= trk.TrackEndSector); + _writingTracks.FirstOrDefault(trk => sectorAddress >= trk.TrackStartSector && + sectorAddress <= trk.TrackEndSector); if(track is null) { @@ -762,7 +763,8 @@ namespace Aaru.DiscImages return false; } - FileStream trackStream = writingStreams.FirstOrDefault(kvp => kvp.Key == track.TrackSequence).Value; + FileStream trackStream = + _writingStreams.FirstOrDefault(kvp => kvp.Key == track.TrackSequence).Value; if(trackStream == null) { diff --git a/Aaru.Images/CDRWin/CDRWin.cs b/Aaru.Images/CDRWin/CDRWin.cs index 932ffc5c6..999708fba 100644 --- a/Aaru.Images/CDRWin/CDRWin.cs +++ b/Aaru.Images/CDRWin/CDRWin.cs @@ -44,6 +44,7 @@ namespace Aaru.DiscImages { IFilter _cdrwinFilter; StreamReader _cueStream; + ulong _densitySeparationSectors; StreamWriter _descriptorStream; CdrWinDisc _discImage; ImageInfo _imageInfo; @@ -57,7 +58,6 @@ namespace Aaru.DiscImages string _writingBaseName; Dictionary _writingStreams; List _writingTracks; - ulong densitySeparationSectors; public CdrWin() => _imageInfo = new ImageInfo { diff --git a/Aaru.Images/CDRWin/Read.cs b/Aaru.Images/CDRWin/Read.cs index fd6328b9c..682c4b2c6 100644 --- a/Aaru.Images/CDRWin/Read.cs +++ b/Aaru.Images/CDRWin/Read.cs @@ -164,7 +164,7 @@ namespace Aaru.DiscImages bool firstTrackInSession = false; ulong gdRomSession2Offset = 45000; - densitySeparationSectors = 0; + _densitySeparationSectors = 0; while(_cueStream.Peek() >= 0) { @@ -1186,8 +1186,8 @@ namespace Aaru.DiscImages _discImage.Tracks[i].Sequence == 3) { _offsetMap.Add(_discImage.Tracks[i].Sequence, gdRomSession2Offset); - densitySeparationSectors += gdRomSession2Offset - previousPartitionsSize; - previousPartitionsSize = gdRomSession2Offset; + _densitySeparationSectors += gdRomSession2Offset - previousPartitionsSize; + previousPartitionsSize = gdRomSession2Offset; } else if(_discImage.Tracks[i].Sequence > 1) _offsetMap.Add(_discImage.Tracks[i].Sequence, @@ -1221,7 +1221,7 @@ namespace Aaru.DiscImages foreach(CdrWinTrack track in _discImage.Tracks) _imageInfo.Sectors += track.Sectors; - _imageInfo.Sectors += densitySeparationSectors; + _imageInfo.Sectors += _densitySeparationSectors; if(_discImage.MediaType != MediaType.CDROMXA && _discImage.MediaType != MediaType.CDDA && diff --git a/Aaru.Images/CHD/CHD.cs b/Aaru.Images/CHD/CHD.cs index 15a100697..10dcde071 100644 --- a/Aaru.Images/CHD/CHD.cs +++ b/Aaru.Images/CHD/CHD.cs @@ -46,40 +46,40 @@ namespace Aaru.DiscImages public partial class Chd : IOpticalMediaImage, IVerifiableImage { /// "MComprHD" - readonly byte[] chdTag = + readonly byte[] _chdTag = { 0x4D, 0x43, 0x6F, 0x6D, 0x70, 0x72, 0x48, 0x44 }; SectorBuilder _sectorBuilder; - uint bytesPerHunk; - byte[] cis; - byte[] expectedChecksum; - uint hdrCompression; - uint hdrCompression1; - uint hdrCompression2; - uint hdrCompression3; - Dictionary hunkCache; - byte[] hunkMap; - ulong[] hunkTable; - uint[] hunkTableSmall; - byte[] identify; - ImageInfo imageInfo; - Stream imageStream; - bool isCdrom; - bool isGdrom; - bool isHdd; - uint mapVersion; - int maxBlockCache; - int maxSectorCache; - Dictionary offsetmap; - List partitions; - Dictionary sectorCache; - uint sectorsPerHunk; - bool swapAudio; - uint totalHunks; - Dictionary tracks; + uint _bytesPerHunk; + byte[] _cis; + byte[] _expectedChecksum; + uint _hdrCompression; + uint _hdrCompression1; + uint _hdrCompression2; + uint _hdrCompression3; + Dictionary _hunkCache; + byte[] _hunkMap; + ulong[] _hunkTable; + uint[] _hunkTableSmall; + byte[] _identify; + ImageInfo _imageInfo; + Stream _imageStream; + bool _isCdrom; + bool _isGdrom; + bool _isHdd; + uint _mapVersion; + int _maxBlockCache; + int _maxSectorCache; + Dictionary _offsetmap; + List _partitions; + Dictionary _sectorCache; + uint _sectorsPerHunk; + bool _swapAudio; + uint _totalHunks; + Dictionary _tracks; - public Chd() => imageInfo = new ImageInfo + public Chd() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/CHD/Helpers.cs b/Aaru.Images/CHD/Helpers.cs index dbbafac4e..4f96f5450 100644 --- a/Aaru.Images/CHD/Helpers.cs +++ b/Aaru.Images/CHD/Helpers.cs @@ -48,48 +48,48 @@ namespace Aaru.DiscImages { var track = new Track(); - foreach(KeyValuePair kvp in offsetmap.Where(kvp => sector >= kvp.Key)) - tracks.TryGetValue(kvp.Value, out track); + foreach(KeyValuePair kvp in _offsetmap.Where(kvp => sector >= kvp.Key)) + _tracks.TryGetValue(kvp.Value, out track); return track; } ulong GetAbsoluteSector(ulong relativeSector, uint track) { - tracks.TryGetValue(track, out Track aaruTrack); + _tracks.TryGetValue(track, out Track aaruTrack); return aaruTrack.TrackStartSector + relativeSector; } byte[] GetHunk(ulong hunkNo) { - if(hunkCache.TryGetValue(hunkNo, out byte[] hunk)) + if(_hunkCache.TryGetValue(hunkNo, out byte[] hunk)) return hunk; - switch(mapVersion) + switch(_mapVersion) { case 1: - ulong offset = hunkTable[hunkNo] & 0x00000FFFFFFFFFFF; - ulong length = hunkTable[hunkNo] >> 44; + ulong offset = _hunkTable[hunkNo] & 0x00000FFFFFFFFFFF; + ulong length = _hunkTable[hunkNo] >> 44; byte[] compHunk = new byte[length]; - imageStream.Seek((long)offset, SeekOrigin.Begin); - imageStream.Read(compHunk, 0, compHunk.Length); + _imageStream.Seek((long)offset, SeekOrigin.Begin); + _imageStream.Read(compHunk, 0, compHunk.Length); - if(length == sectorsPerHunk * imageInfo.SectorSize) + if(length == _sectorsPerHunk * _imageInfo.SectorSize) hunk = compHunk; - else if((ChdCompression)hdrCompression > ChdCompression.Zlib) + else if((ChdCompression)_hdrCompression > ChdCompression.Zlib) throw new - ImageNotSupportedException($"Unsupported compression {(ChdCompression)hdrCompression}"); + ImageNotSupportedException($"Unsupported compression {(ChdCompression)_hdrCompression}"); else { var zStream = new DeflateStream(new MemoryStream(compHunk), CompressionMode.Decompress); - hunk = new byte[sectorsPerHunk * imageInfo.SectorSize]; - int read = zStream.Read(hunk, 0, (int)(sectorsPerHunk * imageInfo.SectorSize)); + hunk = new byte[_sectorsPerHunk * _imageInfo.SectorSize]; + int read = zStream.Read(hunk, 0, (int)(_sectorsPerHunk * _imageInfo.SectorSize)); - if(read != sectorsPerHunk * imageInfo.SectorSize) + if(read != _sectorsPerHunk * _imageInfo.SectorSize) throw new - IOException($"Unable to decompress hunk correctly, got {read} bytes, expected {sectorsPerHunk * imageInfo.SectorSize}"); + IOException($"Unable to decompress hunk correctly, got {read} bytes, expected {_sectorsPerHunk * _imageInfo.SectorSize}"); zStream.Close(); } @@ -97,33 +97,33 @@ namespace Aaru.DiscImages break; case 3: byte[] entryBytes = new byte[16]; - Array.Copy(hunkMap, (int)(hunkNo * 16), entryBytes, 0, 16); + Array.Copy(_hunkMap, (int)(hunkNo * 16), entryBytes, 0, 16); ChdMapV3Entry entry = Marshal.ByteArrayToStructureBigEndian(entryBytes); switch((Chdv3EntryFlags)(entry.flags & 0x0F)) { case Chdv3EntryFlags.Invalid: throw new ArgumentException("Invalid hunk found."); case Chdv3EntryFlags.Compressed: - switch((ChdCompression)hdrCompression) + switch((ChdCompression)_hdrCompression) { case ChdCompression.None: goto uncompressedV3; case ChdCompression.Zlib: case ChdCompression.ZlibPlus: - if(isHdd) + if(_isHdd) { byte[] zHunk = new byte[(entry.lengthLsb << 16) + entry.lengthLsb]; - imageStream.Seek((long)entry.offset, SeekOrigin.Begin); - imageStream.Read(zHunk, 0, zHunk.Length); + _imageStream.Seek((long)entry.offset, SeekOrigin.Begin); + _imageStream.Read(zHunk, 0, zHunk.Length); var zStream = new DeflateStream(new MemoryStream(zHunk), CompressionMode.Decompress); - hunk = new byte[bytesPerHunk]; - int read = zStream.Read(hunk, 0, (int)bytesPerHunk); + hunk = new byte[_bytesPerHunk]; + int read = zStream.Read(hunk, 0, (int)_bytesPerHunk); - if(read != bytesPerHunk) + if(read != _bytesPerHunk) throw new - IOException($"Unable to decompress hunk correctly, got {read} bytes, expected {bytesPerHunk}"); + IOException($"Unable to decompress hunk correctly, got {read} bytes, expected {_bytesPerHunk}"); zStream.Close(); } @@ -136,23 +136,23 @@ namespace Aaru.DiscImages break; case ChdCompression.Av: throw new - ImageNotSupportedException($"Unsupported compression {(ChdCompression)hdrCompression}"); + ImageNotSupportedException($"Unsupported compression {(ChdCompression)_hdrCompression}"); } break; case Chdv3EntryFlags.Uncompressed: uncompressedV3: - hunk = new byte[bytesPerHunk]; - imageStream.Seek((long)entry.offset, SeekOrigin.Begin); - imageStream.Read(hunk, 0, hunk.Length); + hunk = new byte[_bytesPerHunk]; + _imageStream.Seek((long)entry.offset, SeekOrigin.Begin); + _imageStream.Read(hunk, 0, hunk.Length); break; case Chdv3EntryFlags.Mini: - hunk = new byte[bytesPerHunk]; + hunk = new byte[_bytesPerHunk]; byte[] mini; mini = BigEndianBitConverter.GetBytes(entry.offset); - for(int i = 0; i < bytesPerHunk; i++) + for(int i = 0; i < _bytesPerHunk; i++) hunk[i] = mini[i % 8]; break; @@ -167,23 +167,23 @@ namespace Aaru.DiscImages break; case 5: - if(hdrCompression == 0) + if(_hdrCompression == 0) { - hunk = new byte[bytesPerHunk]; - imageStream.Seek(hunkTableSmall[hunkNo] * bytesPerHunk, SeekOrigin.Begin); - imageStream.Read(hunk, 0, hunk.Length); + hunk = new byte[_bytesPerHunk]; + _imageStream.Seek(_hunkTableSmall[hunkNo] * _bytesPerHunk, SeekOrigin.Begin); + _imageStream.Read(hunk, 0, hunk.Length); } else throw new ImageNotSupportedException("Compressed v5 hunks not yet supported"); break; - default: throw new ImageNotSupportedException($"Unsupported hunk map version {mapVersion}"); + default: throw new ImageNotSupportedException($"Unsupported hunk map version {_mapVersion}"); } - if(hunkCache.Count >= maxBlockCache) - hunkCache.Clear(); + if(_hunkCache.Count >= _maxBlockCache) + _hunkCache.Clear(); - hunkCache.Add(hunkNo, hunk); + _hunkCache.Add(hunkNo, hunk); return hunk; } diff --git a/Aaru.Images/CHD/Identify.cs b/Aaru.Images/CHD/Identify.cs index ede9d0376..e6aa3ee2a 100644 --- a/Aaru.Images/CHD/Identify.cs +++ b/Aaru.Images/CHD/Identify.cs @@ -45,7 +45,7 @@ namespace Aaru.DiscImages byte[] magic = new byte[8]; stream.Read(magic, 0, 8); - return chdTag.SequenceEqual(magic); + return _chdTag.SequenceEqual(magic); } } } \ No newline at end of file diff --git a/Aaru.Images/CHD/Properties.cs b/Aaru.Images/CHD/Properties.cs index 68a30e376..4b0872fdd 100644 --- a/Aaru.Images/CHD/Properties.cs +++ b/Aaru.Images/CHD/Properties.cs @@ -42,7 +42,7 @@ namespace Aaru.DiscImages { public partial class Chd { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "MAME Compressed Hunks of Data"; public Guid Id => new Guid("0D50233A-08BD-47D4-988B-27EAA0358597"); public string Format => "Compressed Hunks of Data"; @@ -52,11 +52,11 @@ namespace Aaru.DiscImages { get { - if(isHdd) + if(_isHdd) throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image"); - return partitions; + return _partitions; } } @@ -64,11 +64,11 @@ namespace Aaru.DiscImages { get { - if(isHdd) + if(_isHdd) throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image"); - return tracks.Values.ToList(); + return _tracks.Values.ToList(); } } @@ -76,7 +76,7 @@ namespace Aaru.DiscImages { get { - if(isHdd) + if(_isHdd) throw new FeaturedNotSupportedByDiscImageException("Cannot access optical sessions on a hard disk image"); diff --git a/Aaru.Images/CHD/Read.cs b/Aaru.Images/CHD/Read.cs index 504acde14..d44f35936 100644 --- a/Aaru.Images/CHD/Read.cs +++ b/Aaru.Images/CHD/Read.cs @@ -60,7 +60,7 @@ namespace Aaru.DiscImages byte[] magic = new byte[8]; stream.Read(magic, 0, 8); - if(!chdTag.SequenceEqual(magic)) + if(!_chdTag.SequenceEqual(magic)) return false; // Read length @@ -107,7 +107,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CHD plugin", "Reading Hunk map."); DateTime start = DateTime.UtcNow; - hunkTable = new ulong[hdrV1.totalhunks]; + _hunkTable = new ulong[hdrV1.totalhunks]; uint hunkSectorCount = (uint)Math.Ceiling(((double)hdrV1.totalhunks * 8) / 512); @@ -124,32 +124,32 @@ namespace Aaru.DiscImages // This restores the order of elements Array.Reverse(hunkSector.hunkEntry); - if(hunkTable.Length >= ((i * 512) / 8) + (512 / 8)) - Array.Copy(hunkSector.hunkEntry, 0, hunkTable, (i * 512) / 8, 512 / 8); + if(_hunkTable.Length >= ((i * 512) / 8) + (512 / 8)) + Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, (i * 512) / 8, 512 / 8); else - Array.Copy(hunkSector.hunkEntry, 0, hunkTable, (i * 512) / 8, - hunkTable.Length - ((i * 512) / 8)); + Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, (i * 512) / 8, + _hunkTable.Length - ((i * 512) / 8)); } DateTime end = DateTime.UtcNow; AaruConsole.DebugWriteLine("CHD plugin", "Took {0} seconds", (end - start).TotalSeconds); - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.Sectors = hdrV1.hunksize * hdrV1.totalhunks; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.SectorSize = 512; - imageInfo.Version = "1"; - imageInfo.ImageSize = imageInfo.SectorSize * hdrV1.hunksize * hdrV1.totalhunks; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.Sectors = hdrV1.hunksize * hdrV1.totalhunks; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.SectorSize = 512; + _imageInfo.Version = "1"; + _imageInfo.ImageSize = _imageInfo.SectorSize * hdrV1.hunksize * hdrV1.totalhunks; - totalHunks = hdrV1.totalhunks; - sectorsPerHunk = hdrV1.hunksize; - hdrCompression = hdrV1.compression; - mapVersion = 1; - isHdd = true; + _totalHunks = hdrV1.totalhunks; + _sectorsPerHunk = hdrV1.hunksize; + _hdrCompression = hdrV1.compression; + _mapVersion = 1; + _isHdd = true; - imageInfo.Cylinders = hdrV1.cylinders; - imageInfo.Heads = hdrV1.heads; - imageInfo.SectorsPerTrack = hdrV1.sectors; + _imageInfo.Cylinders = hdrV1.cylinders; + _imageInfo.Heads = hdrV1.heads; + _imageInfo.SectorsPerTrack = hdrV1.sectors; break; } @@ -184,7 +184,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CHD plugin", "Reading Hunk map."); DateTime start = DateTime.UtcNow; - hunkTable = new ulong[hdrV2.totalhunks]; + _hunkTable = new ulong[hdrV2.totalhunks]; // How many sectors uses the BAT uint hunkSectorCount = (uint)Math.Ceiling(((double)hdrV2.totalhunks * 8) / 512); @@ -202,32 +202,32 @@ namespace Aaru.DiscImages // This restores the order of elements Array.Reverse(hunkSector.hunkEntry); - if(hunkTable.Length >= ((i * 512) / 8) + (512 / 8)) - Array.Copy(hunkSector.hunkEntry, 0, hunkTable, (i * 512) / 8, 512 / 8); + if(_hunkTable.Length >= ((i * 512) / 8) + (512 / 8)) + Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, (i * 512) / 8, 512 / 8); else - Array.Copy(hunkSector.hunkEntry, 0, hunkTable, (i * 512) / 8, - hunkTable.Length - ((i * 512) / 8)); + Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, (i * 512) / 8, + _hunkTable.Length - ((i * 512) / 8)); } DateTime end = DateTime.UtcNow; AaruConsole.DebugWriteLine("CHD plugin", "Took {0} seconds", (end - start).TotalSeconds); - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.Sectors = hdrV2.hunksize * hdrV2.totalhunks; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.SectorSize = hdrV2.seclen; - imageInfo.Version = "2"; - imageInfo.ImageSize = imageInfo.SectorSize * hdrV2.hunksize * hdrV2.totalhunks; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.Sectors = hdrV2.hunksize * hdrV2.totalhunks; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.SectorSize = hdrV2.seclen; + _imageInfo.Version = "2"; + _imageInfo.ImageSize = _imageInfo.SectorSize * hdrV2.hunksize * hdrV2.totalhunks; - totalHunks = hdrV2.totalhunks; - sectorsPerHunk = hdrV2.hunksize; - hdrCompression = hdrV2.compression; - mapVersion = 1; - isHdd = true; + _totalHunks = hdrV2.totalhunks; + _sectorsPerHunk = hdrV2.hunksize; + _hdrCompression = hdrV2.compression; + _mapVersion = 1; + _isHdd = true; - imageInfo.Cylinders = hdrV2.cylinders; - imageInfo.Heads = hdrV2.heads; - imageInfo.SectorsPerTrack = hdrV2.sectors; + _imageInfo.Cylinders = hdrV2.cylinders; + _imageInfo.Heads = hdrV2.heads; + _imageInfo.SectorsPerTrack = hdrV2.sectors; break; } @@ -267,21 +267,21 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CHD plugin", "Reading Hunk map."); DateTime start = DateTime.UtcNow; - hunkMap = new byte[hdrV3.totalhunks * 16]; - stream.Read(hunkMap, 0, hunkMap.Length); + _hunkMap = new byte[hdrV3.totalhunks * 16]; + stream.Read(_hunkMap, 0, _hunkMap.Length); DateTime end = DateTime.UtcNow; AaruConsole.DebugWriteLine("CHD plugin", "Took {0} seconds", (end - start).TotalSeconds); nextMetaOff = hdrV3.metaoffset; - imageInfo.ImageSize = hdrV3.logicalbytes; - imageInfo.Version = "3"; + _imageInfo.ImageSize = hdrV3.logicalbytes; + _imageInfo.Version = "3"; - totalHunks = hdrV3.totalhunks; - bytesPerHunk = hdrV3.hunkbytes; - hdrCompression = hdrV3.compression; - mapVersion = 3; + _totalHunks = hdrV3.totalhunks; + _bytesPerHunk = hdrV3.hunkbytes; + _hdrCompression = hdrV3.compression; + _mapVersion = 3; break; } @@ -318,21 +318,21 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CHD plugin", "Reading Hunk map."); DateTime start = DateTime.UtcNow; - hunkMap = new byte[hdrV4.totalhunks * 16]; - stream.Read(hunkMap, 0, hunkMap.Length); + _hunkMap = new byte[hdrV4.totalhunks * 16]; + stream.Read(_hunkMap, 0, _hunkMap.Length); DateTime end = DateTime.UtcNow; AaruConsole.DebugWriteLine("CHD plugin", "Took {0} seconds", (end - start).TotalSeconds); nextMetaOff = hdrV4.metaoffset; - imageInfo.ImageSize = hdrV4.logicalbytes; - imageInfo.Version = "4"; + _imageInfo.ImageSize = hdrV4.logicalbytes; + _imageInfo.Version = "4"; - totalHunks = hdrV4.totalhunks; - bytesPerHunk = hdrV4.hunkbytes; - hdrCompression = hdrV4.compression; - mapVersion = 3; + _totalHunks = hdrV4.totalhunks; + _bytesPerHunk = hdrV4.hunkbytes; + _hdrCompression = hdrV4.compression; + _mapVersion = 3; break; } @@ -388,9 +388,9 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CHD plugin", "Reading Hunk map."); DateTime start = DateTime.UtcNow; - hunkTableSmall = new uint[hdrV5.logicalbytes / hdrV5.hunkbytes]; + _hunkTableSmall = new uint[hdrV5.logicalbytes / hdrV5.hunkbytes]; - uint hunkSectorCount = (uint)Math.Ceiling(((double)hunkTableSmall.Length * 4) / 512); + uint hunkSectorCount = (uint)Math.Ceiling(((double)_hunkTableSmall.Length * 4) / 512); byte[] hunkSectorBytes = new byte[512]; @@ -409,11 +409,11 @@ namespace Aaru.DiscImages // This restores the order of elements Array.Reverse(hunkSector.hunkEntry); - if(hunkTableSmall.Length >= ((i * 512) / 4) + (512 / 4)) - Array.Copy(hunkSector.hunkEntry, 0, hunkTableSmall, (i * 512) / 4, 512 / 4); + if(_hunkTableSmall.Length >= ((i * 512) / 4) + (512 / 4)) + Array.Copy(hunkSector.hunkEntry, 0, _hunkTableSmall, (i * 512) / 4, 512 / 4); else - Array.Copy(hunkSector.hunkEntry, 0, hunkTableSmall, (i * 512) / 4, - hunkTableSmall.Length - ((i * 512) / 4)); + Array.Copy(hunkSector.hunkEntry, 0, _hunkTableSmall, (i * 512) / 4, + _hunkTableSmall.Length - ((i * 512) / 4)); } DateTime end = DateTime.UtcNow; @@ -424,16 +424,16 @@ namespace Aaru.DiscImages nextMetaOff = hdrV5.metaoffset; - imageInfo.ImageSize = hdrV5.logicalbytes; - imageInfo.Version = "5"; + _imageInfo.ImageSize = hdrV5.logicalbytes; + _imageInfo.Version = "5"; - totalHunks = (uint)(hdrV5.logicalbytes / hdrV5.hunkbytes); - bytesPerHunk = hdrV5.hunkbytes; - hdrCompression = hdrV5.compressor0; - hdrCompression1 = hdrV5.compressor1; - hdrCompression2 = hdrV5.compressor2; - hdrCompression3 = hdrV5.compressor3; - mapVersion = 5; + _totalHunks = (uint)(hdrV5.logicalbytes / hdrV5.hunkbytes); + _bytesPerHunk = hdrV5.hunkbytes; + _hdrCompression = hdrV5.compressor0; + _hdrCompression1 = hdrV5.compressor1; + _hdrCompression2 = hdrV5.compressor2; + _hdrCompression3 = hdrV5.compressor3; + _mapVersion = 5; break; } @@ -441,13 +441,13 @@ namespace Aaru.DiscImages default: throw new ImageNotSupportedException($"Unsupported CHD version {version}"); } - if(mapVersion >= 3) + if(_mapVersion >= 3) { - isCdrom = false; - isHdd = false; - isGdrom = false; - swapAudio = false; - tracks = new Dictionary(); + _isCdrom = false; + _isHdd = false; + _isGdrom = false; + _swapAudio = false; + _tracks = new Dictionary(); AaruConsole.DebugWriteLine("CHD plugin", "Reading metadata."); @@ -470,7 +470,7 @@ namespace Aaru.DiscImages { // "GDDD" case HARD_DISK_METADATA: - if(isCdrom || isGdrom) + if(_isCdrom || _isGdrom) throw new ImageNotSupportedException("Image cannot be a hard disk and a C/GD-ROM at the same time, aborting."); @@ -480,22 +480,22 @@ namespace Aaru.DiscImages if(gdddMatch.Success) { - isHdd = true; - imageInfo.SectorSize = uint.Parse(gdddMatch.Groups["bps"].Value); - imageInfo.Cylinders = uint.Parse(gdddMatch.Groups["cylinders"].Value); - imageInfo.Heads = uint.Parse(gdddMatch.Groups["heads"].Value); - imageInfo.SectorsPerTrack = uint.Parse(gdddMatch.Groups["sectors"].Value); + _isHdd = true; + _imageInfo.SectorSize = uint.Parse(gdddMatch.Groups["bps"].Value); + _imageInfo.Cylinders = uint.Parse(gdddMatch.Groups["cylinders"].Value); + _imageInfo.Heads = uint.Parse(gdddMatch.Groups["heads"].Value); + _imageInfo.SectorsPerTrack = uint.Parse(gdddMatch.Groups["sectors"].Value); } break; // "CHCD" case CDROM_OLD_METADATA: - if(isHdd) + if(_isHdd) throw new ImageNotSupportedException("Image cannot be a hard disk and a CD-ROM at the same time, aborting."); - if(isGdrom) + if(_isGdrom) throw new ImageNotSupportedException("Image cannot be a GD-ROM and a CD-ROM at the same time, aborting."); @@ -607,20 +607,20 @@ namespace Aaru.DiscImages aaruTrack.Indexes.Add(1, (int)currentSector); currentSector += chdTrack.frames + chdTrack.extraFrames; - tracks.Add(aaruTrack.TrackSequence, aaruTrack); + _tracks.Add(aaruTrack.TrackSequence, aaruTrack); } - isCdrom = true; + _isCdrom = true; break; // "CHTR" case CDROM_TRACK_METADATA: - if(isHdd) + if(_isHdd) throw new ImageNotSupportedException("Image cannot be a hard disk and a CD-ROM at the same time, aborting."); - if(isGdrom) + if(_isGdrom) throw new ImageNotSupportedException("Image cannot be a GD-ROM and a CD-ROM at the same time, aborting."); @@ -630,7 +630,7 @@ namespace Aaru.DiscImages if(chtrMatch.Success) { - isCdrom = true; + _isCdrom = true; uint trackNo = uint.Parse(chtrMatch.Groups["track"].Value); uint frames = uint.Parse(chtrMatch.Groups["frames"].Value); @@ -734,18 +734,18 @@ namespace Aaru.DiscImages aaruTrack.Indexes.Add(1, (int)currentSector); currentSector += frames; currentTrack++; - tracks.Add(aaruTrack.TrackSequence, aaruTrack); + _tracks.Add(aaruTrack.TrackSequence, aaruTrack); } break; // "CHT2" case CDROM_TRACK_METADATA2: - if(isHdd) + if(_isHdd) throw new ImageNotSupportedException("Image cannot be a hard disk and a CD-ROM at the same time, aborting."); - if(isGdrom) + if(_isGdrom) throw new ImageNotSupportedException("Image cannot be a GD-ROM and a CD-ROM at the same time, aborting."); @@ -755,7 +755,7 @@ namespace Aaru.DiscImages if(cht2Match.Success) { - isCdrom = true; + _isCdrom = true; uint trackNo = uint.Parse(cht2Match.Groups["track"].Value); uint frames = uint.Parse(cht2Match.Groups["frames"].Value); @@ -893,23 +893,23 @@ namespace Aaru.DiscImages currentSector += frames; currentTrack++; - tracks.Add(aaruTrack.TrackSequence, aaruTrack); + _tracks.Add(aaruTrack.TrackSequence, aaruTrack); } break; // "CHGT" case GDROM_OLD_METADATA: - swapAudio = true; + _swapAudio = true; goto case GDROM_METADATA; // "CHGD" case GDROM_METADATA: - if(isHdd) + if(_isHdd) throw new ImageNotSupportedException("Image cannot be a hard disk and a GD-ROM at the same time, aborting."); - if(isCdrom) + if(_isCdrom) throw new ImageNotSupportedException("Image cannot be a CD-ROM and a GD-ROM at the same time, aborting."); @@ -919,7 +919,7 @@ namespace Aaru.DiscImages if(chgdMatch.Success) { - isGdrom = true; + _isGdrom = true; uint trackNo = uint.Parse(chgdMatch.Groups["track"].Value); uint frames = uint.Parse(chgdMatch.Groups["frames"].Value); @@ -1050,7 +1050,7 @@ namespace Aaru.DiscImages currentSector += frames; currentTrack++; - tracks.Add(aaruTrack.TrackSequence, aaruTrack); + _tracks.Add(aaruTrack.TrackSequence, aaruTrack); } break; @@ -1061,39 +1061,39 @@ namespace Aaru.DiscImages if(idnt.HasValue) { - imageInfo.MediaManufacturer = idnt.Value.MediaManufacturer; - imageInfo.MediaSerialNumber = idnt.Value.MediaSerial; - imageInfo.DriveModel = idnt.Value.Model; - imageInfo.DriveSerialNumber = idnt.Value.SerialNumber; - imageInfo.DriveFirmwareRevision = idnt.Value.FirmwareRevision; + _imageInfo.MediaManufacturer = idnt.Value.MediaManufacturer; + _imageInfo.MediaSerialNumber = idnt.Value.MediaSerial; + _imageInfo.DriveModel = idnt.Value.Model; + _imageInfo.DriveSerialNumber = idnt.Value.SerialNumber; + _imageInfo.DriveFirmwareRevision = idnt.Value.FirmwareRevision; if(idnt.Value.CurrentCylinders > 0 && idnt.Value.CurrentHeads > 0 && idnt.Value.CurrentSectorsPerTrack > 0) { - imageInfo.Cylinders = idnt.Value.CurrentCylinders; - imageInfo.Heads = idnt.Value.CurrentHeads; - imageInfo.SectorsPerTrack = idnt.Value.CurrentSectorsPerTrack; + _imageInfo.Cylinders = idnt.Value.CurrentCylinders; + _imageInfo.Heads = idnt.Value.CurrentHeads; + _imageInfo.SectorsPerTrack = idnt.Value.CurrentSectorsPerTrack; } else { - imageInfo.Cylinders = idnt.Value.Cylinders; - imageInfo.Heads = idnt.Value.Heads; - imageInfo.SectorsPerTrack = idnt.Value.SectorsPerTrack; + _imageInfo.Cylinders = idnt.Value.Cylinders; + _imageInfo.Heads = idnt.Value.Heads; + _imageInfo.SectorsPerTrack = idnt.Value.SectorsPerTrack; } } - identify = meta; + _identify = meta; - if(!imageInfo.ReadableMediaTags.Contains(MediaTagType.ATA_IDENTIFY)) - imageInfo.ReadableMediaTags.Add(MediaTagType.ATA_IDENTIFY); + if(!_imageInfo.ReadableMediaTags.Contains(MediaTagType.ATA_IDENTIFY)) + _imageInfo.ReadableMediaTags.Add(MediaTagType.ATA_IDENTIFY); break; case PCMCIA_CIS_METADATA: - cis = meta; + _cis = meta; - if(!imageInfo.ReadableMediaTags.Contains(MediaTagType.PCMCIA_CIS)) - imageInfo.ReadableMediaTags.Add(MediaTagType.PCMCIA_CIS); + if(!_imageInfo.ReadableMediaTags.Contains(MediaTagType.PCMCIA_CIS)) + _imageInfo.ReadableMediaTags.Add(MediaTagType.PCMCIA_CIS); break; } @@ -1101,44 +1101,44 @@ namespace Aaru.DiscImages nextMetaOff = header.next; } - if(isHdd) + if(_isHdd) { - sectorsPerHunk = bytesPerHunk / imageInfo.SectorSize; - imageInfo.Sectors = imageInfo.ImageSize / imageInfo.SectorSize; - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _sectorsPerHunk = _bytesPerHunk / _imageInfo.SectorSize; + _imageInfo.Sectors = _imageInfo.ImageSize / _imageInfo.SectorSize; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; } - else if(isCdrom) + else if(_isCdrom) { // Hardcoded on MAME for CD-ROM - sectorsPerHunk = 8; - imageInfo.MediaType = MediaType.CDROM; - imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; + _sectorsPerHunk = 8; + _imageInfo.MediaType = MediaType.CDROM; + _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; - foreach(Track aaruTrack in tracks.Values) - imageInfo.Sectors += (aaruTrack.TrackEndSector - aaruTrack.TrackStartSector) + 1; + foreach(Track aaruTrack in _tracks.Values) + _imageInfo.Sectors += (aaruTrack.TrackEndSector - aaruTrack.TrackStartSector) + 1; } - else if(isGdrom) + else if(_isGdrom) { // Hardcoded on MAME for GD-ROM - sectorsPerHunk = 8; - imageInfo.MediaType = MediaType.GDROM; - imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; + _sectorsPerHunk = 8; + _imageInfo.MediaType = MediaType.GDROM; + _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; - foreach(Track aaruTrack in tracks.Values) - imageInfo.Sectors += (aaruTrack.TrackEndSector - aaruTrack.TrackStartSector) + 1; + foreach(Track aaruTrack in _tracks.Values) + _imageInfo.Sectors += (aaruTrack.TrackEndSector - aaruTrack.TrackStartSector) + 1; } else throw new ImageNotSupportedException("Image does not represent a known media, aborting"); } - if(isCdrom || isGdrom) + if(_isCdrom || _isGdrom) { - offsetmap = new Dictionary(); - partitions = new List(); + _offsetmap = new Dictionary(); + _partitions = new List(); ulong partPos = 0; - foreach(Track aaruTrack in tracks.Values) + foreach(Track aaruTrack in _tracks.Values) { var partition = new Partition { @@ -1153,11 +1153,11 @@ namespace Aaru.DiscImages }; partPos += partition.Length; - offsetmap.Add(aaruTrack.TrackStartSector, aaruTrack.TrackSequence); + _offsetmap.Add(aaruTrack.TrackStartSector, aaruTrack.TrackSequence); if(aaruTrack.TrackSubchannelType != TrackSubchannelType.None) - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); switch(aaruTrack.TrackType) { @@ -1165,81 +1165,81 @@ namespace Aaru.DiscImages case TrackType.CdMode2Form1: if(aaruTrack.TrackRawBytesPerSector == 2352) { - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); } break; case TrackType.CdMode2Form2: if(aaruTrack.TrackRawBytesPerSector == 2352) { - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); } break; case TrackType.CdMode2Formless: if(aaruTrack.TrackRawBytesPerSector == 2352) { - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); } break; } - if(aaruTrack.TrackBytesPerSector > imageInfo.SectorSize) - imageInfo.SectorSize = (uint)aaruTrack.TrackBytesPerSector; + if(aaruTrack.TrackBytesPerSector > _imageInfo.SectorSize) + _imageInfo.SectorSize = (uint)aaruTrack.TrackBytesPerSector; - partitions.Add(partition); + _partitions.Add(partition); } - imageInfo.HasPartitions = true; - imageInfo.HasSessions = true; + _imageInfo.HasPartitions = true; + _imageInfo.HasSessions = true; } - maxBlockCache = (int)(MAX_CACHE_SIZE / (imageInfo.SectorSize * sectorsPerHunk)); - maxSectorCache = (int)(MAX_CACHE_SIZE / imageInfo.SectorSize); + _maxBlockCache = (int)(MAX_CACHE_SIZE / (_imageInfo.SectorSize * _sectorsPerHunk)); + _maxSectorCache = (int)(MAX_CACHE_SIZE / _imageInfo.SectorSize); - imageStream = stream; + _imageStream = stream; - sectorCache = new Dictionary(); - hunkCache = new Dictionary(); + _sectorCache = new Dictionary(); + _hunkCache = new Dictionary(); // TODO: Detect CompactFlash // TODO: Get manufacturer and drive name from CIS if applicable - if(cis != null) - imageInfo.MediaType = MediaType.PCCardTypeI; + if(_cis != null) + _imageInfo.MediaType = MediaType.PCCardTypeI; _sectorBuilder = new SectorBuilder(); @@ -1248,38 +1248,38 @@ namespace Aaru.DiscImages public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); var track = new Track(); uint sectorSize; - if(!sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(!_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) { - if(isHdd) - sectorSize = imageInfo.SectorSize; + if(_isHdd) + sectorSize = _imageInfo.SectorSize; else { track = GetTrack(sectorAddress); sectorSize = (uint)track.TrackRawBytesPerSector; } - ulong hunkNo = sectorAddress / sectorsPerHunk; - ulong secOff = (sectorAddress * sectorSize) % (sectorsPerHunk * sectorSize); + ulong hunkNo = sectorAddress / _sectorsPerHunk; + ulong secOff = (sectorAddress * sectorSize) % (_sectorsPerHunk * sectorSize); byte[] hunk = GetHunk(hunkNo); - sector = new byte[imageInfo.SectorSize]; + sector = new byte[_imageInfo.SectorSize]; Array.Copy(hunk, (int)secOff, sector, 0, sector.Length); - if(sectorCache.Count >= maxSectorCache) - sectorCache.Clear(); + if(_sectorCache.Count >= _maxSectorCache) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); } - if(isHdd) + if(_isHdd) return sector; uint sectorOffset; @@ -1360,7 +1360,7 @@ namespace Aaru.DiscImages if(mode2) buffer = Sector.GetUserDataFromMode2(sector); - else if(track.TrackType == TrackType.Audio && swapAudio) + else if(track.TrackType == TrackType.Audio && _swapAudio) for(int i = 0; i < 2352; i += 2) { buffer[i + 1] = sector[i]; @@ -1374,10 +1374,10 @@ namespace Aaru.DiscImages public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) { - if(isHdd) + if(_isHdd) throw new FeatureNotPresentImageException("Hard disk images do not have sector tags"); - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); @@ -1385,26 +1385,26 @@ namespace Aaru.DiscImages uint sectorSize; - if(!sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(!_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) { track = GetTrack(sectorAddress); sectorSize = (uint)track.TrackRawBytesPerSector; - ulong hunkNo = sectorAddress / sectorsPerHunk; - ulong secOff = (sectorAddress * sectorSize) % (sectorsPerHunk * sectorSize); + ulong hunkNo = sectorAddress / _sectorsPerHunk; + ulong secOff = (sectorAddress * sectorSize) % (_sectorsPerHunk * sectorSize); byte[] hunk = GetHunk(hunkNo); - sector = new byte[imageInfo.SectorSize]; + sector = new byte[_imageInfo.SectorSize]; Array.Copy(hunk, (int)secOff, sector, 0, sector.Length); - if(sectorCache.Count >= maxSectorCache) - sectorCache.Clear(); + if(_sectorCache.Count >= _maxSectorCache) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); } - if(isHdd) + if(_isHdd) return sector; uint sectorOffset; @@ -1606,7 +1606,7 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize]; - if(track.TrackType == TrackType.Audio && swapAudio) + if(track.TrackType == TrackType.Audio && _swapAudio) for(int i = 0; i < 2352; i += 2) { buffer[i + 1] = sector[i]; @@ -1615,7 +1615,7 @@ namespace Aaru.DiscImages else Array.Copy(sector, sectorOffset, buffer, 0, sectorSize); - if(track.TrackType == TrackType.Audio && swapAudio) + if(track.TrackType == TrackType.Audio && _swapAudio) for(int i = 0; i < 2352; i += 2) { buffer[i + 1] = sector[i]; @@ -1629,13 +1629,13 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), - $"Requested more sectors ({sectorAddress + length}) than available ({imageInfo.Sectors})"); + $"Requested more sectors ({sectorAddress + length}) than available ({_imageInfo.Sectors})"); var ms = new MemoryStream(); @@ -1650,13 +1650,13 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), - $"Requested more sectors ({sectorAddress + length}) than available ({imageInfo.Sectors})"); + $"Requested more sectors ({sectorAddress + length}) than available ({_imageInfo.Sectors})"); var ms = new MemoryStream(); @@ -1671,37 +1671,37 @@ namespace Aaru.DiscImages public byte[] ReadSectorLong(ulong sectorAddress) { - if(isHdd) + if(_isHdd) return ReadSector(sectorAddress); - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); var track = new Track(); - if(!sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(!_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) { track = GetTrack(sectorAddress); uint sectorSize = (uint)track.TrackRawBytesPerSector; - ulong hunkNo = sectorAddress / sectorsPerHunk; - ulong secOff = (sectorAddress * sectorSize) % (sectorsPerHunk * sectorSize); + ulong hunkNo = sectorAddress / _sectorsPerHunk; + ulong secOff = (sectorAddress * sectorSize) % (_sectorsPerHunk * sectorSize); byte[] hunk = GetHunk(hunkNo); - sector = new byte[imageInfo.SectorSize]; + sector = new byte[_imageInfo.SectorSize]; Array.Copy(hunk, (int)secOff, sector, 0, sector.Length); - if(sectorCache.Count >= maxSectorCache) - sectorCache.Clear(); + if(_sectorCache.Count >= _maxSectorCache) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); } byte[] buffer = new byte[track.TrackRawBytesPerSector]; - if(track.TrackType == TrackType.Audio && swapAudio) + if(track.TrackType == TrackType.Audio && _swapAudio) for(int i = 0; i < 2352; i += 2) { buffer[i + 1] = sector[i]; @@ -1766,13 +1766,13 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), - $"Requested more sectors ({sectorAddress + length}) than available ({imageInfo.Sectors})"); + $"Requested more sectors ({sectorAddress + length}) than available ({_imageInfo.Sectors})"); var ms = new MemoryStream(); @@ -1787,18 +1787,18 @@ namespace Aaru.DiscImages public byte[] ReadDiskTag(MediaTagType tag) { - if(imageInfo.ReadableMediaTags.Contains(MediaTagType.ATA_IDENTIFY)) - return identify; + if(_imageInfo.ReadableMediaTags.Contains(MediaTagType.ATA_IDENTIFY)) + return _identify; - if(imageInfo.ReadableMediaTags.Contains(MediaTagType.PCMCIA_CIS)) - return cis; + if(_imageInfo.ReadableMediaTags.Contains(MediaTagType.PCMCIA_CIS)) + return _cis; throw new FeatureUnsupportedImageException("Feature not supported by image format"); } public List GetSessionTracks(Session session) { - if(isHdd) + if(_isHdd) throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image"); return GetSessionTracks(session.SessionSequence); @@ -1806,15 +1806,15 @@ namespace Aaru.DiscImages public List GetSessionTracks(ushort session) { - if(isHdd) + if(_isHdd) throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image"); - return tracks.Values.Where(track => track.TrackSession == session).ToList(); + return _tracks.Values.Where(track => track.TrackSession == session).ToList(); } public byte[] ReadSector(ulong sectorAddress, uint track) { - if(isHdd) + if(_isHdd) throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image"); return ReadSector(GetAbsoluteSector(sectorAddress, track)); @@ -1822,7 +1822,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag) { - if(isHdd) + if(_isHdd) throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image"); return ReadSectorTag(GetAbsoluteSector(sectorAddress, track), tag); @@ -1830,7 +1830,7 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length, uint track) { - if(isHdd) + if(_isHdd) throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image"); return ReadSectors(GetAbsoluteSector(sectorAddress, track), length); @@ -1838,7 +1838,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag) { - if(isHdd) + if(_isHdd) throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image"); return ReadSectorsTag(GetAbsoluteSector(sectorAddress, track), length, tag); @@ -1846,7 +1846,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorLong(ulong sectorAddress, uint track) { - if(isHdd) + if(_isHdd) throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image"); return ReadSectorLong(GetAbsoluteSector(sectorAddress, track)); @@ -1854,7 +1854,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track) { - if(isHdd) + if(_isHdd) throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image"); return ReadSectorLong(GetAbsoluteSector(sectorAddress, track), length); diff --git a/Aaru.Images/CHD/Verify.cs b/Aaru.Images/CHD/Verify.cs index dbec110e8..95013fc37 100644 --- a/Aaru.Images/CHD/Verify.cs +++ b/Aaru.Images/CHD/Verify.cs @@ -42,7 +42,7 @@ namespace Aaru.DiscImages { public bool? VerifySector(ulong sectorAddress) { - if(isHdd) + if(_isHdd) return null; byte[] buffer = ReadSectorLong(sectorAddress); @@ -56,7 +56,7 @@ namespace Aaru.DiscImages unknownLbas = new List(); failingLbas = new List(); - if(isHdd) + if(_isHdd) return null; byte[] buffer = ReadSectorsLong(sectorAddress, length); @@ -93,7 +93,7 @@ namespace Aaru.DiscImages unknownLbas = new List(); failingLbas = new List(); - if(isHdd) + if(_isHdd) return null; byte[] buffer = ReadSectorsLong(sectorAddress, length, track); @@ -128,11 +128,11 @@ namespace Aaru.DiscImages { byte[] calculated; - if(mapVersion >= 3) + if(_mapVersion >= 3) { var sha1Ctx = new Sha1Context(); - for(uint i = 0; i < totalHunks; i++) + for(uint i = 0; i < _totalHunks; i++) sha1Ctx.Update(GetHunk(i)); calculated = sha1Ctx.Final(); @@ -141,18 +141,18 @@ namespace Aaru.DiscImages { var md5Ctx = new Md5Context(); - for(uint i = 0; i < totalHunks; i++) + for(uint i = 0; i < _totalHunks; i++) md5Ctx.Update(GetHunk(i)); calculated = md5Ctx.Final(); } - return expectedChecksum.SequenceEqual(calculated); + return _expectedChecksum.SequenceEqual(calculated); } public bool? VerifySector(ulong sectorAddress, uint track) { - if(isHdd) + if(_isHdd) throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image"); return VerifySector(GetAbsoluteSector(sectorAddress, track)); diff --git a/Aaru.Images/CPCDSK/CPCDSK.cs b/Aaru.Images/CPCDSK/CPCDSK.cs index d4a559019..962a93830 100644 --- a/Aaru.Images/CPCDSK/CPCDSK.cs +++ b/Aaru.Images/CPCDSK/CPCDSK.cs @@ -39,12 +39,12 @@ namespace Aaru.DiscImages { public partial class Cpcdsk : IMediaImage { - Dictionary addressMarks; - bool extended; - ImageInfo imageInfo; - Dictionary sectors; + Dictionary _addressMarks; + bool _extended; + ImageInfo _imageInfo; + Dictionary _sectors; - public Cpcdsk() => imageInfo = new ImageInfo + public Cpcdsk() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/CPCDSK/Constants.cs b/Aaru.Images/CPCDSK/Constants.cs index b0eb64f14..c5af2c82e 100644 --- a/Aaru.Images/CPCDSK/Constants.cs +++ b/Aaru.Images/CPCDSK/Constants.cs @@ -35,24 +35,24 @@ namespace Aaru.DiscImages public partial class Cpcdsk { /// Identifier for CPCEMU disk images, "MV - CPC" + usually : "EMU Disk-File\r\nDisk-Info\r\n" but not required - readonly byte[] cpcdskId = + readonly byte[] _cpcdskId = { 0x4D, 0x56, 0x20, 0x2D, 0x20, 0x43, 0x50, 0x43 }; /// Identifier for DU54 disk images, "MV - CPC format Disk Image (DU54)" - readonly byte[] du54Id = + readonly byte[] _du54Id = { 0x4D, 0x56, 0x20, 0x2D, 0x20, 0x43, 0x50, 0x43, 0x20, 0x66, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x20, 0x44, 0x69, 0x73, 0x6B, 0x20 }; /// Identifier for Extended CPCEMU disk images, "EXTENDED CPC DSK File" - readonly byte[] edskId = + readonly byte[] _edskId = { 0x45, 0x58, 0x54, 0x45, 0x4E, 0x44, 0x45, 0x44, 0x20, 0x43, 0x50, 0x43, 0x20, 0x44, 0x53, 0x4B, 0x20, 0x46, 0x69, 0x6C, 0x65 }; /// Identifier for track information, "Track-Info\r\n" - readonly byte[] trackId = + readonly byte[] _trackId = { 0x54, 0x72, 0x61, 0x63, 0x6B, 0x2D, 0x49, 0x6E, 0x66, 0x6F }; diff --git a/Aaru.Images/CPCDSK/Identify.cs b/Aaru.Images/CPCDSK/Identify.cs index d12b6395b..576c971f7 100644 --- a/Aaru.Images/CPCDSK/Identify.cs +++ b/Aaru.Images/CPCDSK/Identify.cs @@ -55,8 +55,8 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CPCDSK plugin", "header.magic = \"{0}\"", StringHandlers.CToString(header.magic)); - return cpcdskId.SequenceEqual(header.magic.Take(cpcdskId.Length)) || edskId.SequenceEqual(header.magic) || - du54Id.SequenceEqual(header.magic); + return _cpcdskId.SequenceEqual(header.magic.Take(_cpcdskId.Length)) || + _edskId.SequenceEqual(header.magic) || _du54Id.SequenceEqual(header.magic); } } } \ No newline at end of file diff --git a/Aaru.Images/CPCDSK/Properties.cs b/Aaru.Images/CPCDSK/Properties.cs index 0570f8809..b9f3fb3af 100644 --- a/Aaru.Images/CPCDSK/Properties.cs +++ b/Aaru.Images/CPCDSK/Properties.cs @@ -39,10 +39,10 @@ namespace Aaru.DiscImages { public partial class Cpcdsk { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "CPCEMU Disk-File and Extended CPC Disk-File"; public Guid Id => new Guid("724B16CC-ADB9-492E-BA07-CAEEC1012B16"); - public string Format => extended ? "CPCEMU Extended disk image" : "CPCEMU disk image"; + public string Format => _extended ? "CPCEMU Extended disk image" : "CPCEMU disk image"; public string Author => "Natalia Portillo"; public List DumpHardware => null; public CICMMetadataType CicmMetadata => null; diff --git a/Aaru.Images/CPCDSK/Read.cs b/Aaru.Images/CPCDSK/Read.cs index a807f9768..699b20685 100644 --- a/Aaru.Images/CPCDSK/Read.cs +++ b/Aaru.Images/CPCDSK/Read.cs @@ -59,13 +59,13 @@ namespace Aaru.DiscImages stream.Read(headerB, 0, 256); CpcDiskInfo header = Marshal.ByteArrayToStructureLittleEndian(headerB); - if(!cpcdskId.SequenceEqual(header.magic.Take(cpcdskId.Length)) && - !edskId.SequenceEqual(header.magic) && - !du54Id.SequenceEqual(header.magic)) + if(!_cpcdskId.SequenceEqual(header.magic.Take(_cpcdskId.Length)) && + !_edskId.SequenceEqual(header.magic) && + !_du54Id.SequenceEqual(header.magic)) return false; - extended = edskId.SequenceEqual(header.magic); - AaruConsole.DebugWriteLine("CPCDSK plugin", "Extended = {0}", extended); + _extended = _edskId.SequenceEqual(header.magic); + AaruConsole.DebugWriteLine("CPCDSK plugin", "Extended = {0}", _extended); AaruConsole.DebugWriteLine("CPCDSK plugin", "header.magic = \"{0}\"", StringHandlers.CToString(header.magic)); @@ -79,7 +79,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CPCDSK plugin", "header.tracks = {0}", header.tracks); AaruConsole.DebugWriteLine("CPCDSK plugin", "header.sides = {0}", header.sides); - if(!extended) + if(!_extended) AaruConsole.DebugWriteLine("CPCDSK plugin", "header.tracksize = {0}", header.tracksize); else for(int i = 0; i < header.tracks; i++) @@ -90,8 +90,8 @@ namespace Aaru.DiscImages } ulong currentSector = 0; - sectors = new Dictionary(); - addressMarks = new Dictionary(); + _sectors = new Dictionary(); + _addressMarks = new Dictionary(); ulong readtracks = 0; bool allTracksSameSize = true; ulong sectorsPerTrack = 0; @@ -104,7 +104,7 @@ namespace Aaru.DiscImages for(int j = 0; j < header.sides; j++) { // Track not stored in image - if(extended && header.tracksizeTable[(i * header.sides) + j] == 0) + if(_extended && header.tracksizeTable[(i * header.sides) + j] == 0) continue; long trackPos = stream.Position; @@ -113,7 +113,7 @@ namespace Aaru.DiscImages stream.Read(trackB, 0, 256); CpcTrackInfo trackInfo = Marshal.ByteArrayToStructureLittleEndian(trackB); - if(!trackId.SequenceEqual(trackInfo.magic)) + if(!_trackId.SequenceEqual(trackInfo.magic)) { AaruConsole.ErrorWriteLine("Not the expected track info."); @@ -181,7 +181,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CPCDSK plugin", "trackInfo[{1}:{2}].sector[{3}].track = {0}", trackInfo.sectorsInfo[k - 1].track, i, j, k); - int sectLen = extended ? trackInfo.sectorsInfo[k - 1].len + int sectLen = _extended ? trackInfo.sectorsInfo[k - 1].len : SizeCodeToBytes(trackInfo.sectorsInfo[k - 1].size); byte[] sector = new byte[sectLen]; @@ -223,43 +223,43 @@ namespace Aaru.DiscImages for(int s = 0; s < thisTrackSectors.Length; s++) { - sectors.Add(currentSector, thisTrackSectors[s]); - addressMarks.Add(currentSector, thisTrackAddressMarks[s]); + _sectors.Add(currentSector, thisTrackSectors[s]); + _addressMarks.Add(currentSector, thisTrackAddressMarks[s]); currentSector++; - if(thisTrackSectors[s].Length > imageInfo.SectorSize) - imageInfo.SectorSize = (uint)thisTrackSectors[s].Length; + if(thisTrackSectors[s].Length > _imageInfo.SectorSize) + _imageInfo.SectorSize = (uint)thisTrackSectors[s].Length; } stream.Seek(trackPos, SeekOrigin.Begin); - if(extended) + if(_extended) { stream.Seek(header.tracksizeTable[(i * header.sides) + j] * 256, SeekOrigin.Current); - imageInfo.ImageSize += (ulong)(header.tracksizeTable[(i * header.sides) + j] * 256) - 256; + _imageInfo.ImageSize += (ulong)(header.tracksizeTable[(i * header.sides) + j] * 256) - 256; } else { stream.Seek(header.tracksize, SeekOrigin.Current); - imageInfo.ImageSize += (ulong)header.tracksize - 256; + _imageInfo.ImageSize += (ulong)header.tracksize - 256; } readtracks++; } } - AaruConsole.DebugWriteLine("CPCDSK plugin", "Read {0} sectors", sectors.Count); + AaruConsole.DebugWriteLine("CPCDSK plugin", "Read {0} sectors", _sectors.Count); AaruConsole.DebugWriteLine("CPCDSK plugin", "Read {0} tracks", readtracks); AaruConsole.DebugWriteLine("CPCDSK plugin", "All tracks are same size? {0}", allTracksSameSize); - imageInfo.Application = StringHandlers.CToString(header.creator); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = (ulong)sectors.Count; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.MediaType = MediaType.CompactFloppy; - imageInfo.ReadableSectorTags.Add(SectorTagType.FloppyAddressMark); + _imageInfo.Application = StringHandlers.CToString(header.creator); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = (ulong)_sectors.Count; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.MediaType = MediaType.CompactFloppy; + _imageInfo.ReadableSectorTags.Add(SectorTagType.FloppyAddressMark); // Debug writing full disk as raw /* @@ -273,16 +273,16 @@ namespace Aaru.DiscImages foo.Close(); */ - imageInfo.Cylinders = header.tracks; - imageInfo.Heads = header.sides; - imageInfo.SectorsPerTrack = (uint)(imageInfo.Sectors / (imageInfo.Cylinders * imageInfo.Heads)); + _imageInfo.Cylinders = header.tracks; + _imageInfo.Heads = header.sides; + _imageInfo.SectorsPerTrack = (uint)(_imageInfo.Sectors / (_imageInfo.Cylinders * _imageInfo.Heads)); return true; } public byte[] ReadSector(ulong sectorAddress) { - if(sectors.TryGetValue(sectorAddress, out byte[] sector)) + if(_sectors.TryGetValue(sectorAddress, out byte[] sector)) return sector; throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); @@ -290,11 +290,11 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); @@ -313,7 +313,7 @@ namespace Aaru.DiscImages if(tag != SectorTagType.FloppyAddressMark) throw new FeatureUnsupportedImageException($"Tag {tag} not supported by image format"); - if(addressMarks.TryGetValue(sectorAddress, out byte[] addressMark)) + if(_addressMarks.TryGetValue(sectorAddress, out byte[] addressMark)) return addressMark; throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); @@ -324,11 +324,11 @@ namespace Aaru.DiscImages if(tag != SectorTagType.FloppyAddressMark) throw new FeatureUnsupportedImageException($"Tag {tag} not supported by image format"); - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); diff --git a/Aaru.Images/CisCopy/CisCopy.cs b/Aaru.Images/CisCopy/CisCopy.cs index 9e89ccc19..59d083c90 100644 --- a/Aaru.Images/CisCopy/CisCopy.cs +++ b/Aaru.Images/CisCopy/CisCopy.cs @@ -55,12 +55,12 @@ namespace Aaru.DiscImages */ public partial class CisCopy : IWritableImage { - byte[] decodedDisk; - ImageInfo imageInfo; - long writingOffset; - FileStream writingStream; + byte[] _decodedDisk; + ImageInfo _imageInfo; + long _writingOffset; + FileStream _writingStream; - public CisCopy() => imageInfo = new ImageInfo + public CisCopy() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/CisCopy/Properties.cs b/Aaru.Images/CisCopy/Properties.cs index 7eab0e10d..3aae2417a 100644 --- a/Aaru.Images/CisCopy/Properties.cs +++ b/Aaru.Images/CisCopy/Properties.cs @@ -45,7 +45,7 @@ namespace Aaru.DiscImages public Guid Id => new Guid("EDF20CC7-6012-49E2-9E92-663A53E42130"); public string Format => "CisCopy"; public string Author => "Natalia Portillo"; - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public List DumpHardware => null; public CICMMetadataType CicmMetadata => null; public IEnumerable SupportedMediaTags => new MediaTagType[] diff --git a/Aaru.Images/CisCopy/Read.cs b/Aaru.Images/CisCopy/Read.cs index 85c56a5bc..c427f2649 100644 --- a/Aaru.Images/CisCopy/Read.cs +++ b/Aaru.Images/CisCopy/Read.cs @@ -122,79 +122,79 @@ namespace Aaru.DiscImages decodedImage.Write(track, 0, tracksize); } - imageInfo.Application = "CisCopy"; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = imageFilter.GetFilename(); - imageInfo.ImageSize = (ulong)(stream.Length - 2 - trackBytes.Length); - imageInfo.SectorSize = 512; + _imageInfo.Application = "CisCopy"; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = imageFilter.GetFilename(); + _imageInfo.ImageSize = (ulong)(stream.Length - 2 - trackBytes.Length); + _imageInfo.SectorSize = 512; switch(type) { case DiskType.MD1DD8: - imageInfo.MediaType = MediaType.DOS_525_SS_DD_8; - imageInfo.Sectors = 40 * 1 * 8; - imageInfo.Heads = 1; - imageInfo.Cylinders = 40; - imageInfo.SectorsPerTrack = 8; + _imageInfo.MediaType = MediaType.DOS_525_SS_DD_8; + _imageInfo.Sectors = 40 * 1 * 8; + _imageInfo.Heads = 1; + _imageInfo.Cylinders = 40; + _imageInfo.SectorsPerTrack = 8; break; case DiskType.MD2DD8: - imageInfo.MediaType = MediaType.DOS_525_DS_DD_8; - imageInfo.Sectors = 40 * 2 * 8; - imageInfo.Heads = 2; - imageInfo.Cylinders = 40; - imageInfo.SectorsPerTrack = 8; + _imageInfo.MediaType = MediaType.DOS_525_DS_DD_8; + _imageInfo.Sectors = 40 * 2 * 8; + _imageInfo.Heads = 2; + _imageInfo.Cylinders = 40; + _imageInfo.SectorsPerTrack = 8; break; case DiskType.MD1DD: - imageInfo.MediaType = MediaType.DOS_525_SS_DD_9; - imageInfo.Sectors = 40 * 1 * 9; - imageInfo.Heads = 1; - imageInfo.Cylinders = 40; - imageInfo.SectorsPerTrack = 9; + _imageInfo.MediaType = MediaType.DOS_525_SS_DD_9; + _imageInfo.Sectors = 40 * 1 * 9; + _imageInfo.Heads = 1; + _imageInfo.Cylinders = 40; + _imageInfo.SectorsPerTrack = 9; break; case DiskType.MD2DD: - imageInfo.MediaType = MediaType.DOS_525_DS_DD_9; - imageInfo.Sectors = 40 * 2 * 9; - imageInfo.Heads = 2; - imageInfo.Cylinders = 40; - imageInfo.SectorsPerTrack = 9; + _imageInfo.MediaType = MediaType.DOS_525_DS_DD_9; + _imageInfo.Sectors = 40 * 2 * 9; + _imageInfo.Heads = 2; + _imageInfo.Cylinders = 40; + _imageInfo.SectorsPerTrack = 9; break; case DiskType.MF2DD: - imageInfo.MediaType = MediaType.DOS_35_DS_DD_9; - imageInfo.Sectors = 80 * 2 * 9; - imageInfo.Heads = 2; - imageInfo.Cylinders = 80; - imageInfo.SectorsPerTrack = 9; + _imageInfo.MediaType = MediaType.DOS_35_DS_DD_9; + _imageInfo.Sectors = 80 * 2 * 9; + _imageInfo.Heads = 2; + _imageInfo.Cylinders = 80; + _imageInfo.SectorsPerTrack = 9; break; case DiskType.MD2HD: - imageInfo.MediaType = MediaType.DOS_525_HD; - imageInfo.Sectors = 80 * 2 * 15; - imageInfo.Heads = 2; - imageInfo.Cylinders = 80; - imageInfo.SectorsPerTrack = 15; + _imageInfo.MediaType = MediaType.DOS_525_HD; + _imageInfo.Sectors = 80 * 2 * 15; + _imageInfo.Heads = 2; + _imageInfo.Cylinders = 80; + _imageInfo.SectorsPerTrack = 15; break; case DiskType.MF2HD: - imageInfo.MediaType = MediaType.DOS_35_HD; - imageInfo.Sectors = 80 * 2 * 18; - imageInfo.Heads = 2; - imageInfo.Cylinders = 80; - imageInfo.SectorsPerTrack = 18; + _imageInfo.MediaType = MediaType.DOS_35_HD; + _imageInfo.Sectors = 80 * 2 * 18; + _imageInfo.Heads = 2; + _imageInfo.Cylinders = 80; + _imageInfo.SectorsPerTrack = 18; break; } - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - decodedDisk = decodedImage.ToArray(); + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _decodedDisk = decodedImage.ToArray(); decodedImage.Close(); - AaruConsole.VerboseWriteLine("CisCopy image contains a disk of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("CisCopy image contains a disk of type {0}", _imageInfo.MediaType); return true; } @@ -203,16 +203,16 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Array.Copy(decodedDisk, (int)sectorAddress * imageInfo.SectorSize, buffer, 0, - length * imageInfo.SectorSize); + Array.Copy(_decodedDisk, (int)sectorAddress * _imageInfo.SectorSize, buffer, 0, + length * _imageInfo.SectorSize); return buffer; } diff --git a/Aaru.Images/CisCopy/Write.cs b/Aaru.Images/CisCopy/Write.cs index 7b71d5a00..cb4d399c4 100644 --- a/Aaru.Images/CisCopy/Write.cs +++ b/Aaru.Images/CisCopy/Write.cs @@ -59,7 +59,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -68,7 +68,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -115,7 +115,7 @@ namespace Aaru.DiscImages return false; } - writingStream.WriteByte((byte)diskType); + _writingStream.WriteByte((byte)diskType); byte tracks = 0; @@ -144,14 +144,14 @@ namespace Aaru.DiscImages for(int i = 0; i < tracks; i += headstep) { - writingStream.WriteByte((byte)TrackType.Copied); + _writingStream.WriteByte((byte)TrackType.Copied); if(headstep == 2) - writingStream.WriteByte(0); + _writingStream.WriteByte(0); } - writingStream.WriteByte((byte)Compression.None); - writingOffset = writingStream.Position; + _writingStream.WriteByte((byte)Compression.None); + _writingOffset = _writingStream.Position; IsWriting = true; ErrorMessage = null; @@ -182,15 +182,15 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek(writingOffset + (long)(sectorAddress * imageInfo.SectorSize), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek(_writingOffset + (long)(sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -213,15 +213,15 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek(writingOffset + (long)(sectorAddress * imageInfo.SectorSize), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek(_writingOffset + (long)(sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -251,8 +251,8 @@ namespace Aaru.DiscImages return false; } - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; diff --git a/Aaru.Images/CloneCD/CloneCD.cs b/Aaru.Images/CloneCD/CloneCD.cs index 8bffc4044..5ab56f0ac 100644 --- a/Aaru.Images/CloneCD/CloneCD.cs +++ b/Aaru.Images/CloneCD/CloneCD.cs @@ -41,23 +41,23 @@ namespace Aaru.DiscImages // TODO: CloneCD stores subchannel deinterleaved public partial class CloneCd : IWritableOpticalImage { - string catalog; // TODO: Use it - IFilter ccdFilter; - byte[] cdtext; - StreamReader cueStream; - IFilter dataFilter; - Stream dataStream; - StreamWriter descriptorStream; - byte[] fulltoc; - ImageInfo imageInfo; - Dictionary offsetmap; - bool scrambled; - IFilter subFilter; - Stream subStream; - Dictionary trackFlags; - string writingBaseName; + string _catalog; // TODO: Use it + IFilter _ccdFilter; + byte[] _cdtext; + StreamReader _cueStream; + IFilter _dataFilter; + Stream _dataStream; + StreamWriter _descriptorStream; + byte[] _fulltoc; + ImageInfo _imageInfo; + Dictionary _offsetmap; + bool _scrambled; + IFilter _subFilter; + Stream _subStream; + Dictionary _trackFlags; + string _writingBaseName; - public CloneCd() => imageInfo = new ImageInfo + public CloneCd() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/CloneCD/Identify.cs b/Aaru.Images/CloneCD/Identify.cs index 6427f0bb2..57d9810fe 100644 --- a/Aaru.Images/CloneCD/Identify.cs +++ b/Aaru.Images/CloneCD/Identify.cs @@ -42,7 +42,7 @@ namespace Aaru.DiscImages { public bool Identify(IFilter imageFilter) { - ccdFilter = imageFilter; + _ccdFilter = imageFilter; try { @@ -76,9 +76,9 @@ namespace Aaru.DiscImages return false; } - cueStream = new StreamReader(ccdFilter.GetDataForkStream()); + _cueStream = new StreamReader(_ccdFilter.GetDataForkStream()); - string line = cueStream.ReadLine(); + string line = _cueStream.ReadLine(); var hdr = new Regex(CCD_IDENTIFIER); @@ -88,7 +88,7 @@ namespace Aaru.DiscImages } catch(Exception ex) { - AaruConsole.ErrorWriteLine("Exception trying to identify image file {0}", ccdFilter); + AaruConsole.ErrorWriteLine("Exception trying to identify image file {0}", _ccdFilter); AaruConsole.ErrorWriteLine("Exception: {0}", ex.Message); AaruConsole.ErrorWriteLine("Stack trace: {0}", ex.StackTrace); diff --git a/Aaru.Images/CloneCD/Properties.cs b/Aaru.Images/CloneCD/Properties.cs index 85db460c5..45791b240 100644 --- a/Aaru.Images/CloneCD/Properties.cs +++ b/Aaru.Images/CloneCD/Properties.cs @@ -52,7 +52,7 @@ namespace Aaru.DiscImages OpticalImageCapabilities.CanStoreRawData | OpticalImageCapabilities.CanStoreCookedData | OpticalImageCapabilities.CanStoreMultipleTracks; - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "CloneCD"; public Guid Id => new Guid("EE9C2975-2E79-427A-8EE9-F86F19165784"); public string Format => "CloneCD"; diff --git a/Aaru.Images/CloneCD/Read.cs b/Aaru.Images/CloneCD/Read.cs index 4b42f1c3d..c70ee7b01 100644 --- a/Aaru.Images/CloneCD/Read.cs +++ b/Aaru.Images/CloneCD/Read.cs @@ -53,12 +53,12 @@ namespace Aaru.DiscImages if(imageFilter == null) return false; - ccdFilter = imageFilter; + _ccdFilter = imageFilter; try { imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); - cueStream = new StreamReader(imageFilter.GetDataForkStream()); + _cueStream = new StreamReader(imageFilter.GetDataForkStream()); int lineNumber = 0; var ccdIdRegex = new Regex(CCD_IDENTIFIER); @@ -103,13 +103,13 @@ namespace Aaru.DiscImages int maxSession = int.MinValue; var currentEntry = new FullTOC.TrackDataDescriptor(); List entries = new List(); - scrambled = false; - catalog = null; + _scrambled = false; + _catalog = null; - while(cueStream.Peek() >= 0) + while(_cueStream.Peek() >= 0) { lineNumber++; - string line = cueStream.ReadLine(); + string line = _cueStream.ReadLine(); Match ccdIdMatch = ccdIdRegex.Match(line); Match discIdMatch = discIdRegex.Match(line); @@ -166,13 +166,13 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CloneCD plugin", "Found Version at line {0}", lineNumber); - imageInfo.Version = ccdVerMatch.Groups["value"].Value; + _imageInfo.Version = ccdVerMatch.Groups["value"].Value; - if(imageInfo.Version != "2" && - imageInfo.Version != "3") + if(_imageInfo.Version != "2" && + _imageInfo.Version != "3") AaruConsole. ErrorWriteLine("(CloneCD plugin): Warning! Unknown CCD image version {0}, may not work!", - imageInfo.Version); + _imageInfo.Version); } else if(inDisk) { @@ -192,7 +192,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("CloneCD plugin", "Found DataTracksScrambled at line {0}", lineNumber); - scrambled |= discScrMatch.Groups["value"].Value == "1"; + _scrambled |= discScrMatch.Groups["value"].Value == "1"; } else if(cdtLenMatch.Success) AaruConsole.DebugWriteLine("CloneCD plugin", "Found CDTextLength at line {0}", @@ -200,7 +200,7 @@ namespace Aaru.DiscImages else if(discCatMatch.Success) { AaruConsole.DebugWriteLine("CloneCD plugin", "Found Catalog at line {0}", lineNumber); - catalog = discCatMatch.Groups["value"].Value; + _catalog = discCatMatch.Groups["value"].Value; } } @@ -364,20 +364,20 @@ namespace Aaru.DiscImages tocMs.WriteByte(descriptor.PFRAME); } - fulltoc = tocMs.ToArray(); - imageInfo.ReadableMediaTags.Add(MediaTagType.CD_FullTOC); + _fulltoc = tocMs.ToArray(); + _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_FullTOC); string dataFile = Path.GetFileNameWithoutExtension(imageFilter.GetBasePath()) + ".img"; string subFile = Path.GetFileNameWithoutExtension(imageFilter.GetBasePath()) + ".sub"; var filtersList = new FiltersList(); - dataFilter = filtersList.GetFilter(dataFile); + _dataFilter = filtersList.GetFilter(dataFile); - if(dataFilter == null) + if(_dataFilter == null) throw new Exception("Cannot open data file"); filtersList = new FiltersList(); - subFilter = filtersList.GetFilter(subFile); + _subFilter = filtersList.GetFilter(subFile); int curSessionNo = 0; var currentTrack = new Track(); @@ -385,12 +385,12 @@ namespace Aaru.DiscImages Tracks = new List(); ulong leadOutStart = 0; - dataStream = dataFilter.GetDataForkStream(); + _dataStream = _dataFilter.GetDataForkStream(); - if(subFilter != null) - subStream = subFilter.GetDataForkStream(); + if(_subFilter != null) + _subStream = _subFilter.GetDataForkStream(); - trackFlags = new Dictionary(); + _trackFlags = new Dictionary(); foreach(FullTOC.TrackDataDescriptor descriptor in entries) { @@ -439,9 +439,9 @@ namespace Aaru.DiscImages currentTrack = new Track { TrackBytesPerSector = 2352, - TrackFile = dataFilter.GetFilename(), - TrackFileType = scrambled ? "SCRAMBLED" : "BINARY", - TrackFilter = dataFilter, + TrackFile = _dataFilter.GetFilename(), + TrackFileType = _scrambled ? "SCRAMBLED" : "BINARY", + TrackFilter = _dataFilter, TrackRawBytesPerSector = 2352, TrackSequence = descriptor.POINT, TrackStartSector = @@ -456,13 +456,13 @@ namespace Aaru.DiscImages else currentTrack.TrackType = TrackType.Audio; - if(!trackFlags.ContainsKey(descriptor.POINT)) - trackFlags.Add(descriptor.POINT, descriptor.CONTROL); + if(!_trackFlags.ContainsKey(descriptor.POINT)) + _trackFlags.Add(descriptor.POINT, descriptor.CONTROL); - if(subFilter != null) + if(_subFilter != null) { - currentTrack.TrackSubchannelFile = subFilter.GetFilename(); - currentTrack.TrackSubchannelFilter = subFilter; + currentTrack.TrackSubchannelFile = _subFilter.GetFilename(); + currentTrack.TrackSubchannelFilter = _subFilter; currentTrack.TrackSubchannelType = TrackSubchannelType.Raw; } else @@ -482,11 +482,11 @@ namespace Aaru.DiscImages int type = descriptor.PFRAME % 10; int frm = descriptor.PFRAME - type; - imageInfo.MediaManufacturer = ATIP.ManufacturerFromATIP(descriptor.PSEC, frm); + _imageInfo.MediaManufacturer = ATIP.ManufacturerFromATIP(descriptor.PSEC, frm); - if(imageInfo.MediaManufacturer != "") + if(_imageInfo.MediaManufacturer != "") AaruConsole.DebugWriteLine("CloneCD plugin", "Disc manufactured by: {0}", - imageInfo.MediaManufacturer); + _imageInfo.MediaManufacturer); } break; @@ -497,7 +497,7 @@ namespace Aaru.DiscImages { uint id = (uint)((descriptor.Min << 16) + (descriptor.Sec << 8) + descriptor.Frame); AaruConsole.DebugWriteLine("CloneCD plugin", "Disc ID: {0:X6}", id & 0x00FFFFFF); - imageInfo.MediaSerialNumber = $"{id & 0x00FFFFFF:X6}"; + _imageInfo.MediaSerialNumber = $"{id & 0x00FFFFFF:X6}"; break; } @@ -521,7 +521,7 @@ namespace Aaru.DiscImages currentDataOffset += 2352 * ((tmpTracks[i].TrackEndSector - tmpTracks[i].TrackStartSector) + 1); - if(subFilter != null) + if(_subFilter != null) { tmpTracks[i].TrackSubchannelOffset = currentSubchannelOffset; @@ -538,18 +538,18 @@ namespace Aaru.DiscImages long pos = (long)tmpTracks[i].TrackFileOffset + (s * 2352); - if(pos >= dataStream.Length + 2352 || + if(pos >= _dataStream.Length + 2352 || s >= (int)(tmpTracks[i].TrackEndSector - tmpTracks[i].TrackStartSector)) break; - dataStream.Seek(pos, SeekOrigin.Begin); - dataStream.Read(sectTest, 0, 2352); + _dataStream.Seek(pos, SeekOrigin.Begin); + _dataStream.Read(sectTest, 0, 2352); Array.Copy(sectTest, 0, syncTest, 0, 12); if(!Sector.SyncMark.SequenceEqual(syncTest)) continue; - if(scrambled) + if(_scrambled) sectTest = Sector.Scramble(sectTest); if(sectTest[15] == 1) @@ -557,26 +557,26 @@ namespace Aaru.DiscImages tmpTracks[i].TrackBytesPerSector = 2048; tmpTracks[i].TrackType = TrackType.CdMode1; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - if(imageInfo.SectorSize < 2048) - imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) + _imageInfo.SectorSize = 2048; break; } @@ -597,20 +597,20 @@ namespace Aaru.DiscImages tmpTracks[i].TrackBytesPerSector = 2324; tmpTracks[i].TrackType = TrackType.CdMode2Form2; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - if(imageInfo.SectorSize < 2324) - imageInfo.SectorSize = 2324; + if(_imageInfo.SectorSize < 2324) + _imageInfo.SectorSize = 2324; break; } @@ -619,29 +619,29 @@ namespace Aaru.DiscImages tmpTracks[i].TrackBytesPerSector = 2048; tmpTracks[i].TrackType = TrackType.CdMode2Form1; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); - if(imageInfo.SectorSize < 2048) - imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) + _imageInfo.SectorSize = 2048; break; } @@ -649,14 +649,14 @@ namespace Aaru.DiscImages tmpTracks[i].TrackBytesPerSector = 2336; tmpTracks[i].TrackType = TrackType.CdMode2Formless; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(imageInfo.SectorSize < 2336) - imageInfo.SectorSize = 2336; + if(_imageInfo.SectorSize < 2336) + _imageInfo.SectorSize = 2336; break; } @@ -664,18 +664,18 @@ namespace Aaru.DiscImages } else { - if(imageInfo.SectorSize < 2352) - imageInfo.SectorSize = 2352; + if(_imageInfo.SectorSize < 2352) + _imageInfo.SectorSize = 2352; } } Tracks = tmpTracks.ToList(); - if(subFilter != null && - !imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); + if(_subFilter != null && + !_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); - imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); Sessions = new List(); @@ -687,7 +687,7 @@ namespace Aaru.DiscImages }; Partitions = new List(); - offsetmap = new Dictionary(); + _offsetmap = new Dictionary(); foreach(Track track in Tracks) { @@ -729,9 +729,9 @@ namespace Aaru.DiscImages Type = track.TrackType.ToString() }; - imageInfo.Sectors += partition.Length; + _imageInfo.Sectors += partition.Length; Partitions.Add(partition); - offsetmap.Add(track.TrackSequence, track.TrackStartSector); + _offsetmap.Add(track.TrackSequence, track.TrackStartSector); } bool data = false; @@ -766,28 +766,28 @@ namespace Aaru.DiscImages } // TODO: Check format - cdtext = cdtMs.ToArray(); + _cdtext = cdtMs.ToArray(); if(!data && !firstdata) - imageInfo.MediaType = MediaType.CDDA; + _imageInfo.MediaType = MediaType.CDDA; else if(firstaudio && data && Sessions.Count > 1 && mode2) - imageInfo.MediaType = MediaType.CDPLUS; + _imageInfo.MediaType = MediaType.CDPLUS; else if((firstdata && audio) || mode2) - imageInfo.MediaType = MediaType.CDROMXA; + _imageInfo.MediaType = MediaType.CDROMXA; else if(!audio) - imageInfo.MediaType = MediaType.CDROM; + _imageInfo.MediaType = MediaType.CDROM; else - imageInfo.MediaType = MediaType.CD; + _imageInfo.MediaType = MediaType.CD; - imageInfo.Application = "CloneCD"; - imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; + _imageInfo.Application = "CloneCD"; + _imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; return true; } @@ -805,12 +805,12 @@ namespace Aaru.DiscImages { switch(tag) { - case MediaTagType.CD_FullTOC: return fulltoc; + case MediaTagType.CD_FullTOC: return _fulltoc; case MediaTagType.CD_TEXT: { - if(cdtext != null && - cdtext.Length > 0) - return cdtext; + if(_cdtext != null && + _cdtext.Length > 0) + return _cdtext; throw new FeatureNotPresentImageException("Image does not contain CD-TEXT information."); } @@ -830,7 +830,7 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress <= track.TrackEndSector select kvp) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); @@ -840,7 +840,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress <= track.TrackEndSector select kvp) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); @@ -911,13 +911,13 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - dataStream.Seek((long)(aaruTrack.TrackFileOffset + (sectorAddress * 2352)), SeekOrigin.Begin); + _dataStream.Seek((long)(aaruTrack.TrackFileOffset + (sectorAddress * 2352)), SeekOrigin.Begin); if(mode2) { var mode2Ms = new MemoryStream((int)(sectorSize * length)); - dataStream.Read(buffer, 0, buffer.Length); + _dataStream.Read(buffer, 0, buffer.Length); for(int i = 0; i < length; i++) { @@ -931,14 +931,14 @@ namespace Aaru.DiscImages } else if(sectorOffset == 0 && sectorSkip == 0) - dataStream.Read(buffer, 0, buffer.Length); + _dataStream.Read(buffer, 0, buffer.Length); else for(int i = 0; i < length; i++) { byte[] sector = new byte[sectorSize]; - dataStream.Seek(sectorOffset, SeekOrigin.Current); - dataStream.Read(sector, 0, sector.Length); - dataStream.Seek(sectorSkip, SeekOrigin.Current); + _dataStream.Seek(sectorOffset, SeekOrigin.Current); + _dataStream.Read(sector, 0, sector.Length); + _dataStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } @@ -984,14 +984,14 @@ namespace Aaru.DiscImages case SectorTagType.CdSectorSubHeader: case SectorTagType.CdSectorSync: break; case SectorTagType.CdTrackFlags: - return !trackFlags.TryGetValue((byte)aaruTrack.TrackSequence, out byte flags) ? new[] + return !_trackFlags.TryGetValue((byte)aaruTrack.TrackSequence, out byte flags) ? new[] { flags } : new byte[1]; case SectorTagType.CdSectorSubchannel: buffer = new byte[96 * length]; - subStream.Seek((long)(aaruTrack.TrackSubchannelOffset + (sectorAddress * 96)), SeekOrigin.Begin); - subStream.Read(buffer, 0, buffer.Length); + _subStream.Seek((long)(aaruTrack.TrackSubchannelOffset + (sectorAddress * 96)), SeekOrigin.Begin); + _subStream.Read(buffer, 0, buffer.Length); return Subchannel.Interleave(buffer); default: throw new ArgumentException("Unsupported tag requested", nameof(tag)); @@ -1202,18 +1202,18 @@ namespace Aaru.DiscImages buffer = new byte[sectorSize * length]; - dataStream.Seek((long)(aaruTrack.TrackFileOffset + (sectorAddress * 2352)), SeekOrigin.Begin); + _dataStream.Seek((long)(aaruTrack.TrackFileOffset + (sectorAddress * 2352)), SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) - dataStream.Read(buffer, 0, buffer.Length); + _dataStream.Read(buffer, 0, buffer.Length); else for(int i = 0; i < length; i++) { byte[] sector = new byte[sectorSize]; - dataStream.Seek(sectorOffset, SeekOrigin.Current); - dataStream.Read(sector, 0, sector.Length); - dataStream.Seek(sectorSkip, SeekOrigin.Current); + _dataStream.Seek(sectorOffset, SeekOrigin.Current); + _dataStream.Read(sector, 0, sector.Length); + _dataStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } @@ -1226,7 +1226,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value < (track.TrackEndSector - track.TrackStartSector) + 1 @@ -1259,8 +1259,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[2352 * length]; - dataStream.Seek((long)(aaruTrack.TrackFileOffset + (sectorAddress * 2352)), SeekOrigin.Begin); - dataStream.Read(buffer, 0, buffer.Length); + _dataStream.Seek((long)(aaruTrack.TrackFileOffset + (sectorAddress * 2352)), SeekOrigin.Begin); + _dataStream.Read(buffer, 0, buffer.Length); return buffer; } diff --git a/Aaru.Images/CloneCD/Write.cs b/Aaru.Images/CloneCD/Write.cs index 64118bbd4..92f5aa874 100644 --- a/Aaru.Images/CloneCD/Write.cs +++ b/Aaru.Images/CloneCD/Write.cs @@ -57,7 +57,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -66,11 +66,11 @@ namespace Aaru.DiscImages try { - writingBaseName = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)); - descriptorStream = new StreamWriter(path, false, Encoding.ASCII); + _writingBaseName = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)); + _descriptorStream = new StreamWriter(path, false, Encoding.ASCII); - dataStream = new FileStream(writingBaseName + ".img", FileMode.OpenOrCreate, FileAccess.ReadWrite, - FileShare.None); + _dataStream = new FileStream(_writingBaseName + ".img", FileMode.OpenOrCreate, FileAccess.ReadWrite, + FileShare.None); } catch(IOException e) { @@ -79,9 +79,9 @@ namespace Aaru.DiscImages return false; } - imageInfo.MediaType = mediaType; + _imageInfo.MediaType = mediaType; - trackFlags = new Dictionary(); + _trackFlags = new Dictionary(); IsWriting = true; ErrorMessage = null; @@ -101,11 +101,11 @@ namespace Aaru.DiscImages switch(tag) { case MediaTagType.CD_MCN: - catalog = Encoding.ASCII.GetString(data); + _catalog = Encoding.ASCII.GetString(data); return true; case MediaTagType.CD_FullTOC: - fulltoc = data; + _fulltoc = data; return true; default: @@ -172,10 +172,11 @@ namespace Aaru.DiscImages return false; } - dataStream.Seek((long)(track.TrackFileOffset + ((sectorAddress - track.TrackStartSector) * (ulong)track.TrackRawBytesPerSector)), - SeekOrigin.Begin); + _dataStream. + Seek((long)(track.TrackFileOffset + ((sectorAddress - track.TrackStartSector) * (ulong)track.TrackRawBytesPerSector)), + SeekOrigin.Begin); - dataStream.Write(data, 0, data.Length); + _dataStream.Write(data, 0, data.Length); return true; } @@ -214,10 +215,11 @@ namespace Aaru.DiscImages return false; } - dataStream.Seek((long)(track.TrackFileOffset + ((sectorAddress - track.TrackStartSector) * (ulong)track.TrackRawBytesPerSector)), - SeekOrigin.Begin); + _dataStream. + Seek((long)(track.TrackFileOffset + ((sectorAddress - track.TrackStartSector) * (ulong)track.TrackRawBytesPerSector)), + SeekOrigin.Begin); - dataStream.Write(data, 0, data.Length); + _dataStream.Write(data, 0, data.Length); return true; } @@ -287,21 +289,21 @@ namespace Aaru.DiscImages return false; } - dataStream.Flush(); - dataStream.Close(); + _dataStream.Flush(); + _dataStream.Close(); - subStream?.Flush(); - subStream?.Close(); + _subStream?.Flush(); + _subStream?.Close(); FullTOC.CDFullTOC? nullableToc = null; FullTOC.CDFullTOC toc; // Easy, just decode the real toc - if(fulltoc != null) + if(_fulltoc != null) { - byte[] tmp = new byte[fulltoc.Length + 2]; - Array.Copy(BigEndianBitConverter.GetBytes((ushort)fulltoc.Length), 0, tmp, 0, 2); - Array.Copy(fulltoc, 0, tmp, 2, fulltoc.Length); + byte[] tmp = new byte[_fulltoc.Length + 2]; + Array.Copy(BigEndianBitConverter.GetBytes((ushort)_fulltoc.Length), 0, tmp, 0, 2); + Array.Copy(_fulltoc, 0, tmp, 2, _fulltoc.Length); nullableToc = FullTOC.Decode(tmp); } @@ -337,7 +339,7 @@ namespace Aaru.DiscImages foreach(Track track in Tracks.OrderBy(t => t.TrackSession).ThenBy(t => t.TrackSequence)) { - trackFlags.TryGetValue((byte)track.TrackSequence, out byte trackControl); + _trackFlags.TryGetValue((byte)track.TrackSequence, out byte trackControl); if(trackControl == 0 && track.TrackType != TrackType.Audio) @@ -449,20 +451,20 @@ namespace Aaru.DiscImages else toc = nullableToc.Value; - descriptorStream.WriteLine("[CloneCD]"); - descriptorStream.WriteLine("Version=2"); - descriptorStream.WriteLine("[Disc]"); - descriptorStream.WriteLine("TocEntries={0}", toc.TrackDescriptors.Length); - descriptorStream.WriteLine("Sessions={0}", toc.LastCompleteSession); - descriptorStream.WriteLine("DataTracksScrambled=0"); - descriptorStream.WriteLine("CDTextLength=0"); + _descriptorStream.WriteLine("[CloneCD]"); + _descriptorStream.WriteLine("Version=2"); + _descriptorStream.WriteLine("[Disc]"); + _descriptorStream.WriteLine("TocEntries={0}", toc.TrackDescriptors.Length); + _descriptorStream.WriteLine("Sessions={0}", toc.LastCompleteSession); + _descriptorStream.WriteLine("DataTracksScrambled=0"); + _descriptorStream.WriteLine("CDTextLength=0"); - if(!string.IsNullOrEmpty(catalog)) - descriptorStream.WriteLine("CATALOG={0}", catalog); + if(!string.IsNullOrEmpty(_catalog)) + _descriptorStream.WriteLine("CATALOG={0}", _catalog); for(int i = 1; i <= toc.LastCompleteSession; i++) { - descriptorStream.WriteLine("[Session {0}]", i); + _descriptorStream.WriteLine("[Session {0}]", i); Track firstSessionTrack = Tracks.FirstOrDefault(t => t.TrackSession == i); @@ -472,24 +474,24 @@ namespace Aaru.DiscImages // CloneCD always writes this value for first track in disc, however the Rainbow Books // say the first track pregap is no different from other session pregaps, same mode as // the track they belong to. - descriptorStream.WriteLine("PreGapMode=0"); + _descriptorStream.WriteLine("PreGapMode=0"); break; case TrackType.Data: case TrackType.CdMode1: - descriptorStream.WriteLine("PreGapMode=1"); + _descriptorStream.WriteLine("PreGapMode=1"); break; case TrackType.CdMode2Formless: case TrackType.CdMode2Form1: case TrackType.CdMode2Form2: - descriptorStream.WriteLine("PreGapMode=2"); + _descriptorStream.WriteLine("PreGapMode=2"); break; default: throw new ArgumentOutOfRangeException(); } - descriptorStream.WriteLine("PreGapSubC=0"); + _descriptorStream.WriteLine("PreGapSubC=0"); } for(int i = 0; i < toc.TrackDescriptors.Length; i++) @@ -506,29 +508,29 @@ namespace Aaru.DiscImages if(plba > 405000) plba = ((plba - 405000) + 300) * -1; - descriptorStream.WriteLine("[Entry {0}]", i); - descriptorStream.WriteLine("Session={0}", toc.TrackDescriptors[i].SessionNumber); - descriptorStream.WriteLine("Point=0x{0:x2}", toc.TrackDescriptors[i].POINT); - descriptorStream.WriteLine("ADR=0x{0:x2}", toc.TrackDescriptors[i].ADR); - descriptorStream.WriteLine("Control=0x{0:x2}", toc.TrackDescriptors[i].CONTROL); - descriptorStream.WriteLine("TrackNo={0}", toc.TrackDescriptors[i].TNO); - descriptorStream.WriteLine("AMin={0}", toc.TrackDescriptors[i].Min); - descriptorStream.WriteLine("ASec={0}", toc.TrackDescriptors[i].Sec); - descriptorStream.WriteLine("AFrame={0}", toc.TrackDescriptors[i].Frame); - descriptorStream.WriteLine("ALBA={0}", alba); + _descriptorStream.WriteLine("[Entry {0}]", i); + _descriptorStream.WriteLine("Session={0}", toc.TrackDescriptors[i].SessionNumber); + _descriptorStream.WriteLine("Point=0x{0:x2}", toc.TrackDescriptors[i].POINT); + _descriptorStream.WriteLine("ADR=0x{0:x2}", toc.TrackDescriptors[i].ADR); + _descriptorStream.WriteLine("Control=0x{0:x2}", toc.TrackDescriptors[i].CONTROL); + _descriptorStream.WriteLine("TrackNo={0}", toc.TrackDescriptors[i].TNO); + _descriptorStream.WriteLine("AMin={0}", toc.TrackDescriptors[i].Min); + _descriptorStream.WriteLine("ASec={0}", toc.TrackDescriptors[i].Sec); + _descriptorStream.WriteLine("AFrame={0}", toc.TrackDescriptors[i].Frame); + _descriptorStream.WriteLine("ALBA={0}", alba); - descriptorStream.WriteLine("Zero={0}", - ((toc.TrackDescriptors[i].HOUR & 0x0F) << 4) + - (toc.TrackDescriptors[i].PHOUR & 0x0F)); + _descriptorStream.WriteLine("Zero={0}", + ((toc.TrackDescriptors[i].HOUR & 0x0F) << 4) + + (toc.TrackDescriptors[i].PHOUR & 0x0F)); - descriptorStream.WriteLine("PMin={0}", toc.TrackDescriptors[i].PMIN); - descriptorStream.WriteLine("PSec={0}", toc.TrackDescriptors[i].PSEC); - descriptorStream.WriteLine("PFrame={0}", toc.TrackDescriptors[i].PFRAME); - descriptorStream.WriteLine("PLBA={0}", plba); + _descriptorStream.WriteLine("PMin={0}", toc.TrackDescriptors[i].PMIN); + _descriptorStream.WriteLine("PSec={0}", toc.TrackDescriptors[i].PSEC); + _descriptorStream.WriteLine("PFrame={0}", toc.TrackDescriptors[i].PFRAME); + _descriptorStream.WriteLine("PLBA={0}", plba); } - descriptorStream.Flush(); - descriptorStream.Close(); + _descriptorStream.Flush(); + _descriptorStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -576,7 +578,7 @@ namespace Aaru.DiscImages return false; } - trackFlags[(byte)sectorAddress] = data[0]; + _trackFlags[(byte)sectorAddress] = data[0]; return true; } @@ -597,11 +599,11 @@ namespace Aaru.DiscImages return false; } - if(subStream == null) + if(_subStream == null) try { - subStream = new FileStream(writingBaseName + ".sub", FileMode.OpenOrCreate, - FileAccess.ReadWrite, FileShare.None); + _subStream = new FileStream(_writingBaseName + ".sub", FileMode.OpenOrCreate, + FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -610,10 +612,11 @@ namespace Aaru.DiscImages return false; } - subStream.Seek((long)(track.TrackSubchannelOffset + ((sectorAddress - track.TrackStartSector) * 96)), - SeekOrigin.Begin); + _subStream. + Seek((long)(track.TrackSubchannelOffset + ((sectorAddress - track.TrackStartSector) * 96)), + SeekOrigin.Begin); - subStream.Write(Subchannel.Deinterleave(data), 0, data.Length); + _subStream.Write(Subchannel.Deinterleave(data), 0, data.Length); return true; } @@ -665,11 +668,11 @@ namespace Aaru.DiscImages return false; } - if(subStream == null) + if(_subStream == null) try { - subStream = new FileStream(writingBaseName + ".sub", FileMode.OpenOrCreate, - FileAccess.ReadWrite, FileShare.None); + _subStream = new FileStream(_writingBaseName + ".sub", FileMode.OpenOrCreate, + FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -678,10 +681,11 @@ namespace Aaru.DiscImages return false; } - subStream.Seek((long)(track.TrackSubchannelOffset + ((sectorAddress - track.TrackStartSector) * 96)), - SeekOrigin.Begin); + _subStream. + Seek((long)(track.TrackSubchannelOffset + ((sectorAddress - track.TrackStartSector) * 96)), + SeekOrigin.Begin); - subStream.Write(Subchannel.Deinterleave(data), 0, data.Length); + _subStream.Write(Subchannel.Deinterleave(data), 0, data.Length); return true; } diff --git a/Aaru.Images/CopyQM/Constants.cs b/Aaru.Images/CopyQM/Constants.cs index 774278e07..0bdb74509 100644 --- a/Aaru.Images/CopyQM/Constants.cs +++ b/Aaru.Images/CopyQM/Constants.cs @@ -48,7 +48,7 @@ namespace Aaru.DiscImages const byte COPYQM_35_HD = 4; const byte COPYQM_35_ED = 6; - readonly uint[] copyQmCrcTable = + readonly uint[] _copyQmCrcTable = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, diff --git a/Aaru.Images/CopyQM/CopyQM.cs b/Aaru.Images/CopyQM/CopyQM.cs index 1acdb00e8..94a1b5d1c 100644 --- a/Aaru.Images/CopyQM/CopyQM.cs +++ b/Aaru.Images/CopyQM/CopyQM.cs @@ -40,14 +40,14 @@ namespace Aaru.DiscImages { public partial class CopyQm : IMediaImage, IVerifiableImage { - uint calculatedDataCrc; - byte[] decodedDisk; - MemoryStream decodedImage; - CopyQmHeader header; - bool headerChecksumOk; - ImageInfo imageInfo; + uint _calculatedDataCrc; + byte[] _decodedDisk; + MemoryStream _decodedImage; + CopyQmHeader _header; + bool _headerChecksumOk; + ImageInfo _imageInfo; - public CopyQm() => imageInfo = new ImageInfo + public CopyQm() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/CopyQM/Properties.cs b/Aaru.Images/CopyQM/Properties.cs index c42230bff..7d2f95d63 100644 --- a/Aaru.Images/CopyQM/Properties.cs +++ b/Aaru.Images/CopyQM/Properties.cs @@ -39,7 +39,7 @@ namespace Aaru.DiscImages { public partial class CopyQm { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Sydex CopyQM"; public Guid Id => new Guid("147E927D-3A92-4E0C-82CD-142F5A4FA76D"); public string Format => "Sydex CopyQM"; diff --git a/Aaru.Images/CopyQM/Read.cs b/Aaru.Images/CopyQM/Read.cs index dc8f2e5e6..8548b8813 100644 --- a/Aaru.Images/CopyQM/Read.cs +++ b/Aaru.Images/CopyQM/Read.cs @@ -50,44 +50,44 @@ namespace Aaru.DiscImages byte[] hdr = new byte[133]; stream.Read(hdr, 0, 133); - header = Marshal.ByteArrayToStructureLittleEndian(hdr); + _header = Marshal.ByteArrayToStructureLittleEndian(hdr); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.magic = 0x{0:X4}", header.magic); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.mark = 0x{0:X2}", header.mark); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.sectorSize = {0}", header.sectorSize); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.sectorPerCluster = {0}", header.sectorPerCluster); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.reservedSectors = {0}", header.reservedSectors); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.fatCopy = {0}", header.fatCopy); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.rootEntries = {0}", header.rootEntries); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.sectors = {0}", header.sectors); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.mediaType = 0x{0:X2}", header.mediaType); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.sectorsPerFat = {0}", header.sectorsPerFat); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.sectorsPerTrack = {0}", header.sectorsPerTrack); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.heads = {0}", header.heads); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.hidden = {0}", header.hidden); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.sectorsBig = {0}", header.sectorsBig); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.description = {0}", header.description); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.blind = {0}", header.blind); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.density = {0}", header.density); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.imageCylinders = {0}", header.imageCylinders); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.totalCylinders = {0}", header.totalCylinders); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.crc = 0x{0:X8}", header.crc); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.volumeLabel = {0}", header.volumeLabel); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.time = 0x{0:X4}", header.time); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.date = 0x{0:X4}", header.date); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.commentLength = {0}", header.commentLength); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.secbs = {0}", header.secbs); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.unknown = 0x{0:X4}", header.unknown); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.interleave = {0}", header.interleave); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.skew = {0}", header.skew); - AaruConsole.DebugWriteLine("CopyQM plugin", "header.drive = {0}", header.drive); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.magic = 0x{0:X4}", _header.magic); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.mark = 0x{0:X2}", _header.mark); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.sectorSize = {0}", _header.sectorSize); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.sectorPerCluster = {0}", _header.sectorPerCluster); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.reservedSectors = {0}", _header.reservedSectors); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.fatCopy = {0}", _header.fatCopy); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.rootEntries = {0}", _header.rootEntries); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.sectors = {0}", _header.sectors); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.mediaType = 0x{0:X2}", _header.mediaType); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.sectorsPerFat = {0}", _header.sectorsPerFat); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.sectorsPerTrack = {0}", _header.sectorsPerTrack); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.heads = {0}", _header.heads); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.hidden = {0}", _header.hidden); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.sectorsBig = {0}", _header.sectorsBig); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.description = {0}", _header.description); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.blind = {0}", _header.blind); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.density = {0}", _header.density); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.imageCylinders = {0}", _header.imageCylinders); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.totalCylinders = {0}", _header.totalCylinders); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.crc = 0x{0:X8}", _header.crc); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.volumeLabel = {0}", _header.volumeLabel); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.time = 0x{0:X4}", _header.time); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.date = 0x{0:X4}", _header.date); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.commentLength = {0}", _header.commentLength); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.secbs = {0}", _header.secbs); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.unknown = 0x{0:X4}", _header.unknown); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.interleave = {0}", _header.interleave); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.skew = {0}", _header.skew); + AaruConsole.DebugWriteLine("CopyQM plugin", "header.drive = {0}", _header.drive); - byte[] cmt = new byte[header.commentLength]; - stream.Read(cmt, 0, header.commentLength); - imageInfo.Comments = StringHandlers.CToString(cmt); - decodedImage = new MemoryStream(); + byte[] cmt = new byte[_header.commentLength]; + stream.Read(cmt, 0, _header.commentLength); + _imageInfo.Comments = StringHandlers.CToString(cmt); + _decodedImage = new MemoryStream(); - calculatedDataCrc = 0; + _calculatedDataCrc = 0; while(stream.Position + 2 < stream.Length) { @@ -106,33 +106,34 @@ namespace Aaru.DiscImages for(int i = 0; i < runLength * -1; i++) { - decodedImage.WriteByte(repeatedByte); + _decodedImage.WriteByte(repeatedByte); - calculatedDataCrc = copyQmCrcTable[(repeatedByte ^ calculatedDataCrc) & 0x3F] ^ - (calculatedDataCrc >> 8); + _calculatedDataCrc = _copyQmCrcTable[(repeatedByte ^ _calculatedDataCrc) & 0x3F] ^ + (_calculatedDataCrc >> 8); } } else if(runLength > 0) { byte[] nonRepeated = new byte[runLength]; stream.Read(nonRepeated, 0, runLength); - decodedImage.Write(nonRepeated, 0, runLength); + _decodedImage.Write(nonRepeated, 0, runLength); foreach(byte c in nonRepeated) - calculatedDataCrc = copyQmCrcTable[(c ^ calculatedDataCrc) & 0x3F] ^ (calculatedDataCrc >> 8); + _calculatedDataCrc = + _copyQmCrcTable[(c ^ _calculatedDataCrc) & 0x3F] ^ (_calculatedDataCrc >> 8); } } // In case there is omitted data - long sectors = header.sectorsPerTrack * header.heads * header.totalCylinders; + long sectors = _header.sectorsPerTrack * _header.heads * _header.totalCylinders; - long fillingLen = (sectors * header.sectorSize) - decodedImage.Length; + long fillingLen = (sectors * _header.sectorSize) - _decodedImage.Length; if(fillingLen > 0) { byte[] filling = new byte[fillingLen]; ArrayHelpers.ArrayFill(filling, (byte)0xF6); - decodedImage.Write(filling, 0, filling.Length); + _decodedImage.Write(filling, 0, filling.Length); } int sum = 0; @@ -140,55 +141,55 @@ namespace Aaru.DiscImages for(int i = 0; i < hdr.Length - 1; i++) sum += hdr[i]; - headerChecksumOk = ((-1 * sum) & 0xFF) == header.headerChecksum; + _headerChecksumOk = ((-1 * sum) & 0xFF) == _header.headerChecksum; AaruConsole.DebugWriteLine("CopyQM plugin", "Calculated header checksum = 0x{0:X2}, {1}", (-1 * sum) & 0xFF, - headerChecksumOk); + _headerChecksumOk); - AaruConsole.DebugWriteLine("CopyQM plugin", "Calculated data CRC = 0x{0:X8}, {1}", calculatedDataCrc, - calculatedDataCrc == header.crc); + AaruConsole.DebugWriteLine("CopyQM plugin", "Calculated data CRC = 0x{0:X8}, {1}", _calculatedDataCrc, + _calculatedDataCrc == _header.crc); - imageInfo.Application = "CopyQM"; - imageInfo.CreationTime = DateHandlers.DosToDateTime(header.date, header.time); - imageInfo.LastModificationTime = imageInfo.CreationTime; - imageInfo.MediaTitle = header.volumeLabel; - imageInfo.ImageSize = (ulong)(stream.Length - 133 - header.commentLength); - imageInfo.Sectors = (ulong)sectors; - imageInfo.SectorSize = header.sectorSize; + _imageInfo.Application = "CopyQM"; + _imageInfo.CreationTime = DateHandlers.DosToDateTime(_header.date, _header.time); + _imageInfo.LastModificationTime = _imageInfo.CreationTime; + _imageInfo.MediaTitle = _header.volumeLabel; + _imageInfo.ImageSize = (ulong)(stream.Length - 133 - _header.commentLength); + _imageInfo.Sectors = (ulong)sectors; + _imageInfo.SectorSize = _header.sectorSize; - imageInfo.MediaType = Geometry.GetMediaType(((ushort)header.totalCylinders, (byte)header.heads, - header.sectorsPerTrack, (uint)header.sectorSize, - MediaEncoding.MFM, false)); + _imageInfo.MediaType = Geometry.GetMediaType(((ushort)_header.totalCylinders, (byte)_header.heads, + _header.sectorsPerTrack, (uint)_header.sectorSize, + MediaEncoding.MFM, false)); - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { - case MediaType.NEC_525_HD when header.drive == COPYQM_35_HD || header.drive == COPYQM_35_ED: - imageInfo.MediaType = MediaType.NEC_35_HD_8; + case MediaType.NEC_525_HD when _header.drive == COPYQM_35_HD || _header.drive == COPYQM_35_ED: + _imageInfo.MediaType = MediaType.NEC_35_HD_8; break; - case MediaType.DOS_525_HD when header.drive == COPYQM_35_HD || header.drive == COPYQM_35_ED: - imageInfo.MediaType = MediaType.NEC_35_HD_15; + case MediaType.DOS_525_HD when _header.drive == COPYQM_35_HD || _header.drive == COPYQM_35_ED: + _imageInfo.MediaType = MediaType.NEC_35_HD_15; break; - case MediaType.RX50 when header.drive == COPYQM_525_DD || header.drive == COPYQM_525_HD: - imageInfo.MediaType = MediaType.ATARI_35_SS_DD; + case MediaType.RX50 when _header.drive == COPYQM_525_DD || _header.drive == COPYQM_525_HD: + _imageInfo.MediaType = MediaType.ATARI_35_SS_DD; break; } - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - decodedDisk = decodedImage.ToArray(); + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _decodedDisk = _decodedImage.ToArray(); - decodedImage.Close(); + _decodedImage.Close(); - AaruConsole.VerboseWriteLine("CopyQM image contains a disk of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("CopyQM image contains a disk of type {0}", _imageInfo.MediaType); - if(!string.IsNullOrEmpty(imageInfo.Comments)) - AaruConsole.VerboseWriteLine("CopyQM comments: {0}", imageInfo.Comments); + if(!string.IsNullOrEmpty(_imageInfo.Comments)) + AaruConsole.VerboseWriteLine("CopyQM comments: {0}", _imageInfo.Comments); - imageInfo.Heads = header.heads; - imageInfo.Cylinders = header.totalCylinders; - imageInfo.SectorsPerTrack = header.sectorsPerTrack; + _imageInfo.Heads = _header.heads; + _imageInfo.Cylinders = _header.totalCylinders; + _imageInfo.SectorsPerTrack = _header.sectorsPerTrack; return true; } @@ -197,20 +198,20 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Array.Copy(decodedDisk, (int)sectorAddress * imageInfo.SectorSize, buffer, 0, - length * imageInfo.SectorSize); + Array.Copy(_decodedDisk, (int)sectorAddress * _imageInfo.SectorSize, buffer, 0, + length * _imageInfo.SectorSize); return buffer; } - public bool? VerifyMediaImage() => calculatedDataCrc == header.crc && headerChecksumOk; + public bool? VerifyMediaImage() => _calculatedDataCrc == _header.crc && _headerChecksumOk; } } \ No newline at end of file diff --git a/Aaru.Images/CopyTape/Constants.cs b/Aaru.Images/CopyTape/Constants.cs index 5443f3c50..5f9740739 100644 --- a/Aaru.Images/CopyTape/Constants.cs +++ b/Aaru.Images/CopyTape/Constants.cs @@ -34,9 +34,9 @@ namespace Aaru.DiscImages { public partial class CopyTape { - const string BlockRegex = @"^CPTP:BLK (?\d{6})\n$"; - const string PartialBlockRegex = @"^CPTP:BLK $"; - const string FilemarkRegex = @"^CPTP:MRK\n$"; - const string EndOfTapeRegex = @"^CPTP:EOT\n$"; + const string _blockRegex = @"^CPTP:BLK (?\d{6})\n$"; + const string _partialBlockRegex = @"^CPTP:BLK $"; + const string _filemarkRegex = @"^CPTP:MRK\n$"; + const string _endOfTapeRegex = @"^CPTP:EOT\n$"; } } \ No newline at end of file diff --git a/Aaru.Images/CopyTape/CopyTape.cs b/Aaru.Images/CopyTape/CopyTape.cs index 6a1f0f2e2..9385c3ab2 100644 --- a/Aaru.Images/CopyTape/CopyTape.cs +++ b/Aaru.Images/CopyTape/CopyTape.cs @@ -8,11 +8,11 @@ namespace Aaru.DiscImages { public partial class CopyTape : IWritableTapeImage { - long[] blockPositionCache; - ImageInfo imageInfo; - Stream imageStream; + long[] _blockPositionCache; + ImageInfo _imageInfo; + Stream _imageStream; - public CopyTape() => imageInfo = new ImageInfo + public CopyTape() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/CopyTape/Identify.cs b/Aaru.Images/CopyTape/Identify.cs index 4c8a51c59..c1277804c 100644 --- a/Aaru.Images/CopyTape/Identify.cs +++ b/Aaru.Images/CopyTape/Identify.cs @@ -52,7 +52,7 @@ namespace Aaru.DiscImages string mark = Encoding.ASCII.GetString(header); - var blockRx = new Regex(BlockRegex); + var blockRx = new Regex(_blockRegex); Match blockMt = blockRx.Match(mark); if(!blockMt.Success) diff --git a/Aaru.Images/CopyTape/Properties.cs b/Aaru.Images/CopyTape/Properties.cs index 21fdea791..b2e1d0247 100644 --- a/Aaru.Images/CopyTape/Properties.cs +++ b/Aaru.Images/CopyTape/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class CopyTape { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "CopyTape"; public Guid Id => new Guid("C537D41E-D6A7-4922-9AA9-8E8442D0E340"); public string Author => "Natalia Portillo"; diff --git a/Aaru.Images/CopyTape/Read.cs b/Aaru.Images/CopyTape/Read.cs index 9e58efa96..fc3b0ad67 100644 --- a/Aaru.Images/CopyTape/Read.cs +++ b/Aaru.Images/CopyTape/Read.cs @@ -47,16 +47,16 @@ namespace Aaru.DiscImages public bool Open(IFilter imageFilter) { List blockPositions = new List(); - var partialBlockRx = new Regex(PartialBlockRegex); - var blockRx = new Regex(BlockRegex); - var filemarkRx = new Regex(FilemarkRegex); - var eotRx = new Regex(EndOfTapeRegex); + var partialBlockRx = new Regex(_partialBlockRegex); + var blockRx = new Regex(_blockRegex); + var filemarkRx = new Regex(_filemarkRegex); + var eotRx = new Regex(_endOfTapeRegex); if(imageFilter.GetDataForkLength() <= 16) return false; - imageStream = imageFilter.GetDataForkStream(); - imageStream.Position = 0; + _imageStream = imageFilter.GetDataForkStream(); + _imageStream.Position = 0; byte[] header = new byte[9]; byte[] blockHeader = new byte[16]; @@ -67,9 +67,9 @@ namespace Aaru.DiscImages Files = new List(); - while(imageStream.Position + 9 < imageStream.Length) + while(_imageStream.Position + 9 < _imageStream.Length) { - imageStream.Read(header, 0, 9); + _imageStream.Read(header, 0, 9); string mark = Encoding.ASCII.GetString(header); Match partialBlockMt = partialBlockRx.Match(mark); @@ -98,7 +98,7 @@ namespace Aaru.DiscImages if(!partialBlockMt.Success) throw new ArgumentException("Found unhandled header, cannot open."); - imageStream.Position -= 9; + _imageStream.Position -= 9; if(!inFile) { @@ -106,7 +106,7 @@ namespace Aaru.DiscImages inFile = true; } - imageStream.Read(blockHeader, 0, 16); + _imageStream.Read(blockHeader, 0, 16); mark = Encoding.ASCII.GetString(blockHeader); Match blockMt = blockRx.Match(mark); @@ -125,22 +125,22 @@ namespace Aaru.DiscImages blockSize + 17 > imageFilter.GetDataForkLength()) throw new ArgumentException("Cannot decode block header, cannot open."); - imageStream.Position += blockSize; + _imageStream.Position += blockSize; - int newLine = imageStream.ReadByte(); + int newLine = _imageStream.ReadByte(); if(newLine != 0x0A) throw new ArgumentException("Cannot decode block header, cannot open."); - blockPositions.Add(imageStream.Position - blockSize - 17); + blockPositions.Add(_imageStream.Position - blockSize - 17); currentBlock++; - imageInfo.ImageSize += blockSize; + _imageInfo.ImageSize += blockSize; - if(imageInfo.SectorSize < blockSize) - imageInfo.SectorSize = blockSize; + if(_imageInfo.SectorSize < blockSize) + _imageInfo.SectorSize = blockSize; } - blockPositionCache = blockPositions.ToArray(); + _blockPositionCache = blockPositions.ToArray(); TapePartitions = new List { @@ -152,29 +152,29 @@ namespace Aaru.DiscImages } }; - imageInfo.Sectors = (ulong)blockPositionCache.LongLength; - imageInfo.MediaType = MediaType.UnknownTape; - imageInfo.Application = "CopyTape"; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - IsTape = true; + _imageInfo.Sectors = (ulong)_blockPositionCache.LongLength; + _imageInfo.MediaType = MediaType.UnknownTape; + _imageInfo.Application = "CopyTape"; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + IsTape = true; return true; } public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress >= (ulong)blockPositionCache.LongLength) + if(sectorAddress >= (ulong)_blockPositionCache.LongLength) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - imageStream.Position = blockPositionCache[sectorAddress]; + _imageStream.Position = _blockPositionCache[sectorAddress]; byte[] blockHeader = new byte[16]; - var blockRx = new Regex(BlockRegex); + var blockRx = new Regex(_blockRegex); - imageStream.Read(blockHeader, 0, 16); + _imageStream.Read(blockHeader, 0, 16); string mark = Encoding.ASCII.GetString(blockHeader); Match blockMt = blockRx.Match(mark); @@ -190,14 +190,14 @@ namespace Aaru.DiscImages throw new ArgumentException("Cannot decode block header, cannot read."); if(blockSize == 0 || - blockSize + 17 > imageStream.Length) + blockSize + 17 > _imageStream.Length) throw new ArgumentException("Cannot decode block header, cannot read."); byte[] data = new byte[blockSize]; - imageStream.Read(data, 0, (int)blockSize); + _imageStream.Read(data, 0, (int)blockSize); - if(imageStream.ReadByte() != 0x0A) + if(_imageStream.ReadByte() != 0x0A) throw new ArgumentException("Cannot decode block header, cannot read."); return data; diff --git a/Aaru.Images/CopyTape/Write.cs b/Aaru.Images/CopyTape/Write.cs index 4bec22401..c8b206475 100644 --- a/Aaru.Images/CopyTape/Write.cs +++ b/Aaru.Images/CopyTape/Write.cs @@ -43,9 +43,9 @@ namespace Aaru.DiscImages { public partial class CopyTape { - FileStream dataStream; - ulong lastWrittenBlock; - Dictionary writtenBlockPositions; + FileStream _dataStream; + ulong _lastWrittenBlock; + Dictionary _writtenBlockPositions; public bool Create(string path, MediaType mediaType, Dictionary options, ulong sectors, uint sectorSize) @@ -57,7 +57,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -66,7 +66,7 @@ namespace Aaru.DiscImages try { - dataStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _dataStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -75,13 +75,13 @@ namespace Aaru.DiscImages return false; } - imageInfo.MediaType = mediaType; + _imageInfo.MediaType = mediaType; - IsWriting = true; - IsTape = false; - ErrorMessage = null; - lastWrittenBlock = 0; - writtenBlockPositions = new Dictionary(); + IsWriting = true; + IsTape = false; + ErrorMessage = null; + _lastWrittenBlock = 0; + _writtenBlockPositions = new Dictionary(); return true; } @@ -95,19 +95,19 @@ namespace Aaru.DiscImages public bool WriteSector(byte[] data, ulong sectorAddress) { - if(!writtenBlockPositions.TryGetValue(sectorAddress, out ulong position)) + if(!_writtenBlockPositions.TryGetValue(sectorAddress, out ulong position)) { - if(dataStream.Length != 0 && - lastWrittenBlock >= sectorAddress) + if(_dataStream.Length != 0 && + _lastWrittenBlock >= sectorAddress) { ErrorMessage = "Cannot write unwritten blocks"; return false; } - if(lastWrittenBlock + 1 != sectorAddress && - sectorAddress != 0 && - lastWrittenBlock != 0) + if(_lastWrittenBlock + 1 != sectorAddress && + sectorAddress != 0 && + _lastWrittenBlock != 0) { ErrorMessage = "Cannot skip blocks"; @@ -115,19 +115,19 @@ namespace Aaru.DiscImages } } else - dataStream.Position = (long)position; + _dataStream.Position = (long)position; byte[] header = Encoding.ASCII.GetBytes($"CPTP:BLK {data.Length:D6}\n"); - writtenBlockPositions[sectorAddress] = (ulong)dataStream.Position; - dataStream.Write(header, 0, header.Length); - dataStream.Write(data, 0, data.Length); - dataStream.WriteByte(0x0A); + _writtenBlockPositions[sectorAddress] = (ulong)_dataStream.Position; + _dataStream.Write(header, 0, header.Length); + _dataStream.Write(data, 0, data.Length); + _dataStream.WriteByte(0x0A); - if(sectorAddress > lastWrittenBlock) - lastWrittenBlock = sectorAddress; + if(sectorAddress > _lastWrittenBlock) + _lastWrittenBlock = sectorAddress; - dataStream.Seek(0, SeekOrigin.End); + _dataStream.Seek(0, SeekOrigin.End); return true; } @@ -170,9 +170,9 @@ namespace Aaru.DiscImages byte[] footer = Encoding.ASCII.GetBytes("CPTP:EOT\n"); - dataStream.Write(footer, 0, footer.Length); - dataStream.Flush(); - dataStream.Close(); + _dataStream.Write(footer, 0, footer.Length); + _dataStream.Flush(); + _dataStream.Close(); IsWriting = false; @@ -217,7 +217,7 @@ namespace Aaru.DiscImages byte[] marker = Encoding.ASCII.GetBytes("CPTP:MRK\n"); - dataStream.Write(marker, 0, marker.Length); + _dataStream.Write(marker, 0, marker.Length); return true; } diff --git a/Aaru.Images/D88/Constants.cs b/Aaru.Images/D88/Constants.cs index 077073b26..a15543aea 100644 --- a/Aaru.Images/D88/Constants.cs +++ b/Aaru.Images/D88/Constants.cs @@ -38,7 +38,7 @@ namespace Aaru.DiscImages public partial class D88 { const byte READ_ONLY = 0x10; - readonly byte[] reservedEmpty = + readonly byte[] _reservedEmpty = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/Aaru.Images/D88/D88.cs b/Aaru.Images/D88/D88.cs index 5c39bd002..fe0fa3a0a 100644 --- a/Aaru.Images/D88/D88.cs +++ b/Aaru.Images/D88/D88.cs @@ -42,10 +42,10 @@ namespace Aaru.DiscImages // TODO: Solve media types public partial class D88 : IMediaImage { - ImageInfo imageInfo; - List sectorsData; + ImageInfo _imageInfo; + List _sectorsData; - public D88() => imageInfo = new ImageInfo + public D88() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/D88/Identify.cs b/Aaru.Images/D88/Identify.cs index e040d182f..6ea6c404a 100644 --- a/Aaru.Images/D88/Identify.cs +++ b/Aaru.Images/D88/Identify.cs @@ -61,7 +61,7 @@ namespace Aaru.DiscImages StringHandlers.CToString(d88Hdr.name, shiftjis)); AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.reserved is empty? = {0}", - d88Hdr.reserved.SequenceEqual(reservedEmpty)); + d88Hdr.reserved.SequenceEqual(_reservedEmpty)); AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.write_protect = 0x{0:X2}", d88Hdr.write_protect); @@ -78,7 +78,7 @@ namespace Aaru.DiscImages d88Hdr.disk_type != DiskType.Hd2) return false; - if(!d88Hdr.reserved.SequenceEqual(reservedEmpty)) + if(!d88Hdr.reserved.SequenceEqual(_reservedEmpty)) return false; int counter = 0; diff --git a/Aaru.Images/D88/Properties.cs b/Aaru.Images/D88/Properties.cs index 9eb32cc12..72ca95b37 100644 --- a/Aaru.Images/D88/Properties.cs +++ b/Aaru.Images/D88/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public string Name => "D88 Disk Image"; public Guid Id => new Guid("669EDC77-EC41-4720-A88C-49C38CFFBAA0"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Format => "D88 disk image"; public string Author => "Natalia Portillo"; public List DumpHardware => null; diff --git a/Aaru.Images/D88/Read.cs b/Aaru.Images/D88/Read.cs index b8cc375af..bc7f583fb 100644 --- a/Aaru.Images/D88/Read.cs +++ b/Aaru.Images/D88/Read.cs @@ -65,7 +65,7 @@ namespace Aaru.DiscImages StringHandlers.CToString(d88Hdr.name, shiftjis)); AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.reserved is empty? = {0}", - d88Hdr.reserved.SequenceEqual(reservedEmpty)); + d88Hdr.reserved.SequenceEqual(_reservedEmpty)); AaruConsole.DebugWriteLine("D88 plugin", "d88hdr.write_protect = 0x{0:X2}", d88Hdr.write_protect); @@ -82,7 +82,7 @@ namespace Aaru.DiscImages d88Hdr.disk_type != DiskType.Hd2) return false; - if(!d88Hdr.reserved.SequenceEqual(reservedEmpty)) + if(!d88Hdr.reserved.SequenceEqual(_reservedEmpty)) return false; int trkCounter = 0; @@ -121,7 +121,7 @@ namespace Aaru.DiscImages short spt = sechdr.spt; IBMSectorSizeCode bps = sechdr.n; bool allEqual = true; - sectorsData = new List(); + _sectorsData = new List(); for(int i = 0; i < trkCounter; i++) { @@ -169,38 +169,38 @@ namespace Aaru.DiscImages sectors.Add(sechdr.r, secB); foreach(KeyValuePair kvp in sectors) - sectorsData.Add(kvp.Value); + _sectorsData.Add(kvp.Value); } - AaruConsole.DebugWriteLine("D88 plugin", "{0} sectors", sectorsData.Count); + AaruConsole.DebugWriteLine("D88 plugin", "{0} sectors", _sectorsData.Count); - imageInfo.MediaType = MediaType.Unknown; + _imageInfo.MediaType = MediaType.Unknown; if(allEqual) if(trkCounter == 154 && spt == 26 && bps == IBMSectorSizeCode.EighthKilo) - imageInfo.MediaType = MediaType.NEC_8_SD; + _imageInfo.MediaType = MediaType.NEC_8_SD; else if(bps == IBMSectorSizeCode.QuarterKilo) switch(trkCounter) { case 80 when spt == 16: - imageInfo.MediaType = MediaType.NEC_525_SS; + _imageInfo.MediaType = MediaType.NEC_525_SS; break; case 154 when spt == 26: - imageInfo.MediaType = MediaType.NEC_8_DD; + _imageInfo.MediaType = MediaType.NEC_8_DD; break; case 160 when spt == 16: - imageInfo.MediaType = MediaType.NEC_525_DS; + _imageInfo.MediaType = MediaType.NEC_525_DS; break; } else if(trkCounter == 154 && spt == 8 && bps == IBMSectorSizeCode.Kilo) - imageInfo.MediaType = MediaType.NEC_525_HD; + _imageInfo.MediaType = MediaType.NEC_525_HD; else if(bps == IBMSectorSizeCode.HalfKilo) switch(d88Hdr.track_table.Length) { @@ -209,11 +209,11 @@ namespace Aaru.DiscImages switch(spt) { case 8: - imageInfo.MediaType = MediaType.DOS_525_SS_DD_8; + _imageInfo.MediaType = MediaType.DOS_525_SS_DD_8; break; case 9: - imageInfo.MediaType = MediaType.DOS_525_SS_DD_9; + _imageInfo.MediaType = MediaType.DOS_525_SS_DD_9; break; } @@ -225,11 +225,11 @@ namespace Aaru.DiscImages switch(spt) { case 8: - imageInfo.MediaType = MediaType.DOS_525_DS_DD_8; + _imageInfo.MediaType = MediaType.DOS_525_DS_DD_8; break; case 9: - imageInfo.MediaType = MediaType.DOS_525_DS_DD_9; + _imageInfo.MediaType = MediaType.DOS_525_DS_DD_9; break; } @@ -241,19 +241,19 @@ namespace Aaru.DiscImages switch(spt) { case 15: - imageInfo.MediaType = MediaType.NEC_35_HD_15; + _imageInfo.MediaType = MediaType.NEC_35_HD_15; break; case 9: - imageInfo.MediaType = MediaType.DOS_35_DS_DD_9; + _imageInfo.MediaType = MediaType.DOS_35_DS_DD_9; break; case 18: - imageInfo.MediaType = MediaType.DOS_35_HD; + _imageInfo.MediaType = MediaType.DOS_35_HD; break; case 36: - imageInfo.MediaType = MediaType.DOS_35_ED; + _imageInfo.MediaType = MediaType.DOS_35_ED; break; } @@ -262,101 +262,101 @@ namespace Aaru.DiscImages break; case 480: if(spt == 38) - imageInfo.MediaType = MediaType.NEC_35_TD; + _imageInfo.MediaType = MediaType.NEC_35_TD; break; } - AaruConsole.DebugWriteLine("D88 plugin", "MediaType: {0}", imageInfo.MediaType); + AaruConsole.DebugWriteLine("D88 plugin", "MediaType: {0}", _imageInfo.MediaType); - imageInfo.ImageSize = (ulong)d88Hdr.disk_size; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = (ulong)sectorsData.Count; - imageInfo.Comments = StringHandlers.CToString(d88Hdr.name, shiftjis); - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.SectorSize = (uint)(128 << (int)bps); + _imageInfo.ImageSize = (ulong)d88Hdr.disk_size; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = (ulong)_sectorsData.Count; + _imageInfo.Comments = StringHandlers.CToString(d88Hdr.name, shiftjis); + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.SectorSize = (uint)(128 << (int)bps); - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.NEC_525_SS: - imageInfo.Cylinders = 80; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 16; break; case MediaType.NEC_8_SD: case MediaType.NEC_8_DD: - imageInfo.Cylinders = 77; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 26; + _imageInfo.Cylinders = 77; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 26; break; case MediaType.NEC_525_DS: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 16; break; case MediaType.NEC_525_HD: - imageInfo.Cylinders = 77; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 8; + _imageInfo.Cylinders = 77; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 8; break; case MediaType.DOS_525_SS_DD_8: - imageInfo.Cylinders = 40; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 8; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 8; break; case MediaType.DOS_525_SS_DD_9: - imageInfo.Cylinders = 40; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 9; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 9; break; case MediaType.DOS_525_DS_DD_8: - imageInfo.Cylinders = 40; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 8; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 8; break; case MediaType.DOS_525_DS_DD_9: - imageInfo.Cylinders = 40; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 9; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 9; break; case MediaType.NEC_35_HD_15: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 15; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 15; break; case MediaType.DOS_35_DS_DD_9: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 9; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 9; break; case MediaType.DOS_35_HD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 18; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 18; break; case MediaType.DOS_35_ED: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 36; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 36; break; case MediaType.NEC_35_TD: - imageInfo.Cylinders = 240; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 38; + _imageInfo.Cylinders = 240; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 38; break; } @@ -368,16 +368,16 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var buffer = new MemoryStream(); for(int i = 0; i < length; i++) - buffer.Write(sectorsData[(int)sectorAddress + i], 0, sectorsData[(int)sectorAddress + i].Length); + buffer.Write(_sectorsData[(int)sectorAddress + i], 0, _sectorsData[(int)sectorAddress + i].Length); return buffer.ToArray(); } diff --git a/Aaru.Images/DART/Constants.cs b/Aaru.Images/DART/Constants.cs index 536cb7784..78185470a 100644 --- a/Aaru.Images/DART/Constants.cs +++ b/Aaru.Images/DART/Constants.cs @@ -74,5 +74,8 @@ namespace Aaru.DiscImages const int DATA_SIZE = SECTORS_PER_BLOCK * SECTOR_SIZE; const int TAG_SIZE = SECTORS_PER_BLOCK * TAG_SECTOR_SIZE; const int BUFFER_SIZE = (SECTORS_PER_BLOCK * SECTOR_SIZE) + (SECTORS_PER_BLOCK * TAG_SECTOR_SIZE); + + const string DART_REGEX = + @"(?\S+), tag checksum=\$(?[0123456789ABCDEF]{8}), data checksum=\$(?[0123456789ABCDEF]{8})$"; } } \ No newline at end of file diff --git a/Aaru.Images/DART/DART.cs b/Aaru.Images/DART/DART.cs index a5ac3849c..49c97f5d6 100644 --- a/Aaru.Images/DART/DART.cs +++ b/Aaru.Images/DART/DART.cs @@ -40,13 +40,13 @@ namespace Aaru.DiscImages public partial class Dart : IMediaImage { // DART images are at most 1474560 bytes, so let's cache the whole - byte[] dataCache; - uint dataChecksum; - ImageInfo imageInfo; - byte[] tagCache; - uint tagChecksum; + byte[] _dataCache; + uint _dataChecksum; + ImageInfo _imageInfo; + byte[] _tagCache; + uint _tagChecksum; - public Dart() => imageInfo = new ImageInfo + public Dart() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/DART/Properties.cs b/Aaru.Images/DART/Properties.cs index 1fb78a7f5..4cc22afef 100644 --- a/Aaru.Images/DART/Properties.cs +++ b/Aaru.Images/DART/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public string Name => "Apple Disk Archival/Retrieval Tool"; public Guid Id => new Guid("B3E06BF8-F98D-4F9B-BBE2-342C373BAF3E"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Format => "Apple Disk Archival/Retrieval Tool"; public List DumpHardware => null; diff --git a/Aaru.Images/DART/Read.cs b/Aaru.Images/DART/Read.cs index e02689d6e..6c235abe6 100644 --- a/Aaru.Images/DART/Read.cs +++ b/Aaru.Images/DART/Read.cs @@ -165,14 +165,14 @@ namespace Aaru.DiscImages } } - dataCache = dataMs.ToArray(); + _dataCache = dataMs.ToArray(); if(header.srcType == DISK_LISA || header.srcType == DISK_MAC || header.srcType == DISK_APPLE2) { - imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag); - tagCache = tagMs.ToArray(); + _imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag); + _tagCache = tagMs.ToArray(); } try @@ -225,9 +225,9 @@ namespace Aaru.DiscImages if(dev != null) pre = $"{version.PreReleaseVersion}"; - imageInfo.ApplicationVersion = $"{major}{minor}{release}{dev}{pre}"; - imageInfo.Application = version.VersionString; - imageInfo.Comments = version.VersionMessage; + _imageInfo.ApplicationVersion = $"{major}{minor}{release}{dev}{pre}"; + _imageInfo.Application = version.VersionString; + _imageInfo.Comments = version.VersionMessage; } } @@ -241,18 +241,15 @@ namespace Aaru.DiscImages string dArt = StringHandlers.PascalToString(dartRsrc.GetResource(dartRsrc.GetIds()[0]), Encoding.GetEncoding("macintosh")); - const string DART_REGEX = - @"(?\S+), tag checksum=\$(?[0123456789ABCDEF]{8}), data checksum=\$(?[0123456789ABCDEF]{8})$"; - var dArtEx = new Regex(DART_REGEX); Match dArtMatch = dArtEx.Match(dArt); if(dArtMatch.Success) { - imageInfo.Application = "DART"; - imageInfo.ApplicationVersion = dArtMatch.Groups["version"].Value; - dataChecksum = Convert.ToUInt32(dArtMatch.Groups["datachk"].Value, 16); - tagChecksum = Convert.ToUInt32(dArtMatch.Groups["tagchk"].Value, 16); + _imageInfo.Application = "DART"; + _imageInfo.ApplicationVersion = dArtMatch.Groups["version"].Value; + _dataChecksum = Convert.ToUInt32(dArtMatch.Groups["datachk"].Value, 16); + _tagChecksum = Convert.ToUInt32(dArtMatch.Groups["tagchk"].Value, 16); } } } @@ -265,59 +262,59 @@ namespace Aaru.DiscImages if(cksmRsrc?.ContainsId(1) == true) { byte[] tagChk = cksmRsrc.GetResource(1); - tagChecksum = BigEndianBitConverter.ToUInt32(tagChk, 0); + _tagChecksum = BigEndianBitConverter.ToUInt32(tagChk, 0); } if(cksmRsrc?.ContainsId(2) == true) { byte[] dataChk = cksmRsrc.GetResource(1); - dataChecksum = BigEndianBitConverter.ToUInt32(dataChk, 0); + _dataChecksum = BigEndianBitConverter.ToUInt32(dataChk, 0); } } } } catch(InvalidCastException) {} - AaruConsole.DebugWriteLine("DART plugin", "Image application = {0} version {1}", imageInfo.Application, - imageInfo.ApplicationVersion); + AaruConsole.DebugWriteLine("DART plugin", "Image application = {0} version {1}", _imageInfo.Application, + _imageInfo.ApplicationVersion); - imageInfo.Sectors = (ulong)(header.srcSize * 2); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.SectorSize = SECTOR_SIZE; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.ImageSize = imageInfo.Sectors * SECTOR_SIZE; - imageInfo.Version = header.srcCmp == COMPRESS_NONE ? "1.4" : "1.5"; + _imageInfo.Sectors = (ulong)(header.srcSize * 2); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.SectorSize = SECTOR_SIZE; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.ImageSize = _imageInfo.Sectors * SECTOR_SIZE; + _imageInfo.Version = header.srcCmp == COMPRESS_NONE ? "1.4" : "1.5"; switch(header.srcSize) { case SIZE_MAC_SS: - imageInfo.Cylinders = 80; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 10; - imageInfo.MediaType = MediaType.AppleSonySS; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 10; + _imageInfo.MediaType = MediaType.AppleSonySS; break; case SIZE_MAC: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 10; - imageInfo.MediaType = MediaType.AppleSonyDS; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 10; + _imageInfo.MediaType = MediaType.AppleSonyDS; break; case SIZE_DOS: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 9; - imageInfo.MediaType = MediaType.DOS_35_DS_DD_9; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 9; + _imageInfo.MediaType = MediaType.DOS_35_DS_DD_9; break; case SIZE_MAC_HD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 18; - imageInfo.MediaType = MediaType.DOS_35_HD; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 18; + _imageInfo.MediaType = MediaType.DOS_35_HD; break; } @@ -331,15 +328,16 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Array.Copy(dataCache, (int)sectorAddress * imageInfo.SectorSize, buffer, 0, length * imageInfo.SectorSize); + Array.Copy(_dataCache, (int)sectorAddress * _imageInfo.SectorSize, buffer, 0, + length * _imageInfo.SectorSize); return buffer; } @@ -349,19 +347,19 @@ namespace Aaru.DiscImages if(tag != SectorTagType.AppleSectorTag) throw new FeatureUnsupportedImageException($"Tag {tag} not supported by image format"); - if(tagCache == null || - tagCache.Length == 0) + if(_tagCache == null || + _tagCache.Length == 0) throw new FeatureNotPresentImageException("Disk image does not have tags"); - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); byte[] buffer = new byte[length * TAG_SECTOR_SIZE]; - Array.Copy(tagCache, (int)sectorAddress * TAG_SECTOR_SIZE, buffer, 0, length * TAG_SECTOR_SIZE); + Array.Copy(_tagCache, (int)sectorAddress * TAG_SECTOR_SIZE, buffer, 0, length * TAG_SECTOR_SIZE); return buffer; } @@ -370,10 +368,10 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); byte[] data = ReadSectors(sectorAddress, length); @@ -382,11 +380,11 @@ namespace Aaru.DiscImages for(uint i = 0; i < length; i++) { - Array.Copy(data, i * imageInfo.SectorSize, buffer, i * (imageInfo.SectorSize + TAG_SECTOR_SIZE), - imageInfo.SectorSize); + Array.Copy(data, i * _imageInfo.SectorSize, buffer, i * (_imageInfo.SectorSize + TAG_SECTOR_SIZE), + _imageInfo.SectorSize); Array.Copy(tags, i * TAG_SECTOR_SIZE, buffer, - (i * (imageInfo.SectorSize + TAG_SECTOR_SIZE)) + imageInfo.SectorSize, TAG_SECTOR_SIZE); + (i * (_imageInfo.SectorSize + TAG_SECTOR_SIZE)) + _imageInfo.SectorSize, TAG_SECTOR_SIZE); } return buffer; diff --git a/Aaru.Images/DIM/Constants.cs b/Aaru.Images/DIM/Constants.cs index 2049f0076..b8ec6c461 100644 --- a/Aaru.Images/DIM/Constants.cs +++ b/Aaru.Images/DIM/Constants.cs @@ -36,7 +36,7 @@ namespace Aaru.DiscImages { /// Start of data sectors in disk image, should be 0x100 const uint DATA_OFFSET = 0x100; - readonly byte[] headerId = + readonly byte[] _headerId = { 0x44, 0x49, 0x46, 0x43, 0x20, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x20, 0x20 }; diff --git a/Aaru.Images/DIM/DIM.cs b/Aaru.Images/DIM/DIM.cs index 0399b9eb9..41ab0ac81 100644 --- a/Aaru.Images/DIM/DIM.cs +++ b/Aaru.Images/DIM/DIM.cs @@ -40,13 +40,13 @@ namespace Aaru.DiscImages // TODO: What are the real supported floppies for this image format? public partial class Dim : IMediaImage { - byte[] comment; - IFilter dimImageFilter; - DiskType dskType; - byte[] hdrId; - ImageInfo imageInfo; + byte[] _comment; + IFilter _dimImageFilter; + DiskType _dskType; + byte[] _hdrId; + ImageInfo _imageInfo; - public Dim() => imageInfo = new ImageInfo + public Dim() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/DIM/Identify.cs b/Aaru.Images/DIM/Identify.cs index e23bec31a..b047a5f18 100644 --- a/Aaru.Images/DIM/Identify.cs +++ b/Aaru.Images/DIM/Identify.cs @@ -46,16 +46,16 @@ namespace Aaru.DiscImages if(stream.Length < DATA_OFFSET) return false; - comment = new byte[60]; - hdrId = new byte[13]; + _comment = new byte[60]; + _hdrId = new byte[13]; stream.Seek(0, SeekOrigin.Begin); - dskType = (DiskType)stream.ReadByte(); + _dskType = (DiskType)stream.ReadByte(); stream.Seek(0xAB, SeekOrigin.Begin); - stream.Read(hdrId, 0, 13); + stream.Read(_hdrId, 0, 13); stream.Seek(0xC2, SeekOrigin.Begin); - stream.Read(comment, 0, 60); + stream.Read(_comment, 0, 60); - return headerId.SequenceEqual(hdrId); + return _headerId.SequenceEqual(_hdrId); } } } \ No newline at end of file diff --git a/Aaru.Images/DIM/Properties.cs b/Aaru.Images/DIM/Properties.cs index b75e4df63..eaf27742b 100644 --- a/Aaru.Images/DIM/Properties.cs +++ b/Aaru.Images/DIM/Properties.cs @@ -49,7 +49,7 @@ namespace Aaru.DiscImages throw new FeatureUnsupportedImageException("Feature not supported by image format"); public string Name => "DIM Disk Image"; public Guid Id => new Guid("0240B7B1-E959-4CDC-B0BD-386D6E467B88"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Format => "DIM disk image"; public List DumpHardware => null; diff --git a/Aaru.Images/DIM/Read.cs b/Aaru.Images/DIM/Read.cs index 4001aef16..f9c575a7f 100644 --- a/Aaru.Images/DIM/Read.cs +++ b/Aaru.Images/DIM/Read.cs @@ -54,21 +54,21 @@ namespace Aaru.DiscImages long diskSize = stream.Length - DATA_OFFSET; - comment = new byte[60]; - hdrId = new byte[13]; + _comment = new byte[60]; + _hdrId = new byte[13]; stream.Seek(0, SeekOrigin.Begin); - dskType = (DiskType)stream.ReadByte(); + _dskType = (DiskType)stream.ReadByte(); stream.Seek(0xAB, SeekOrigin.Begin); - stream.Read(hdrId, 0, 13); + stream.Read(_hdrId, 0, 13); stream.Seek(0xC2, SeekOrigin.Begin); - stream.Read(comment, 0, 60); + stream.Read(_comment, 0, 60); - if(!headerId.SequenceEqual(hdrId)) + if(!_headerId.SequenceEqual(_hdrId)) return false; - imageInfo.MediaType = MediaType.Unknown; + _imageInfo.MediaType = MediaType.Unknown; - switch(dskType) + switch(_dskType) { // 8 spt, 1024 bps case DiskType.Hd2: @@ -81,9 +81,9 @@ namespace Aaru.DiscImages } if(diskSize / (2 * 8 * 1024) == 77) - imageInfo.MediaType = MediaType.SHARP_525; + _imageInfo.MediaType = MediaType.SHARP_525; - imageInfo.SectorSize = 1024; + _imageInfo.SectorSize = 1024; break; @@ -97,9 +97,9 @@ namespace Aaru.DiscImages } if(diskSize / (2 * 9 * 512) == 80) - imageInfo.MediaType = MediaType.SHARP_525_9; + _imageInfo.MediaType = MediaType.SHARP_525_9; - imageInfo.SectorSize = 512; + _imageInfo.SectorSize = 512; break; @@ -114,9 +114,9 @@ namespace Aaru.DiscImages } if(diskSize / (2 * 15 * 512) == 80) - imageInfo.MediaType = MediaType.DOS_525_HD; + _imageInfo.MediaType = MediaType.DOS_525_HD; - imageInfo.SectorSize = 512; + _imageInfo.SectorSize = 512; break; @@ -130,9 +130,9 @@ namespace Aaru.DiscImages } if(diskSize / (2 * 9 * 512) == 80) - imageInfo.MediaType = MediaType.SHARP_35_9; + _imageInfo.MediaType = MediaType.SHARP_35_9; - imageInfo.SectorSize = 512; + _imageInfo.SectorSize = 512; break; @@ -147,9 +147,9 @@ namespace Aaru.DiscImages } if(diskSize / (2 * 18 * 512) == 80) - imageInfo.MediaType = MediaType.DOS_35_HD; + _imageInfo.MediaType = MediaType.DOS_35_HD; - imageInfo.SectorSize = 512; + _imageInfo.SectorSize = 512; break; @@ -158,16 +158,16 @@ namespace Aaru.DiscImages if(diskSize % (2 * 26 * 256) == 0) { if(diskSize % (2 * 26 * 256) == 77) - imageInfo.MediaType = MediaType.NEC_8_DD; + _imageInfo.MediaType = MediaType.NEC_8_DD; - imageInfo.SectorSize = 256; + _imageInfo.SectorSize = 256; } else if(diskSize % (2 * 26 * 128) == 0) { if(diskSize % (2 * 26 * 128) == 77) - imageInfo.MediaType = MediaType.NEC_8_SD; + _imageInfo.MediaType = MediaType.NEC_8_SD; - imageInfo.SectorSize = 256; + _imageInfo.SectorSize = 256; } else { @@ -181,58 +181,58 @@ namespace Aaru.DiscImages default: return false; } - AaruConsole.VerboseWriteLine("DIM image contains a disk of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("DIM image contains a disk of type {0}", _imageInfo.MediaType); - if(!string.IsNullOrEmpty(imageInfo.Comments)) - AaruConsole.VerboseWriteLine("DIM comments: {0}", imageInfo.Comments); + if(!string.IsNullOrEmpty(_imageInfo.Comments)) + AaruConsole.VerboseWriteLine("DIM comments: {0}", _imageInfo.Comments); - dimImageFilter = imageFilter; + _dimImageFilter = imageFilter; - imageInfo.ImageSize = (ulong)diskSize; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = imageInfo.ImageSize / imageInfo.SectorSize; - imageInfo.Comments = StringHandlers.CToString(comment, Encoding.GetEncoding(932)); - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.ImageSize = (ulong)diskSize; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = _imageInfo.ImageSize / _imageInfo.SectorSize; + _imageInfo.Comments = StringHandlers.CToString(_comment, Encoding.GetEncoding(932)); + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.SHARP_525: - imageInfo.Cylinders = 77; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 8; + _imageInfo.Cylinders = 77; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 8; break; case MediaType.SHARP_525_9: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 9; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 9; break; case MediaType.DOS_525_HD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 15; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 15; break; case MediaType.SHARP_35_9: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 9; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 9; break; case MediaType.DOS_35_HD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 18; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 18; break; case MediaType.NEC_8_DD: case MediaType.NEC_8_SD: - imageInfo.Cylinders = 77; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 26; + _imageInfo.Cylinders = 77; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 26; break; } @@ -244,19 +244,19 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Stream stream = dimImageFilter.GetDataForkStream(); + Stream stream = _dimImageFilter.GetDataForkStream(); - stream.Seek((long)(DATA_OFFSET + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)(DATA_OFFSET + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); - stream.Read(buffer, 0, (int)(length * imageInfo.SectorSize)); + stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); return buffer; } diff --git a/Aaru.Images/DiscFerret/DiscFerret.cs b/Aaru.Images/DiscFerret/DiscFerret.cs index 71e918e54..855b6d4b3 100644 --- a/Aaru.Images/DiscFerret/DiscFerret.cs +++ b/Aaru.Images/DiscFerret/DiscFerret.cs @@ -39,13 +39,13 @@ namespace Aaru.DiscImages { public partial class DiscFerret : IMediaImage, IVerifiableSectorsImage { - ImageInfo imageInfo; + ImageInfo _imageInfo; // TODO: These variables have been made public so create-sidecar can access to this information until I define an API >4.0 public SortedDictionary TrackLengths; public SortedDictionary TrackOffsets; - public DiscFerret() => imageInfo = new ImageInfo + public DiscFerret() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/DiscFerret/Properties.cs b/Aaru.Images/DiscFerret/Properties.cs index b82ef6e15..14513e48b 100644 --- a/Aaru.Images/DiscFerret/Properties.cs +++ b/Aaru.Images/DiscFerret/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public string Name => "DiscFerret"; public Guid Id => new Guid("70EA7B9B-5323-42EB-9B40-8DDA37C5EB4D"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Format => "DiscFerret"; public string Author => "Natalia Portillo"; public List DumpHardware => null; diff --git a/Aaru.Images/DiscFerret/Read.cs b/Aaru.Images/DiscFerret/Read.cs index 2fb55f665..53d52e248 100644 --- a/Aaru.Images/DiscFerret/Read.cs +++ b/Aaru.Images/DiscFerret/Read.cs @@ -107,18 +107,18 @@ namespace Aaru.DiscImages t++; } - if(blockHeader.cylinder > imageInfo.Cylinders) - imageInfo.Cylinders = blockHeader.cylinder; + if(blockHeader.cylinder > _imageInfo.Cylinders) + _imageInfo.Cylinders = blockHeader.cylinder; - if(blockHeader.head > imageInfo.Heads) - imageInfo.Heads = blockHeader.head; + if(blockHeader.head > _imageInfo.Heads) + _imageInfo.Heads = blockHeader.head; } - imageInfo.Heads++; - imageInfo.Cylinders++; + _imageInfo.Heads++; + _imageInfo.Cylinders++; - imageInfo.Application = "DiscFerret"; - imageInfo.ApplicationVersion = magic == DFI_MAGIC2 ? "2.0" : "1.0"; + _imageInfo.Application = "DiscFerret"; + _imageInfo.ApplicationVersion = magic == DFI_MAGIC2 ? "2.0" : "1.0"; throw new NotImplementedException("Flux decoding is not yet implemented."); } diff --git a/Aaru.Images/DiscJuggler/DiscJuggler.cs b/Aaru.Images/DiscJuggler/DiscJuggler.cs index 12adca453..ddbddf318 100644 --- a/Aaru.Images/DiscJuggler/DiscJuggler.cs +++ b/Aaru.Images/DiscJuggler/DiscJuggler.cs @@ -43,14 +43,14 @@ namespace Aaru.DiscImages // TODO: Too many unknowns to make this writable public partial class DiscJuggler : IOpticalMediaImage { + byte[] _cdtext; + ImageInfo _imageInfo; + Stream _imageStream; + Dictionary _offsetmap; SectorBuilder _sectorBuilder; - byte[] cdtext; - ImageInfo imageInfo; - Stream imageStream; - Dictionary offsetmap; - Dictionary trackFlags; + Dictionary _trackFlags; - public DiscJuggler() => imageInfo = new ImageInfo + public DiscJuggler() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/DiscJuggler/Identify.cs b/Aaru.Images/DiscJuggler/Identify.cs index dc2819bca..30aff1a88 100644 --- a/Aaru.Images/DiscJuggler/Identify.cs +++ b/Aaru.Images/DiscJuggler/Identify.cs @@ -41,21 +41,21 @@ namespace Aaru.DiscImages { public bool Identify(IFilter imageFilter) { - imageStream = imageFilter.GetDataForkStream(); + _imageStream = imageFilter.GetDataForkStream(); - imageStream.Seek(-4, SeekOrigin.End); + _imageStream.Seek(-4, SeekOrigin.End); byte[] dscLenB = new byte[4]; - imageStream.Read(dscLenB, 0, 4); + _imageStream.Read(dscLenB, 0, 4); int dscLen = BitConverter.ToInt32(dscLenB, 0); AaruConsole.DebugWriteLine("DiscJuggler plugin", "dscLen = {0}", dscLen); - if(dscLen >= imageStream.Length) + if(dscLen >= _imageStream.Length) return false; byte[] descriptor = new byte[dscLen]; - imageStream.Seek(-dscLen, SeekOrigin.End); - imageStream.Read(descriptor, 0, dscLen); + _imageStream.Seek(-dscLen, SeekOrigin.End); + _imageStream.Read(descriptor, 0, dscLen); // Sessions if(descriptor[0] > 99 || diff --git a/Aaru.Images/DiscJuggler/Properties.cs b/Aaru.Images/DiscJuggler/Properties.cs index 3010208ed..93acc0436 100644 --- a/Aaru.Images/DiscJuggler/Properties.cs +++ b/Aaru.Images/DiscJuggler/Properties.cs @@ -42,7 +42,7 @@ namespace Aaru.DiscImages { public string Name => "DiscJuggler"; public Guid Id => new Guid("2444DBC6-CD35-424C-A227-39B0C4DB01B2"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Format => "DiscJuggler"; public string Author => "Natalia Portillo"; public List Partitions { get; private set; } diff --git a/Aaru.Images/DiscJuggler/Read.cs b/Aaru.Images/DiscJuggler/Read.cs index fb17d4992..4d53d2068 100644 --- a/Aaru.Images/DiscJuggler/Read.cs +++ b/Aaru.Images/DiscJuggler/Read.cs @@ -51,19 +51,19 @@ namespace Aaru.DiscImages { public bool Open(IFilter imageFilter) { - imageStream = imageFilter.GetDataForkStream(); + _imageStream = imageFilter.GetDataForkStream(); - imageStream.Seek(-4, SeekOrigin.End); + _imageStream.Seek(-4, SeekOrigin.End); byte[] dscLenB = new byte[4]; - imageStream.Read(dscLenB, 0, 4); + _imageStream.Read(dscLenB, 0, 4); int dscLen = BitConverter.ToInt32(dscLenB, 0); - if(dscLen >= imageStream.Length) + if(dscLen >= _imageStream.Length) return false; byte[] descriptor = new byte[dscLen]; - imageStream.Seek(-dscLen, SeekOrigin.End); - imageStream.Read(descriptor, 0, dscLen); + _imageStream.Seek(-dscLen, SeekOrigin.End); + _imageStream.Read(descriptor, 0, dscLen); // Sessions if(descriptor[0] > 99 || @@ -73,11 +73,11 @@ namespace Aaru.DiscImages int position = 1; ushort sessionSequence = 0; - Sessions = new List(); - Tracks = new List(); - Partitions = new List(); - offsetmap = new Dictionary(); - trackFlags = new Dictionary(); + Sessions = new List(); + Tracks = new List(); + Partitions = new List(); + _offsetmap = new Dictionary(); + _trackFlags = new Dictionary(); ushort mediumType; byte maxS = descriptor[0]; @@ -311,8 +311,8 @@ namespace Aaru.DiscImages { // Audio case 0: - if(imageInfo.SectorSize < 2352) - imageInfo.SectorSize = 2352; + if(_imageInfo.SectorSize < 2352) + _imageInfo.SectorSize = 2352; track.TrackType = TrackType.Audio; track.TrackBytesPerSector = 2352; @@ -359,8 +359,8 @@ namespace Aaru.DiscImages // Mode 1 or DVD case 1: - if(imageInfo.SectorSize < 2048) - imageInfo.SectorSize = 2048; + if(_imageInfo.SectorSize < 2048) + _imageInfo.SectorSize = 2048; track.TrackType = TrackType.CdMode1; track.TrackBytesPerSector = 2048; @@ -384,23 +384,23 @@ namespace Aaru.DiscImages track.TrackRawBytesPerSector = 2352; currentOffset += trackLen * (ulong)track.TrackRawBytesPerSector; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); break; case 3: @@ -416,23 +416,23 @@ namespace Aaru.DiscImages currentOffset += trackLen * (ulong)(track.TrackRawBytesPerSector + 16); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); break; case 4: @@ -448,23 +448,23 @@ namespace Aaru.DiscImages currentOffset += trackLen * (ulong)(track.TrackRawBytesPerSector + 96); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); break; default: throw new ImageNotSupportedException($"Unknown read mode {readMode}"); @@ -474,8 +474,8 @@ namespace Aaru.DiscImages // Mode 2 case 2: - if(imageInfo.SectorSize < 2336) - imageInfo.SectorSize = 2336; + if(_imageInfo.SectorSize < 2336) + _imageInfo.SectorSize = 2336; track.TrackType = TrackType.CdMode2Formless; track.TrackBytesPerSector = 2336; @@ -499,11 +499,11 @@ namespace Aaru.DiscImages track.TrackRawBytesPerSector = 2352; currentOffset += trackLen * (ulong)track.TrackRawBytesPerSector; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); break; case 3: @@ -519,11 +519,11 @@ namespace Aaru.DiscImages currentOffset += trackLen * (ulong)(track.TrackRawBytesPerSector + 16); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); break; case 4: @@ -539,11 +539,11 @@ namespace Aaru.DiscImages currentOffset += trackLen * (ulong)(track.TrackRawBytesPerSector + 96); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); break; default: throw new ImageNotSupportedException($"Unknown read mode {readMode}"); @@ -561,8 +561,8 @@ namespace Aaru.DiscImages track.TrackSubchannelFile = imageFilter.GetFilename(); track.TrackSubchannelFilter = imageFilter; - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); } var partition = new Partition @@ -584,11 +584,11 @@ namespace Aaru.DiscImages partition.Size = partition.Length * (ulong)track.TrackBytesPerSector; - imageInfo.Sectors += partition.Length; + _imageInfo.Sectors += partition.Length; Partitions.Add(partition); - offsetmap.Add(track.TrackSequence, track.TrackStartSector); + _offsetmap.Add(track.TrackSequence, track.TrackStartSector); Tracks.Add(track); - trackFlags.Add(track.TrackSequence, (byte)(trackCtl & 0xFF)); + _trackFlags.Add(track.TrackSequence, (byte)(trackCtl & 0xFF)); addedATrack = true; } @@ -652,10 +652,10 @@ namespace Aaru.DiscImages if(cdtextLen > 0) { - cdtext = new byte[cdtextLen]; - Array.Copy(descriptor, position, cdtext, 0, cdtextLen); + _cdtext = new byte[cdtextLen]; + Array.Copy(descriptor, position, _cdtext, 0, cdtextLen); position += (int)cdtextLen; - imageInfo.ReadableMediaTags.Add(MediaTagType.CD_TEXT); + _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_TEXT); } // Skip unknown @@ -663,9 +663,9 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("DiscJuggler plugin", "End position = {0}", position); - imageInfo.MediaType = DecodeCdiMediumType(mediumType); + _imageInfo.MediaType = DecodeCdiMediumType(mediumType); - if(imageInfo.MediaType == MediaType.CDROM) + if(_imageInfo.MediaType == MediaType.CDROM) { bool data = false; bool mode2 = false; @@ -700,25 +700,25 @@ namespace Aaru.DiscImages if(!data && !firstdata) - imageInfo.MediaType = MediaType.CDDA; + _imageInfo.MediaType = MediaType.CDDA; else if(firstaudio && data && Sessions.Count > 1 && mode2) - imageInfo.MediaType = MediaType.CDPLUS; + _imageInfo.MediaType = MediaType.CDPLUS; else if((firstdata && audio) || mode2) - imageInfo.MediaType = MediaType.CDROMXA; + _imageInfo.MediaType = MediaType.CDROMXA; else if(!audio) - imageInfo.MediaType = MediaType.CDROM; + _imageInfo.MediaType = MediaType.CDROM; else - imageInfo.MediaType = MediaType.CD; + _imageInfo.MediaType = MediaType.CD; } - imageInfo.Application = "DiscJuggler"; - imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; + _imageInfo.Application = "DiscJuggler"; + _imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; _sectorBuilder = new SectorBuilder(); @@ -738,9 +738,9 @@ namespace Aaru.DiscImages { case MediaTagType.CD_TEXT: { - if(cdtext != null && - cdtext.Length > 0) - return cdtext; + if(_cdtext != null && + _cdtext.Length > 0) + return _cdtext; throw new FeatureNotPresentImageException("Image does not contain CD-TEXT information."); } @@ -760,7 +760,7 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress < track.TrackEndSector select kvp) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); @@ -770,7 +770,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { - foreach(KeyValuePair kvp in offsetmap. + foreach(KeyValuePair kvp in _offsetmap. Where(kvp => sectorAddress >= kvp.Value). Where(kvp => Tracks. Where(track => track.TrackSequence == kvp.Key). @@ -862,7 +862,7 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream. + _imageStream. Seek((long)(aaruTrack.TrackFileOffset + (sectorAddress * (ulong)aaruTrack.TrackRawBytesPerSector)), SeekOrigin.Begin); @@ -870,7 +870,7 @@ namespace Aaru.DiscImages { var mode2Ms = new MemoryStream((int)((sectorSize + sectorSkip) * length)); - imageStream.Read(buffer, 0, buffer.Length); + _imageStream.Read(buffer, 0, buffer.Length); for(int i = 0; i < length; i++) { @@ -884,14 +884,14 @@ namespace Aaru.DiscImages } else if(sectorOffset == 0 && sectorSkip == 0) - imageStream.Read(buffer, 0, buffer.Length); + _imageStream.Read(buffer, 0, buffer.Length); else for(int i = 0; i < length; i++) { byte[] sector = new byte[sectorSize]; - imageStream.Seek(sectorOffset, SeekOrigin.Current); - imageStream.Read(sector, 0, sector.Length); - imageStream.Seek(sectorSkip, SeekOrigin.Current); + _imageStream.Seek(sectorOffset, SeekOrigin.Current); + _imageStream.Read(sector, 0, sector.Length); + _imageStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } @@ -936,7 +936,7 @@ namespace Aaru.DiscImages case SectorTagType.CdSectorSubHeader: case SectorTagType.CdSectorSync: break; case SectorTagType.CdTrackFlags: - if(trackFlags.TryGetValue(track, out byte flag)) + if(_trackFlags.TryGetValue(track, out byte flag)) return new[] { flag @@ -1138,20 +1138,20 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream. + _imageStream. Seek((long)(aaruTrack.TrackFileOffset + (sectorAddress * (ulong)aaruTrack.TrackRawBytesPerSector)), SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) - imageStream.Read(buffer, 0, buffer.Length); + _imageStream.Read(buffer, 0, buffer.Length); else for(int i = 0; i < length; i++) { byte[] sector = new byte[sectorSize]; - imageStream.Seek(sectorOffset, SeekOrigin.Current); - imageStream.Read(sector, 0, sector.Length); - imageStream.Seek(sectorSkip, SeekOrigin.Current); + _imageStream.Seek(sectorOffset, SeekOrigin.Current); + _imageStream.Read(sector, 0, sector.Length); + _imageStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } @@ -1168,7 +1168,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector select kvp) @@ -1220,18 +1220,18 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream. + _imageStream. Seek((long)(aaruTrack.TrackFileOffset + (sectorAddress * (ulong)aaruTrack.TrackRawBytesPerSector)), SeekOrigin.Begin); if(sectorSkip == 0) - imageStream.Read(buffer, 0, buffer.Length); + _imageStream.Read(buffer, 0, buffer.Length); else for(int i = 0; i < length; i++) { byte[] sector = new byte[sectorSize]; - imageStream.Read(sector, 0, sector.Length); - imageStream.Seek(sectorSkip, SeekOrigin.Current); + _imageStream.Read(sector, 0, sector.Length); + _imageStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } diff --git a/Aaru.Images/DriDiskCopy/DriDiskCopy.cs b/Aaru.Images/DriDiskCopy/DriDiskCopy.cs index 3bac59548..f5d7fa3a9 100644 --- a/Aaru.Images/DriDiskCopy/DriDiskCopy.cs +++ b/Aaru.Images/DriDiskCopy/DriDiskCopy.cs @@ -41,14 +41,14 @@ namespace Aaru.DiscImages public partial class DriDiskCopy : IWritableImage { /// Disk image file - IFilter driImageFilter; + IFilter _driImageFilter; /// Footer of opened image - DriFooter footer; - ImageInfo imageInfo; - FileStream writingStream; + DriFooter _footer; + ImageInfo _imageInfo; + FileStream _writingStream; - public DriDiskCopy() => imageInfo = new ImageInfo + public DriDiskCopy() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/DriDiskCopy/Properties.cs b/Aaru.Images/DriDiskCopy/Properties.cs index 3be0d002e..51b08dc1a 100644 --- a/Aaru.Images/DriDiskCopy/Properties.cs +++ b/Aaru.Images/DriDiskCopy/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class DriDiskCopy { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Digital Research DiskCopy"; public Guid Id => new Guid("9F0BE551-8BAB-4038-8B5A-691F1BF5FFF3"); diff --git a/Aaru.Images/DriDiskCopy/Read.cs b/Aaru.Images/DriDiskCopy/Read.cs index bc36adae8..757927c65 100644 --- a/Aaru.Images/DriDiskCopy/Read.cs +++ b/Aaru.Images/DriDiskCopy/Read.cs @@ -54,9 +54,9 @@ namespace Aaru.DiscImages stream.Seek(-buffer.Length, SeekOrigin.End); stream.Read(buffer, 0, buffer.Length); - footer = Marshal.ByteArrayToStructureLittleEndian(buffer); + _footer = Marshal.ByteArrayToStructureLittleEndian(buffer); - string sig = StringHandlers.CToString(footer.signature); + string sig = StringHandlers.CToString(_footer.signature); var regexSignature = new Regex(REGEX_DRI); Match matchSignature = regexSignature.Match(sig); @@ -64,66 +64,66 @@ namespace Aaru.DiscImages if(!matchSignature.Success) return false; - if(footer.bpb.sptrack * footer.bpb.cylinders * footer.bpb.heads != footer.bpb.sectors) + if(_footer.bpb.sptrack * _footer.bpb.cylinders * _footer.bpb.heads != _footer.bpb.sectors) return false; - if((footer.bpb.sectors * footer.bpb.bps) + Marshal.SizeOf() != stream.Length) + if((_footer.bpb.sectors * _footer.bpb.bps) + Marshal.SizeOf() != stream.Length) return false; - imageInfo.Cylinders = footer.bpb.cylinders; - imageInfo.Heads = footer.bpb.heads; - imageInfo.SectorsPerTrack = footer.bpb.sptrack; - imageInfo.Sectors = footer.bpb.sectors; - imageInfo.SectorSize = footer.bpb.bps; - imageInfo.ApplicationVersion = matchSignature.Groups["version"].Value; + _imageInfo.Cylinders = _footer.bpb.cylinders; + _imageInfo.Heads = _footer.bpb.heads; + _imageInfo.SectorsPerTrack = _footer.bpb.sptrack; + _imageInfo.Sectors = _footer.bpb.sectors; + _imageInfo.SectorSize = _footer.bpb.bps; + _imageInfo.ApplicationVersion = matchSignature.Groups["version"].Value; - driImageFilter = imageFilter; + _driImageFilter = imageFilter; - imageInfo.ImageSize = (ulong)(stream.Length - Marshal.SizeOf()); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.ImageSize = (ulong)(stream.Length - Marshal.SizeOf()); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); AaruConsole.DebugWriteLine("DRI DiskCopy plugin", "Image application = {0} version {1}", - imageInfo.Application, imageInfo.ApplicationVersion); + _imageInfo.Application, _imageInfo.ApplicationVersion); // Correct some incorrect data in images of NEC 2HD disks - if(imageInfo.Cylinders == 77 && - imageInfo.Heads == 2 && - imageInfo.SectorsPerTrack == 16 && - imageInfo.SectorSize == 512 && - (footer.bpb.driveCode == DriDriveCodes.md2hd || footer.bpb.driveCode == DriDriveCodes.mf2hd)) + if(_imageInfo.Cylinders == 77 && + _imageInfo.Heads == 2 && + _imageInfo.SectorsPerTrack == 16 && + _imageInfo.SectorSize == 512 && + (_footer.bpb.driveCode == DriDriveCodes.md2hd || _footer.bpb.driveCode == DriDriveCodes.mf2hd)) { - imageInfo.SectorsPerTrack = 8; - imageInfo.SectorSize = 1024; + _imageInfo.SectorsPerTrack = 8; + _imageInfo.SectorSize = 1024; } - imageInfo.MediaType = Geometry.GetMediaType(((ushort)imageInfo.Cylinders, (byte)imageInfo.Heads, - (ushort)imageInfo.SectorsPerTrack, imageInfo.SectorSize, - MediaEncoding.MFM, false)); + _imageInfo.MediaType = Geometry.GetMediaType(((ushort)_imageInfo.Cylinders, (byte)_imageInfo.Heads, + (ushort)_imageInfo.SectorsPerTrack, _imageInfo.SectorSize, + MediaEncoding.MFM, false)); - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { - case MediaType.NEC_525_HD when footer.bpb.driveCode == DriDriveCodes.mf2hd || - footer.bpb.driveCode == DriDriveCodes.mf2ed: - imageInfo.MediaType = MediaType.NEC_35_HD_8; + case MediaType.NEC_525_HD when _footer.bpb.driveCode == DriDriveCodes.mf2hd || + _footer.bpb.driveCode == DriDriveCodes.mf2ed: + _imageInfo.MediaType = MediaType.NEC_35_HD_8; break; - case MediaType.DOS_525_HD when footer.bpb.driveCode == DriDriveCodes.mf2hd || - footer.bpb.driveCode == DriDriveCodes.mf2ed: - imageInfo.MediaType = MediaType.NEC_35_HD_15; + case MediaType.DOS_525_HD when _footer.bpb.driveCode == DriDriveCodes.mf2hd || + _footer.bpb.driveCode == DriDriveCodes.mf2ed: + _imageInfo.MediaType = MediaType.NEC_35_HD_15; break; - case MediaType.RX50 when footer.bpb.driveCode == DriDriveCodes.md2dd || - footer.bpb.driveCode == DriDriveCodes.md2hd: - imageInfo.MediaType = MediaType.ATARI_35_SS_DD; + case MediaType.RX50 when _footer.bpb.driveCode == DriDriveCodes.md2dd || + _footer.bpb.driveCode == DriDriveCodes.md2hd: + _imageInfo.MediaType = MediaType.ATARI_35_SS_DD; break; } - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; AaruConsole.VerboseWriteLine("Digital Research DiskCopy image contains a disk of type {0}", - imageInfo.MediaType); + _imageInfo.MediaType); return true; } @@ -132,17 +132,17 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Stream stream = driImageFilter.GetDataForkStream(); - stream.Seek((long)(sectorAddress * imageInfo.SectorSize), SeekOrigin.Begin); - stream.Read(buffer, 0, (int)(length * imageInfo.SectorSize)); + Stream stream = _driImageFilter.GetDataForkStream(); + stream.Seek((long)(sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); + stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); return buffer; } diff --git a/Aaru.Images/DriDiskCopy/Write.cs b/Aaru.Images/DriDiskCopy/Write.cs index 305fb2a68..5d58b50c3 100644 --- a/Aaru.Images/DriDiskCopy/Write.cs +++ b/Aaru.Images/DriDiskCopy/Write.cs @@ -69,7 +69,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -78,7 +78,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -91,7 +91,7 @@ namespace Aaru.DiscImages (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding, bool variableSectorsPerTrack, MediaType type) geometry = Geometry.GetGeometry(mediaType); - footer = new DriFooter + _footer = new DriFooter { signature = new byte[51], bpb = new DriBpb @@ -99,19 +99,19 @@ namespace Aaru.DiscImages five = 5, driveCode = DriDriveCodes.mf2ed, cylinders = geometry.cylinders, - bps = (ushort)imageInfo.SectorSize, - sectors = (ushort)imageInfo.Sectors, - sptrack = (ushort)imageInfo.SectorsPerTrack, - heads = (ushort)imageInfo.Heads, - sptrack2 = (ushort)imageInfo.SectorsPerTrack, + bps = (ushort)_imageInfo.SectorSize, + sectors = (ushort)_imageInfo.Sectors, + sptrack = (ushort)_imageInfo.SectorsPerTrack, + heads = (ushort)_imageInfo.Heads, + sptrack2 = (ushort)_imageInfo.SectorsPerTrack, unknown5 = new byte[144] } }; Array.Copy(Encoding.ASCII.GetBytes("DiskImage 2.01 (C) 1990,1991 Digital Research Inc"), 0, - footer.signature, 0, 49); + _footer.signature, 0, 49); - footer.bpbcopy = footer.bpb; + _footer.bpbcopy = _footer.bpb; IsWriting = true; ErrorMessage = null; @@ -135,22 +135,22 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(sectorAddress * imageInfo.SectorSize), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -166,22 +166,22 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(sectorAddress * imageInfo.SectorSize), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -213,15 +213,15 @@ namespace Aaru.DiscImages byte[] hdr = new byte[Marshal.SizeOf()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); - System.Runtime.InteropServices.Marshal.StructureToPtr(footer, hdrPtr, true); + System.Runtime.InteropServices.Marshal.StructureToPtr(_footer, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); - writingStream.Seek(0, SeekOrigin.End); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.End); + _writingStream.Write(hdr, 0, hdr.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; diff --git a/Aaru.Images/GDI/GDI.cs b/Aaru.Images/GDI/GDI.cs index e77a1809d..a7fb05aba 100644 --- a/Aaru.Images/GDI/GDI.cs +++ b/Aaru.Images/GDI/GDI.cs @@ -43,16 +43,16 @@ namespace Aaru.DiscImages // TODO: This format doesn't support to specify pregaps that are included in the file (like Redump ones) public partial class Gdi : IOpticalMediaImage { - SectorBuilder _sectorBuilder; - ulong densitySeparationSectors; - GdiDisc discimage; - StreamReader gdiStream; - ImageInfo imageInfo; - Stream imageStream; + ulong _densitySeparationSectors; + GdiDisc _discimage; + StreamReader _gdiStream; + ImageInfo _imageInfo; + Stream _imageStream; /// Dictionary, index is track #, value is track number, or 0 if a TOC - Dictionary offsetmap; + Dictionary _offsetmap; + SectorBuilder _sectorBuilder; - public Gdi() => imageInfo = new ImageInfo + public Gdi() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/GDI/Identify.cs b/Aaru.Images/GDI/Identify.cs index 0d72e3635..ccf4ae874 100644 --- a/Aaru.Images/GDI/Identify.cs +++ b/Aaru.Images/GDI/Identify.cs @@ -75,15 +75,15 @@ namespace Aaru.DiscImages return false; } - gdiStream = new StreamReader(imageFilter.GetDataForkStream()); + _gdiStream = new StreamReader(imageFilter.GetDataForkStream()); int lineNumber = 0; int tracksFound = 0; int tracks = 0; - while(gdiStream.Peek() >= 0) + while(_gdiStream.Peek() >= 0) { lineNumber++; - string line = gdiStream.ReadLine(); + string line = _gdiStream.ReadLine(); if(lineNumber == 1) { diff --git a/Aaru.Images/GDI/Properties.cs b/Aaru.Images/GDI/Properties.cs index 5400f1515..5d3f50660 100644 --- a/Aaru.Images/GDI/Properties.cs +++ b/Aaru.Images/GDI/Properties.cs @@ -44,7 +44,7 @@ namespace Aaru.DiscImages { public string Name => "Dreamcast GDI image"; public Guid Id => new Guid("281ECBF2-D2A7-414C-8497-1A33F6DCB2DD"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Format => "Dreamcast GDI image"; @@ -56,7 +56,7 @@ namespace Aaru.DiscImages { List tracks = new List(); - foreach(GdiTrack gdiTrack in discimage.Tracks) + foreach(GdiTrack gdiTrack in _discimage.Tracks) { var track = new Track { @@ -84,7 +84,7 @@ namespace Aaru.DiscImages } } - public List Sessions => discimage.Sessions; + public List Sessions => _discimage.Sessions; public List DumpHardware => null; public CICMMetadataType CicmMetadata => null; } diff --git a/Aaru.Images/GDI/Read.cs b/Aaru.Images/GDI/Read.cs index 36b721808..b63881c18 100644 --- a/Aaru.Images/GDI/Read.cs +++ b/Aaru.Images/GDI/Read.cs @@ -56,7 +56,7 @@ namespace Aaru.DiscImages try { imageFilter.GetDataForkStream().Seek(0, SeekOrigin.Begin); - gdiStream = new StreamReader(imageFilter.GetDataForkStream()); + _gdiStream = new StreamReader(imageFilter.GetDataForkStream()); int lineNumber = 0; bool highDensity = false; @@ -66,20 +66,20 @@ namespace Aaru.DiscImages // Initialize all RegEx matches // Initialize disc - discimage = new GdiDisc + _discimage = new GdiDisc { Sessions = new List(), Tracks = new List() }; ulong currentStart = 0; - offsetmap = new Dictionary(); - densitySeparationSectors = 0; + _offsetmap = new Dictionary(); + _densitySeparationSectors = 0; - while(gdiStream.Peek() >= 0) + while(_gdiStream.Peek() >= 0) { lineNumber++; - string line = gdiStream.ReadLine(); + string line = _gdiStream.ReadLine(); if(lineNumber == 1) { @@ -121,9 +121,9 @@ namespace Aaru.DiscImages if(currentTrack.StartSector == 45000) { highDensity = true; - offsetmap.Add(0, currentStart); - densitySeparationSectors = currentTrack.StartSector - currentStart; - currentStart = currentTrack.StartSector; + _offsetmap.Add(0, currentStart); + _densitySeparationSectors = currentTrack.StartSector - currentStart; + currentStart = currentTrack.StartSector; } else { @@ -145,7 +145,7 @@ namespace Aaru.DiscImages currentTrack.Tracktype = (currentTrack.Flags & 0x4) == 0x4 ? TrackType.CdMode1 : TrackType.Audio; - discimage.Tracks.Add(currentTrack); + _discimage.Tracks.Add(currentTrack); } } @@ -156,7 +156,7 @@ namespace Aaru.DiscImages { sessions[s].SessionSequence = 1; - foreach(GdiTrack trk in discimage.Tracks.Where(trk => !trk.HighDensity)) + foreach(GdiTrack trk in _discimage.Tracks.Where(trk => !trk.HighDensity)) { if(sessions[s].StartTrack == 0) sessions[s].StartTrack = trk.Sequence; @@ -177,7 +177,7 @@ namespace Aaru.DiscImages { sessions[s].SessionSequence = 2; - foreach(GdiTrack trk in discimage.Tracks.Where(trk => trk.HighDensity)) + foreach(GdiTrack trk in _discimage.Tracks.Where(trk => trk.HighDensity)) { if(sessions[s].StartTrack == 0) sessions[s].StartTrack = trk.Sequence; @@ -195,56 +195,58 @@ namespace Aaru.DiscImages } } - discimage.Sessions.Add(sessions[0]); - discimage.Sessions.Add(sessions[1]); + _discimage.Sessions.Add(sessions[0]); + _discimage.Sessions.Add(sessions[1]); - discimage.Disktype = MediaType.GDROM; + _discimage.Disktype = MediaType.GDROM; // DEBUG information AaruConsole.DebugWriteLine("GDI plugin", "Disc image parsing results"); AaruConsole.DebugWriteLine("GDI plugin", "Session information:"); - AaruConsole.DebugWriteLine("GDI plugin", "\tDisc contains {0} sessions", discimage.Sessions.Count); + AaruConsole.DebugWriteLine("GDI plugin", "\tDisc contains {0} sessions", _discimage.Sessions.Count); - for(int i = 0; i < discimage.Sessions.Count; i++) + for(int i = 0; i < _discimage.Sessions.Count; i++) { AaruConsole.DebugWriteLine("GDI plugin", "\tSession {0} information:", i + 1); AaruConsole.DebugWriteLine("GDI plugin", "\t\tStarting track: {0}", - discimage.Sessions[i].StartTrack); + _discimage.Sessions[i].StartTrack); AaruConsole.DebugWriteLine("GDI plugin", "\t\tStarting sector: {0}", - discimage.Sessions[i].StartSector); + _discimage.Sessions[i].StartSector); - AaruConsole.DebugWriteLine("GDI plugin", "\t\tEnding track: {0}", discimage.Sessions[i].EndTrack); - AaruConsole.DebugWriteLine("GDI plugin", "\t\tEnding sector: {0}", discimage.Sessions[i].EndSector); + AaruConsole.DebugWriteLine("GDI plugin", "\t\tEnding track: {0}", _discimage.Sessions[i].EndTrack); + + AaruConsole.DebugWriteLine("GDI plugin", "\t\tEnding sector: {0}", + _discimage.Sessions[i].EndSector); } AaruConsole.DebugWriteLine("GDI plugin", "Track information:"); - AaruConsole.DebugWriteLine("GDI plugin", "\tDisc contains {0} tracks", discimage.Tracks.Count); + AaruConsole.DebugWriteLine("GDI plugin", "\tDisc contains {0} tracks", _discimage.Tracks.Count); - for(int i = 0; i < discimage.Tracks.Count; i++) + for(int i = 0; i < _discimage.Tracks.Count; i++) { - AaruConsole.DebugWriteLine("GDI plugin", "\tTrack {0} information:", discimage.Tracks[i].Sequence); - AaruConsole.DebugWriteLine("GDI plugin", "\t\t{0} bytes per sector", discimage.Tracks[i].Bps); - AaruConsole.DebugWriteLine("GDI plugin", "\t\tPregap: {0} sectors", discimage.Tracks[i].Pregap); + AaruConsole.DebugWriteLine("GDI plugin", "\tTrack {0} information:", _discimage.Tracks[i].Sequence); + AaruConsole.DebugWriteLine("GDI plugin", "\t\t{0} bytes per sector", _discimage.Tracks[i].Bps); + AaruConsole.DebugWriteLine("GDI plugin", "\t\tPregap: {0} sectors", _discimage.Tracks[i].Pregap); - if((discimage.Tracks[i].Flags & 0x8) == 0x8) + if((_discimage.Tracks[i].Flags & 0x8) == 0x8) AaruConsole.DebugWriteLine("GDI plugin", "\t\tTrack is flagged as quadraphonic"); - if((discimage.Tracks[i].Flags & 0x4) == 0x4) + if((_discimage.Tracks[i].Flags & 0x4) == 0x4) AaruConsole.DebugWriteLine("GDI plugin", "\t\tTrack is data"); - if((discimage.Tracks[i].Flags & 0x2) == 0x2) + if((_discimage.Tracks[i].Flags & 0x2) == 0x2) AaruConsole.DebugWriteLine("GDI plugin", "\t\tTrack allows digital copy"); - if((discimage.Tracks[i].Flags & 0x1) == 0x1) + if((_discimage.Tracks[i].Flags & 0x1) == 0x1) AaruConsole.DebugWriteLine("GDI plugin", "\t\tTrack has pre-emphasis applied"); AaruConsole.DebugWriteLine("GDI plugin", "\t\tTrack resides in file {0}, type defined as {1}, starting at byte {2}", - discimage.Tracks[i].Trackfilter, discimage.Tracks[i].Tracktype, - discimage.Tracks[i].Offset); + _discimage.Tracks[i].Trackfilter, _discimage.Tracks[i].Tracktype, + _discimage.Tracks[i].Offset); } AaruConsole.DebugWriteLine("GDI plugin", "Building offset map"); @@ -252,62 +254,62 @@ namespace Aaru.DiscImages Partitions = new List(); ulong byteOffset = 0; - for(int i = 0; i < discimage.Tracks.Count; i++) + for(int i = 0; i < _discimage.Tracks.Count; i++) { - if(discimage.Tracks[i].Sequence == 1 && - i != 0) + if(_discimage.Tracks[i].Sequence == 1 && + i != 0) throw new ImageNotSupportedException("Unordered tracks"); // Index 01 var partition = new Partition { - Description = $"Track {discimage.Tracks[i].Sequence}.", + Description = $"Track {_discimage.Tracks[i].Sequence}.", Name = null, - Start = discimage.Tracks[i].StartSector, - Size = discimage.Tracks[i].Sectors * discimage.Tracks[i].Bps, - Length = discimage.Tracks[i].Sectors, - Sequence = discimage.Tracks[i].Sequence, + Start = _discimage.Tracks[i].StartSector, + Size = _discimage.Tracks[i].Sectors * _discimage.Tracks[i].Bps, + Length = _discimage.Tracks[i].Sectors, + Sequence = _discimage.Tracks[i].Sequence, Offset = byteOffset, - Type = discimage.Tracks[i].Tracktype.ToString() + Type = _discimage.Tracks[i].Tracktype.ToString() }; byteOffset += partition.Size; - offsetmap.Add(discimage.Tracks[i].Sequence, partition.Start); + _offsetmap.Add(_discimage.Tracks[i].Sequence, partition.Start); Partitions.Add(partition); } - foreach(GdiTrack track in discimage.Tracks) - imageInfo.ImageSize += track.Bps * track.Sectors; + foreach(GdiTrack track in _discimage.Tracks) + _imageInfo.ImageSize += track.Bps * track.Sectors; - foreach(GdiTrack track in discimage.Tracks) - imageInfo.Sectors += track.Sectors; + foreach(GdiTrack track in _discimage.Tracks) + _imageInfo.Sectors += track.Sectors; - imageInfo.Sectors += densitySeparationSectors; + _imageInfo.Sectors += _densitySeparationSectors; - imageInfo.SectorSize = 2352; // All others + _imageInfo.SectorSize = 2352; // All others - foreach(GdiTrack unused in discimage.Tracks.Where(track => (track.Flags & 0x4) == 0x4 && - track.Bps == 2352)) + foreach(GdiTrack unused in _discimage.Tracks.Where(track => (track.Flags & 0x4) == 0x4 && + track.Bps == 2352)) { - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); } - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaType = discimage.Disktype; + _imageInfo.MediaType = _discimage.Disktype; - imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); - imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; + _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; - AaruConsole.VerboseWriteLine("GDI image describes a disc of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("GDI image describes a disc of type {0}", _imageInfo.MediaType); _sectorBuilder = new SectorBuilder(); @@ -334,16 +336,16 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value - from gdiTrack in discimage.Tracks + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value + from gdiTrack in _discimage.Tracks where gdiTrack.Sequence == kvp.Key where sectorAddress - kvp.Value < gdiTrack.Sectors select kvp) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); - offsetmap.TryGetValue(0, out ulong transitionStart); + _offsetmap.TryGetValue(0, out ulong transitionStart); if(sectorAddress >= transitionStart && - sectorAddress < densitySeparationSectors + transitionStart) + sectorAddress < _densitySeparationSectors + transitionStart) return ReadSectors(sectorAddress - transitionStart, length, 0); throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); @@ -351,16 +353,16 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value - from gdiTrack in discimage.Tracks + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value + from gdiTrack in _discimage.Tracks where gdiTrack.Sequence == kvp.Key where sectorAddress - kvp.Value < gdiTrack.Sectors select kvp) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); - offsetmap.TryGetValue(0, out ulong transitionStart); + _offsetmap.TryGetValue(0, out ulong transitionStart); if(sectorAddress >= transitionStart && - sectorAddress < densitySeparationSectors + transitionStart) + sectorAddress < _densitySeparationSectors + transitionStart) return ReadSectorsTag(sectorAddress - transitionStart, length, 0, tag); throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); @@ -370,7 +372,7 @@ namespace Aaru.DiscImages { if(track == 0) { - if(sectorAddress + length > densitySeparationSectors) + if(sectorAddress + length > _densitySeparationSectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); @@ -382,7 +384,7 @@ namespace Aaru.DiscImages Sequence = 0 }; - foreach(GdiTrack gdiTrack in discimage.Tracks.Where(gdiTrack => gdiTrack.Sequence == track)) + foreach(GdiTrack gdiTrack in _discimage.Tracks.Where(gdiTrack => gdiTrack.Sequence == track)) { aaruTrack = gdiTrack; @@ -445,8 +447,8 @@ namespace Aaru.DiscImages if(remainingSectors == 0) return buffer; - imageStream = aaruTrack.Trackfilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = aaruTrack.Trackfilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); long pos = aaruTrack.Offset + (long)((sectorAddress * (sectorOffset + sectorSize + sectorSkip)) - (aaruTrack.Pregap * aaruTrack.Bps)); @@ -492,7 +494,7 @@ namespace Aaru.DiscImages if(track == 0) { - if(sectorAddress + length > densitySeparationSectors) + if(sectorAddress + length > _densitySeparationSectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); @@ -510,7 +512,7 @@ namespace Aaru.DiscImages Sequence = 0 }; - foreach(GdiTrack gdiTrack in discimage.Tracks.Where(gdiTrack => gdiTrack.Sequence == track)) + foreach(GdiTrack gdiTrack in _discimage.Tracks.Where(gdiTrack => gdiTrack.Sequence == track)) { aaruTrack = gdiTrack; @@ -631,8 +633,8 @@ namespace Aaru.DiscImages if(remainingSectors == 0) return buffer; - imageStream = aaruTrack.Trackfilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = aaruTrack.Trackfilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); long pos = aaruTrack.Offset + (long)((sectorAddress * (sectorOffset + sectorSize + sectorSkip)) - (aaruTrack.Pregap * aaruTrack.Bps)); @@ -677,8 +679,8 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value - from gdiTrack in discimage.Tracks + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value + from gdiTrack in _discimage.Tracks where gdiTrack.Sequence == kvp.Key where sectorAddress - kvp.Value < gdiTrack.Sectors select kvp) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); @@ -690,7 +692,7 @@ namespace Aaru.DiscImages { if(track == 0) { - if(sectorAddress + length > densitySeparationSectors) + if(sectorAddress + length > _densitySeparationSectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than present in track, won't cross tracks"); @@ -702,7 +704,7 @@ namespace Aaru.DiscImages Sequence = 0 }; - foreach(GdiTrack gdiTrack in discimage.Tracks.Where(gdiTrack => gdiTrack.Sequence == track)) + foreach(GdiTrack gdiTrack in _discimage.Tracks.Where(gdiTrack => gdiTrack.Sequence == track)) { aaruTrack = gdiTrack; @@ -765,8 +767,8 @@ namespace Aaru.DiscImages if(remainingSectors == 0) return buffer; - imageStream = aaruTrack.Trackfilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = aaruTrack.Trackfilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); long pos = aaruTrack.Offset + (long)((sectorAddress * (sectorOffset + sectorSize + sectorSkip)) - (aaruTrack.Pregap * aaruTrack.Bps)); @@ -828,7 +830,7 @@ namespace Aaru.DiscImages public List GetSessionTracks(Session session) { - if(discimage.Sessions.Contains(session)) + if(_discimage.Sessions.Contains(session)) return GetSessionTracks(session.SessionSequence); throw new ImageNotSupportedException("Session does not exist in disc image"); @@ -852,7 +854,7 @@ namespace Aaru.DiscImages default: throw new ImageNotSupportedException("Session does not exist in disc image"); } - foreach(GdiTrack gdiTrack in discimage.Tracks) + foreach(GdiTrack gdiTrack in _discimage.Tracks) if(gdiTrack.HighDensity == expectedDensity) { var track = new Track diff --git a/Aaru.Images/HDCopy/HDCopy.cs b/Aaru.Images/HDCopy/HDCopy.cs index b862b913e..58fbf74eb 100644 --- a/Aaru.Images/HDCopy/HDCopy.cs +++ b/Aaru.Images/HDCopy/HDCopy.cs @@ -75,18 +75,18 @@ namespace Aaru.DiscImages public partial class HdCopy : IMediaImage { /// Every track that has been read is cached here - readonly Dictionary trackCache = new Dictionary(); + readonly Dictionary _trackCache = new Dictionary(); /// The offset in the file where each track starts, or -1 if the track is not present - readonly Dictionary trackOffset = new Dictionary(); + readonly Dictionary _trackOffset = new Dictionary(); /// The HDCP file header after the image has been opened - HdcpFileHeader fileHeader; + HdcpFileHeader _fileHeader; /// The ImageFilter we're reading from, after the file has been opened - IFilter hdcpImageFilter; - ImageInfo imageInfo; + IFilter _hdcpImageFilter; + ImageInfo _imageInfo; - public HdCopy() => imageInfo = new ImageInfo + public HdCopy() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/HDCopy/Helpers.cs b/Aaru.Images/HDCopy/Helpers.cs index 2196345b1..ac9084e14 100644 --- a/Aaru.Images/HDCopy/Helpers.cs +++ b/Aaru.Images/HDCopy/Helpers.cs @@ -40,14 +40,14 @@ namespace Aaru.DiscImages { void ReadTrackIntoCache(Stream stream, int tracknum) { - byte[] trackData = new byte[imageInfo.SectorSize * imageInfo.SectorsPerTrack]; + byte[] trackData = new byte[_imageInfo.SectorSize * _imageInfo.SectorsPerTrack]; byte[] blkHeader = new byte[3]; // check that track is present - if(trackOffset[tracknum] == -1) + if(_trackOffset[tracknum] == -1) throw new InvalidDataException("Tried reading a track that is not present in image"); - stream.Seek(trackOffset[tracknum], SeekOrigin.Begin); + stream.Seek(_trackOffset[tracknum], SeekOrigin.Begin); // read the compressed track data stream.Read(blkHeader, 0, 3); @@ -76,11 +76,11 @@ namespace Aaru.DiscImages trackData[dIndex++] = cBuffer[sIndex++]; // check that the number of bytes decompressed matches a whole track - if(dIndex != imageInfo.SectorSize * imageInfo.SectorsPerTrack) + if(dIndex != _imageInfo.SectorSize * _imageInfo.SectorsPerTrack) throw new InvalidDataException("Track decompression yielded incomplete data"); // store track in cache - trackCache[tracknum] = trackData; + _trackCache[tracknum] = trackData; } } } \ No newline at end of file diff --git a/Aaru.Images/HDCopy/Properties.cs b/Aaru.Images/HDCopy/Properties.cs index 1398f6d7f..a28538ec9 100644 --- a/Aaru.Images/HDCopy/Properties.cs +++ b/Aaru.Images/HDCopy/Properties.cs @@ -40,7 +40,7 @@ namespace Aaru.DiscImages { public partial class HdCopy { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "HD-Copy disk image"; public Guid Id => new Guid("8D57483F-71A5-42EC-9B87-66AEC439C792"); diff --git a/Aaru.Images/HDCopy/Read.cs b/Aaru.Images/HDCopy/Read.cs index fc37dd1f9..5156e453b 100644 --- a/Aaru.Images/HDCopy/Read.cs +++ b/Aaru.Images/HDCopy/Read.cs @@ -57,30 +57,30 @@ namespace Aaru.DiscImages "Detected HD-Copy image with {0} tracks and {1} sectors per track.", fheader.lastCylinder + 1, fheader.sectorsPerTrack); - imageInfo.Cylinders = (uint)fheader.lastCylinder + 1; - imageInfo.SectorsPerTrack = fheader.sectorsPerTrack; - imageInfo.SectorSize = 512; // only 512 bytes per sector supported - imageInfo.Heads = 2; // only 2-sided floppies are supported - imageInfo.Sectors = 2 * imageInfo.Cylinders * imageInfo.SectorsPerTrack; - imageInfo.ImageSize = imageInfo.Sectors * imageInfo.SectorSize; + _imageInfo.Cylinders = (uint)fheader.lastCylinder + 1; + _imageInfo.SectorsPerTrack = fheader.sectorsPerTrack; + _imageInfo.SectorSize = 512; // only 512 bytes per sector supported + _imageInfo.Heads = 2; // only 2-sided floppies are supported + _imageInfo.Sectors = 2 * _imageInfo.Cylinders * _imageInfo.SectorsPerTrack; + _imageInfo.ImageSize = _imageInfo.Sectors * _imageInfo.SectorSize; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.MediaType = Geometry.GetMediaType(((ushort)imageInfo.Cylinders, 2, - (ushort)imageInfo.SectorsPerTrack, 512, MediaEncoding.MFM, - false)); + _imageInfo.MediaType = Geometry.GetMediaType(((ushort)_imageInfo.Cylinders, 2, + (ushort)_imageInfo.SectorsPerTrack, 512, MediaEncoding.MFM, + false)); // the start offset of the track data long currentOffset = 2 + (2 * 82); // build table of track offsets - for(int i = 0; i < imageInfo.Cylinders * 2; i++) + for(int i = 0; i < _imageInfo.Cylinders * 2; i++) if(fheader.trackMap[i] == 0) - trackOffset[i] = -1; + _trackOffset[i] = -1; else { // track is present, read the block header @@ -98,7 +98,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("HDCP plugin", "Track {0} offset 0x{1:x8}, size={2:x4}", i, currentOffset, blkLength); - trackOffset[i] = currentOffset; + _trackOffset[i] = currentOffset; currentOffset += 2 + blkLength; @@ -111,34 +111,35 @@ namespace Aaru.DiscImages return false; // save some variables for later use - fileHeader = fheader; - hdcpImageFilter = imageFilter; + _fileHeader = fheader; + _hdcpImageFilter = imageFilter; return true; } public byte[] ReadSector(ulong sectorAddress) { - int trackNum = (int)(sectorAddress / imageInfo.SectorsPerTrack); - int sectorOffset = (int)(sectorAddress % imageInfo.SectorsPerTrack); + int trackNum = (int)(sectorAddress / _imageInfo.SectorsPerTrack); + int sectorOffset = (int)(sectorAddress % _imageInfo.SectorsPerTrack); - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(trackNum > 2 * imageInfo.Cylinders) + if(trackNum > 2 * _imageInfo.Cylinders) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - byte[] result = new byte[imageInfo.SectorSize]; + byte[] result = new byte[_imageInfo.SectorSize]; - if(trackOffset[trackNum] == -1) - Array.Clear(result, 0, (int)imageInfo.SectorSize); + if(_trackOffset[trackNum] == -1) + Array.Clear(result, 0, (int)_imageInfo.SectorSize); else { // track is present in file, make sure it has been loaded - if(!trackCache.ContainsKey(trackNum)) - ReadTrackIntoCache(hdcpImageFilter.GetDataForkStream(), trackNum); + if(!_trackCache.ContainsKey(trackNum)) + ReadTrackIntoCache(_hdcpImageFilter.GetDataForkStream(), trackNum); - Array.Copy(trackCache[trackNum], sectorOffset * imageInfo.SectorSize, result, 0, imageInfo.SectorSize); + Array.Copy(_trackCache[trackNum], sectorOffset * _imageInfo.SectorSize, result, 0, + _imageInfo.SectorSize); } return result; @@ -146,13 +147,13 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - byte[] result = new byte[length * imageInfo.SectorSize]; + byte[] result = new byte[length * _imageInfo.SectorSize]; - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); for(int i = 0; i < length; i++) - ReadSector(sectorAddress + (ulong)i).CopyTo(result, i * imageInfo.SectorSize); + ReadSector(sectorAddress + (ulong)i).CopyTo(result, i * _imageInfo.SectorSize); return result; } diff --git a/Aaru.Images/IMD/IMD.cs b/Aaru.Images/IMD/IMD.cs index b22b18e4f..6cf7f7d78 100644 --- a/Aaru.Images/IMD/IMD.cs +++ b/Aaru.Images/IMD/IMD.cs @@ -39,10 +39,10 @@ namespace Aaru.DiscImages { public partial class Imd : IMediaImage { - ImageInfo imageInfo; - List sectorsData; + ImageInfo _imageInfo; + List _sectorsData; - public Imd() => imageInfo = new ImageInfo + public Imd() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/IMD/Properties.cs b/Aaru.Images/IMD/Properties.cs index 9715427d5..bfc04ffbb 100644 --- a/Aaru.Images/IMD/Properties.cs +++ b/Aaru.Images/IMD/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public string Name => "Dunfield's IMD"; public Guid Id => new Guid("0D67162E-38A3-407D-9B1A-CF40080A48CB"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Format => "IMageDisk"; public List DumpHardware => null; diff --git a/Aaru.Images/IMD/Read.cs b/Aaru.Images/IMD/Read.cs index 03a8437ff..1dc267470 100644 --- a/Aaru.Images/IMD/Read.cs +++ b/Aaru.Images/IMD/Read.cs @@ -62,12 +62,12 @@ namespace Aaru.DiscImages cmt.WriteByte(b); } - imageInfo.Comments = StringHandlers.CToString(cmt.ToArray()); - sectorsData = new List(); + _imageInfo.Comments = StringHandlers.CToString(cmt.ToArray()); + _sectorsData = new List(); byte currentCylinder = 0; - imageInfo.Cylinders = 1; - imageInfo.Heads = 1; + _imageInfo.Cylinders = 1; + _imageInfo.Heads = 1; ulong currentLba = 0; TransferRate mode = TransferRate.TwoHundred; @@ -87,11 +87,11 @@ namespace Aaru.DiscImages if(cylinder != currentCylinder) { currentCylinder = cylinder; - imageInfo.Cylinders++; + _imageInfo.Cylinders++; } if((head & 1) == 1) - imageInfo.Heads = 2; + _imageInfo.Heads = 2; stream.Read(idmap, 0, idmap.Length); @@ -113,8 +113,8 @@ namespace Aaru.DiscImages for(int i = 0; i < spt; i++) bps[i] = (ushort)(128 << n); - if(spt > imageInfo.SectorsPerTrack) - imageInfo.SectorsPerTrack = spt; + if(spt > _imageInfo.SectorsPerTrack) + _imageInfo.SectorsPerTrack = spt; SortedDictionary track = new SortedDictionary(); @@ -124,8 +124,8 @@ namespace Aaru.DiscImages byte[] data = new byte[bps[i]]; // TODO; Handle disks with different bps in track 0 - if(bps[i] > imageInfo.SectorSize) - imageInfo.SectorSize = bps[i]; + if(bps[i] > _imageInfo.SectorSize) + _imageInfo.SectorSize = bps[i]; switch(type) { @@ -143,7 +143,7 @@ namespace Aaru.DiscImages if(!track.ContainsKey(idmap[i])) track.Add(idmap[i], data); - imageInfo.ImageSize += (ulong)data.Length; + _imageInfo.ImageSize += (ulong)data.Length; break; case SectorType.Compressed: @@ -163,20 +163,20 @@ namespace Aaru.DiscImages foreach(KeyValuePair kvp in track) { - sectorsData.Add(kvp.Value); + _sectorsData.Add(kvp.Value); currentLba++; } } - imageInfo.Application = "IMD"; + _imageInfo.Application = "IMD"; // TODO: The header is the date of dump or the date of the application compilation? - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Comments = StringHandlers.CToString(cmt.ToArray()); - imageInfo.Sectors = currentLba; - imageInfo.MediaType = MediaType.Unknown; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Comments = StringHandlers.CToString(cmt.ToArray()); + _imageInfo.Sectors = currentLba; + _imageInfo.MediaType = MediaType.Unknown; MediaEncoding mediaEncoding = MediaEncoding.MFM; @@ -185,32 +185,32 @@ namespace Aaru.DiscImages mode == TransferRate.FiveHundred) mediaEncoding = MediaEncoding.FM; - imageInfo.MediaType = Geometry.GetMediaType(((ushort)imageInfo.Cylinders, (byte)imageInfo.Heads, - (ushort)imageInfo.SectorsPerTrack, imageInfo.SectorSize, - mediaEncoding, false)); + _imageInfo.MediaType = Geometry.GetMediaType(((ushort)_imageInfo.Cylinders, (byte)_imageInfo.Heads, + (ushort)_imageInfo.SectorsPerTrack, _imageInfo.SectorSize, + mediaEncoding, false)); - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.NEC_525_HD when mode == TransferRate.FiveHundredMfm: - imageInfo.MediaType = MediaType.NEC_35_HD_8; + _imageInfo.MediaType = MediaType.NEC_35_HD_8; break; case MediaType.DOS_525_HD when mode == TransferRate.FiveHundredMfm: - imageInfo.MediaType = MediaType.NEC_35_HD_15; + _imageInfo.MediaType = MediaType.NEC_35_HD_15; break; case MediaType.RX50 when mode == TransferRate.FiveHundredMfm: - imageInfo.MediaType = MediaType.ATARI_35_SS_DD; + _imageInfo.MediaType = MediaType.ATARI_35_SS_DD; break; } - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - AaruConsole.VerboseWriteLine("IMD image contains a disk of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("IMD image contains a disk of type {0}", _imageInfo.MediaType); - if(!string.IsNullOrEmpty(imageInfo.Comments)) - AaruConsole.VerboseWriteLine("IMD comments: {0}", imageInfo.Comments); + if(!string.IsNullOrEmpty(_imageInfo.Comments)) + AaruConsole.VerboseWriteLine("IMD comments: {0}", _imageInfo.Comments); return true; } @@ -219,16 +219,16 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var buffer = new MemoryStream(); for(int i = 0; i < length; i++) - buffer.Write(sectorsData[(int)sectorAddress + i], 0, sectorsData[(int)sectorAddress + i].Length); + buffer.Write(_sectorsData[(int)sectorAddress + i], 0, _sectorsData[(int)sectorAddress + i].Length); return buffer.ToArray(); } diff --git a/Aaru.Images/KryoFlux/Constants.cs b/Aaru.Images/KryoFlux/Constants.cs index 8e0111672..518d50e1a 100644 --- a/Aaru.Images/KryoFlux/Constants.cs +++ b/Aaru.Images/KryoFlux/Constants.cs @@ -37,15 +37,15 @@ namespace Aaru.DiscImages [SuppressMessage("ReSharper", "UnusedMember.Local")] public partial class KryoFlux { - const string hostDate = "host_date"; - const string hostTime = "host_time"; - const string kfName = "name"; - const string kfVersion = "version"; - const string kfDate = "date"; - const string kfTime = "time"; - const string kfHwId = "hwid"; - const string kfHwRv = "hwrv"; - const string kfSck = "sck"; - const string kfIck = "ick"; + const string _hostDate = "host_date"; + const string _hostTime = "host_time"; + const string _kfName = "name"; + const string _kfVersion = "version"; + const string _kfDate = "date"; + const string _kfTime = "time"; + const string _kfHwId = "hwid"; + const string _kfHwRv = "hwrv"; + const string _kfSck = "sck"; + const string _kfIck = "ick"; } } \ No newline at end of file diff --git a/Aaru.Images/KryoFlux/Read.cs b/Aaru.Images/KryoFlux/Read.cs index 88be0c20f..fedca15ba 100644 --- a/Aaru.Images/KryoFlux/Read.cs +++ b/Aaru.Images/KryoFlux/Read.cs @@ -186,22 +186,22 @@ namespace Aaru.DiscImages switch(kvp[0]) { - case hostDate: + case _hostDate: if(DateTime.TryParseExact(kvp[1], "yyyy.MM.dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out blockDate)) foundDate = true; break; - case hostTime: + case _hostTime: DateTime.TryParseExact(kvp[1], "HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out blockTime); break; - case kfName: + case _kfName: imageInfo.Application = kvp[1]; break; - case kfVersion: + case _kfVersion: imageInfo.ApplicationVersion = kvp[1]; break; diff --git a/Aaru.Images/MaxiDisk/MaxiDisk.cs b/Aaru.Images/MaxiDisk/MaxiDisk.cs index e3e53137e..9ef19308f 100644 --- a/Aaru.Images/MaxiDisk/MaxiDisk.cs +++ b/Aaru.Images/MaxiDisk/MaxiDisk.cs @@ -41,11 +41,11 @@ namespace Aaru.DiscImages public partial class MaxiDisk : IWritableImage { /// Disk image file - IFilter hdkImageFilter; - ImageInfo imageInfo; - FileStream writingStream; + IFilter _hdkImageFilter; + ImageInfo _imageInfo; + FileStream _writingStream; - public MaxiDisk() => imageInfo = new ImageInfo + public MaxiDisk() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/MaxiDisk/Properties.cs b/Aaru.Images/MaxiDisk/Properties.cs index d74316769..fedabbf14 100644 --- a/Aaru.Images/MaxiDisk/Properties.cs +++ b/Aaru.Images/MaxiDisk/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class MaxiDisk { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Name => "MAXI Disk image"; public Guid Id => new Guid("D27D924A-7034-466E-ADE1-B81EF37E469E"); diff --git a/Aaru.Images/MaxiDisk/Read.cs b/Aaru.Images/MaxiDisk/Read.cs index 5bce6b968..3bf53787f 100644 --- a/Aaru.Images/MaxiDisk/Read.cs +++ b/Aaru.Images/MaxiDisk/Read.cs @@ -78,23 +78,23 @@ namespace Aaru.DiscImages if(expectedFileSize != stream.Length) return false; - imageInfo.Cylinders = tmpHeader.cylinders; - imageInfo.Heads = tmpHeader.heads; - imageInfo.SectorsPerTrack = tmpHeader.sectorsPerTrack; - imageInfo.Sectors = (ulong)(tmpHeader.heads * tmpHeader.cylinders * tmpHeader.sectorsPerTrack); - imageInfo.SectorSize = (uint)(128 << tmpHeader.bytesPerSector); + _imageInfo.Cylinders = tmpHeader.cylinders; + _imageInfo.Heads = tmpHeader.heads; + _imageInfo.SectorsPerTrack = tmpHeader.sectorsPerTrack; + _imageInfo.Sectors = (ulong)(tmpHeader.heads * tmpHeader.cylinders * tmpHeader.sectorsPerTrack); + _imageInfo.SectorSize = (uint)(128 << tmpHeader.bytesPerSector); - hdkImageFilter = imageFilter; + _hdkImageFilter = imageFilter; - imageInfo.ImageSize = (ulong)(stream.Length - 8); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.ImageSize = (ulong)(stream.Length - 8); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaType = Geometry.GetMediaType(((ushort)imageInfo.Cylinders, (byte)imageInfo.Heads, - (ushort)imageInfo.SectorsPerTrack, imageInfo.SectorSize, - MediaEncoding.MFM, false)); + _imageInfo.MediaType = Geometry.GetMediaType(((ushort)_imageInfo.Cylinders, (byte)_imageInfo.Heads, + (ushort)_imageInfo.SectorsPerTrack, _imageInfo.SectorSize, + MediaEncoding.MFM, false)); - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; return true; } @@ -103,17 +103,17 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Stream stream = hdkImageFilter.GetDataForkStream(); - stream.Seek((long)(8 + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); - stream.Read(buffer, 0, (int)(length * imageInfo.SectorSize)); + Stream stream = _hdkImageFilter.GetDataForkStream(); + stream.Seek((long)(8 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); return buffer; } diff --git a/Aaru.Images/MaxiDisk/Write.cs b/Aaru.Images/MaxiDisk/Write.cs index 90822ffb2..8af85dc30 100644 --- a/Aaru.Images/MaxiDisk/Write.cs +++ b/Aaru.Images/MaxiDisk/Write.cs @@ -72,7 +72,7 @@ namespace Aaru.DiscImages (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding, bool variableSectorsPerTrack, MediaType type) geometry = Geometry.GetGeometry(mediaType); - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -82,14 +82,14 @@ namespace Aaru.DiscImages SectorsPerTrack = geometry.sectorsPerTrack }; - if(imageInfo.Cylinders > 90) + if(_imageInfo.Cylinders > 90) { ErrorMessage = "Too many cylinders"; return false; } - if(imageInfo.Heads > 2) + if(_imageInfo.Heads > 2) { ErrorMessage = "Too many heads"; @@ -98,7 +98,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -136,17 +136,17 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * imageInfo.SectorSize)), - SeekOrigin.Begin); + _writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * _imageInfo.SectorSize)), + SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -169,17 +169,17 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * imageInfo.SectorSize)), - SeekOrigin.Begin); + _writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * _imageInfo.SectorSize)), + SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -212,12 +212,12 @@ namespace Aaru.DiscImages var header = new HdkHeader { diskType = (byte)HdkDiskTypes.Dos2880, - cylinders = (byte)imageInfo.Cylinders, - heads = (byte)imageInfo.Heads, - sectorsPerTrack = (byte)imageInfo.SectorsPerTrack + cylinders = (byte)_imageInfo.Cylinders, + heads = (byte)_imageInfo.Heads, + sectorsPerTrack = (byte)_imageInfo.SectorsPerTrack }; - for(uint i = imageInfo.SectorSize / 128; i > 1;) + for(uint i = _imageInfo.SectorSize / 128; i > 1;) { header.bytesPerSector++; i >>= 1; @@ -229,11 +229,11 @@ namespace Aaru.DiscImages System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(hdr, 0, hdr.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -266,9 +266,9 @@ namespace Aaru.DiscImages return false; } - imageInfo.SectorsPerTrack = sectorsPerTrack; - imageInfo.Heads = heads; - imageInfo.Cylinders = cylinders; + _imageInfo.SectorsPerTrack = sectorsPerTrack; + _imageInfo.Heads = heads; + _imageInfo.Cylinders = cylinders; return true; } diff --git a/Aaru.Images/NDIF/NDIF.cs b/Aaru.Images/NDIF/NDIF.cs index 395f62691..36a28579e 100644 --- a/Aaru.Images/NDIF/NDIF.cs +++ b/Aaru.Images/NDIF/NDIF.cs @@ -44,16 +44,16 @@ namespace Aaru.DiscImages // TODO: Implement compression public partial class Ndif : IMediaImage { - uint buffersize; - Dictionary chunkCache; - Dictionary chunks; - uint currentChunkCacheSize; - ChunkHeader header; - ImageInfo imageInfo; - Stream imageStream; - Dictionary sectorCache; + uint _buffersize; + Dictionary _chunkCache; + Dictionary _chunks; + uint _currentChunkCacheSize; + ChunkHeader _header; + ImageInfo _imageInfo; + Stream _imageStream; + Dictionary _sectorCache; - public Ndif() => imageInfo = new ImageInfo + public Ndif() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/NDIF/Properties.cs b/Aaru.Images/NDIF/Properties.cs index 429b60834..c737f0d63 100644 --- a/Aaru.Images/NDIF/Properties.cs +++ b/Aaru.Images/NDIF/Properties.cs @@ -39,7 +39,7 @@ namespace Aaru.DiscImages { public partial class Ndif { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Apple New Disk Image Format"; public Guid Id => new Guid("5A7FF7D8-491E-458D-8674-5B5EADBECC24"); public string Format => "Apple New Disk Image Format"; diff --git a/Aaru.Images/NDIF/Read.cs b/Aaru.Images/NDIF/Read.cs index 8a7fd2d32..3e5687fd5 100644 --- a/Aaru.Images/NDIF/Read.cs +++ b/Aaru.Images/NDIF/Read.cs @@ -80,42 +80,45 @@ namespace Aaru.DiscImages return false; } - imageInfo.Sectors = 0; + _imageInfo.Sectors = 0; foreach(byte[] bcem in bcems.Select(id => rsrc.GetResource(NDIF_RESOURCEID))) { if(bcem.Length < 128) return false; - header = Marshal.ByteArrayToStructureBigEndian(bcem); + _header = Marshal.ByteArrayToStructureBigEndian(bcem); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.type = {0}", header.version); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.driver = {0}", header.driver); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.type = {0}", _header.version); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.driver = {0}", _header.driver); AaruConsole.DebugWriteLine("NDIF plugin", "footer.name = {0}", - StringHandlers.PascalToString(header.name, + StringHandlers.PascalToString(_header.name, Encoding.GetEncoding("macintosh"))); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.sectors = {0}", header.sectors); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.maxSectorsPerChunk = {0}", header.maxSectorsPerChunk); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.dataOffset = {0}", header.dataOffset); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.crc = 0x{0:X7}", header.crc); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.segmented = {0}", header.segmented); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.p1 = 0x{0:X8}", header.p1); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.p2 = 0x{0:X8}", header.p2); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.unknown[0] = 0x{0:X8}", header.unknown[0]); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.unknown[1] = 0x{0:X8}", header.unknown[1]); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.unknown[2] = 0x{0:X8}", header.unknown[2]); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.unknown[3] = 0x{0:X8}", header.unknown[3]); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.unknown[4] = 0x{0:X8}", header.unknown[4]); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.encrypted = {0}", header.encrypted); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.hash = 0x{0:X8}", header.hash); - AaruConsole.DebugWriteLine("NDIF plugin", "footer.chunks = {0}", header.chunks); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.sectors = {0}", _header.sectors); + + AaruConsole.DebugWriteLine("NDIF plugin", "footer.maxSectorsPerChunk = {0}", + _header.maxSectorsPerChunk); + + AaruConsole.DebugWriteLine("NDIF plugin", "footer.dataOffset = {0}", _header.dataOffset); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.crc = 0x{0:X7}", _header.crc); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.segmented = {0}", _header.segmented); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.p1 = 0x{0:X8}", _header.p1); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.p2 = 0x{0:X8}", _header.p2); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.unknown[0] = 0x{0:X8}", _header.unknown[0]); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.unknown[1] = 0x{0:X8}", _header.unknown[1]); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.unknown[2] = 0x{0:X8}", _header.unknown[2]); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.unknown[3] = 0x{0:X8}", _header.unknown[3]); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.unknown[4] = 0x{0:X8}", _header.unknown[4]); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.encrypted = {0}", _header.encrypted); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.hash = 0x{0:X8}", _header.hash); + AaruConsole.DebugWriteLine("NDIF plugin", "footer.chunks = {0}", _header.chunks); // Block chunks and headers - chunks = new Dictionary(); + _chunks = new Dictionary(); - for(int i = 0; i < header.chunks; i++) + for(int i = 0; i < _header.chunks; i++) { // Obsolete read-only NDIF only prepended the header and then put the image without any kind of block references. // So let's falsify a block chunk @@ -135,8 +138,8 @@ namespace Aaru.DiscImages if(bChnk.type == CHUNK_TYPE_END) break; - bChnk.offset += header.dataOffset; - bChnk.sector += (uint)imageInfo.Sectors; + bChnk.offset += _header.dataOffset; + bChnk.sector += (uint)_imageInfo.Sectors; // TODO: Handle compressed chunks switch(bChnk.type) @@ -158,38 +161,38 @@ namespace Aaru.DiscImages bChnk.type == 1) throw new ImageNotSupportedException($"Unsupported chunk type 0x{bChnk.type:X8} found"); - chunks.Add(bChnk.sector, bChnk); + _chunks.Add(bChnk.sector, bChnk); } - imageInfo.Sectors += header.sectors; + _imageInfo.Sectors += _header.sectors; } - if(header.segmented > 0) + if(_header.segmented > 0) throw new ImageNotSupportedException("Segmented images are not yet supported."); - if(header.encrypted > 0) + if(_header.encrypted > 0) throw new ImageNotSupportedException("Encrypted images are not yet supported."); - switch(imageInfo.Sectors) + switch(_imageInfo.Sectors) { case 1440: - imageInfo.MediaType = MediaType.DOS_35_DS_DD_9; + _imageInfo.MediaType = MediaType.DOS_35_DS_DD_9; break; case 1600: - imageInfo.MediaType = MediaType.AppleSonyDS; + _imageInfo.MediaType = MediaType.AppleSonyDS; break; case 2880: - imageInfo.MediaType = MediaType.DOS_35_HD; + _imageInfo.MediaType = MediaType.DOS_35_HD; break; case 3360: - imageInfo.MediaType = MediaType.DMF; + _imageInfo.MediaType = MediaType.DMF; break; default: - imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.MediaType = MediaType.GENERIC_HDD; break; } @@ -237,68 +240,68 @@ namespace Aaru.DiscImages if(dev != null) pre = $"{version.PreReleaseVersion}"; - imageInfo.ApplicationVersion = $"{major}{minor}{release}{dev}{pre}"; - imageInfo.Application = version.VersionString; - imageInfo.Comments = version.VersionMessage; + _imageInfo.ApplicationVersion = $"{major}{minor}{release}{dev}{pre}"; + _imageInfo.Application = version.VersionString; + _imageInfo.Comments = version.VersionMessage; if(version.MajorVersion == 3) - imageInfo.Application = "ShrinkWrapâ„¢"; + _imageInfo.Application = "ShrinkWrapâ„¢"; else if(version.MajorVersion == 6) - imageInfo.Application = "DiskCopy"; + _imageInfo.Application = "DiskCopy"; } } - AaruConsole.DebugWriteLine("NDIF plugin", "Image application = {0} version {1}", imageInfo.Application, - imageInfo.ApplicationVersion); + AaruConsole.DebugWriteLine("NDIF plugin", "Image application = {0} version {1}", _imageInfo.Application, + _imageInfo.ApplicationVersion); - sectorCache = new Dictionary(); - chunkCache = new Dictionary(); - currentChunkCacheSize = 0; - imageStream = imageFilter.GetDataForkStream(); - buffersize = header.maxSectorsPerChunk * SECTOR_SIZE; + _sectorCache = new Dictionary(); + _chunkCache = new Dictionary(); + _currentChunkCacheSize = 0; + _imageStream = imageFilter.GetDataForkStream(); + _buffersize = _header.maxSectorsPerChunk * SECTOR_SIZE; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = StringHandlers.PascalToString(header.name, Encoding.GetEncoding("macintosh")); + _imageInfo.MediaTitle = StringHandlers.PascalToString(_header.name, Encoding.GetEncoding("macintosh")); - imageInfo.SectorSize = SECTOR_SIZE; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.ImageSize = imageInfo.Sectors * SECTOR_SIZE; - imageInfo.ApplicationVersion = "6"; - imageInfo.Application = "Apple DiskCopy"; + _imageInfo.SectorSize = SECTOR_SIZE; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.ImageSize = _imageInfo.Sectors * SECTOR_SIZE; + _imageInfo.ApplicationVersion = "6"; + _imageInfo.Application = "Apple DiskCopy"; - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.AppleSonyDS: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 10; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 10; break; case MediaType.DOS_35_DS_DD_9: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 9; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 9; break; case MediaType.DOS_35_HD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 18; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 18; break; case MediaType.DMF: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 21; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 21; break; default: - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; break; } @@ -308,18 +311,18 @@ namespace Aaru.DiscImages public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector; var currentChunk = new BlockChunk(); bool chunkFound = false; ulong chunkStartSector = 0; - foreach(KeyValuePair kvp in chunks.Where(kvp => sectorAddress >= kvp.Key)) + foreach(KeyValuePair kvp in _chunks.Where(kvp => sectorAddress >= kvp.Key)) { currentChunk = kvp.Value; chunkFound = true; @@ -338,11 +341,11 @@ namespace Aaru.DiscImages if((currentChunk.type & CHUNK_TYPE_COMPRESSED_MASK) == CHUNK_TYPE_COMPRESSED_MASK) { - if(!chunkCache.TryGetValue(chunkStartSector, out byte[] buffer)) + if(!_chunkCache.TryGetValue(chunkStartSector, out byte[] buffer)) { byte[] cmpBuffer = new byte[currentChunk.length]; - imageStream.Seek(currentChunk.offset, SeekOrigin.Begin); - imageStream.Read(cmpBuffer, 0, cmpBuffer.Length); + _imageStream.Seek(currentChunk.offset, SeekOrigin.Begin); + _imageStream.Read(cmpBuffer, 0, cmpBuffer.Length); var cmpMs = new MemoryStream(cmpBuffer); int realSize; @@ -351,8 +354,8 @@ namespace Aaru.DiscImages case CHUNK_TYPE_ADC: { Stream decStream = new ADCStream(cmpMs); - byte[] tmpBuffer = new byte[buffersize]; - realSize = decStream.Read(tmpBuffer, 0, (int)buffersize); + byte[] tmpBuffer = new byte[_buffersize]; + realSize = decStream.Read(tmpBuffer, 0, (int)_buffersize); buffer = new byte[realSize]; Array.Copy(tmpBuffer, 0, buffer, 0, realSize); @@ -361,11 +364,11 @@ namespace Aaru.DiscImages case CHUNK_TYPE_RLE: { - byte[] tmpBuffer = new byte[buffersize]; + byte[] tmpBuffer = new byte[_buffersize]; realSize = 0; var rle = new AppleRle(cmpMs); - for(int i = 0; i < buffersize; i++) + for(int i = 0; i < _buffersize; i++) { int b = rle.ProduceByte(); @@ -387,23 +390,23 @@ namespace Aaru.DiscImages ImageNotSupportedException($"Unsupported chunk type 0x{currentChunk.type:X8} found"); } - if(currentChunkCacheSize + realSize > MAX_CACHE_SIZE) + if(_currentChunkCacheSize + realSize > MAX_CACHE_SIZE) { - chunkCache.Clear(); - currentChunkCacheSize = 0; + _chunkCache.Clear(); + _currentChunkCacheSize = 0; } - chunkCache.Add(chunkStartSector, buffer); - currentChunkCacheSize += (uint)realSize; + _chunkCache.Add(chunkStartSector, buffer); + _currentChunkCacheSize += (uint)realSize; } sector = new byte[SECTOR_SIZE]; Array.Copy(buffer, relOff, sector, 0, SECTOR_SIZE); - if(sectorCache.Count >= MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count >= MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } @@ -413,21 +416,21 @@ namespace Aaru.DiscImages case CHUNK_TYPE_NOCOPY: sector = new byte[SECTOR_SIZE]; - if(sectorCache.Count >= MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count >= MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; case CHUNK_TYPE_COPY: - imageStream.Seek(currentChunk.offset + relOff, SeekOrigin.Begin); + _imageStream.Seek(currentChunk.offset + relOff, SeekOrigin.Begin); sector = new byte[SECTOR_SIZE]; - imageStream.Read(sector, 0, sector.Length); + _imageStream.Read(sector, 0, sector.Length); - if(sectorCache.Count >= MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count >= MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } @@ -437,11 +440,11 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); diff --git a/Aaru.Images/NHDr0/Constants.cs b/Aaru.Images/NHDr0/Constants.cs index c1a45d6d9..14ae04606 100644 --- a/Aaru.Images/NHDr0/Constants.cs +++ b/Aaru.Images/NHDr0/Constants.cs @@ -34,7 +34,7 @@ namespace Aaru.DiscImages { public partial class Nhdr0 { - readonly byte[] signature = + readonly byte[] _signature = { 0x54, 0x39, 0x38, 0x48, 0x44, 0x44, 0x49, 0x4D, 0x41, 0x47, 0x45, 0x2E, 0x52, 0x30, 0x00 }; diff --git a/Aaru.Images/NHDr0/Identify.cs b/Aaru.Images/NHDr0/Identify.cs index c8fc97dfe..2b109a74e 100644 --- a/Aaru.Images/NHDr0/Identify.cs +++ b/Aaru.Images/NHDr0/Identify.cs @@ -55,24 +55,24 @@ namespace Aaru.DiscImages byte[] hdrB = new byte[Marshal.SizeOf()]; stream.Read(hdrB, 0, hdrB.Length); - nhdhdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); + _nhdhdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); - if(!nhdhdr.szFileID.SequenceEqual(signature)) + if(!_nhdhdr.szFileID.SequenceEqual(_signature)) return false; AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.szFileID = \"{0}\"", - StringHandlers.CToString(nhdhdr.szFileID, shiftjis)); + StringHandlers.CToString(_nhdhdr.szFileID, shiftjis)); - AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.reserved1 = {0}", nhdhdr.reserved1); + AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.reserved1 = {0}", _nhdhdr.reserved1); AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.szComment = \"{0}\"", - StringHandlers.CToString(nhdhdr.szComment, shiftjis)); + StringHandlers.CToString(_nhdhdr.szComment, shiftjis)); - AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.dwHeadSize = {0}", nhdhdr.dwHeadSize); - AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.dwCylinder = {0}", nhdhdr.dwCylinder); - AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.wHead = {0}", nhdhdr.wHead); - AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.wSect = {0}", nhdhdr.wSect); - AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.wSectLen = {0}", nhdhdr.wSectLen); + AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.dwHeadSize = {0}", _nhdhdr.dwHeadSize); + AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.dwCylinder = {0}", _nhdhdr.dwCylinder); + AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.wHead = {0}", _nhdhdr.wHead); + AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.wSect = {0}", _nhdhdr.wSect); + AaruConsole.DebugWriteLine("NHDr0 plugin", "nhdhdr.wSectLen = {0}", _nhdhdr.wSectLen); return true; } diff --git a/Aaru.Images/NHDr0/NHDr0.cs b/Aaru.Images/NHDr0/NHDr0.cs index f40e036b5..4ac1f8d80 100644 --- a/Aaru.Images/NHDr0/NHDr0.cs +++ b/Aaru.Images/NHDr0/NHDr0.cs @@ -41,12 +41,12 @@ namespace Aaru.DiscImages // Info from http://www.geocities.jp/t98next/nhdr0.txt public partial class Nhdr0 : IWritableImage { - ImageInfo imageInfo; - Nhdr0Header nhdhdr; - IFilter nhdImageFilter; - FileStream writingStream; + ImageInfo _imageInfo; + Nhdr0Header _nhdhdr; + IFilter _nhdImageFilter; + FileStream _writingStream; - public Nhdr0() => imageInfo = new ImageInfo + public Nhdr0() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/NHDr0/Properties.cs b/Aaru.Images/NHDr0/Properties.cs index 8fe842442..6da800773 100644 --- a/Aaru.Images/NHDr0/Properties.cs +++ b/Aaru.Images/NHDr0/Properties.cs @@ -43,7 +43,7 @@ namespace Aaru.DiscImages { public string Name => "T98-Next NHD r0 Disk Image"; public Guid Id => new Guid("6ECACD0A-8F4D-4465-8815-AEA000D370E3"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Format => "NHDr0 disk image"; public List DumpHardware => null; diff --git a/Aaru.Images/NHDr0/Read.cs b/Aaru.Images/NHDr0/Read.cs index 88a82d9ec..c0e4b8724 100644 --- a/Aaru.Images/NHDr0/Read.cs +++ b/Aaru.Images/NHDr0/Read.cs @@ -56,23 +56,23 @@ namespace Aaru.DiscImages byte[] hdrB = new byte[Marshal.SizeOf()]; stream.Read(hdrB, 0, hdrB.Length); - nhdhdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); + _nhdhdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); - imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.ImageSize = (ulong)(stream.Length - nhdhdr.dwHeadSize); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = (ulong)(nhdhdr.dwCylinder * nhdhdr.wHead * nhdhdr.wSect); - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.SectorSize = (uint)nhdhdr.wSectLen; - imageInfo.Cylinders = (uint)nhdhdr.dwCylinder; - imageInfo.Heads = (uint)nhdhdr.wHead; - imageInfo.SectorsPerTrack = (uint)nhdhdr.wSect; - imageInfo.Comments = StringHandlers.CToString(nhdhdr.szComment, shiftjis); + _imageInfo.ImageSize = (ulong)(stream.Length - _nhdhdr.dwHeadSize); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = (ulong)(_nhdhdr.dwCylinder * _nhdhdr.wHead * _nhdhdr.wSect); + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.SectorSize = (uint)_nhdhdr.wSectLen; + _imageInfo.Cylinders = (uint)_nhdhdr.dwCylinder; + _imageInfo.Heads = (uint)_nhdhdr.wHead; + _imageInfo.SectorsPerTrack = (uint)_nhdhdr.wSect; + _imageInfo.Comments = StringHandlers.CToString(_nhdhdr.szComment, shiftjis); - nhdImageFilter = imageFilter; + _nhdImageFilter = imageFilter; return true; } @@ -81,19 +81,19 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Stream stream = nhdImageFilter.GetDataForkStream(); + Stream stream = _nhdImageFilter.GetDataForkStream(); - stream.Seek((long)((ulong)nhdhdr.dwHeadSize + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)((ulong)_nhdhdr.dwHeadSize + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); - stream.Read(buffer, 0, (int)(length * imageInfo.SectorSize)); + stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); return buffer; } diff --git a/Aaru.Images/NHDr0/Write.cs b/Aaru.Images/NHDr0/Write.cs index ea8c4322a..cca2b271e 100644 --- a/Aaru.Images/NHDr0/Write.cs +++ b/Aaru.Images/NHDr0/Write.cs @@ -62,7 +62,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -71,7 +71,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -102,24 +102,24 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * imageInfo.SectorSize)), - SeekOrigin.Begin); + _writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * _imageInfo.SectorSize)), + SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -142,17 +142,17 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * imageInfo.SectorSize)), - SeekOrigin.Begin); + _writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * _imageInfo.SectorSize)), + SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -182,47 +182,47 @@ namespace Aaru.DiscImages return false; } - if(imageInfo.Cylinders == 0) + if(_imageInfo.Cylinders == 0) { - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 8 / 17); - imageInfo.Heads = 8; - imageInfo.SectorsPerTrack = 17; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 8 / 17); + _imageInfo.Heads = 8; + _imageInfo.SectorsPerTrack = 17; - while(imageInfo.Cylinders == 0) + while(_imageInfo.Cylinders == 0) { - imageInfo.Heads--; + _imageInfo.Heads--; - if(imageInfo.Heads == 0) + if(_imageInfo.Heads == 0) { - imageInfo.SectorsPerTrack--; - imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack--; + _imageInfo.Heads = 16; } - imageInfo.Cylinders = (uint)(imageInfo.Sectors / imageInfo.Heads / imageInfo.SectorsPerTrack); + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / _imageInfo.Heads / _imageInfo.SectorsPerTrack); - if(imageInfo.Cylinders == 0 && - imageInfo.Heads == 0 && - imageInfo.SectorsPerTrack == 0) + if(_imageInfo.Cylinders == 0 && + _imageInfo.Heads == 0 && + _imageInfo.SectorsPerTrack == 0) break; } } var header = new Nhdr0Header { - szFileID = signature, + szFileID = _signature, szComment = new byte[0x100], dwHeadSize = Marshal.SizeOf(), - dwCylinder = (byte)imageInfo.Cylinders, - wHead = (byte)imageInfo.Heads, - wSect = (byte)imageInfo.SectorsPerTrack, - wSectLen = (byte)imageInfo.SectorSize, + dwCylinder = (byte)_imageInfo.Cylinders, + wHead = (byte)_imageInfo.Heads, + wSect = (byte)_imageInfo.SectorsPerTrack, + wSectLen = (byte)_imageInfo.SectorSize, reserved2 = new byte[2], reserved3 = new byte[0xE0] }; - if(!string.IsNullOrEmpty(imageInfo.Comments)) + if(!string.IsNullOrEmpty(_imageInfo.Comments)) { - byte[] commentBytes = Encoding.GetEncoding("shift_jis").GetBytes(imageInfo.Comments); + byte[] commentBytes = Encoding.GetEncoding("shift_jis").GetBytes(_imageInfo.Comments); Array.Copy(commentBytes, 0, header.szComment, 0, commentBytes.Length >= 0x100 ? 0x100 : commentBytes.Length); @@ -234,11 +234,11 @@ namespace Aaru.DiscImages System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(hdr, 0, hdr.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; return true; @@ -246,7 +246,7 @@ namespace Aaru.DiscImages public bool SetMetadata(ImageInfo metadata) { - imageInfo.Comments = metadata.Comments; + _imageInfo.Comments = metadata.Comments; return true; } @@ -274,9 +274,9 @@ namespace Aaru.DiscImages return false; } - imageInfo.SectorsPerTrack = sectorsPerTrack; - imageInfo.Heads = heads; - imageInfo.Cylinders = cylinders; + _imageInfo.SectorsPerTrack = sectorsPerTrack; + _imageInfo.Heads = heads; + _imageInfo.Cylinders = cylinders; return true; } diff --git a/Aaru.Images/Nero/Identify.cs b/Aaru.Images/Nero/Identify.cs index a4ce545a0..163612ae4 100644 --- a/Aaru.Images/Nero/Identify.cs +++ b/Aaru.Images/Nero/Identify.cs @@ -41,33 +41,33 @@ namespace Aaru.DiscImages { public bool Identify(IFilter imageFilter) { - imageStream = imageFilter.GetDataForkStream(); + _imageStream = imageFilter.GetDataForkStream(); var footerV1 = new NeroV1Footer(); var footerV2 = new NeroV2Footer(); - imageStream.Seek(-8, SeekOrigin.End); + _imageStream.Seek(-8, SeekOrigin.End); byte[] buffer = new byte[8]; - imageStream.Read(buffer, 0, 8); + _imageStream.Read(buffer, 0, 8); footerV1.ChunkId = BigEndianBitConverter.ToUInt32(buffer, 0); footerV1.FirstChunkOffset = BigEndianBitConverter.ToUInt32(buffer, 4); - imageStream.Seek(-12, SeekOrigin.End); + _imageStream.Seek(-12, SeekOrigin.End); buffer = new byte[12]; - imageStream.Read(buffer, 0, 12); + _imageStream.Read(buffer, 0, 12); footerV2.ChunkId = BigEndianBitConverter.ToUInt32(buffer, 0); footerV2.FirstChunkOffset = BigEndianBitConverter.ToUInt64(buffer, 4); - AaruConsole.DebugWriteLine("Nero plugin", "imageStream.Length = {0}", imageStream.Length); + AaruConsole.DebugWriteLine("Nero plugin", "imageStream.Length = {0}", _imageStream.Length); AaruConsole.DebugWriteLine("Nero plugin", "footerV1.ChunkID = 0x{0:X8}", footerV1.ChunkId); AaruConsole.DebugWriteLine("Nero plugin", "footerV1.FirstChunkOffset = {0}", footerV1.FirstChunkOffset); AaruConsole.DebugWriteLine("Nero plugin", "footerV2.ChunkID = 0x{0:X8}", footerV2.ChunkId); AaruConsole.DebugWriteLine("Nero plugin", "footerV2.FirstChunkOffset = {0}", footerV2.FirstChunkOffset); if(footerV2.ChunkId == NERO_FOOTER_V2 && - footerV2.FirstChunkOffset < (ulong)imageStream.Length) + footerV2.FirstChunkOffset < (ulong)_imageStream.Length) return true; - return footerV1.ChunkId == NERO_FOOTER_V1 && footerV1.FirstChunkOffset < (ulong)imageStream.Length; + return footerV1.ChunkId == NERO_FOOTER_V1 && footerV1.FirstChunkOffset < (ulong)_imageStream.Length; } } } \ No newline at end of file diff --git a/Aaru.Images/Nero/Nero.cs b/Aaru.Images/Nero/Nero.cs index e6f3d6117..23d1a226b 100644 --- a/Aaru.Images/Nero/Nero.cs +++ b/Aaru.Images/Nero/Nero.cs @@ -49,43 +49,43 @@ namespace Aaru.DiscImages SuppressMessage("ReSharper", "CollectionNeverQueried.Local")] public partial class Nero : IOpticalMediaImage { - bool imageNewFormat; - Stream imageStream; - ImageInfo imageInfo; - NeroCdText neroCdtxt; - NeroV1Cuesheet neroCuesheetV1; - NeroV2Cuesheet neroCuesheetV2; - NeroV1Dao neroDaov1; - NeroV2Dao neroDaov2; - NeroDiscInformation neroDiscInfo; - IFilter neroFilter; - NeroMediaType neroMediaTyp; - NeroReloChunk neroRelo; - readonly Dictionary neroSessions; - NeroV1Tao neroTaov1; - NeroV2Tao neroTaov2; - NeroTocChunk neroToc; - readonly Dictionary neroTracks; - readonly Dictionary offsetmap; - Dictionary trackIsrCs; - byte[] upc; + bool _imageNewFormat; + Stream _imageStream; + ImageInfo _imageInfo; + NeroCdText _neroCdtxt; + NeroV1Cuesheet _neroCuesheetV1; + NeroV2Cuesheet _neroCuesheetV2; + NeroV1Dao _neroDaov1; + NeroV2Dao _neroDaov2; + NeroDiscInformation _neroDiscInfo; + IFilter _neroFilter; + NeroMediaType _neroMediaTyp; + NeroReloChunk _neroRelo; + readonly Dictionary _neroSessions; + NeroV1Tao _neroTaov1; + NeroV2Tao _neroTaov2; + NeroTocChunk _neroToc; + readonly Dictionary _neroTracks; + readonly Dictionary _offsetmap; + Dictionary _trackIsrCs; + byte[] _upc; SectorBuilder _sectorBuilder; public Nero() { - imageNewFormat = false; + _imageNewFormat = false; - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List() }; - neroSessions = new Dictionary(); - neroTracks = new Dictionary(); - offsetmap = new Dictionary(); - Sessions = new List(); - Partitions = new List(); + _neroSessions = new Dictionary(); + _neroTracks = new Dictionary(); + _offsetmap = new Dictionary(); + Sessions = new List(); + Partitions = new List(); } } } \ No newline at end of file diff --git a/Aaru.Images/Nero/Properties.cs b/Aaru.Images/Nero/Properties.cs index 6f221f4d2..62b5b3fe9 100644 --- a/Aaru.Images/Nero/Properties.cs +++ b/Aaru.Images/Nero/Properties.cs @@ -40,7 +40,7 @@ namespace Aaru.DiscImages { public partial class Nero { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Nero Burning ROM image"; public Guid Id => new Guid("D160F9FF-5941-43FC-B037-AD81DD141F05"); public string Author => "Natalia Portillo"; diff --git a/Aaru.Images/Nero/Read.cs b/Aaru.Images/Nero/Read.cs index d9bedc2e8..0ee34d457 100644 --- a/Aaru.Images/Nero/Read.cs +++ b/Aaru.Images/Nero/Read.cs @@ -53,23 +53,23 @@ namespace Aaru.DiscImages { try { - imageStream = imageFilter.GetDataForkStream(); + _imageStream = imageFilter.GetDataForkStream(); var footerV1 = new NeroV1Footer(); var footerV2 = new NeroV2Footer(); - imageStream.Seek(-8, SeekOrigin.End); + _imageStream.Seek(-8, SeekOrigin.End); byte[] buffer = new byte[8]; - imageStream.Read(buffer, 0, 8); + _imageStream.Read(buffer, 0, 8); footerV1.ChunkId = BigEndianBitConverter.ToUInt32(buffer, 0); footerV1.FirstChunkOffset = BigEndianBitConverter.ToUInt32(buffer, 4); - imageStream.Seek(-12, SeekOrigin.End); + _imageStream.Seek(-12, SeekOrigin.End); buffer = new byte[12]; - imageStream.Read(buffer, 0, 12); + _imageStream.Read(buffer, 0, 12); footerV2.ChunkId = BigEndianBitConverter.ToUInt32(buffer, 0); footerV2.FirstChunkOffset = BigEndianBitConverter.ToUInt64(buffer, 4); - AaruConsole.DebugWriteLine("Nero plugin", "imageStream.Length = {0}", imageStream.Length); + AaruConsole.DebugWriteLine("Nero plugin", "imageStream.Length = {0}", _imageStream.Length); AaruConsole.DebugWriteLine("Nero plugin", "footerV1.ChunkID = 0x{0:X8} (\"{1}\")", footerV1.ChunkId, Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(footerV1.ChunkId))); @@ -82,11 +82,11 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "footerV2.FirstChunkOffset = {0}", footerV2.FirstChunkOffset); if(footerV1.ChunkId == NERO_FOOTER_V1 && - footerV1.FirstChunkOffset < (ulong)imageStream.Length) - imageNewFormat = false; + footerV1.FirstChunkOffset < (ulong)_imageStream.Length) + _imageNewFormat = false; else if(footerV2.ChunkId == NERO_FOOTER_V2 && - footerV2.FirstChunkOffset < (ulong)imageStream.Length) - imageNewFormat = true; + footerV2.FirstChunkOffset < (ulong)_imageStream.Length) + _imageNewFormat = true; else { AaruConsole.DebugWrite("Nero plugin", "Nero version not recognized."); @@ -94,28 +94,28 @@ namespace Aaru.DiscImages return false; } - if(imageNewFormat) - imageStream.Seek((long)footerV2.FirstChunkOffset, SeekOrigin.Begin); + if(_imageNewFormat) + _imageStream.Seek((long)footerV2.FirstChunkOffset, SeekOrigin.Begin); else - imageStream.Seek(footerV1.FirstChunkOffset, SeekOrigin.Begin); + _imageStream.Seek(footerV1.FirstChunkOffset, SeekOrigin.Begin); bool parsing = true; ushort currentsession = 1; uint currenttrack = 1; - Tracks = new List(); - trackIsrCs = new Dictionary(); + Tracks = new List(); + _trackIsrCs = new Dictionary(); - imageInfo.MediaType = MediaType.CD; - imageInfo.Sectors = 0; - imageInfo.SectorSize = 0; + _imageInfo.MediaType = MediaType.CD; + _imageInfo.Sectors = 0; + _imageInfo.SectorSize = 0; ulong currentSector = 0; while(parsing) { byte[] chunkHeaderBuffer = new byte[8]; - imageStream.Read(chunkHeaderBuffer, 0, 8); + _imageStream.Read(chunkHeaderBuffer, 0, 8); uint chunkId = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 0); uint chunkLength = BigEndianBitConverter.ToUInt32(chunkHeaderBuffer, 4); @@ -143,7 +143,7 @@ namespace Aaru.DiscImages for(int i = 0; i < newCuesheetV1.ChunkSize; i += 8) { var entry = new NeroV1CueEntry(); - imageStream.Read(tmpbuffer, 0, 8); + _imageStream.Read(tmpbuffer, 0, 8); entry.Mode = tmpbuffer[0]; entry.TrackNumber = tmpbuffer[1]; entry.IndexNumber = tmpbuffer[2]; @@ -178,10 +178,10 @@ namespace Aaru.DiscImages newCuesheetV1.Entries.Add(entry); } - if(neroCuesheetV1 is null) - neroCuesheetV1 = newCuesheetV1; + if(_neroCuesheetV1 is null) + _neroCuesheetV1 = newCuesheetV1; else - neroCuesheetV1.Entries.AddRange(newCuesheetV1.Entries); + _neroCuesheetV1.Entries.AddRange(newCuesheetV1.Entries); break; } @@ -203,7 +203,7 @@ namespace Aaru.DiscImages for(int i = 0; i < newCuesheetV2.ChunkSize; i += 8) { var entry = new NeroV2CueEntry(); - imageStream.Read(tmpbuffer, 0, 8); + _imageStream.Read(tmpbuffer, 0, 8); entry.Mode = tmpbuffer[0]; entry.TrackNumber = tmpbuffer[1]; entry.IndexNumber = tmpbuffer[2]; @@ -230,10 +230,10 @@ namespace Aaru.DiscImages newCuesheetV2.Entries.Add(entry); } - if(neroCuesheetV2 is null) - neroCuesheetV2 = newCuesheetV2; + if(_neroCuesheetV2 is null) + _neroCuesheetV2 = newCuesheetV2; else - neroCuesheetV2.Entries.AddRange(newCuesheetV2.Entries); + _neroCuesheetV2.Entries.AddRange(newCuesheetV2.Entries); break; } @@ -243,50 +243,51 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "Found \"DAOI\" chunk, parsing {0} bytes", chunkLength); - neroDaov1 = new NeroV1Dao + _neroDaov1 = new NeroV1Dao { ChunkId = chunkId, ChunkSizeBe = chunkLength }; byte[] tmpbuffer = new byte[22]; - imageStream.Read(tmpbuffer, 0, 22); - neroDaov1.ChunkSizeLe = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); - neroDaov1.Upc = new byte[14]; - Array.Copy(tmpbuffer, 4, neroDaov1.Upc, 0, 14); - neroDaov1.TocType = BigEndianBitConverter.ToUInt16(tmpbuffer, 18); - neroDaov1.FirstTrack = tmpbuffer[20]; - neroDaov1.LastTrack = tmpbuffer[21]; - neroDaov1.Tracks = new List(); + _imageStream.Read(tmpbuffer, 0, 22); + _neroDaov1.ChunkSizeLe = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); + _neroDaov1.Upc = new byte[14]; + Array.Copy(tmpbuffer, 4, _neroDaov1.Upc, 0, 14); + _neroDaov1.TocType = BigEndianBitConverter.ToUInt16(tmpbuffer, 18); + _neroDaov1.FirstTrack = tmpbuffer[20]; + _neroDaov1.LastTrack = tmpbuffer[21]; + _neroDaov1.Tracks = new List(); - if(!imageInfo.ReadableMediaTags.Contains(MediaTagType.CD_MCN)) - imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); + if(!_imageInfo.ReadableMediaTags.Contains(MediaTagType.CD_MCN)) + _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc); AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.ChunkSizeLe = {0} bytes", - neroDaov1.ChunkSizeLe); + _neroDaov1.ChunkSizeLe); AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.UPC = \"{0}\"", - StringHandlers.CToString(neroDaov1.Upc)); + StringHandlers.CToString(_neroDaov1.Upc)); AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.TocType = 0x{0:X4}", - neroDaov1.TocType); + _neroDaov1.TocType); AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.FirstTrack = {0}", - neroDaov1.FirstTrack); + _neroDaov1.FirstTrack); - AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.LastTrack = {0}", neroDaov1.LastTrack); + AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV1.LastTrack = {0}", + _neroDaov1.LastTrack); - upc = neroDaov1.Upc; + _upc = _neroDaov1.Upc; tmpbuffer = new byte[30]; - for(int i = 0; i < neroDaov1.ChunkSizeBe - 22; i += 30) + for(int i = 0; i < _neroDaov1.ChunkSizeBe - 22; i += 30) { var entry = new NeroV1DaoEntry(); - imageStream.Read(tmpbuffer, 0, 30); + _imageStream.Read(tmpbuffer, 0, 30); entry.Isrc = new byte[12]; Array.Copy(tmpbuffer, 4, entry.Isrc, 0, 12); entry.SectorSize = BigEndianBitConverter.ToUInt16(tmpbuffer, 12); @@ -319,12 +320,12 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].EndOfTrack = {1}", (i / 32) + 1, entry.EndOfTrack); - neroDaov1.Tracks.Add(entry); + _neroDaov1.Tracks.Add(entry); - if(entry.SectorSize > imageInfo.SectorSize) - imageInfo.SectorSize = entry.SectorSize; + if(entry.SectorSize > _imageInfo.SectorSize) + _imageInfo.SectorSize = entry.SectorSize; - trackIsrCs.Add(currenttrack, entry.Isrc); + _trackIsrCs.Add(currenttrack, entry.Isrc); if(currenttrack == 1) entry.Index0 = entry.Index1; @@ -344,10 +345,10 @@ namespace Aaru.DiscImages }; neroTrack.Sectors = neroTrack.Length / entry.SectorSize; - neroTracks.Add(currenttrack, neroTrack); + _neroTracks.Add(currenttrack, neroTrack); - imageInfo.Sectors += neroTrack.Sectors; - currentSector += neroTrack.Sectors; + _imageInfo.Sectors += neroTrack.Sectors; + currentSector += neroTrack.Sectors; currenttrack++; } @@ -360,50 +361,51 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "Found \"DAOX\" chunk, parsing {0} bytes", chunkLength); - neroDaov2 = new NeroV2Dao + _neroDaov2 = new NeroV2Dao { ChunkId = chunkId, ChunkSizeBe = chunkLength }; byte[] tmpbuffer = new byte[22]; - imageStream.Read(tmpbuffer, 0, 22); - neroDaov2.ChunkSizeLe = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); - neroDaov2.Upc = new byte[14]; - Array.Copy(tmpbuffer, 4, neroDaov2.Upc, 0, 14); - neroDaov2.TocType = BigEndianBitConverter.ToUInt16(tmpbuffer, 18); - neroDaov2.FirstTrack = tmpbuffer[20]; - neroDaov2.LastTrack = tmpbuffer[21]; - neroDaov2.Tracks = new List(); + _imageStream.Read(tmpbuffer, 0, 22); + _neroDaov2.ChunkSizeLe = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); + _neroDaov2.Upc = new byte[14]; + Array.Copy(tmpbuffer, 4, _neroDaov2.Upc, 0, 14); + _neroDaov2.TocType = BigEndianBitConverter.ToUInt16(tmpbuffer, 18); + _neroDaov2.FirstTrack = tmpbuffer[20]; + _neroDaov2.LastTrack = tmpbuffer[21]; + _neroDaov2.Tracks = new List(); - if(!imageInfo.ReadableMediaTags.Contains(MediaTagType.CD_MCN)) - imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); + if(!_imageInfo.ReadableMediaTags.Contains(MediaTagType.CD_MCN)) + _imageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdTrackIsrc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackIsrc); - upc = neroDaov2.Upc; + _upc = _neroDaov2.Upc; AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.ChunkSizeLe = {0} bytes", - neroDaov2.ChunkSizeLe); + _neroDaov2.ChunkSizeLe); AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.UPC = \"{0}\"", - StringHandlers.CToString(neroDaov2.Upc)); + StringHandlers.CToString(_neroDaov2.Upc)); AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.TocType = 0x{0:X4}", - neroDaov2.TocType); + _neroDaov2.TocType); AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.FirstTrack = {0}", - neroDaov2.FirstTrack); + _neroDaov2.FirstTrack); - AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.LastTrack = {0}", neroDaov2.LastTrack); + AaruConsole.DebugWriteLine("Nero plugin", "neroDAOV2.LastTrack = {0}", + _neroDaov2.LastTrack); tmpbuffer = new byte[42]; - for(int i = 0; i < neroDaov2.ChunkSizeBe - 22; i += 42) + for(int i = 0; i < _neroDaov2.ChunkSizeBe - 22; i += 42) { var entry = new NeroV2DaoEntry(); - imageStream.Read(tmpbuffer, 0, 42); + _imageStream.Read(tmpbuffer, 0, 42); entry.Isrc = new byte[12]; Array.Copy(tmpbuffer, 4, entry.Isrc, 0, 12); entry.SectorSize = BigEndianBitConverter.ToUInt16(tmpbuffer, 12); @@ -436,12 +438,12 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].EndOfTrack = {1}", (i / 32) + 1, entry.EndOfTrack); - neroDaov2.Tracks.Add(entry); + _neroDaov2.Tracks.Add(entry); - if(entry.SectorSize > imageInfo.SectorSize) - imageInfo.SectorSize = entry.SectorSize; + if(entry.SectorSize > _imageInfo.SectorSize) + _imageInfo.SectorSize = entry.SectorSize; - trackIsrCs.Add(currenttrack, entry.Isrc); + _trackIsrCs.Add(currenttrack, entry.Isrc); if(currenttrack == 1) entry.Index0 = entry.Index1; @@ -461,10 +463,10 @@ namespace Aaru.DiscImages }; neroTrack.Sectors = neroTrack.Length / entry.SectorSize; - neroTracks.Add(currenttrack, neroTrack); + _neroTracks.Add(currenttrack, neroTrack); - imageInfo.Sectors += neroTrack.Sectors; - currentSector += neroTrack.Sectors; + _imageInfo.Sectors += neroTrack.Sectors; + currentSector += neroTrack.Sectors; currenttrack++; } @@ -477,7 +479,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "Found \"CDTX\" chunk, parsing {0} bytes", chunkLength); - neroCdtxt = new NeroCdText + _neroCdtxt = new NeroCdText { ChunkId = chunkId, ChunkSize = chunkLength, @@ -486,10 +488,10 @@ namespace Aaru.DiscImages byte[] tmpbuffer = new byte[18]; - for(int i = 0; i < neroCdtxt.ChunkSize; i += 18) + for(int i = 0; i < _neroCdtxt.ChunkSize; i += 18) { var entry = new NeroCdTextPack(); - imageStream.Read(tmpbuffer, 0, 18); + _imageStream.Read(tmpbuffer, 0, 18); entry.PackType = tmpbuffer[0]; entry.TrackNumber = tmpbuffer[1]; @@ -519,7 +521,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].CRC = 0x{1:X4}", (i / 18) + 1, entry.Crc); - neroCdtxt.Packs.Add(entry); + _neroCdtxt.Packs.Add(entry); } break; @@ -530,7 +532,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "Found \"ETNF\" chunk, parsing {0} bytes", chunkLength); - neroTaov1 = new NeroV1Tao + _neroTaov1 = new NeroV1Tao { ChunkId = chunkId, ChunkSize = chunkLength, @@ -539,10 +541,10 @@ namespace Aaru.DiscImages byte[] tmpbuffer = new byte[20]; - for(int i = 0; i < neroTaov1.ChunkSize; i += 20) + for(int i = 0; i < _neroTaov1.ChunkSize; i += 20) { var entry = new NeroV1TaoEntry(); - imageStream.Read(tmpbuffer, 0, 20); + _imageStream.Read(tmpbuffer, 0, 20); entry.Offset = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); entry.Length = BigEndianBitConverter.ToUInt32(tmpbuffer, 4); @@ -567,10 +569,10 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Unknown = 0x{1:X4}", (i / 20) + 1, entry.Unknown); - neroTaov1.Tracks.Add(entry); + _neroTaov1.Tracks.Add(entry); - if(NeroTrackModeToBytesPerSector((DaoMode)entry.Mode) > imageInfo.SectorSize) - imageInfo.SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode); + if(NeroTrackModeToBytesPerSector((DaoMode)entry.Mode) > _imageInfo.SectorSize) + _imageInfo.SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode); var neroTrack = new NeroTrack { @@ -588,9 +590,9 @@ namespace Aaru.DiscImages neroTrack.Sectors = neroTrack.Length / NeroTrackModeToBytesPerSector((DaoMode)entry.Mode); - neroTracks.Add(currenttrack, neroTrack); + _neroTracks.Add(currenttrack, neroTrack); - imageInfo.Sectors += neroTrack.Sectors; + _imageInfo.Sectors += neroTrack.Sectors; currenttrack++; } @@ -603,7 +605,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "Found \"ETN2\" chunk, parsing {0} bytes", chunkLength); - neroTaov2 = new NeroV2Tao + _neroTaov2 = new NeroV2Tao { ChunkId = chunkId, ChunkSize = chunkLength, @@ -612,10 +614,10 @@ namespace Aaru.DiscImages byte[] tmpbuffer = new byte[32]; - for(int i = 0; i < neroTaov2.ChunkSize; i += 32) + for(int i = 0; i < _neroTaov2.ChunkSize; i += 32) { var entry = new NeroV2TaoEntry(); - imageStream.Read(tmpbuffer, 0, 32); + _imageStream.Read(tmpbuffer, 0, 32); entry.Offset = BigEndianBitConverter.ToUInt64(tmpbuffer, 0); entry.Length = BigEndianBitConverter.ToUInt64(tmpbuffer, 8); @@ -644,10 +646,10 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "\t _entry[{0}].Sectors = {1}", (i / 32) + 1, entry.Sectors); - neroTaov2.Tracks.Add(entry); + _neroTaov2.Tracks.Add(entry); - if(NeroTrackModeToBytesPerSector((DaoMode)entry.Mode) > imageInfo.SectorSize) - imageInfo.SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode); + if(NeroTrackModeToBytesPerSector((DaoMode)entry.Mode) > _imageInfo.SectorSize) + _imageInfo.SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode); var neroTrack = new NeroTrack { @@ -665,9 +667,9 @@ namespace Aaru.DiscImages neroTrack.SectorSize = NeroTrackModeToBytesPerSector((DaoMode)entry.Mode); neroTrack.StartLba = entry.StartLba; neroTrack.Sequence = currenttrack; - neroTracks.Add(currenttrack, neroTrack); + _neroTracks.Add(currenttrack, neroTrack); - imageInfo.Sectors += neroTrack.Sectors; + _imageInfo.Sectors += neroTrack.Sectors; currenttrack++; } @@ -681,9 +683,9 @@ namespace Aaru.DiscImages chunkLength); byte[] tmpbuffer = new byte[4]; - imageStream.Read(tmpbuffer, 0, 4); + _imageStream.Read(tmpbuffer, 0, 4); uint sessionTracks = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); - neroSessions.Add(currentsession, sessionTracks); + _neroSessions.Add(currentsession, sessionTracks); AaruConsole.DebugWriteLine("Nero plugin", "\tSession {0} has {1} tracks", currentsession, sessionTracks); @@ -698,20 +700,20 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "Found \"MTYP\" chunk, parsing {0} bytes", chunkLength); - neroMediaTyp = new NeroMediaType + _neroMediaTyp = new NeroMediaType { ChunkId = chunkId, ChunkSize = chunkLength }; byte[] tmpbuffer = new byte[4]; - imageStream.Read(tmpbuffer, 0, 4); - neroMediaTyp.Type = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); + _imageStream.Read(tmpbuffer, 0, 4); + _neroMediaTyp.Type = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); AaruConsole.DebugWriteLine("Nero plugin", "\tMedia type is {0} ({1})", - (NeroMediaTypes)neroMediaTyp.Type, neroMediaTyp.Type); + (NeroMediaTypes)_neroMediaTyp.Type, _neroMediaTyp.Type); - imageInfo.MediaType = NeroMediaTypeToMediaType((NeroMediaTypes)neroMediaTyp.Type); + _imageInfo.MediaType = NeroMediaTypeToMediaType((NeroMediaTypes)_neroMediaTyp.Type); break; } @@ -721,18 +723,18 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "Found \"DINF\" chunk, parsing {0} bytes", chunkLength); - neroDiscInfo = new NeroDiscInformation + _neroDiscInfo = new NeroDiscInformation { ChunkId = chunkId, ChunkSize = chunkLength }; byte[] tmpbuffer = new byte[4]; - imageStream.Read(tmpbuffer, 0, 4); - neroDiscInfo.Unknown = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); + _imageStream.Read(tmpbuffer, 0, 4); + _neroDiscInfo.Unknown = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); AaruConsole.DebugWriteLine("Nero plugin", "\tneroDiscInfo.Unknown = 0x{0:X4} ({0})", - neroDiscInfo.Unknown); + _neroDiscInfo.Unknown); break; } @@ -742,18 +744,18 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "Found \"RELO\" chunk, parsing {0} bytes", chunkLength); - neroRelo = new NeroReloChunk + _neroRelo = new NeroReloChunk { ChunkId = chunkId, ChunkSize = chunkLength }; byte[] tmpbuffer = new byte[4]; - imageStream.Read(tmpbuffer, 0, 4); - neroRelo.Unknown = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); + _imageStream.Read(tmpbuffer, 0, 4); + _neroRelo.Unknown = BigEndianBitConverter.ToUInt32(tmpbuffer, 0); AaruConsole.DebugWriteLine("Nero plugin", "\tneroRELO.Unknown = 0x{0:X4} ({0})", - neroRelo.Unknown); + _neroRelo.Unknown); break; } @@ -763,18 +765,18 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Nero plugin", "Found \"TOCT\" chunk, parsing {0} bytes", chunkLength); - neroToc = new NeroTocChunk + _neroToc = new NeroTocChunk { ChunkId = chunkId, ChunkSize = chunkLength }; byte[] tmpbuffer = new byte[2]; - imageStream.Read(tmpbuffer, 0, 2); - neroToc.Unknown = BigEndianBitConverter.ToUInt16(tmpbuffer, 0); + _imageStream.Read(tmpbuffer, 0, 2); + _neroToc.Unknown = BigEndianBitConverter.ToUInt16(tmpbuffer, 0); AaruConsole.DebugWriteLine("Nero plugin", "\tneroTOC.Unknown = 0x{0:X4} ({0})", - neroToc.Unknown); + _neroToc.Unknown); break; } @@ -793,62 +795,62 @@ namespace Aaru.DiscImages Encoding.ASCII.GetString(BigEndianBitConverter. GetBytes(chunkId))); - imageStream.Seek(chunkLength, SeekOrigin.Current); + _imageStream.Seek(chunkLength, SeekOrigin.Current); break; } } } - imageInfo.HasPartitions = true; - imageInfo.HasSessions = true; - imageInfo.Creator = null; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Comments = null; - imageInfo.MediaManufacturer = null; - imageInfo.MediaModel = null; - imageInfo.MediaSerialNumber = null; - imageInfo.MediaBarcode = null; - imageInfo.MediaPartNumber = null; - imageInfo.DriveManufacturer = null; - imageInfo.DriveModel = null; - imageInfo.DriveSerialNumber = null; - imageInfo.DriveFirmwareRevision = null; - imageInfo.MediaSequence = 0; - imageInfo.LastMediaSequence = 0; + _imageInfo.HasPartitions = true; + _imageInfo.HasSessions = true; + _imageInfo.Creator = null; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Comments = null; + _imageInfo.MediaManufacturer = null; + _imageInfo.MediaModel = null; + _imageInfo.MediaSerialNumber = null; + _imageInfo.MediaBarcode = null; + _imageInfo.MediaPartNumber = null; + _imageInfo.DriveManufacturer = null; + _imageInfo.DriveModel = null; + _imageInfo.DriveSerialNumber = null; + _imageInfo.DriveFirmwareRevision = null; + _imageInfo.MediaSequence = 0; + _imageInfo.LastMediaSequence = 0; - if(imageNewFormat) + if(_imageNewFormat) { - imageInfo.ImageSize = footerV2.FirstChunkOffset; - imageInfo.Version = "Nero Burning ROM >= 5.5"; - imageInfo.Application = "Nero Burning ROM"; - imageInfo.ApplicationVersion = ">= 5.5"; + _imageInfo.ImageSize = footerV2.FirstChunkOffset; + _imageInfo.Version = "Nero Burning ROM >= 5.5"; + _imageInfo.Application = "Nero Burning ROM"; + _imageInfo.ApplicationVersion = ">= 5.5"; } else { - imageInfo.ImageSize = footerV1.FirstChunkOffset; - imageInfo.Version = "Nero Burning ROM <= 5.0"; - imageInfo.Application = "Nero Burning ROM"; - imageInfo.ApplicationVersion = "<= 5.0"; + _imageInfo.ImageSize = footerV1.FirstChunkOffset; + _imageInfo.Version = "Nero Burning ROM <= 5.0"; + _imageInfo.Application = "Nero Burning ROM"; + _imageInfo.ApplicationVersion = "<= 5.0"; } - if(neroSessions.Count == 0) - neroSessions.Add(1, currenttrack); + if(_neroSessions.Count == 0) + _neroSessions.Add(1, currenttrack); AaruConsole.DebugWriteLine("Nero plugin", "Building offset, track and session maps"); currentsession = 1; - neroSessions.TryGetValue(1, out uint currentsessionmaxtrack); + _neroSessions.TryGetValue(1, out uint currentsessionmaxtrack); uint currentsessioncurrenttrack = 1; var currentsessionstruct = new Session(); ulong partitionSequence = 0; ulong partitionStartByte = 0; - for(uint i = 1; i <= neroTracks.Count; i++) + for(uint i = 1; i <= _neroTracks.Count; i++) { - if(!neroTracks.TryGetValue(i, out NeroTrack neroTrack)) + if(!_neroTracks.TryGetValue(i, out NeroTrack neroTrack)) continue; AaruConsole.DebugWriteLine("Nero plugin", "\tcurrentsession = {0}", currentsession); @@ -859,9 +861,9 @@ namespace Aaru.DiscImages var track = new Track(); - if(neroCuesheetV1?.Entries?.Count > 0) + if(_neroCuesheetV1?.Entries?.Count > 0) { - foreach(NeroV1CueEntry entry in neroCuesheetV1. + foreach(NeroV1CueEntry entry in _neroCuesheetV1. Entries.Where(e => e.TrackNumber == neroTrack.Sequence). OrderBy(e => e.IndexNumber)) { @@ -874,8 +876,8 @@ namespace Aaru.DiscImages track.Indexes[entry.IndexNumber] = indexSector; } } - else if(neroCuesheetV2?.Entries?.Count > 0) - foreach(NeroV2CueEntry entry in neroCuesheetV2. + else if(_neroCuesheetV2?.Entries?.Count > 0) + foreach(NeroV2CueEntry entry in _neroCuesheetV2. Entries.Where(e => e.TrackNumber == neroTrack.Sequence). OrderBy(e => e.IndexNumber)) track.Indexes[entry.IndexNumber] = entry.LbaStart; @@ -1005,23 +1007,23 @@ namespace Aaru.DiscImages if(currentsessioncurrenttrack > currentsessionmaxtrack) { currentsession++; - neroSessions.TryGetValue(currentsession, out currentsessionmaxtrack); + _neroSessions.TryGetValue(currentsession, out currentsessionmaxtrack); currentsessioncurrenttrack = 1; currentsessionstruct.EndTrack = track.TrackSequence; currentsessionstruct.EndSector = track.TrackEndSector; Sessions.Add(currentsessionstruct); } - else if(i == neroTracks.Count) + else if(i == _neroTracks.Count) { - neroSessions.TryGetValue(currentsession, out currentsessionmaxtrack); + _neroSessions.TryGetValue(currentsession, out currentsessionmaxtrack); currentsessioncurrenttrack = 1; currentsessionstruct.EndTrack = track.TrackSequence; currentsessionstruct.EndSector = track.TrackEndSector; Sessions.Add(currentsessionstruct); } - offsetmap.Add(track.TrackSequence, track.TrackStartSector); + _offsetmap.Add(track.TrackSequence, track.TrackStartSector); AaruConsole.DebugWriteLine("Nero plugin", "\t\t Offset[{0}]: {1}", track.TrackSequence, track.TrackStartSector); @@ -1069,10 +1071,10 @@ namespace Aaru.DiscImages track.TrackStartSector -= 150; } - neroFilter = imageFilter; + _neroFilter = imageFilter; - if(imageInfo.MediaType == MediaType.Unknown || - imageInfo.MediaType == MediaType.CD) + if(_imageInfo.MediaType == MediaType.Unknown || + _imageInfo.MediaType == MediaType.CD) { bool data = false; bool mode2 = false; @@ -1080,25 +1082,25 @@ namespace Aaru.DiscImages bool firstdata = false; bool audio = false; - for(int i = 0; i < neroTracks.Count; i++) + for(int i = 0; i < _neroTracks.Count; i++) { // First track is audio - firstaudio |= i == 0 && ((DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.Audio || - (DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.AudioSub); + firstaudio |= i == 0 && ((DaoMode)_neroTracks.ElementAt(i).Value.Mode == DaoMode.Audio || + (DaoMode)_neroTracks.ElementAt(i).Value.Mode == DaoMode.AudioSub); // First track is data - firstdata |= i == 0 && (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio && - (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioSub; + firstdata |= i == 0 && (DaoMode)_neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio && + (DaoMode)_neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioSub; // Any non first track is data - data |= i != 0 && (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio && - (DaoMode)neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioSub; + data |= i != 0 && (DaoMode)_neroTracks.ElementAt(i).Value.Mode != DaoMode.Audio && + (DaoMode)_neroTracks.ElementAt(i).Value.Mode != DaoMode.AudioSub; // Any non first track is audio - audio |= i != 0 && ((DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.Audio || - (DaoMode)neroTracks.ElementAt(i).Value.Mode == DaoMode.AudioSub); + audio |= i != 0 && ((DaoMode)_neroTracks.ElementAt(i).Value.Mode == DaoMode.Audio || + (DaoMode)_neroTracks.ElementAt(i).Value.Mode == DaoMode.AudioSub); - switch((DaoMode)neroTracks.ElementAt(i).Value.Mode) + switch((DaoMode)_neroTracks.ElementAt(i).Value.Mode) { case DaoMode.DataM2F1: case DaoMode.DataM2F2: @@ -1112,65 +1114,65 @@ namespace Aaru.DiscImages if(!data && !firstdata) - imageInfo.MediaType = MediaType.CDDA; + _imageInfo.MediaType = MediaType.CDDA; else if(firstaudio && data && Sessions.Count > 1 && mode2) - imageInfo.MediaType = MediaType.CDPLUS; + _imageInfo.MediaType = MediaType.CDPLUS; else if((firstdata && audio) || mode2) - imageInfo.MediaType = MediaType.CDROMXA; + _imageInfo.MediaType = MediaType.CDROMXA; else if(!audio) - imageInfo.MediaType = MediaType.CDROM; + _imageInfo.MediaType = MediaType.CDROM; else - imageInfo.MediaType = MediaType.CD; + _imageInfo.MediaType = MediaType.CD; } - imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; - AaruConsole.VerboseWriteLine("Nero image contains a disc of type {0}", imageInfo.MediaType); + _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; + AaruConsole.VerboseWriteLine("Nero image contains a disc of type {0}", _imageInfo.MediaType); _sectorBuilder = new SectorBuilder(); - if(imageInfo.MediaType != MediaType.CD && - imageInfo.MediaType != MediaType.CDDA && - imageInfo.MediaType != MediaType.CDG && - imageInfo.MediaType != MediaType.CDEG && - imageInfo.MediaType != MediaType.CDI && - imageInfo.MediaType != MediaType.CDROM && - imageInfo.MediaType != MediaType.CDROMXA && - imageInfo.MediaType != MediaType.CDPLUS && - imageInfo.MediaType != MediaType.CDMO && - imageInfo.MediaType != MediaType.CDR && - imageInfo.MediaType != MediaType.CDRW && - imageInfo.MediaType != MediaType.CDMRW && - imageInfo.MediaType != MediaType.VCD && - imageInfo.MediaType != MediaType.SVCD && - imageInfo.MediaType != MediaType.PCD && - imageInfo.MediaType != MediaType.DTSCD && - imageInfo.MediaType != MediaType.CDMIDI && - imageInfo.MediaType != MediaType.CDV && - imageInfo.MediaType != MediaType.CDIREADY && - imageInfo.MediaType != MediaType.FMTOWNS && - imageInfo.MediaType != MediaType.PS1CD && - imageInfo.MediaType != MediaType.PS2CD && - imageInfo.MediaType != MediaType.MEGACD && - imageInfo.MediaType != MediaType.SATURNCD && - imageInfo.MediaType != MediaType.GDROM && - imageInfo.MediaType != MediaType.GDR && - imageInfo.MediaType != MediaType.MilCD && - imageInfo.MediaType != MediaType.SuperCDROM2 && - imageInfo.MediaType != MediaType.JaguarCD && - imageInfo.MediaType != MediaType.ThreeDO && - imageInfo.MediaType != MediaType.PCFX && - imageInfo.MediaType != MediaType.NeoGeoCD && - imageInfo.MediaType != MediaType.CDTV && - imageInfo.MediaType != MediaType.CD32 && - imageInfo.MediaType != MediaType.Playdia && - imageInfo.MediaType != MediaType.Pippin && - imageInfo.MediaType != MediaType.VideoNow && - imageInfo.MediaType != MediaType.VideoNowColor && - imageInfo.MediaType != MediaType.VideoNowXp && - imageInfo.MediaType != MediaType.CVD) + if(_imageInfo.MediaType != MediaType.CD && + _imageInfo.MediaType != MediaType.CDDA && + _imageInfo.MediaType != MediaType.CDG && + _imageInfo.MediaType != MediaType.CDEG && + _imageInfo.MediaType != MediaType.CDI && + _imageInfo.MediaType != MediaType.CDROM && + _imageInfo.MediaType != MediaType.CDROMXA && + _imageInfo.MediaType != MediaType.CDPLUS && + _imageInfo.MediaType != MediaType.CDMO && + _imageInfo.MediaType != MediaType.CDR && + _imageInfo.MediaType != MediaType.CDRW && + _imageInfo.MediaType != MediaType.CDMRW && + _imageInfo.MediaType != MediaType.VCD && + _imageInfo.MediaType != MediaType.SVCD && + _imageInfo.MediaType != MediaType.PCD && + _imageInfo.MediaType != MediaType.DTSCD && + _imageInfo.MediaType != MediaType.CDMIDI && + _imageInfo.MediaType != MediaType.CDV && + _imageInfo.MediaType != MediaType.CDIREADY && + _imageInfo.MediaType != MediaType.FMTOWNS && + _imageInfo.MediaType != MediaType.PS1CD && + _imageInfo.MediaType != MediaType.PS2CD && + _imageInfo.MediaType != MediaType.MEGACD && + _imageInfo.MediaType != MediaType.SATURNCD && + _imageInfo.MediaType != MediaType.GDROM && + _imageInfo.MediaType != MediaType.GDR && + _imageInfo.MediaType != MediaType.MilCD && + _imageInfo.MediaType != MediaType.SuperCDROM2 && + _imageInfo.MediaType != MediaType.JaguarCD && + _imageInfo.MediaType != MediaType.ThreeDO && + _imageInfo.MediaType != MediaType.PCFX && + _imageInfo.MediaType != MediaType.NeoGeoCD && + _imageInfo.MediaType != MediaType.CDTV && + _imageInfo.MediaType != MediaType.CD32 && + _imageInfo.MediaType != MediaType.Playdia && + _imageInfo.MediaType != MediaType.Pippin && + _imageInfo.MediaType != MediaType.VideoNow && + _imageInfo.MediaType != MediaType.VideoNowColor && + _imageInfo.MediaType != MediaType.VideoNowXp && + _imageInfo.MediaType != MediaType.CVD) foreach(Track track in Tracks) { track.TrackPregap = 0; @@ -1191,7 +1193,7 @@ namespace Aaru.DiscImages { switch(tag) { - case MediaTagType.CD_MCN: return upc; + case MediaTagType.CD_MCN: return _upc; case MediaTagType.CD_TEXT: throw new NotImplementedException("Not yet implemented"); default: throw new FeaturedNotSupportedByDiscImageException("Requested disk tag not supported by image"); @@ -1209,7 +1211,7 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value <= track.TrackEndSector - track.TrackStartSector select kvp) @@ -1220,7 +1222,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value <= track.TrackEndSector - track.TrackStartSector select kvp) @@ -1231,7 +1233,7 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length, uint track) { - if(!neroTracks.TryGetValue(track, out NeroTrack aaruTrack)) + if(!_neroTracks.TryGetValue(track, out NeroTrack aaruTrack)) throw new ArgumentOutOfRangeException(nameof(track), "Track not found"); if(length > aaruTrack.Sectors) @@ -1327,8 +1329,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = neroFilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = _neroFilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), @@ -1371,7 +1373,7 @@ namespace Aaru.DiscImages tag == SectorTagType.CdTrackIsrc) track = (uint)sectorAddress; - if(!neroTracks.TryGetValue(track, out NeroTrack aaruTrack)) + if(!_neroTracks.TryGetValue(track, out NeroTrack aaruTrack)) throw new ArgumentOutOfRangeException(nameof(track), "Track not found"); if(length > aaruTrack.Sectors) @@ -1612,8 +1614,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = neroFilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = _neroFilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), @@ -1640,7 +1642,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - foreach(KeyValuePair kvp in from kvp in offsetmap where sectorAddress >= kvp.Value + foreach(KeyValuePair kvp in from kvp in _offsetmap where sectorAddress >= kvp.Value from track in Tracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value <= track.TrackEndSector - track.TrackStartSector select kvp) @@ -1651,7 +1653,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track) { - if(!neroTracks.TryGetValue(track, out NeroTrack aaruTrack)) + if(!_neroTracks.TryGetValue(track, out NeroTrack aaruTrack)) throw new ArgumentOutOfRangeException(nameof(track), "Track not found"); if(length > aaruTrack.Sectors) @@ -1710,8 +1712,8 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - imageStream = neroFilter.GetDataForkStream(); - var br = new BinaryReader(imageStream); + _imageStream = _neroFilter.GetDataForkStream(); + var br = new BinaryReader(_imageStream); br.BaseStream. Seek((long)aaruTrack.Offset + (long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), diff --git a/Aaru.Images/Parallels/Constants.cs b/Aaru.Images/Parallels/Constants.cs index f9c6334a7..83cca54e0 100644 --- a/Aaru.Images/Parallels/Constants.cs +++ b/Aaru.Images/Parallels/Constants.cs @@ -44,11 +44,11 @@ namespace Aaru.DiscImages const uint MAX_CACHE_SIZE = 16777216; const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / 512; const uint DEFAULT_CLUSTER_SIZE = 1048576; - readonly byte[] parallelsExtMagic = + readonly byte[] _parallelsExtMagic = { 0x57, 0x69, 0x74, 0x68, 0x6F, 0x75, 0x46, 0x72, 0x65, 0x53, 0x70, 0x61, 0x63, 0x45, 0x78, 0x74 }; - readonly byte[] parallelsMagic = + readonly byte[] _parallelsMagic = { 0x57, 0x69, 0x74, 0x68, 0x6F, 0x75, 0x74, 0x46, 0x72, 0x65, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65 }; diff --git a/Aaru.Images/Parallels/Identify.cs b/Aaru.Images/Parallels/Identify.cs index e6a58592b..c36543e01 100644 --- a/Aaru.Images/Parallels/Identify.cs +++ b/Aaru.Images/Parallels/Identify.cs @@ -49,9 +49,9 @@ namespace Aaru.DiscImages byte[] pHdrB = new byte[Marshal.SizeOf()]; stream.Read(pHdrB, 0, Marshal.SizeOf()); - pHdr = Marshal.ByteArrayToStructureLittleEndian(pHdrB); + _pHdr = Marshal.ByteArrayToStructureLittleEndian(pHdrB); - return parallelsMagic.SequenceEqual(pHdr.magic) || parallelsExtMagic.SequenceEqual(pHdr.magic); + return _parallelsMagic.SequenceEqual(_pHdr.magic) || _parallelsExtMagic.SequenceEqual(_pHdr.magic); } } } \ No newline at end of file diff --git a/Aaru.Images/Parallels/Parallels.cs b/Aaru.Images/Parallels/Parallels.cs index 9606ef47f..eecaffae8 100644 --- a/Aaru.Images/Parallels/Parallels.cs +++ b/Aaru.Images/Parallels/Parallels.cs @@ -42,19 +42,19 @@ namespace Aaru.DiscImages { public partial class Parallels : IWritableImage { - uint[] bat; - uint clusterBytes; - long currentWritingPosition; - long dataOffset; - bool empty; - bool extended; - ImageInfo imageInfo; - Stream imageStream; - ParallelsHeader pHdr; - Dictionary sectorCache; - FileStream writingStream; + uint[] _bat; + uint _clusterBytes; + long _currentWritingPosition; + long _dataOffset; + bool _empty; + bool _extended; + ImageInfo _imageInfo; + Stream _imageStream; + ParallelsHeader _pHdr; + Dictionary _sectorCache; + FileStream _writingStream; - public Parallels() => imageInfo = new ImageInfo + public Parallels() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/Parallels/Properties.cs b/Aaru.Images/Parallels/Properties.cs index 98eb7de82..8b0eb73b3 100644 --- a/Aaru.Images/Parallels/Properties.cs +++ b/Aaru.Images/Parallels/Properties.cs @@ -43,7 +43,7 @@ namespace Aaru.DiscImages { public string Name => "Parallels disk image"; public Guid Id => new Guid("E314DE35-C103-48A3-AD36-990F68523C46"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Format => "Parallels"; public List DumpHardware => null; diff --git a/Aaru.Images/Parallels/Read.cs b/Aaru.Images/Parallels/Read.cs index b6a0e45df..043b4eb61 100644 --- a/Aaru.Images/Parallels/Read.cs +++ b/Aaru.Images/Parallels/Read.cs @@ -54,108 +54,108 @@ namespace Aaru.DiscImages byte[] pHdrB = new byte[Marshal.SizeOf()]; stream.Read(pHdrB, 0, Marshal.SizeOf()); - pHdr = Marshal.ByteArrayToStructureLittleEndian(pHdrB); + _pHdr = Marshal.ByteArrayToStructureLittleEndian(pHdrB); - AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.magic = {0}", StringHandlers.CToString(pHdr.magic)); - AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.version = {0}", pHdr.version); - AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.heads = {0}", pHdr.heads); - AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.cylinders = {0}", pHdr.cylinders); - AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.cluster_size = {0}", pHdr.cluster_size); - AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.bat_entries = {0}", pHdr.bat_entries); - AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.sectors = {0}", pHdr.sectors); - AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.in_use = 0x{0:X8}", pHdr.in_use); - AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.data_off = {0}", pHdr.data_off); - AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.flags = {0}", pHdr.flags); - AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.ext_off = {0}", pHdr.ext_off); + AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.magic = {0}", StringHandlers.CToString(_pHdr.magic)); + AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.version = {0}", _pHdr.version); + AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.heads = {0}", _pHdr.heads); + AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.cylinders = {0}", _pHdr.cylinders); + AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.cluster_size = {0}", _pHdr.cluster_size); + AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.bat_entries = {0}", _pHdr.bat_entries); + AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.sectors = {0}", _pHdr.sectors); + AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.in_use = 0x{0:X8}", _pHdr.in_use); + AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.data_off = {0}", _pHdr.data_off); + AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.flags = {0}", _pHdr.flags); + AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.ext_off = {0}", _pHdr.ext_off); - extended = parallelsExtMagic.SequenceEqual(pHdr.magic); - AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.extended = {0}", extended); + _extended = _parallelsExtMagic.SequenceEqual(_pHdr.magic); + AaruConsole.DebugWriteLine("Parallels plugin", "pHdr.extended = {0}", _extended); AaruConsole.DebugWriteLine("Parallels plugin", "Reading BAT"); - bat = new uint[pHdr.bat_entries]; - byte[] batB = new byte[pHdr.bat_entries * 4]; + _bat = new uint[_pHdr.bat_entries]; + byte[] batB = new byte[_pHdr.bat_entries * 4]; stream.Read(batB, 0, batB.Length); - for(int i = 0; i < bat.Length; i++) - bat[i] = BitConverter.ToUInt32(batB, i * 4); + for(int i = 0; i < _bat.Length; i++) + _bat[i] = BitConverter.ToUInt32(batB, i * 4); - clusterBytes = pHdr.cluster_size * 512; + _clusterBytes = _pHdr.cluster_size * 512; - if(pHdr.data_off > 0) - dataOffset = pHdr.data_off * 512; + if(_pHdr.data_off > 0) + _dataOffset = _pHdr.data_off * 512; else - dataOffset = ((stream.Position / clusterBytes) + (stream.Position % clusterBytes)) * clusterBytes; + _dataOffset = ((stream.Position / _clusterBytes) + (stream.Position % _clusterBytes)) * _clusterBytes; - sectorCache = new Dictionary(); + _sectorCache = new Dictionary(); - empty = (pHdr.flags & PARALLELS_EMPTY) == PARALLELS_EMPTY; + _empty = (_pHdr.flags & PARALLELS_EMPTY) == PARALLELS_EMPTY; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = pHdr.sectors; - imageInfo.SectorSize = 512; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.ImageSize = pHdr.sectors * 512; - imageInfo.Cylinders = pHdr.cylinders; - imageInfo.Heads = pHdr.heads; - imageInfo.SectorsPerTrack = (uint)(imageInfo.Sectors / imageInfo.Cylinders / imageInfo.Heads); - imageStream = stream; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = _pHdr.sectors; + _imageInfo.SectorSize = 512; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.ImageSize = _pHdr.sectors * 512; + _imageInfo.Cylinders = _pHdr.cylinders; + _imageInfo.Heads = _pHdr.heads; + _imageInfo.SectorsPerTrack = (uint)(_imageInfo.Sectors / _imageInfo.Cylinders / _imageInfo.Heads); + _imageStream = stream; return true; } public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(empty) + if(_empty) return new byte[512]; - if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector; - ulong index = sectorAddress / pHdr.cluster_size; - ulong secOff = sectorAddress % pHdr.cluster_size; + ulong index = sectorAddress / _pHdr.cluster_size; + ulong secOff = sectorAddress % _pHdr.cluster_size; - uint batOff = bat[index]; + uint batOff = _bat[index]; ulong imageOff; if(batOff == 0) return new byte[512]; - if(extended) - imageOff = batOff * clusterBytes; + if(_extended) + imageOff = batOff * _clusterBytes; else imageOff = batOff * 512; - byte[] cluster = new byte[clusterBytes]; - imageStream.Seek((long)imageOff, SeekOrigin.Begin); - imageStream.Read(cluster, 0, (int)clusterBytes); + byte[] cluster = new byte[_clusterBytes]; + _imageStream.Seek((long)imageOff, SeekOrigin.Begin); + _imageStream.Read(cluster, 0, (int)_clusterBytes); sector = new byte[512]; Array.Copy(cluster, (int)(secOff * 512), sector, 0, 512); - if(sectorCache.Count > MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count > MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - if(empty) + if(_empty) return new byte[512 * length]; var ms = new MemoryStream(); diff --git a/Aaru.Images/Parallels/Structs.cs b/Aaru.Images/Parallels/Structs.cs index fec3d83aa..2350e3b5c 100644 --- a/Aaru.Images/Parallels/Structs.cs +++ b/Aaru.Images/Parallels/Structs.cs @@ -40,7 +40,7 @@ namespace Aaru.DiscImages [StructLayout(LayoutKind.Sequential, Pack = 1)] struct ParallelsHeader { - /// Magic, or + /// Magic, or [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] magic; /// Version diff --git a/Aaru.Images/Parallels/Write.cs b/Aaru.Images/Parallels/Write.cs index 464adf7eb..cee38cdb0 100644 --- a/Aaru.Images/Parallels/Write.cs +++ b/Aaru.Images/Parallels/Write.cs @@ -69,7 +69,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -78,7 +78,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -97,9 +97,9 @@ namespace Aaru.DiscImages if((uint)Marshal.SizeOf() + (batEntries % 4) > 0) headerSectors++; - pHdr = new ParallelsHeader + _pHdr = new ParallelsHeader { - magic = parallelsMagic, + magic = _parallelsMagic, version = PARALLELS_VERSION, sectors = sectors, in_use = PARALLELS_CLOSED, @@ -108,8 +108,8 @@ namespace Aaru.DiscImages cluster_size = DEFAULT_CLUSTER_SIZE / 512 }; - bat = new uint[batEntries]; - currentWritingPosition = headerSectors * 512; + _bat = new uint[batEntries]; + _currentWritingPosition = headerSectors * 512; IsWriting = true; ErrorMessage = null; @@ -140,7 +140,7 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -151,23 +151,23 @@ namespace Aaru.DiscImages if(ArrayHelpers.ArrayIsNullOrEmpty(data)) return true; - ulong index = sectorAddress / pHdr.cluster_size; - ulong secOff = sectorAddress % pHdr.cluster_size; + ulong index = sectorAddress / _pHdr.cluster_size; + ulong secOff = sectorAddress % _pHdr.cluster_size; - uint batOff = bat[index]; + uint batOff = _bat[index]; if(batOff == 0) { - batOff = (uint)(currentWritingPosition / 512); - bat[index] = batOff; - currentWritingPosition += pHdr.cluster_size * 512; + batOff = (uint)(_currentWritingPosition / 512); + _bat[index] = batOff; + _currentWritingPosition += _pHdr.cluster_size * 512; } ulong imageOff = batOff * 512; - writingStream.Seek((long)imageOff, SeekOrigin.Begin); - writingStream.Seek((long)secOff * 512, SeekOrigin.Current); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)imageOff, SeekOrigin.Begin); + _writingStream.Seek((long)secOff * 512, SeekOrigin.Current); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -191,7 +191,7 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -239,45 +239,45 @@ namespace Aaru.DiscImages return false; } - if(pHdr.cylinders == 0) + if(_pHdr.cylinders == 0) { - pHdr.cylinders = (uint)(imageInfo.Sectors / 16 / 63); - pHdr.heads = 16; - imageInfo.SectorsPerTrack = 63; + _pHdr.cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _pHdr.heads = 16; + _imageInfo.SectorsPerTrack = 63; - while(pHdr.cylinders == 0) + while(_pHdr.cylinders == 0) { - pHdr.heads--; + _pHdr.heads--; - if(pHdr.heads == 0) + if(_pHdr.heads == 0) { - imageInfo.SectorsPerTrack--; - pHdr.heads = 16; + _imageInfo.SectorsPerTrack--; + _pHdr.heads = 16; } - pHdr.cylinders = (uint)(imageInfo.Sectors / pHdr.heads / imageInfo.SectorsPerTrack); + _pHdr.cylinders = (uint)(_imageInfo.Sectors / _pHdr.heads / _imageInfo.SectorsPerTrack); - if(pHdr.cylinders == 0 && - pHdr.heads == 0 && - imageInfo.SectorsPerTrack == 0) + if(_pHdr.cylinders == 0 && + _pHdr.heads == 0 && + _imageInfo.SectorsPerTrack == 0) break; } } byte[] hdr = new byte[Marshal.SizeOf()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); - System.Runtime.InteropServices.Marshal.StructureToPtr(pHdr, hdrPtr, true); + System.Runtime.InteropServices.Marshal.StructureToPtr(_pHdr, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(hdr, 0, hdr.Length); - for(long i = 0; i < bat.LongLength; i++) - writingStream.Write(BitConverter.GetBytes(bat[i]), 0, 4); + for(long i = 0; i < _bat.LongLength; i++) + _writingStream.Write(BitConverter.GetBytes(_bat[i]), 0, 4); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -289,8 +289,8 @@ namespace Aaru.DiscImages public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) { - pHdr.cylinders = cylinders; - pHdr.heads = heads; + _pHdr.cylinders = cylinders; + _pHdr.heads = heads; return true; } diff --git a/Aaru.Images/PartClone/Constants.cs b/Aaru.Images/PartClone/Constants.cs index 9548441d2..8cda4bf1f 100644 --- a/Aaru.Images/PartClone/Constants.cs +++ b/Aaru.Images/PartClone/Constants.cs @@ -37,11 +37,11 @@ namespace Aaru.DiscImages const int CRC_SIZE = 4; const uint MAX_CACHE_SIZE = 16777216; const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / 512; - readonly byte[] biTmAgIc = + readonly byte[] _biTmAgIc = { 0x42, 0x69, 0x54, 0x6D, 0x41, 0x67, 0x49, 0x63 }; - readonly byte[] partCloneMagic = + readonly byte[] _partCloneMagic = { 0x70, 0x61, 0x72, 0x74, 0x63, 0x6C, 0x6F, 0x6E, 0x65, 0x2D, 0x69, 0x6D, 0x61, 0x67, 0x65 }; diff --git a/Aaru.Images/PartClone/Helpers.cs b/Aaru.Images/PartClone/Helpers.cs index 5cf5cc333..8efbcd763 100644 --- a/Aaru.Images/PartClone/Helpers.cs +++ b/Aaru.Images/PartClone/Helpers.cs @@ -36,8 +36,8 @@ namespace Aaru.DiscImages { ulong BlockOffset(ulong sectorAddress) { - extents.GetStart(sectorAddress, out ulong extentStart); - extentsOff.TryGetValue(extentStart, out ulong extentStartingOffset); + _extents.GetStart(sectorAddress, out ulong extentStart); + _extentsOff.TryGetValue(extentStart, out ulong extentStartingOffset); return extentStartingOffset + (sectorAddress - extentStart); } diff --git a/Aaru.Images/PartClone/Identify.cs b/Aaru.Images/PartClone/Identify.cs index 73810ba07..7508fbc0f 100644 --- a/Aaru.Images/PartClone/Identify.cs +++ b/Aaru.Images/PartClone/Identify.cs @@ -49,17 +49,17 @@ namespace Aaru.DiscImages byte[] pHdrB = new byte[Marshal.SizeOf()]; stream.Read(pHdrB, 0, Marshal.SizeOf()); - pHdr = Marshal.ByteArrayToStructureLittleEndian(pHdrB); + _pHdr = Marshal.ByteArrayToStructureLittleEndian(pHdrB); - if(stream.Position + (long)pHdr.totalBlocks > stream.Length) + if(stream.Position + (long)_pHdr.totalBlocks > stream.Length) return false; - stream.Seek((long)pHdr.totalBlocks, SeekOrigin.Current); + stream.Seek((long)_pHdr.totalBlocks, SeekOrigin.Current); byte[] bitmagic = new byte[8]; stream.Read(bitmagic, 0, 8); - return partCloneMagic.SequenceEqual(pHdr.magic) && biTmAgIc.SequenceEqual(bitmagic); + return _partCloneMagic.SequenceEqual(_pHdr.magic) && _biTmAgIc.SequenceEqual(bitmagic); } } } \ No newline at end of file diff --git a/Aaru.Images/PartClone/PartClone.cs b/Aaru.Images/PartClone/PartClone.cs index c8f24a59c..d8780bf14 100644 --- a/Aaru.Images/PartClone/PartClone.cs +++ b/Aaru.Images/PartClone/PartClone.cs @@ -43,16 +43,16 @@ namespace Aaru.DiscImages { // The used block "bitmap" uses one byte per block // TODO: Convert on-image bytemap to on-memory bitmap - byte[] byteMap; - long dataOff; - ExtentsULong extents; - Dictionary extentsOff; - ImageInfo imageInfo; - Stream imageStream; - PartCloneHeader pHdr; - Dictionary sectorCache; + byte[] _byteMap; + long _dataOff; + ExtentsULong _extents; + Dictionary _extentsOff; + ImageInfo _imageInfo; + Stream _imageStream; + PartCloneHeader _pHdr; + Dictionary _sectorCache; - public PartClone() => imageInfo = new ImageInfo + public PartClone() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/PartClone/Properties.cs b/Aaru.Images/PartClone/Properties.cs index 098b6f2b2..c1c94f4e0 100644 --- a/Aaru.Images/PartClone/Properties.cs +++ b/Aaru.Images/PartClone/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public string Name => "PartClone disk image"; public Guid Id => new Guid("AB1D7518-B548-4099-A4E2-C29C53DDE0C3"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Format => "PartClone"; public List DumpHardware => null; diff --git a/Aaru.Images/PartClone/Read.cs b/Aaru.Images/PartClone/Read.cs index b4769f5fe..af772a852 100644 --- a/Aaru.Images/PartClone/Read.cs +++ b/Aaru.Images/PartClone/Read.cs @@ -56,59 +56,59 @@ namespace Aaru.DiscImages byte[] pHdrB = new byte[Marshal.SizeOf()]; stream.Read(pHdrB, 0, Marshal.SizeOf()); - pHdr = Marshal.ByteArrayToStructureLittleEndian(pHdrB); + _pHdr = Marshal.ByteArrayToStructureLittleEndian(pHdrB); - AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.magic = {0}", StringHandlers.CToString(pHdr.magic)); + AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.magic = {0}", StringHandlers.CToString(_pHdr.magic)); AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.filesystem = {0}", - StringHandlers.CToString(pHdr.filesystem)); + StringHandlers.CToString(_pHdr.filesystem)); AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.version = {0}", - StringHandlers.CToString(pHdr.version)); + StringHandlers.CToString(_pHdr.version)); - AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.blockSize = {0}", pHdr.blockSize); - AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.deviceSize = {0}", pHdr.deviceSize); - AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.totalBlocks = {0}", pHdr.totalBlocks); - AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.usedBlocks = {0}", pHdr.usedBlocks); + AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.blockSize = {0}", _pHdr.blockSize); + AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.deviceSize = {0}", _pHdr.deviceSize); + AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.totalBlocks = {0}", _pHdr.totalBlocks); + AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.usedBlocks = {0}", _pHdr.usedBlocks); - byteMap = new byte[pHdr.totalBlocks]; - AaruConsole.DebugWriteLine("PartClone plugin", "Reading bytemap {0} bytes", byteMap.Length); - stream.Read(byteMap, 0, byteMap.Length); + _byteMap = new byte[_pHdr.totalBlocks]; + AaruConsole.DebugWriteLine("PartClone plugin", "Reading bytemap {0} bytes", _byteMap.Length); + stream.Read(_byteMap, 0, _byteMap.Length); byte[] bitmagic = new byte[8]; stream.Read(bitmagic, 0, 8); AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.bitmagic = {0}", StringHandlers.CToString(bitmagic)); - if(!biTmAgIc.SequenceEqual(bitmagic)) + if(!_biTmAgIc.SequenceEqual(bitmagic)) throw new ImageNotSupportedException("Could not find partclone BiTmAgIc, not continuing..."); - dataOff = stream.Position; - AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.dataOff = {0}", dataOff); + _dataOff = stream.Position; + AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.dataOff = {0}", _dataOff); AaruConsole.DebugWriteLine("PartClone plugin", "Filling extents"); DateTime start = DateTime.Now; - extents = new ExtentsULong(); - extentsOff = new Dictionary(); - bool current = byteMap[0] > 0; + _extents = new ExtentsULong(); + _extentsOff = new Dictionary(); + bool current = _byteMap[0] > 0; ulong blockOff = 0; ulong extentStart = 0; - for(ulong i = 1; i < pHdr.totalBlocks; i++) + for(ulong i = 1; i < _pHdr.totalBlocks; i++) { - bool next = byteMap[i] > 0; + bool next = _byteMap[i] > 0; // Flux if(next != current) if(next) { extentStart = i; - extentsOff.Add(i, ++blockOff); + _extentsOff.Add(i, ++blockOff); } else { - extents.Add(extentStart, i); - extentsOff.TryGetValue(extentStart, out _); + _extents.Add(extentStart, i); + _extentsOff.TryGetValue(extentStart, out _); } if(next && current) @@ -122,54 +122,54 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("PartClone plugin", "Took {0} seconds to fill extents", (end - start).TotalSeconds); - sectorCache = new Dictionary(); + _sectorCache = new Dictionary(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = pHdr.totalBlocks; - imageInfo.SectorSize = pHdr.blockSize; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.ImageSize = (ulong)(stream.Length - (4096 + 0x40 + (long)pHdr.totalBlocks)); - imageStream = stream; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = _pHdr.totalBlocks; + _imageInfo.SectorSize = _pHdr.blockSize; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.ImageSize = (ulong)(stream.Length - (4096 + 0x40 + (long)_pHdr.totalBlocks)); + _imageStream = stream; return true; } public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(byteMap[sectorAddress] == 0) - return new byte[pHdr.blockSize]; + if(_byteMap[sectorAddress] == 0) + return new byte[_pHdr.blockSize]; - if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector; - long imageOff = dataOff + (long)(BlockOffset(sectorAddress) * (pHdr.blockSize + CRC_SIZE)); + long imageOff = _dataOff + (long)(BlockOffset(sectorAddress) * (_pHdr.blockSize + CRC_SIZE)); - sector = new byte[pHdr.blockSize]; - imageStream.Seek(imageOff, SeekOrigin.Begin); - imageStream.Read(sector, 0, (int)pHdr.blockSize); + sector = new byte[_pHdr.blockSize]; + _imageStream.Seek(imageOff, SeekOrigin.Begin); + _imageStream.Read(sector, 0, (int)_pHdr.blockSize); - if(sectorCache.Count > MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count > MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); @@ -177,7 +177,7 @@ namespace Aaru.DiscImages bool allEmpty = true; for(uint i = 0; i < length; i++) - if(byteMap[sectorAddress + i] != 0) + if(_byteMap[sectorAddress + i] != 0) { allEmpty = false; @@ -185,7 +185,7 @@ namespace Aaru.DiscImages } if(allEmpty) - return new byte[pHdr.blockSize * length]; + return new byte[_pHdr.blockSize * length]; for(uint i = 0; i < length; i++) { diff --git a/Aaru.Images/PartClone/Structs.cs b/Aaru.Images/PartClone/Structs.cs index 953fea72b..413d520d9 100644 --- a/Aaru.Images/PartClone/Structs.cs +++ b/Aaru.Images/PartClone/Structs.cs @@ -40,7 +40,7 @@ namespace Aaru.DiscImages [StructLayout(LayoutKind.Sequential, Pack = 1)] struct PartCloneHeader { - /// Magic, + /// Magic, [MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)] public readonly byte[] magic; /// Source filesystem diff --git a/Aaru.Images/Partimage/Constants.cs b/Aaru.Images/Partimage/Constants.cs index 051f9f334..3d191fb3e 100644 --- a/Aaru.Images/Partimage/Constants.cs +++ b/Aaru.Images/Partimage/Constants.cs @@ -65,7 +65,7 @@ namespace Aaru.DiscImages const string MAGIC_BEGIN_VOLUME = "PaRtImAgE-VoLuMe"; const uint MAX_CACHE_SIZE = 16777216; const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / 512; - readonly byte[] partimageMagic = + readonly byte[] _partimageMagic = { 0x50, 0x61, 0x52, 0x74, 0x49, 0x6D, 0x41, 0x67, 0x45, 0x2D, 0x56, 0x6F, 0x4C, 0x75, 0x4D, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/Aaru.Images/Partimage/Helpers.cs b/Aaru.Images/Partimage/Helpers.cs index bb48ea72b..dad208341 100644 --- a/Aaru.Images/Partimage/Helpers.cs +++ b/Aaru.Images/Partimage/Helpers.cs @@ -36,8 +36,8 @@ namespace Aaru.DiscImages { ulong BlockOffset(ulong sectorAddress) { - extents.GetStart(sectorAddress, out ulong extentStart); - extentsOff.TryGetValue(extentStart, out ulong extentStartingOffset); + _extents.GetStart(sectorAddress, out ulong extentStart); + _extentsOff.TryGetValue(extentStart, out ulong extentStartingOffset); return extentStartingOffset + (sectorAddress - extentStart); } diff --git a/Aaru.Images/Partimage/Identify.cs b/Aaru.Images/Partimage/Identify.cs index a32db594f..19bc0c263 100644 --- a/Aaru.Images/Partimage/Identify.cs +++ b/Aaru.Images/Partimage/Identify.cs @@ -49,9 +49,9 @@ namespace Aaru.DiscImages byte[] pHdrB = new byte[Marshal.SizeOf()]; stream.Read(pHdrB, 0, Marshal.SizeOf()); - cVolumeHeader = Marshal.ByteArrayToStructureLittleEndian(pHdrB); + _cVolumeHeader = Marshal.ByteArrayToStructureLittleEndian(pHdrB); - return partimageMagic.SequenceEqual(cVolumeHeader.magic); + return _partimageMagic.SequenceEqual(_cVolumeHeader.magic); } } } \ No newline at end of file diff --git a/Aaru.Images/Partimage/Partimage.cs b/Aaru.Images/Partimage/Partimage.cs index f981cf4e1..0b66cffe6 100644 --- a/Aaru.Images/Partimage/Partimage.cs +++ b/Aaru.Images/Partimage/Partimage.cs @@ -43,17 +43,17 @@ namespace Aaru.DiscImages { public partial class Partimage : IMediaImage, IVerifiableImage { - byte[] bitmap; - PartimageMainHeader cMainHeader; - PartimageHeader cVolumeHeader; - long dataOff; - ExtentsULong extents; - Dictionary extentsOff; - ImageInfo imageInfo; - Stream imageStream; - Dictionary sectorCache; + byte[] _bitmap; + PartimageMainHeader _cMainHeader; + PartimageHeader _cVolumeHeader; + long _dataOff; + ExtentsULong _extents; + Dictionary _extentsOff; + ImageInfo _imageInfo; + Stream _imageStream; + Dictionary _sectorCache; - public Partimage() => imageInfo = new ImageInfo + public Partimage() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/Partimage/Properties.cs b/Aaru.Images/Partimage/Properties.cs index bd23b9a10..131bf9405 100644 --- a/Aaru.Images/Partimage/Properties.cs +++ b/Aaru.Images/Partimage/Properties.cs @@ -39,7 +39,7 @@ namespace Aaru.DiscImages { public partial class Partimage { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Partimage disk image"; public Guid Id => new Guid("AAFDB99D-2B77-49EA-831C-C9BB58C68C95"); diff --git a/Aaru.Images/Partimage/Read.cs b/Aaru.Images/Partimage/Read.cs index 39cfe7a03..e427212ce 100644 --- a/Aaru.Images/Partimage/Read.cs +++ b/Aaru.Images/Partimage/Read.cs @@ -55,160 +55,160 @@ namespace Aaru.DiscImages byte[] hdrB = new byte[Marshal.SizeOf()]; stream.Read(hdrB, 0, Marshal.SizeOf()); - cVolumeHeader = Marshal.ByteArrayToStructureLittleEndian(hdrB); + _cVolumeHeader = Marshal.ByteArrayToStructureLittleEndian(hdrB); AaruConsole.DebugWriteLine("Partimage plugin", "CVolumeHeader.magic = {0}", - StringHandlers.CToString(cVolumeHeader.magic)); + StringHandlers.CToString(_cVolumeHeader.magic)); AaruConsole.DebugWriteLine("Partimage plugin", "CVolumeHeader.version = {0}", - StringHandlers.CToString(cVolumeHeader.version)); + StringHandlers.CToString(_cVolumeHeader.version)); AaruConsole.DebugWriteLine("Partimage plugin", "CVolumeHeader.volumeNumber = {0}", - cVolumeHeader.volumeNumber); + _cVolumeHeader.volumeNumber); AaruConsole.DebugWriteLine("Partimage plugin", "CVolumeHeader.identificator = {0:X16}", - cVolumeHeader.identificator); + _cVolumeHeader.identificator); // TODO: Support multifile volumes - if(cVolumeHeader.volumeNumber > 0) + if(_cVolumeHeader.volumeNumber > 0) throw new FeatureSupportedButNotImplementedImageException("Support for multiple volumes not supported"); hdrB = new byte[Marshal.SizeOf()]; stream.Read(hdrB, 0, Marshal.SizeOf()); - cMainHeader = Marshal.ByteArrayToStructureLittleEndian(hdrB); + _cMainHeader = Marshal.ByteArrayToStructureLittleEndian(hdrB); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szFileSystem = {0}", - StringHandlers.CToString(cMainHeader.szFileSystem)); + StringHandlers.CToString(_cMainHeader.szFileSystem)); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szPartDescription = {0}", - StringHandlers.CToString(cMainHeader.szPartDescription)); + StringHandlers.CToString(_cMainHeader.szPartDescription)); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szOriginalDevice = {0}", - StringHandlers.CToString(cMainHeader.szOriginalDevice)); + StringHandlers.CToString(_cMainHeader.szOriginalDevice)); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szFirstImageFilepath = {0}", - StringHandlers.CToString(cMainHeader.szFirstImageFilepath)); + StringHandlers.CToString(_cMainHeader.szFirstImageFilepath)); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szUnameSysname = {0}", - StringHandlers.CToString(cMainHeader.szUnameSysname)); + StringHandlers.CToString(_cMainHeader.szUnameSysname)); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szUnameNodename = {0}", - StringHandlers.CToString(cMainHeader.szUnameNodename)); + StringHandlers.CToString(_cMainHeader.szUnameNodename)); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szUnameRelease = {0}", - StringHandlers.CToString(cMainHeader.szUnameRelease)); + StringHandlers.CToString(_cMainHeader.szUnameRelease)); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szUnameVersion = {0}", - StringHandlers.CToString(cMainHeader.szUnameVersion)); + StringHandlers.CToString(_cMainHeader.szUnameVersion)); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szUnameMachine = {0}", - StringHandlers.CToString(cMainHeader.szUnameMachine)); + StringHandlers.CToString(_cMainHeader.szUnameMachine)); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwCompression = {0} ({1})", - cMainHeader.dwCompression, (uint)cMainHeader.dwCompression); + _cMainHeader.dwCompression, (uint)_cMainHeader.dwCompression); - AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwMainFlags = {0}", cMainHeader.dwMainFlags); + AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwMainFlags = {0}", _cMainHeader.dwMainFlags); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate.tm_sec = {0}", - cMainHeader.dateCreate.Second); + _cMainHeader.dateCreate.Second); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate.tm_min = {0}", - cMainHeader.dateCreate.Minute); + _cMainHeader.dateCreate.Minute); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate.tm_hour = {0}", - cMainHeader.dateCreate.Hour); + _cMainHeader.dateCreate.Hour); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate.tm_mday = {0}", - cMainHeader.dateCreate.DayOfMonth); + _cMainHeader.dateCreate.DayOfMonth); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate.tm_mon = {0}", - cMainHeader.dateCreate.Month); + _cMainHeader.dateCreate.Month); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate.tm_year = {0}", - cMainHeader.dateCreate.Year); + _cMainHeader.dateCreate.Year); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate.tm_wday = {0}", - cMainHeader.dateCreate.DayOfWeek); + _cMainHeader.dateCreate.DayOfWeek); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate.tm_yday = {0}", - cMainHeader.dateCreate.DayOfYear); + _cMainHeader.dateCreate.DayOfYear); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate.tm_isdst = {0}", - cMainHeader.dateCreate.IsDst); + _cMainHeader.dateCreate.IsDst); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate.tm_gmtoffsec = {0}", - cMainHeader.dateCreate.GmtOff); + _cMainHeader.dateCreate.GmtOff); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate.tm_zone = {0}", - cMainHeader.dateCreate.Timezone); + _cMainHeader.dateCreate.Timezone); - var dateCreate = new DateTime(1900 + (int)cMainHeader.dateCreate.Year, - (int)cMainHeader.dateCreate.Month + 1, (int)cMainHeader.dateCreate.DayOfMonth, - (int)cMainHeader.dateCreate.Hour, (int)cMainHeader.dateCreate.Minute, - (int)cMainHeader.dateCreate.Second); + var dateCreate = new DateTime(1900 + (int)_cMainHeader.dateCreate.Year, + (int)_cMainHeader.dateCreate.Month + 1, + (int)_cMainHeader.dateCreate.DayOfMonth, (int)_cMainHeader.dateCreate.Hour, + (int)_cMainHeader.dateCreate.Minute, (int)_cMainHeader.dateCreate.Second); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dateCreate = {0}", dateCreate); - AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.qwPartSize = {0}", cMainHeader.qwPartSize); + AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.qwPartSize = {0}", _cMainHeader.qwPartSize); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szHostname = {0}", - StringHandlers.CToString(cMainHeader.szHostname)); + StringHandlers.CToString(_cMainHeader.szHostname)); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.szVersion = {0}", - StringHandlers.CToString(cMainHeader.szVersion)); + StringHandlers.CToString(_cMainHeader.szVersion)); - AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwMbrCount = {0}", cMainHeader.dwMbrCount); - AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwMbrSize = {0}", cMainHeader.dwMbrSize); + AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwMbrCount = {0}", _cMainHeader.dwMbrCount); + AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwMbrSize = {0}", _cMainHeader.dwMbrSize); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwEncryptAlgo = {0} ({1})", - cMainHeader.dwEncryptAlgo, (uint)cMainHeader.dwEncryptAlgo); + _cMainHeader.dwEncryptAlgo, (uint)_cMainHeader.dwEncryptAlgo); AaruConsole.DebugWriteLine("Partimage plugin", "ArrayIsNullOrEmpty(CMainHeader.cHashTestKey) = {0}", - ArrayHelpers.ArrayIsNullOrEmpty(cMainHeader.cHashTestKey)); + ArrayHelpers.ArrayIsNullOrEmpty(_cMainHeader.cHashTestKey)); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwReservedFuture000 = {0}", - cMainHeader.dwReservedFuture000); + _cMainHeader.dwReservedFuture000); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwReservedFuture001 = {0}", - cMainHeader.dwReservedFuture001); + _cMainHeader.dwReservedFuture001); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwReservedFuture002 = {0}", - cMainHeader.dwReservedFuture002); + _cMainHeader.dwReservedFuture002); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwReservedFuture003 = {0}", - cMainHeader.dwReservedFuture003); + _cMainHeader.dwReservedFuture003); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwReservedFuture004 = {0}", - cMainHeader.dwReservedFuture004); + _cMainHeader.dwReservedFuture004); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwReservedFuture005 = {0}", - cMainHeader.dwReservedFuture005); + _cMainHeader.dwReservedFuture005); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwReservedFuture006 = {0}", - cMainHeader.dwReservedFuture006); + _cMainHeader.dwReservedFuture006); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwReservedFuture007 = {0}", - cMainHeader.dwReservedFuture007); + _cMainHeader.dwReservedFuture007); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwReservedFuture008 = {0}", - cMainHeader.dwReservedFuture008); + _cMainHeader.dwReservedFuture008); AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.dwReservedFuture009 = {0}", - cMainHeader.dwReservedFuture009); + _cMainHeader.dwReservedFuture009); AaruConsole.DebugWriteLine("Partimage plugin", "ArrayIsNullOrEmpty(CMainHeader.cReserved) = {0}", - ArrayHelpers.ArrayIsNullOrEmpty(cMainHeader.cReserved)); + ArrayHelpers.ArrayIsNullOrEmpty(_cMainHeader.cReserved)); - AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.crc = 0x{0:X8}", cMainHeader.crc); + AaruConsole.DebugWriteLine("Partimage plugin", "CMainHeader.crc = 0x{0:X8}", _cMainHeader.crc); // partimage 0.6.1 does not support them either - if(cMainHeader.dwEncryptAlgo != PEncryption.None) + if(_cMainHeader.dwEncryptAlgo != PEncryption.None) throw new ImageNotSupportedException("Encrypted images are currently not supported."); string magic; // Skip MBRs - if(cMainHeader.dwMbrCount > 0) + if(_cMainHeader.dwMbrCount > 0) { hdrB = new byte[MAGIC_BEGIN_MBRBACKUP.Length]; stream.Read(hdrB, 0, MAGIC_BEGIN_MBRBACKUP.Length); @@ -217,7 +217,7 @@ namespace Aaru.DiscImages if(!magic.Equals(MAGIC_BEGIN_MBRBACKUP)) throw new ImageNotSupportedException("Cannot find MBRs"); - stream.Seek(cMainHeader.dwMbrSize * cMainHeader.dwMbrCount, SeekOrigin.Current); + stream.Seek(_cMainHeader.dwMbrSize * _cMainHeader.dwMbrCount, SeekOrigin.Current); } // Skip extended headers and their CRC fields @@ -260,8 +260,8 @@ namespace Aaru.DiscImages if(!magic.Equals(MAGIC_BEGIN_BITMAP)) throw new ImageNotSupportedException("Cannot find bitmap"); - bitmap = new byte[localHeader.qwBitmapSize]; - stream.Read(bitmap, 0, (int)localHeader.qwBitmapSize); + _bitmap = new byte[localHeader.qwBitmapSize]; + stream.Read(_bitmap, 0, (int)localHeader.qwBitmapSize); hdrB = new byte[MAGIC_BEGIN_INFO.Length]; stream.Read(hdrB, 0, MAGIC_BEGIN_INFO.Length); @@ -280,9 +280,9 @@ namespace Aaru.DiscImages if(!magic.Equals(MAGIC_BEGIN_DATABLOCKS)) throw new ImageNotSupportedException("Cannot find data blocks"); - dataOff = stream.Position; + _dataOff = stream.Position; - AaruConsole.DebugWriteLine("Partimage plugin", "dataOff = {0}", dataOff); + AaruConsole.DebugWriteLine("Partimage plugin", "dataOff = {0}", _dataOff); // Seek to tail stream.Seek(-(Marshal.SizeOf() + MAGIC_BEGIN_TAIL.Length), SeekOrigin.End); @@ -297,27 +297,27 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Partimage plugin", "Filling extents"); DateTime start = DateTime.Now; - extents = new ExtentsULong(); - extentsOff = new Dictionary(); - bool current = (bitmap[0] & (1 << (0 % 8))) != 0; + _extents = new ExtentsULong(); + _extentsOff = new Dictionary(); + bool current = (_bitmap[0] & (1 << (0 % 8))) != 0; ulong blockOff = 0; ulong extentStart = 0; for(ulong i = 1; i <= localHeader.qwBlocksCount; i++) { - bool next = (bitmap[i / 8] & (1 << (int)(i % 8))) != 0; + bool next = (_bitmap[i / 8] & (1 << (int)(i % 8))) != 0; // Flux if(next != current) if(next) { extentStart = i; - extentsOff.Add(i, ++blockOff); + _extentsOff.Add(i, ++blockOff); } else { - extents.Add(extentStart, i); - extentsOff.TryGetValue(extentStart, out ulong _); + _extents.Add(extentStart, i); + _extentsOff.TryGetValue(extentStart, out ulong _); } if(next && current) @@ -331,69 +331,69 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("Partimage plugin", "Took {0} seconds to fill extents", (end - start).TotalSeconds); - sectorCache = new Dictionary(); + _sectorCache = new Dictionary(); - imageInfo.CreationTime = dateCreate; - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = localHeader.qwBlocksCount + 1; - imageInfo.SectorSize = (uint)localHeader.qwBlockSize; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.Version = StringHandlers.CToString(cMainHeader.szVersion); - imageInfo.Comments = StringHandlers.CToString(cMainHeader.szPartDescription); + _imageInfo.CreationTime = dateCreate; + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = localHeader.qwBlocksCount + 1; + _imageInfo.SectorSize = (uint)localHeader.qwBlockSize; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.Version = StringHandlers.CToString(_cMainHeader.szVersion); + _imageInfo.Comments = StringHandlers.CToString(_cMainHeader.szPartDescription); - imageInfo.ImageSize = - (ulong)(stream.Length - (dataOff + Marshal.SizeOf() + MAGIC_BEGIN_TAIL.Length)); + _imageInfo.ImageSize = + (ulong)(stream.Length - (_dataOff + Marshal.SizeOf() + MAGIC_BEGIN_TAIL.Length)); - imageStream = stream; + _imageStream = stream; return true; } public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if((bitmap[sectorAddress / 8] & (1 << (int)(sectorAddress % 8))) == 0) - return new byte[imageInfo.SectorSize]; + if((_bitmap[sectorAddress / 8] & (1 << (int)(sectorAddress % 8))) == 0) + return new byte[_imageInfo.SectorSize]; - if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector; ulong blockOff = BlockOffset(sectorAddress); // Offset of requested sector is: // Start of data + - long imageOff = dataOff + + long imageOff = _dataOff + // How many stored bytes to skip - (long)(blockOff * imageInfo.SectorSize) + + (long)(blockOff * _imageInfo.SectorSize) + // How many bytes of CRC blocks to skip - ((long)(blockOff / (CHECK_FREQUENCY / imageInfo.SectorSize)) * Marshal.SizeOf()); + ((long)(blockOff / (CHECK_FREQUENCY / _imageInfo.SectorSize)) * Marshal.SizeOf()); - sector = new byte[imageInfo.SectorSize]; - imageStream.Seek(imageOff, SeekOrigin.Begin); - imageStream.Read(sector, 0, (int)imageInfo.SectorSize); + sector = new byte[_imageInfo.SectorSize]; + _imageStream.Seek(imageOff, SeekOrigin.Begin); + _imageStream.Read(sector, 0, (int)_imageInfo.SectorSize); - if(sectorCache.Count > MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count > MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); @@ -401,7 +401,7 @@ namespace Aaru.DiscImages bool allEmpty = true; for(uint i = 0; i < length; i++) - if((bitmap[sectorAddress / 8] & (1 << (int)(sectorAddress % 8))) != 0) + if((_bitmap[sectorAddress / 8] & (1 << (int)(sectorAddress % 8))) != 0) { allEmpty = false; @@ -409,7 +409,7 @@ namespace Aaru.DiscImages } if(allEmpty) - return new byte[imageInfo.SectorSize * length]; + return new byte[_imageInfo.SectorSize * length]; for(uint i = 0; i < length; i++) { diff --git a/Aaru.Images/Partimage/Structs.cs b/Aaru.Images/Partimage/Structs.cs index 83ca237ec..4cb4c5594 100644 --- a/Aaru.Images/Partimage/Structs.cs +++ b/Aaru.Images/Partimage/Structs.cs @@ -42,7 +42,7 @@ namespace Aaru.DiscImages [StructLayout(LayoutKind.Sequential, Pack = 1)] struct PartimageHeader { - /// Magic, + /// Magic, [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public readonly byte[] magic; /// Source filesystem diff --git a/Aaru.Images/QCOW/Identify.cs b/Aaru.Images/QCOW/Identify.cs index c1857935b..d4aa9cfa2 100644 --- a/Aaru.Images/QCOW/Identify.cs +++ b/Aaru.Images/QCOW/Identify.cs @@ -48,9 +48,9 @@ namespace Aaru.DiscImages byte[] qHdrB = new byte[48]; stream.Read(qHdrB, 0, 48); - qHdr = Marshal.SpanToStructureBigEndian(qHdrB); + _qHdr = Marshal.SpanToStructureBigEndian(qHdrB); - return qHdr.magic == QCOW_MAGIC && qHdr.version == QCOW_VERSION; + return _qHdr.magic == QCOW_MAGIC && _qHdr.version == QCOW_VERSION; } } } \ No newline at end of file diff --git a/Aaru.Images/QCOW/Properties.cs b/Aaru.Images/QCOW/Properties.cs index a6c5adbe8..4d34bc2a7 100644 --- a/Aaru.Images/QCOW/Properties.cs +++ b/Aaru.Images/QCOW/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class Qcow { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "QEMU Copy-On-Write disk image"; public Guid Id => new Guid("A5C35765-9FE2-469D-BBBF-ACDEBDB7B954"); diff --git a/Aaru.Images/QCOW/QCOW.cs b/Aaru.Images/QCOW/QCOW.cs index 70b6d7a85..9d2d0b642 100644 --- a/Aaru.Images/QCOW/QCOW.cs +++ b/Aaru.Images/QCOW/QCOW.cs @@ -40,26 +40,26 @@ namespace Aaru.DiscImages { public partial class Qcow : IWritableImage { - Dictionary clusterCache; - int clusterSectors; - int clusterSize; - ImageInfo imageInfo; - Stream imageStream; - ulong l1Mask; - int l1Shift; - uint l1Size; - ulong[] l1Table; - ulong l2Mask; - int l2Size; - Dictionary l2TableCache; - int maxClusterCache; - int maxL2TableCache; - QCowHeader qHdr; - Dictionary sectorCache; - ulong sectorMask; - FileStream writingStream; + Dictionary _clusterCache; + int _clusterSectors; + int _clusterSize; + ImageInfo _imageInfo; + Stream _imageStream; + ulong _l1Mask; + int _l1Shift; + uint _l1Size; + ulong[] _l1Table; + ulong _l2Mask; + int _l2Size; + Dictionary _l2TableCache; + int _maxClusterCache; + int _maxL2TableCache; + QCowHeader _qHdr; + Dictionary _sectorCache; + ulong _sectorMask; + FileStream _writingStream; - public Qcow() => imageInfo = new ImageInfo + public Qcow() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/QCOW/Read.cs b/Aaru.Images/QCOW/Read.cs index 85976b285..8a96dbef6 100644 --- a/Aaru.Images/QCOW/Read.cs +++ b/Aaru.Images/QCOW/Read.cs @@ -57,167 +57,167 @@ namespace Aaru.DiscImages byte[] qHdrB = new byte[48]; stream.Read(qHdrB, 0, 48); - qHdr = Marshal.SpanToStructureBigEndian(qHdrB); + _qHdr = Marshal.SpanToStructureBigEndian(qHdrB); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.magic = 0x{0:X8}", qHdr.magic); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.version = {0}", qHdr.version); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.backing_file_offset = {0}", qHdr.backing_file_offset); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.backing_file_size = {0}", qHdr.backing_file_size); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.mtime = {0}", qHdr.mtime); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.size = {0}", qHdr.size); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.cluster_bits = {0}", qHdr.cluster_bits); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l2_bits = {0}", qHdr.l2_bits); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.padding = {0}", qHdr.padding); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.crypt_method = {0}", qHdr.crypt_method); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1_table_offset = {0}", qHdr.l1_table_offset); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.magic = 0x{0:X8}", _qHdr.magic); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.version = {0}", _qHdr.version); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.backing_file_offset = {0}", _qHdr.backing_file_offset); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.backing_file_size = {0}", _qHdr.backing_file_size); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.mtime = {0}", _qHdr.mtime); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.size = {0}", _qHdr.size); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.cluster_bits = {0}", _qHdr.cluster_bits); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l2_bits = {0}", _qHdr.l2_bits); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.padding = {0}", _qHdr.padding); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.crypt_method = {0}", _qHdr.crypt_method); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1_table_offset = {0}", _qHdr.l1_table_offset); - if(qHdr.size <= 1) - throw new ArgumentOutOfRangeException(nameof(qHdr.size), "Image size is too small"); + if(_qHdr.size <= 1) + throw new ArgumentOutOfRangeException(nameof(_qHdr.size), "Image size is too small"); - if(qHdr.cluster_bits < 9 || - qHdr.cluster_bits > 16) - throw new ArgumentOutOfRangeException(nameof(qHdr.cluster_bits), + if(_qHdr.cluster_bits < 9 || + _qHdr.cluster_bits > 16) + throw new ArgumentOutOfRangeException(nameof(_qHdr.cluster_bits), "Cluster size must be between 512 bytes and 64 Kbytes"); - if(qHdr.l2_bits < 9 - 3 || - qHdr.l2_bits > 16 - 3) - throw new ArgumentOutOfRangeException(nameof(qHdr.l2_bits), + if(_qHdr.l2_bits < 9 - 3 || + _qHdr.l2_bits > 16 - 3) + throw new ArgumentOutOfRangeException(nameof(_qHdr.l2_bits), "L2 size must be between 512 bytes and 64 Kbytes"); - if(qHdr.crypt_method > QCOW_ENCRYPTION_AES) - throw new ArgumentOutOfRangeException(nameof(qHdr.crypt_method), "Invalid encryption method"); + if(_qHdr.crypt_method > QCOW_ENCRYPTION_AES) + throw new ArgumentOutOfRangeException(nameof(_qHdr.crypt_method), "Invalid encryption method"); - if(qHdr.crypt_method > QCOW_ENCRYPTION_NONE) + if(_qHdr.crypt_method > QCOW_ENCRYPTION_NONE) throw new NotImplementedException("AES encrypted images not yet supported"); - if(qHdr.backing_file_offset != 0) + if(_qHdr.backing_file_offset != 0) throw new NotImplementedException("Differencing images not yet supported"); - int shift = qHdr.cluster_bits + qHdr.l2_bits; + int shift = _qHdr.cluster_bits + _qHdr.l2_bits; - if(qHdr.size > ulong.MaxValue - (ulong)(1 << shift)) - throw new ArgumentOutOfRangeException(nameof(qHdr.size), "Image is too large"); + if(_qHdr.size > ulong.MaxValue - (ulong)(1 << shift)) + throw new ArgumentOutOfRangeException(nameof(_qHdr.size), "Image is too large"); - clusterSize = 1 << qHdr.cluster_bits; - clusterSectors = 1 << (qHdr.cluster_bits - 9); - l1Size = (uint)(((qHdr.size + (ulong)(1 << shift)) - 1) >> shift); - l2Size = 1 << qHdr.l2_bits; + _clusterSize = 1 << _qHdr.cluster_bits; + _clusterSectors = 1 << (_qHdr.cluster_bits - 9); + _l1Size = (uint)(((_qHdr.size + (ulong)(1 << shift)) - 1) >> shift); + _l2Size = 1 << _qHdr.l2_bits; - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.clusterSize = {0}", clusterSize); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.clusterSectors = {0}", clusterSectors); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1Size = {0}", l1Size); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l2Size = {0}", l2Size); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.sectors = {0}", imageInfo.Sectors); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.clusterSize = {0}", _clusterSize); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.clusterSectors = {0}", _clusterSectors); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1Size = {0}", _l1Size); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l2Size = {0}", _l2Size); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.sectors = {0}", _imageInfo.Sectors); - byte[] l1TableB = new byte[l1Size * 8]; - stream.Seek((long)qHdr.l1_table_offset, SeekOrigin.Begin); - stream.Read(l1TableB, 0, (int)l1Size * 8); - l1Table = MemoryMarshal.Cast(l1TableB).ToArray(); + byte[] l1TableB = new byte[_l1Size * 8]; + stream.Seek((long)_qHdr.l1_table_offset, SeekOrigin.Begin); + stream.Read(l1TableB, 0, (int)_l1Size * 8); + _l1Table = MemoryMarshal.Cast(l1TableB).ToArray(); AaruConsole.DebugWriteLine("QCOW plugin", "Reading L1 table"); - for(long i = 0; i < l1Table.LongLength; i++) - l1Table[i] = Swapping.Swap(l1Table[i]); + for(long i = 0; i < _l1Table.LongLength; i++) + _l1Table[i] = Swapping.Swap(_l1Table[i]); - l1Mask = 0; + _l1Mask = 0; int c = 0; - l1Shift = qHdr.l2_bits + qHdr.cluster_bits; + _l1Shift = _qHdr.l2_bits + _qHdr.cluster_bits; for(int i = 0; i < 64; i++) { - l1Mask <<= 1; + _l1Mask <<= 1; - if(c >= 64 - l1Shift) + if(c >= 64 - _l1Shift) continue; - l1Mask += 1; + _l1Mask += 1; c++; } - l2Mask = 0; + _l2Mask = 0; - for(int i = 0; i < qHdr.l2_bits; i++) - l2Mask = (l2Mask << 1) + 1; + for(int i = 0; i < _qHdr.l2_bits; i++) + _l2Mask = (_l2Mask << 1) + 1; - l2Mask <<= qHdr.cluster_bits; + _l2Mask <<= _qHdr.cluster_bits; - sectorMask = 0; + _sectorMask = 0; - for(int i = 0; i < qHdr.cluster_bits; i++) - sectorMask = (sectorMask << 1) + 1; + for(int i = 0; i < _qHdr.cluster_bits; i++) + _sectorMask = (_sectorMask << 1) + 1; - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1Mask = {0:X}", l1Mask); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1Shift = {0}", l1Shift); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l2Mask = {0:X}", l2Mask); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.sectorMask = {0:X}", sectorMask); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1Mask = {0:X}", _l1Mask); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1Shift = {0}", _l1Shift); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l2Mask = {0:X}", _l2Mask); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.sectorMask = {0:X}", _sectorMask); - maxL2TableCache = MAX_CACHE_SIZE / (l2Size * 8); - maxClusterCache = MAX_CACHE_SIZE / clusterSize; + _maxL2TableCache = MAX_CACHE_SIZE / (_l2Size * 8); + _maxClusterCache = MAX_CACHE_SIZE / _clusterSize; - imageStream = stream; + _imageStream = stream; - sectorCache = new Dictionary(); - l2TableCache = new Dictionary(); - clusterCache = new Dictionary(); + _sectorCache = new Dictionary(); + _l2TableCache = new Dictionary(); + _clusterCache = new Dictionary(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = qHdr.mtime > 0 ? DateHandlers.UnixUnsignedToDateTime(qHdr.mtime) - : imageFilter.GetLastWriteTime(); + _imageInfo.LastModificationTime = _qHdr.mtime > 0 ? DateHandlers.UnixUnsignedToDateTime(_qHdr.mtime) + : imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = qHdr.size / 512; - imageInfo.SectorSize = 512; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.ImageSize = qHdr.size; + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = _qHdr.size / 512; + _imageInfo.SectorSize = 512; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.ImageSize = _qHdr.size; - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; return true; } public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); // Check cache - if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector; ulong byteAddress = sectorAddress * 512; - ulong l1Off = (byteAddress & l1Mask) >> l1Shift; + ulong l1Off = (byteAddress & _l1Mask) >> _l1Shift; - if((long)l1Off >= l1Table.LongLength) + if((long)l1Off >= _l1Table.LongLength) throw new ArgumentOutOfRangeException(nameof(l1Off), - $"Trying to read past L1 table, position {l1Off} of a max {l1Table.LongLength}"); + $"Trying to read past L1 table, position {l1Off} of a max {_l1Table.LongLength}"); // TODO: Implement differential images - if(l1Table[l1Off] == 0) + if(_l1Table[l1Off] == 0) return new byte[512]; - if(!l2TableCache.TryGetValue(l1Off, out ulong[] l2Table)) + if(!_l2TableCache.TryGetValue(l1Off, out ulong[] l2Table)) { - imageStream.Seek((long)l1Table[l1Off], SeekOrigin.Begin); - byte[] l2TableB = new byte[l2Size * 8]; - imageStream.Read(l2TableB, 0, l2Size * 8); + _imageStream.Seek((long)_l1Table[l1Off], SeekOrigin.Begin); + byte[] l2TableB = new byte[_l2Size * 8]; + _imageStream.Read(l2TableB, 0, _l2Size * 8); AaruConsole.DebugWriteLine("QCOW plugin", "Reading L2 table #{0}", l1Off); l2Table = MemoryMarshal.Cast(l2TableB).ToArray(); for(long i = 0; i < l2Table.LongLength; i++) l2Table[i] = Swapping.Swap(l2Table[i]); - if(l2TableCache.Count >= maxL2TableCache) - l2TableCache.Clear(); + if(_l2TableCache.Count >= _maxL2TableCache) + _l2TableCache.Clear(); - l2TableCache.Add(l1Off, l2Table); + _l2TableCache.Add(l1Off, l2Table); } - ulong l2Off = (byteAddress & l2Mask) >> qHdr.cluster_bits; + ulong l2Off = (byteAddress & _l2Mask) >> _qHdr.cluster_bits; ulong offset = l2Table[l2Off]; @@ -225,60 +225,60 @@ namespace Aaru.DiscImages if(offset != 0) { - if(!clusterCache.TryGetValue(offset, out byte[] cluster)) + if(!_clusterCache.TryGetValue(offset, out byte[] cluster)) { if((offset & QCOW_COMPRESSED) == QCOW_COMPRESSED) { - ulong compSizeMask = (ulong)(1 << qHdr.cluster_bits) - 1; - compSizeMask <<= 63 - qHdr.cluster_bits; + ulong compSizeMask = (ulong)(1 << _qHdr.cluster_bits) - 1; + compSizeMask <<= 63 - _qHdr.cluster_bits; ulong offMask = ~compSizeMask ^ QCOW_COMPRESSED; ulong realOff = offset & offMask; - ulong compSize = (offset & compSizeMask) >> (63 - qHdr.cluster_bits); + ulong compSize = (offset & compSizeMask) >> (63 - _qHdr.cluster_bits); byte[] zCluster = new byte[compSize]; - imageStream.Seek((long)realOff, SeekOrigin.Begin); - imageStream.Read(zCluster, 0, (int)compSize); + _imageStream.Seek((long)realOff, SeekOrigin.Begin); + _imageStream.Read(zCluster, 0, (int)compSize); var zStream = new DeflateStream(new MemoryStream(zCluster), CompressionMode.Decompress); - cluster = new byte[clusterSize]; - int read = zStream.Read(cluster, 0, clusterSize); + cluster = new byte[_clusterSize]; + int read = zStream.Read(cluster, 0, _clusterSize); - if(read != clusterSize) + if(read != _clusterSize) throw new - IOException($"Unable to decompress cluster, expected {clusterSize} bytes got {read}"); + IOException($"Unable to decompress cluster, expected {_clusterSize} bytes got {read}"); } else { - cluster = new byte[clusterSize]; - imageStream.Seek((long)offset, SeekOrigin.Begin); - imageStream.Read(cluster, 0, clusterSize); + cluster = new byte[_clusterSize]; + _imageStream.Seek((long)offset, SeekOrigin.Begin); + _imageStream.Read(cluster, 0, _clusterSize); } - if(clusterCache.Count >= maxClusterCache) - clusterCache.Clear(); + if(_clusterCache.Count >= _maxClusterCache) + _clusterCache.Clear(); - clusterCache.Add(offset, cluster); + _clusterCache.Add(offset, cluster); } - Array.Copy(cluster, (int)(byteAddress & sectorMask), sector, 0, 512); + Array.Copy(cluster, (int)(byteAddress & _sectorMask), sector, 0, 512); } - if(sectorCache.Count >= MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count >= MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); diff --git a/Aaru.Images/QCOW/Write.cs b/Aaru.Images/QCOW/Write.cs index fcfef9c79..1d411cfc0 100644 --- a/Aaru.Images/QCOW/Write.cs +++ b/Aaru.Images/QCOW/Write.cs @@ -71,7 +71,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -80,7 +80,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -89,7 +89,7 @@ namespace Aaru.DiscImages return false; } - qHdr = new QCowHeader + _qHdr = new QCowHeader { magic = QCOW_MAGIC, version = QCOW_VERSION, @@ -99,43 +99,43 @@ namespace Aaru.DiscImages l1_table_offset = (ulong)Marshal.SizeOf() }; - int shift = qHdr.cluster_bits + qHdr.l2_bits; - clusterSize = 1 << qHdr.cluster_bits; - clusterSectors = 1 << (qHdr.cluster_bits - 9); - l1Size = (uint)(((qHdr.size + (ulong)(1 << shift)) - 1) >> shift); - l2Size = 1 << qHdr.l2_bits; + int shift = _qHdr.cluster_bits + _qHdr.l2_bits; + _clusterSize = 1 << _qHdr.cluster_bits; + _clusterSectors = 1 << (_qHdr.cluster_bits - 9); + _l1Size = (uint)(((_qHdr.size + (ulong)(1 << shift)) - 1) >> shift); + _l2Size = 1 << _qHdr.l2_bits; - l1Table = new ulong[l1Size]; + _l1Table = new ulong[_l1Size]; - l1Mask = 0; + _l1Mask = 0; int c = 0; - l1Shift = qHdr.l2_bits + qHdr.cluster_bits; + _l1Shift = _qHdr.l2_bits + _qHdr.cluster_bits; for(int i = 0; i < 64; i++) { - l1Mask <<= 1; + _l1Mask <<= 1; - if(c >= 64 - l1Shift) + if(c >= 64 - _l1Shift) continue; - l1Mask += 1; + _l1Mask += 1; c++; } - l2Mask = 0; + _l2Mask = 0; - for(int i = 0; i < qHdr.l2_bits; i++) - l2Mask = (l2Mask << 1) + 1; + for(int i = 0; i < _qHdr.l2_bits; i++) + _l2Mask = (_l2Mask << 1) + 1; - l2Mask <<= qHdr.cluster_bits; + _l2Mask <<= _qHdr.cluster_bits; - sectorMask = 0; + _sectorMask = 0; - for(int i = 0; i < qHdr.cluster_bits; i++) - sectorMask = (sectorMask << 1) + 1; + for(int i = 0; i < _qHdr.cluster_bits; i++) + _sectorMask = (_sectorMask << 1) + 1; - byte[] empty = new byte[qHdr.l1_table_offset + (l1Size * 8)]; - writingStream.Write(empty, 0, empty.Length); + byte[] empty = new byte[_qHdr.l1_table_offset + (_l1Size * 8)]; + _writingStream.Write(empty, 0, empty.Length); IsWriting = true; ErrorMessage = null; @@ -159,14 +159,14 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -179,44 +179,44 @@ namespace Aaru.DiscImages ulong byteAddress = sectorAddress * 512; - ulong l1Off = (byteAddress & l1Mask) >> l1Shift; + ulong l1Off = (byteAddress & _l1Mask) >> _l1Shift; - if((long)l1Off >= l1Table.LongLength) + if((long)l1Off >= _l1Table.LongLength) throw new ArgumentOutOfRangeException(nameof(l1Off), - $"Trying to write past L1 table, position {l1Off} of a max {l1Table.LongLength}"); + $"Trying to write past L1 table, position {l1Off} of a max {_l1Table.LongLength}"); - if(l1Table[l1Off] == 0) + if(_l1Table[l1Off] == 0) { - writingStream.Seek(0, SeekOrigin.End); - l1Table[l1Off] = (ulong)writingStream.Position; - byte[] l2TableB = new byte[l2Size * 8]; - writingStream.Seek(0, SeekOrigin.End); - writingStream.Write(l2TableB, 0, l2TableB.Length); + _writingStream.Seek(0, SeekOrigin.End); + _l1Table[l1Off] = (ulong)_writingStream.Position; + byte[] l2TableB = new byte[_l2Size * 8]; + _writingStream.Seek(0, SeekOrigin.End); + _writingStream.Write(l2TableB, 0, l2TableB.Length); } - writingStream.Position = (long)l1Table[l1Off]; + _writingStream.Position = (long)_l1Table[l1Off]; - ulong l2Off = (byteAddress & l2Mask) >> qHdr.cluster_bits; + ulong l2Off = (byteAddress & _l2Mask) >> _qHdr.cluster_bits; - writingStream.Seek((long)(l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); + _writingStream.Seek((long)(_l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); byte[] entry = new byte[8]; - writingStream.Read(entry, 0, 8); + _writingStream.Read(entry, 0, 8); ulong offset = BigEndianBitConverter.ToUInt64(entry, 0); if(offset == 0) { - offset = (ulong)writingStream.Length; - byte[] cluster = new byte[clusterSize]; + offset = (ulong)_writingStream.Length; + byte[] cluster = new byte[_clusterSize]; entry = BigEndianBitConverter.GetBytes(offset); - writingStream.Seek((long)(l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); - writingStream.Write(entry, 0, 8); - writingStream.Seek(0, SeekOrigin.End); - writingStream.Write(cluster, 0, cluster.Length); + _writingStream.Seek((long)(_l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); + _writingStream.Write(entry, 0, 8); + _writingStream.Seek(0, SeekOrigin.End); + _writingStream.Write(cluster, 0, cluster.Length); } - writingStream.Seek((long)(offset + (byteAddress & sectorMask)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(offset + (byteAddress & _sectorMask)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -233,14 +233,14 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -253,8 +253,8 @@ namespace Aaru.DiscImages for(uint i = 0; i < length; i++) { - byte[] tmp = new byte[imageInfo.SectorSize]; - Array.Copy(data, i * imageInfo.SectorSize, tmp, 0, imageInfo.SectorSize); + byte[] tmp = new byte[_imageInfo.SectorSize]; + Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); if(!WriteSector(tmp, sectorAddress + i)) return false; @@ -288,31 +288,31 @@ namespace Aaru.DiscImages return false; } - qHdr.mtime = (uint)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; + _qHdr.mtime = (uint)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.magic), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.version), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.backing_file_offset), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.backing_file_size), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.mtime), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.size), 0, 8); - writingStream.WriteByte(qHdr.cluster_bits); - writingStream.WriteByte(qHdr.l2_bits); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.padding), 0, 2); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.crypt_method), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.l1_table_offset), 0, 8); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.magic), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.version), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.backing_file_offset), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.backing_file_size), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.mtime), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.size), 0, 8); + _writingStream.WriteByte(_qHdr.cluster_bits); + _writingStream.WriteByte(_qHdr.l2_bits); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.padding), 0, 2); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.crypt_method), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.l1_table_offset), 0, 8); - writingStream.Seek((long)qHdr.l1_table_offset, SeekOrigin.Begin); + _writingStream.Seek((long)_qHdr.l1_table_offset, SeekOrigin.Begin); - for(long i = 0; i < l1Table.LongLength; i++) - l1Table[i] = Swapping.Swap(l1Table[i]); + for(long i = 0; i < _l1Table.LongLength; i++) + _l1Table[i] = Swapping.Swap(_l1Table[i]); - byte[] l1TableB = MemoryMarshal.Cast(l1Table).ToArray(); - writingStream.Write(l1TableB, 0, l1TableB.Length); + byte[] l1TableB = MemoryMarshal.Cast(_l1Table).ToArray(); + _writingStream.Write(l1TableB, 0, l1TableB.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; diff --git a/Aaru.Images/QCOW2/Identify.cs b/Aaru.Images/QCOW2/Identify.cs index f3d7d7aef..435bb2771 100644 --- a/Aaru.Images/QCOW2/Identify.cs +++ b/Aaru.Images/QCOW2/Identify.cs @@ -49,12 +49,12 @@ namespace Aaru.DiscImages byte[] qHdrB = new byte[Marshal.SizeOf()]; stream.Read(qHdrB, 0, Marshal.SizeOf()); - qHdr = Marshal.SpanToStructureBigEndian(qHdrB); + _qHdr = Marshal.SpanToStructureBigEndian(qHdrB); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.magic = 0x{0:X8}", qHdr.magic); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.version = {0}", qHdr.version); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.magic = 0x{0:X8}", _qHdr.magic); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.version = {0}", _qHdr.version); - return qHdr.magic == QCOW_MAGIC && (qHdr.version == QCOW_VERSION2 || qHdr.version == QCOW_VERSION3); + return _qHdr.magic == QCOW_MAGIC && (_qHdr.version == QCOW_VERSION2 || _qHdr.version == QCOW_VERSION3); } } } \ No newline at end of file diff --git a/Aaru.Images/QCOW2/Properties.cs b/Aaru.Images/QCOW2/Properties.cs index 6330d1d62..e0ade9669 100644 --- a/Aaru.Images/QCOW2/Properties.cs +++ b/Aaru.Images/QCOW2/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class Qcow2 { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "QEMU Copy-On-Write disk image v2"; public Guid Id => new Guid("F20107CB-95B3-4398-894B-975261F1E8C5"); diff --git a/Aaru.Images/QCOW2/QCOW2.cs b/Aaru.Images/QCOW2/QCOW2.cs index f1ad7e6e8..0682dc2c6 100644 --- a/Aaru.Images/QCOW2/QCOW2.cs +++ b/Aaru.Images/QCOW2/QCOW2.cs @@ -40,27 +40,27 @@ namespace Aaru.DiscImages { public partial class Qcow2 : IWritableImage { - Dictionary clusterCache; - int clusterSectors; - int clusterSize; - ImageInfo imageInfo; - Stream imageStream; - ulong l1Mask; - int l1Shift; - ulong[] l1Table; - int l2Bits; - ulong l2Mask; - int l2Size; - Dictionary l2TableCache; - int maxClusterCache; - int maxL2TableCache; - QCow2Header qHdr; - ulong[] refCountTable; - Dictionary sectorCache; - ulong sectorMask; - FileStream writingStream; + Dictionary _clusterCache; + int _clusterSectors; + int _clusterSize; + ImageInfo _imageInfo; + Stream _imageStream; + ulong _l1Mask; + int _l1Shift; + ulong[] _l1Table; + int _l2Bits; + ulong _l2Mask; + int _l2Size; + Dictionary _l2TableCache; + int _maxClusterCache; + int _maxL2TableCache; + QCow2Header _qHdr; + ulong[] _refCountTable; + Dictionary _sectorCache; + ulong _sectorMask; + FileStream _writingStream; - public Qcow2() => imageInfo = new ImageInfo + public Qcow2() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/QCOW2/Read.cs b/Aaru.Images/QCOW2/Read.cs index 0137e2542..dcd7ac4e2 100644 --- a/Aaru.Images/QCOW2/Read.cs +++ b/Aaru.Images/QCOW2/Read.cs @@ -58,173 +58,173 @@ namespace Aaru.DiscImages byte[] qHdrB = new byte[Marshal.SizeOf()]; stream.Read(qHdrB, 0, Marshal.SizeOf()); - qHdr = Marshal.SpanToStructureBigEndian(qHdrB); + _qHdr = Marshal.SpanToStructureBigEndian(qHdrB); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.magic = 0x{0:X8}", qHdr.magic); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.version = {0}", qHdr.version); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.backing_file_offset = {0}", qHdr.backing_file_offset); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.backing_file_size = {0}", qHdr.backing_file_size); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.cluster_bits = {0}", qHdr.cluster_bits); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.size = {0}", qHdr.size); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.crypt_method = {0}", qHdr.crypt_method); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1_size = {0}", qHdr.l1_size); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1_table_offset = {0}", qHdr.l1_table_offset); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.refcount_table_offset = {0}", qHdr.refcount_table_offset); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.magic = 0x{0:X8}", _qHdr.magic); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.version = {0}", _qHdr.version); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.backing_file_offset = {0}", _qHdr.backing_file_offset); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.backing_file_size = {0}", _qHdr.backing_file_size); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.cluster_bits = {0}", _qHdr.cluster_bits); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.size = {0}", _qHdr.size); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.crypt_method = {0}", _qHdr.crypt_method); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1_size = {0}", _qHdr.l1_size); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1_table_offset = {0}", _qHdr.l1_table_offset); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.refcount_table_offset = {0}", _qHdr.refcount_table_offset); AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.refcount_table_clusters = {0}", - qHdr.refcount_table_clusters); + _qHdr.refcount_table_clusters); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.nb_snapshots = {0}", qHdr.nb_snapshots); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.snapshots_offset = {0}", qHdr.snapshots_offset); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.nb_snapshots = {0}", _qHdr.nb_snapshots); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.snapshots_offset = {0}", _qHdr.snapshots_offset); - if(qHdr.version >= QCOW_VERSION3) + if(_qHdr.version >= QCOW_VERSION3) { - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.features = {0:X}", qHdr.features); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.compat_features = {0:X}", qHdr.compat_features); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.autoclear_features = {0:X}", qHdr.autoclear_features); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.refcount_order = {0}", qHdr.refcount_order); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.header_length = {0}", qHdr.header_length); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.features = {0:X}", _qHdr.features); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.compat_features = {0:X}", _qHdr.compat_features); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.autoclear_features = {0:X}", _qHdr.autoclear_features); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.refcount_order = {0}", _qHdr.refcount_order); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.header_length = {0}", _qHdr.header_length); - if((qHdr.features & QCOW_FEATURE_MASK) != 0) + if((_qHdr.features & QCOW_FEATURE_MASK) != 0) throw new - ImageNotSupportedException($"Unknown incompatible features {qHdr.features & QCOW_FEATURE_MASK:X} enabled, not proceeding."); + ImageNotSupportedException($"Unknown incompatible features {_qHdr.features & QCOW_FEATURE_MASK:X} enabled, not proceeding."); } - if(qHdr.size <= 1) - throw new ArgumentOutOfRangeException(nameof(qHdr.size), "Image size is too small"); + if(_qHdr.size <= 1) + throw new ArgumentOutOfRangeException(nameof(_qHdr.size), "Image size is too small"); - if(qHdr.cluster_bits < 9 || - qHdr.cluster_bits > 16) - throw new ArgumentOutOfRangeException(nameof(qHdr.cluster_bits), + if(_qHdr.cluster_bits < 9 || + _qHdr.cluster_bits > 16) + throw new ArgumentOutOfRangeException(nameof(_qHdr.cluster_bits), "Cluster size must be between 512 bytes and 64 Kbytes"); - if(qHdr.crypt_method > QCOW_ENCRYPTION_AES) - throw new ArgumentOutOfRangeException(nameof(qHdr.crypt_method), "Invalid encryption method"); + if(_qHdr.crypt_method > QCOW_ENCRYPTION_AES) + throw new ArgumentOutOfRangeException(nameof(_qHdr.crypt_method), "Invalid encryption method"); - if(qHdr.crypt_method > QCOW_ENCRYPTION_NONE) + if(_qHdr.crypt_method > QCOW_ENCRYPTION_NONE) throw new NotImplementedException("AES encrypted images not yet supported"); - if(qHdr.backing_file_offset != 0) + if(_qHdr.backing_file_offset != 0) throw new NotImplementedException("Differencing images not yet supported"); - clusterSize = 1 << (int)qHdr.cluster_bits; - clusterSectors = 1 << ((int)qHdr.cluster_bits - 9); - l2Bits = (int)(qHdr.cluster_bits - 3); - l2Size = 1 << l2Bits; + _clusterSize = 1 << (int)_qHdr.cluster_bits; + _clusterSectors = 1 << ((int)_qHdr.cluster_bits - 9); + _l2Bits = (int)(_qHdr.cluster_bits - 3); + _l2Size = 1 << _l2Bits; - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.clusterSize = {0}", clusterSize); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.clusterSectors = {0}", clusterSectors); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.qHdr.l1_size = {0}", qHdr.l1_size); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l2Size = {0}", l2Size); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.sectors = {0}", imageInfo.Sectors); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.clusterSize = {0}", _clusterSize); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.clusterSectors = {0}", _clusterSectors); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.qHdr.l1_size = {0}", _qHdr.l1_size); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l2Size = {0}", _l2Size); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.sectors = {0}", _imageInfo.Sectors); - byte[] l1TableB = new byte[qHdr.l1_size * 8]; - stream.Seek((long)qHdr.l1_table_offset, SeekOrigin.Begin); - stream.Read(l1TableB, 0, (int)qHdr.l1_size * 8); - l1Table = MemoryMarshal.Cast(l1TableB).ToArray(); + byte[] l1TableB = new byte[_qHdr.l1_size * 8]; + stream.Seek((long)_qHdr.l1_table_offset, SeekOrigin.Begin); + stream.Read(l1TableB, 0, (int)_qHdr.l1_size * 8); + _l1Table = MemoryMarshal.Cast(l1TableB).ToArray(); AaruConsole.DebugWriteLine("QCOW plugin", "Reading L1 table"); - for(long i = 0; i < l1Table.LongLength; i++) - l1Table[i] = Swapping.Swap(l1Table[i]); + for(long i = 0; i < _l1Table.LongLength; i++) + _l1Table[i] = Swapping.Swap(_l1Table[i]); - l1Mask = 0; + _l1Mask = 0; int c = 0; - l1Shift = (int)(l2Bits + qHdr.cluster_bits); + _l1Shift = (int)(_l2Bits + _qHdr.cluster_bits); for(int i = 0; i < 64; i++) { - l1Mask <<= 1; + _l1Mask <<= 1; - if(c >= 64 - l1Shift) + if(c >= 64 - _l1Shift) continue; - l1Mask += 1; + _l1Mask += 1; c++; } - l2Mask = 0; + _l2Mask = 0; - for(int i = 0; i < l2Bits; i++) - l2Mask = (l2Mask << 1) + 1; + for(int i = 0; i < _l2Bits; i++) + _l2Mask = (_l2Mask << 1) + 1; - l2Mask <<= (int)qHdr.cluster_bits; + _l2Mask <<= (int)_qHdr.cluster_bits; - sectorMask = 0; + _sectorMask = 0; - for(int i = 0; i < qHdr.cluster_bits; i++) - sectorMask = (sectorMask << 1) + 1; + for(int i = 0; i < _qHdr.cluster_bits; i++) + _sectorMask = (_sectorMask << 1) + 1; - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1Mask = {0:X}", l1Mask); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1Shift = {0}", l1Shift); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l2Mask = {0:X}", l2Mask); - AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.sectorMask = {0:X}", sectorMask); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1Mask = {0:X}", _l1Mask); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l1Shift = {0}", _l1Shift); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.l2Mask = {0:X}", _l2Mask); + AaruConsole.DebugWriteLine("QCOW plugin", "qHdr.sectorMask = {0:X}", _sectorMask); - maxL2TableCache = MAX_CACHE_SIZE / (l2Size * 8); - maxClusterCache = MAX_CACHE_SIZE / clusterSize; + _maxL2TableCache = MAX_CACHE_SIZE / (_l2Size * 8); + _maxClusterCache = MAX_CACHE_SIZE / _clusterSize; - imageStream = stream; + _imageStream = stream; - sectorCache = new Dictionary(); - l2TableCache = new Dictionary(); - clusterCache = new Dictionary(); + _sectorCache = new Dictionary(); + _l2TableCache = new Dictionary(); + _clusterCache = new Dictionary(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = qHdr.size / 512; - imageInfo.SectorSize = 512; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.ImageSize = qHdr.size; - imageInfo.Version = $"{qHdr.version}"; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = _qHdr.size / 512; + _imageInfo.SectorSize = 512; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.ImageSize = _qHdr.size; + _imageInfo.Version = $"{_qHdr.version}"; - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; return true; } public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); // Check cache - if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector; ulong byteAddress = sectorAddress * 512; - ulong l1Off = (byteAddress & l1Mask) >> l1Shift; + ulong l1Off = (byteAddress & _l1Mask) >> _l1Shift; - if((long)l1Off >= l1Table.LongLength) + if((long)l1Off >= _l1Table.LongLength) throw new ArgumentOutOfRangeException(nameof(l1Off), - $"Trying to read past L1 table, position {l1Off} of a max {l1Table.LongLength}"); + $"Trying to read past L1 table, position {l1Off} of a max {_l1Table.LongLength}"); // TODO: Implement differential images - if(l1Table[l1Off] == 0) + if(_l1Table[l1Off] == 0) return new byte[512]; - if(!l2TableCache.TryGetValue(l1Off, out ulong[] l2Table)) + if(!_l2TableCache.TryGetValue(l1Off, out ulong[] l2Table)) { - imageStream.Seek((long)(l1Table[l1Off] & QCOW_FLAGS_MASK), SeekOrigin.Begin); - byte[] l2TableB = new byte[l2Size * 8]; - imageStream.Read(l2TableB, 0, l2Size * 8); + _imageStream.Seek((long)(_l1Table[l1Off] & QCOW_FLAGS_MASK), SeekOrigin.Begin); + byte[] l2TableB = new byte[_l2Size * 8]; + _imageStream.Read(l2TableB, 0, _l2Size * 8); AaruConsole.DebugWriteLine("QCOW plugin", "Reading L2 table #{0}", l1Off); l2Table = MemoryMarshal.Cast(l2TableB).ToArray(); for(long i = 0; i < l2Table.LongLength; i++) l2Table[i] = Swapping.Swap(l2Table[i]); - if(l2TableCache.Count >= maxL2TableCache) - l2TableCache.Clear(); + if(_l2TableCache.Count >= _maxL2TableCache) + _l2TableCache.Clear(); - l2TableCache.Add(l1Off, l2Table); + _l2TableCache.Add(l1Off, l2Table); } - ulong l2Off = (byteAddress & l2Mask) >> (int)qHdr.cluster_bits; + ulong l2Off = (byteAddress & _l2Mask) >> (int)_qHdr.cluster_bits; ulong offset = l2Table[l2Off]; @@ -232,12 +232,12 @@ namespace Aaru.DiscImages if((offset & QCOW_FLAGS_MASK) != 0) { - if(!clusterCache.TryGetValue(offset, out byte[] cluster)) + if(!_clusterCache.TryGetValue(offset, out byte[] cluster)) { if((offset & QCOW_COMPRESSED) == QCOW_COMPRESSED) { - ulong compSizeMask = (ulong)(1 << (int)(qHdr.cluster_bits - 8)) - 1; - byte countbits = (byte)(qHdr.cluster_bits - 8); + ulong compSizeMask = (ulong)(1 << (int)(_qHdr.cluster_bits - 8)) - 1; + byte countbits = (byte)(_qHdr.cluster_bits - 8); compSizeMask <<= 62 - countbits; ulong offMask = ~compSizeMask & QCOW_FLAGS_MASK; @@ -245,48 +245,48 @@ namespace Aaru.DiscImages ulong compSize = (((offset & compSizeMask) >> (62 - countbits)) + 1) * 512; byte[] zCluster = new byte[compSize]; - imageStream.Seek((long)realOff, SeekOrigin.Begin); - imageStream.Read(zCluster, 0, (int)compSize); + _imageStream.Seek((long)realOff, SeekOrigin.Begin); + _imageStream.Read(zCluster, 0, (int)compSize); var zStream = new DeflateStream(new MemoryStream(zCluster), CompressionMode.Decompress); - cluster = new byte[clusterSize]; - int read = zStream.Read(cluster, 0, clusterSize); + cluster = new byte[_clusterSize]; + int read = zStream.Read(cluster, 0, _clusterSize); - if(read != clusterSize) + if(read != _clusterSize) throw new - IOException($"Unable to decompress cluster, expected {clusterSize} bytes got {read}"); + IOException($"Unable to decompress cluster, expected {_clusterSize} bytes got {read}"); } else { - cluster = new byte[clusterSize]; - imageStream.Seek((long)(offset & QCOW_FLAGS_MASK), SeekOrigin.Begin); - imageStream.Read(cluster, 0, clusterSize); + cluster = new byte[_clusterSize]; + _imageStream.Seek((long)(offset & QCOW_FLAGS_MASK), SeekOrigin.Begin); + _imageStream.Read(cluster, 0, _clusterSize); } - if(clusterCache.Count >= maxClusterCache) - clusterCache.Clear(); + if(_clusterCache.Count >= _maxClusterCache) + _clusterCache.Clear(); - clusterCache.Add(offset, cluster); + _clusterCache.Add(offset, cluster); } - Array.Copy(cluster, (int)(byteAddress & sectorMask), sector, 0, 512); + Array.Copy(cluster, (int)(byteAddress & _sectorMask), sector, 0, 512); } - if(sectorCache.Count >= MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count >= MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); diff --git a/Aaru.Images/QCOW2/Write.cs b/Aaru.Images/QCOW2/Write.cs index 390a6a4d8..a89a91447 100644 --- a/Aaru.Images/QCOW2/Write.cs +++ b/Aaru.Images/QCOW2/Write.cs @@ -71,7 +71,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -80,7 +80,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -92,7 +92,7 @@ namespace Aaru.DiscImages string extension = Path.GetExtension(path); bool version3 = extension == ".qcow3" || extension == ".qc3"; - qHdr = new QCow2Header + _qHdr = new QCow2Header { magic = QCOW_MAGIC, version = version3 ? QCOW_VERSION3 : QCOW_VERSION2, @@ -101,66 +101,66 @@ namespace Aaru.DiscImages header_length = (uint)Marshal.SizeOf() }; - clusterSize = 1 << (int)qHdr.cluster_bits; - clusterSectors = 1 << ((int)qHdr.cluster_bits - 9); - l2Bits = (int)(qHdr.cluster_bits - 3); - l2Size = 1 << l2Bits; + _clusterSize = 1 << (int)_qHdr.cluster_bits; + _clusterSectors = 1 << ((int)_qHdr.cluster_bits - 9); + _l2Bits = (int)(_qHdr.cluster_bits - 3); + _l2Size = 1 << _l2Bits; - l1Mask = 0; + _l1Mask = 0; int c = 0; - l1Shift = (int)(l2Bits + qHdr.cluster_bits); + _l1Shift = (int)(_l2Bits + _qHdr.cluster_bits); for(int i = 0; i < 64; i++) { - l1Mask <<= 1; + _l1Mask <<= 1; - if(c >= 64 - l1Shift) + if(c >= 64 - _l1Shift) continue; - l1Mask += 1; + _l1Mask += 1; c++; } - l2Mask = 0; + _l2Mask = 0; - for(int i = 0; i < l2Bits; i++) - l2Mask = (l2Mask << 1) + 1; + for(int i = 0; i < _l2Bits; i++) + _l2Mask = (_l2Mask << 1) + 1; - l2Mask <<= (int)qHdr.cluster_bits; + _l2Mask <<= (int)_qHdr.cluster_bits; - sectorMask = 0; + _sectorMask = 0; - for(int i = 0; i < qHdr.cluster_bits; i++) - sectorMask = (sectorMask << 1) + 1; + for(int i = 0; i < _qHdr.cluster_bits; i++) + _sectorMask = (_sectorMask << 1) + 1; - qHdr.l1_size = (uint)(qHdr.size >> l1Shift); + _qHdr.l1_size = (uint)(_qHdr.size >> _l1Shift); - if(qHdr.l1_size == 0) - qHdr.l1_size = 1; + if(_qHdr.l1_size == 0) + _qHdr.l1_size = 1; - l1Table = new ulong[qHdr.l1_size]; + _l1Table = new ulong[_qHdr.l1_size]; - ulong clusters = qHdr.size / (ulong)clusterSize; - ulong refCountBlocks = (clusters * 2) / (ulong)clusterSize; + ulong clusters = _qHdr.size / (ulong)_clusterSize; + ulong refCountBlocks = (clusters * 2) / (ulong)_clusterSize; if(refCountBlocks == 0) refCountBlocks = 1; - qHdr.refcount_table_offset = (ulong)clusterSize; - qHdr.refcount_table_clusters = (uint)((refCountBlocks * 8) / (ulong)clusterSize); + _qHdr.refcount_table_offset = (ulong)_clusterSize; + _qHdr.refcount_table_clusters = (uint)((refCountBlocks * 8) / (ulong)_clusterSize); - if(qHdr.refcount_table_clusters == 0) - qHdr.refcount_table_clusters = 1; + if(_qHdr.refcount_table_clusters == 0) + _qHdr.refcount_table_clusters = 1; - refCountTable = new ulong[refCountBlocks]; - qHdr.l1_table_offset = qHdr.refcount_table_offset + (ulong)(qHdr.refcount_table_clusters * clusterSize); - ulong l1TableClusters = (qHdr.l1_size * 8) / (ulong)clusterSize; + _refCountTable = new ulong[refCountBlocks]; + _qHdr.l1_table_offset = _qHdr.refcount_table_offset + (ulong)(_qHdr.refcount_table_clusters * _clusterSize); + ulong l1TableClusters = (_qHdr.l1_size * 8) / (ulong)_clusterSize; if(l1TableClusters == 0) l1TableClusters = 1; - byte[] empty = new byte[qHdr.l1_table_offset + (l1TableClusters * (ulong)clusterSize)]; - writingStream.Write(empty, 0, empty.Length); + byte[] empty = new byte[_qHdr.l1_table_offset + (l1TableClusters * (ulong)_clusterSize)]; + _writingStream.Write(empty, 0, empty.Length); IsWriting = true; ErrorMessage = null; @@ -184,14 +184,14 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -204,63 +204,63 @@ namespace Aaru.DiscImages ulong byteAddress = sectorAddress * 512; - ulong l1Off = (byteAddress & l1Mask) >> l1Shift; + ulong l1Off = (byteAddress & _l1Mask) >> _l1Shift; - if((long)l1Off >= l1Table.LongLength) + if((long)l1Off >= _l1Table.LongLength) throw new ArgumentOutOfRangeException(nameof(l1Off), - $"Trying to write past L1 table, position {l1Off} of a max {l1Table.LongLength}"); + $"Trying to write past L1 table, position {l1Off} of a max {_l1Table.LongLength}"); - if(l1Table[l1Off] == 0) + if(_l1Table[l1Off] == 0) { - writingStream.Seek(0, SeekOrigin.End); - l1Table[l1Off] = (ulong)writingStream.Position; - byte[] l2TableB = new byte[l2Size * 8]; - writingStream.Seek(0, SeekOrigin.End); - writingStream.Write(l2TableB, 0, l2TableB.Length); + _writingStream.Seek(0, SeekOrigin.End); + _l1Table[l1Off] = (ulong)_writingStream.Position; + byte[] l2TableB = new byte[_l2Size * 8]; + _writingStream.Seek(0, SeekOrigin.End); + _writingStream.Write(l2TableB, 0, l2TableB.Length); } - writingStream.Position = (long)l1Table[l1Off]; + _writingStream.Position = (long)_l1Table[l1Off]; - ulong l2Off = (byteAddress & l2Mask) >> (int)qHdr.cluster_bits; + ulong l2Off = (byteAddress & _l2Mask) >> (int)_qHdr.cluster_bits; - writingStream.Seek((long)(l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); + _writingStream.Seek((long)(_l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); byte[] entry = new byte[8]; - writingStream.Read(entry, 0, 8); + _writingStream.Read(entry, 0, 8); ulong offset = BigEndianBitConverter.ToUInt64(entry, 0); if(offset == 0) { - offset = (ulong)writingStream.Length; - byte[] cluster = new byte[clusterSize]; + offset = (ulong)_writingStream.Length; + byte[] cluster = new byte[_clusterSize]; entry = BigEndianBitConverter.GetBytes(offset); - writingStream.Seek((long)(l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); - writingStream.Write(entry, 0, 8); - writingStream.Seek(0, SeekOrigin.End); - writingStream.Write(cluster, 0, cluster.Length); + _writingStream.Seek((long)(_l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); + _writingStream.Write(entry, 0, 8); + _writingStream.Seek(0, SeekOrigin.End); + _writingStream.Write(cluster, 0, cluster.Length); } - writingStream.Seek((long)(offset + (byteAddress & sectorMask)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(offset + (byteAddress & _sectorMask)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); - int refCountBlockEntries = (clusterSize * 8) / 16; - ulong refCountBlockIndex = (offset / (ulong)clusterSize) % (ulong)refCountBlockEntries; - ulong refCountTableIndex = offset / (ulong)clusterSize / (ulong)refCountBlockEntries; + int refCountBlockEntries = (_clusterSize * 8) / 16; + ulong refCountBlockIndex = (offset / (ulong)_clusterSize) % (ulong)refCountBlockEntries; + ulong refCountTableIndex = offset / (ulong)_clusterSize / (ulong)refCountBlockEntries; - ulong refBlockOffset = refCountTable[refCountTableIndex]; + ulong refBlockOffset = _refCountTable[refCountTableIndex]; if(refBlockOffset == 0) { - refBlockOffset = (ulong)writingStream.Length; - refCountTable[refCountTableIndex] = refBlockOffset; - byte[] cluster = new byte[clusterSize]; - writingStream.Seek(0, SeekOrigin.End); - writingStream.Write(cluster, 0, cluster.Length); + refBlockOffset = (ulong)_writingStream.Length; + _refCountTable[refCountTableIndex] = refBlockOffset; + byte[] cluster = new byte[_clusterSize]; + _writingStream.Seek(0, SeekOrigin.End); + _writingStream.Write(cluster, 0, cluster.Length); } - writingStream.Seek((long)(refBlockOffset + refCountBlockIndex), SeekOrigin.Begin); + _writingStream.Seek((long)(refBlockOffset + refCountBlockIndex), SeekOrigin.Begin); - writingStream.Write(new byte[] + _writingStream.Write(new byte[] { 0, 1 }, 0, 2); @@ -280,14 +280,14 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -300,8 +300,8 @@ namespace Aaru.DiscImages for(uint i = 0; i < length; i++) { - byte[] tmp = new byte[imageInfo.SectorSize]; - Array.Copy(data, i * imageInfo.SectorSize, tmp, 0, imageInfo.SectorSize); + byte[] tmp = new byte[_imageInfo.SectorSize]; + Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); if(!WriteSector(tmp, sectorAddress + i)) return false; @@ -335,45 +335,45 @@ namespace Aaru.DiscImages return false; } - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.magic), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.version), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.backing_file_offset), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.backing_file_size), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.cluster_bits), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.size), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.crypt_method), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.l1_size), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.l1_table_offset), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.refcount_table_offset), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.refcount_table_clusters), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.nb_snapshots), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.snapshots_offset), 0, 8); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.magic), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.version), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.backing_file_offset), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.backing_file_size), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.cluster_bits), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.size), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.crypt_method), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.l1_size), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.l1_table_offset), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.refcount_table_offset), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.refcount_table_clusters), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.nb_snapshots), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.snapshots_offset), 0, 8); - if(qHdr.version == QCOW_VERSION3) + if(_qHdr.version == QCOW_VERSION3) { - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.features), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.compat_features), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.autoclear_features), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.refcount_order), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(qHdr.header_length), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.features), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.compat_features), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.autoclear_features), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.refcount_order), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_qHdr.header_length), 0, 4); } - writingStream.Seek((long)qHdr.refcount_table_offset, SeekOrigin.Begin); + _writingStream.Seek((long)_qHdr.refcount_table_offset, SeekOrigin.Begin); - for(long i = 0; i < refCountTable.LongLength; i++) - writingStream.Write(BigEndianBitConverter.GetBytes(refCountTable[i]), 0, 8); + for(long i = 0; i < _refCountTable.LongLength; i++) + _writingStream.Write(BigEndianBitConverter.GetBytes(_refCountTable[i]), 0, 8); - writingStream.Seek((long)qHdr.l1_table_offset, SeekOrigin.Begin); + _writingStream.Seek((long)_qHdr.l1_table_offset, SeekOrigin.Begin); - for(long i = 0; i < l1Table.LongLength; i++) - l1Table[i] = Swapping.Swap(l1Table[i]); + for(long i = 0; i < _l1Table.LongLength; i++) + _l1Table[i] = Swapping.Swap(_l1Table[i]); - byte[] l1TableB = MemoryMarshal.Cast(l1Table).ToArray(); - writingStream.Write(l1TableB, 0, l1TableB.Length); + byte[] l1TableB = MemoryMarshal.Cast(_l1Table).ToArray(); + _writingStream.Write(l1TableB, 0, l1TableB.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; diff --git a/Aaru.Images/QED/Identify.cs b/Aaru.Images/QED/Identify.cs index 1f0579dd7..cc26ccd73 100644 --- a/Aaru.Images/QED/Identify.cs +++ b/Aaru.Images/QED/Identify.cs @@ -48,9 +48,9 @@ namespace Aaru.DiscImages byte[] qHdrB = new byte[68]; stream.Read(qHdrB, 0, 68); - qHdr = Marshal.SpanToStructureLittleEndian(qHdrB); + _qHdr = Marshal.SpanToStructureLittleEndian(qHdrB); - return qHdr.magic == QED_MAGIC; + return _qHdr.magic == QED_MAGIC; } } } \ No newline at end of file diff --git a/Aaru.Images/QED/Properties.cs b/Aaru.Images/QED/Properties.cs index 717aac593..e368f06e2 100644 --- a/Aaru.Images/QED/Properties.cs +++ b/Aaru.Images/QED/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class Qed { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "QEMU Enhanced Disk image"; public Guid Id => new Guid("B9DBB155-A69A-4C10-BF91-96BF431B9BB6"); diff --git a/Aaru.Images/QED/QED.cs b/Aaru.Images/QED/QED.cs index d4352ec53..e9ccf1457 100644 --- a/Aaru.Images/QED/QED.cs +++ b/Aaru.Images/QED/QED.cs @@ -40,25 +40,25 @@ namespace Aaru.DiscImages { public partial class Qed : IWritableImage { - int clusterBits; - Dictionary clusterCache; - uint clusterSectors; - ImageInfo imageInfo; - Stream imageStream; - ulong l1Mask; - int l1Shift; - ulong[] l1Table; - ulong l2Mask; - Dictionary l2TableCache; - uint maxClusterCache; - uint maxL2TableCache; - QedHeader qHdr; - Dictionary sectorCache; - ulong sectorMask; - uint tableSize; - FileStream writingStream; + int _clusterBits; + Dictionary _clusterCache; + uint _clusterSectors; + ImageInfo _imageInfo; + Stream _imageStream; + ulong _l1Mask; + int _l1Shift; + ulong[] _l1Table; + ulong _l2Mask; + Dictionary _l2TableCache; + uint _maxClusterCache; + uint _maxL2TableCache; + QedHeader _qHdr; + Dictionary _sectorCache; + ulong _sectorMask; + uint _tableSize; + FileStream _writingStream; - public Qed() => imageInfo = new ImageInfo + public Qed() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/QED/Read.cs b/Aaru.Images/QED/Read.cs index e8ff3c500..c99a95c4b 100644 --- a/Aaru.Images/QED/Read.cs +++ b/Aaru.Images/QED/Read.cs @@ -54,148 +54,148 @@ namespace Aaru.DiscImages byte[] qHdrB = new byte[68]; stream.Read(qHdrB, 0, 68); - qHdr = Marshal.SpanToStructureLittleEndian(qHdrB); + _qHdr = Marshal.SpanToStructureLittleEndian(qHdrB); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.magic = 0x{0:X8}", qHdr.magic); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.cluster_size = {0}", qHdr.cluster_size); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.table_size = {0}", qHdr.table_size); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.header_size = {0}", qHdr.header_size); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.features = {0}", qHdr.features); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.compat_features = {0}", qHdr.compat_features); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.autoclear_features = {0}", qHdr.autoclear_features); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.l1_table_offset = {0}", qHdr.l1_table_offset); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.image_size = {0}", qHdr.image_size); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.backing_file_offset = {0}", qHdr.backing_file_offset); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.backing_file_size = {0}", qHdr.backing_file_size); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.magic = 0x{0:X8}", _qHdr.magic); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.cluster_size = {0}", _qHdr.cluster_size); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.table_size = {0}", _qHdr.table_size); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.header_size = {0}", _qHdr.header_size); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.features = {0}", _qHdr.features); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.compat_features = {0}", _qHdr.compat_features); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.autoclear_features = {0}", _qHdr.autoclear_features); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.l1_table_offset = {0}", _qHdr.l1_table_offset); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.image_size = {0}", _qHdr.image_size); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.backing_file_offset = {0}", _qHdr.backing_file_offset); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.backing_file_size = {0}", _qHdr.backing_file_size); - if(qHdr.image_size <= 1) - throw new ArgumentOutOfRangeException(nameof(qHdr.image_size), "Image size is too small"); + if(_qHdr.image_size <= 1) + throw new ArgumentOutOfRangeException(nameof(_qHdr.image_size), "Image size is too small"); - if(!IsPowerOfTwo(qHdr.cluster_size)) - throw new ArgumentOutOfRangeException(nameof(qHdr.cluster_size), "Cluster size must be a power of 2"); + if(!IsPowerOfTwo(_qHdr.cluster_size)) + throw new ArgumentOutOfRangeException(nameof(_qHdr.cluster_size), "Cluster size must be a power of 2"); - if(qHdr.cluster_size < 4096 || - qHdr.cluster_size > 67108864) - throw new ArgumentOutOfRangeException(nameof(qHdr.cluster_size), + if(_qHdr.cluster_size < 4096 || + _qHdr.cluster_size > 67108864) + throw new ArgumentOutOfRangeException(nameof(_qHdr.cluster_size), "Cluster size must be between 4 Kbytes and 64 Mbytes"); - if(!IsPowerOfTwo(qHdr.table_size)) - throw new ArgumentOutOfRangeException(nameof(qHdr.table_size), "Table size must be a power of 2"); + if(!IsPowerOfTwo(_qHdr.table_size)) + throw new ArgumentOutOfRangeException(nameof(_qHdr.table_size), "Table size must be a power of 2"); - if(qHdr.table_size < 1 || - qHdr.table_size > 16) - throw new ArgumentOutOfRangeException(nameof(qHdr.table_size), + if(_qHdr.table_size < 1 || + _qHdr.table_size > 16) + throw new ArgumentOutOfRangeException(nameof(_qHdr.table_size), "Table size must be between 1 and 16 clusters"); - if((qHdr.features & QED_FEATURE_MASK) > 0) - throw new ArgumentOutOfRangeException(nameof(qHdr.features), - $"Image uses unknown incompatible features {qHdr.features & QED_FEATURE_MASK:X}"); + if((_qHdr.features & QED_FEATURE_MASK) > 0) + throw new ArgumentOutOfRangeException(nameof(_qHdr.features), + $"Image uses unknown incompatible features {_qHdr.features & QED_FEATURE_MASK:X}"); - if((qHdr.features & QED_FEATURE_BACKING_FILE) == QED_FEATURE_BACKING_FILE) + if((_qHdr.features & QED_FEATURE_BACKING_FILE) == QED_FEATURE_BACKING_FILE) throw new NotImplementedException("Differencing images not yet supported"); - clusterSectors = qHdr.cluster_size / 512; - tableSize = (qHdr.cluster_size * qHdr.table_size) / 8; + _clusterSectors = _qHdr.cluster_size / 512; + _tableSize = (_qHdr.cluster_size * _qHdr.table_size) / 8; - AaruConsole.DebugWriteLine("QED plugin", "qHdr.clusterSectors = {0}", clusterSectors); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.tableSize = {0}", tableSize); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.clusterSectors = {0}", _clusterSectors); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.tableSize = {0}", _tableSize); - byte[] l1TableB = new byte[tableSize * 8]; - stream.Seek((long)qHdr.l1_table_offset, SeekOrigin.Begin); - stream.Read(l1TableB, 0, (int)tableSize * 8); + byte[] l1TableB = new byte[_tableSize * 8]; + stream.Seek((long)_qHdr.l1_table_offset, SeekOrigin.Begin); + stream.Read(l1TableB, 0, (int)_tableSize * 8); AaruConsole.DebugWriteLine("QED plugin", "Reading L1 table"); - l1Table = MemoryMarshal.Cast(l1TableB).ToArray(); + _l1Table = MemoryMarshal.Cast(l1TableB).ToArray(); - l1Mask = 0; + _l1Mask = 0; int c = 0; - clusterBits = Ctz32(qHdr.cluster_size); - l2Mask = (tableSize - 1) << clusterBits; - l1Shift = clusterBits + Ctz32(tableSize); + _clusterBits = Ctz32(_qHdr.cluster_size); + _l2Mask = (_tableSize - 1) << _clusterBits; + _l1Shift = _clusterBits + Ctz32(_tableSize); for(int i = 0; i < 64; i++) { - l1Mask <<= 1; + _l1Mask <<= 1; - if(c >= 64 - l1Shift) + if(c >= 64 - _l1Shift) continue; - l1Mask += 1; + _l1Mask += 1; c++; } - sectorMask = 0; + _sectorMask = 0; - for(int i = 0; i < clusterBits; i++) - sectorMask = (sectorMask << 1) + 1; + for(int i = 0; i < _clusterBits; i++) + _sectorMask = (_sectorMask << 1) + 1; - AaruConsole.DebugWriteLine("QED plugin", "qHdr.clusterBits = {0}", clusterBits); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.l1Mask = {0:X}", l1Mask); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.l1Shift = {0}", l1Shift); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.l2Mask = {0:X}", l2Mask); - AaruConsole.DebugWriteLine("QED plugin", "qHdr.sectorMask = {0:X}", sectorMask); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.clusterBits = {0}", _clusterBits); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.l1Mask = {0:X}", _l1Mask); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.l1Shift = {0}", _l1Shift); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.l2Mask = {0:X}", _l2Mask); + AaruConsole.DebugWriteLine("QED plugin", "qHdr.sectorMask = {0:X}", _sectorMask); - maxL2TableCache = MAX_CACHE_SIZE / tableSize; - maxClusterCache = MAX_CACHE_SIZE / qHdr.cluster_size; + _maxL2TableCache = MAX_CACHE_SIZE / _tableSize; + _maxClusterCache = MAX_CACHE_SIZE / _qHdr.cluster_size; - imageStream = stream; + _imageStream = stream; - sectorCache = new Dictionary(); - l2TableCache = new Dictionary(); - clusterCache = new Dictionary(); + _sectorCache = new Dictionary(); + _l2TableCache = new Dictionary(); + _clusterCache = new Dictionary(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = qHdr.image_size / 512; - imageInfo.SectorSize = 512; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.ImageSize = qHdr.image_size; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = _qHdr.image_size / 512; + _imageInfo.SectorSize = 512; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.ImageSize = _qHdr.image_size; - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; return true; } public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); // Check cache - if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector; ulong byteAddress = sectorAddress * 512; - ulong l1Off = (byteAddress & l1Mask) >> l1Shift; + ulong l1Off = (byteAddress & _l1Mask) >> _l1Shift; - if((long)l1Off >= l1Table.LongLength) + if((long)l1Off >= _l1Table.LongLength) throw new ArgumentOutOfRangeException(nameof(l1Off), - $"Trying to read past L1 table, position {l1Off} of a max {l1Table.LongLength}"); + $"Trying to read past L1 table, position {l1Off} of a max {_l1Table.LongLength}"); // TODO: Implement differential images - if(l1Table[l1Off] == 0) + if(_l1Table[l1Off] == 0) return new byte[512]; - if(!l2TableCache.TryGetValue(l1Off, out ulong[] l2Table)) + if(!_l2TableCache.TryGetValue(l1Off, out ulong[] l2Table)) { - imageStream.Seek((long)l1Table[l1Off], SeekOrigin.Begin); - byte[] l2TableB = new byte[tableSize * 8]; - imageStream.Read(l2TableB, 0, (int)tableSize * 8); + _imageStream.Seek((long)_l1Table[l1Off], SeekOrigin.Begin); + byte[] l2TableB = new byte[_tableSize * 8]; + _imageStream.Read(l2TableB, 0, (int)_tableSize * 8); AaruConsole.DebugWriteLine("QED plugin", "Reading L2 table #{0}", l1Off); l2Table = MemoryMarshal.Cast(l2TableB).ToArray(); - if(l2TableCache.Count >= maxL2TableCache) - l2TableCache.Clear(); + if(_l2TableCache.Count >= _maxL2TableCache) + _l2TableCache.Clear(); - l2TableCache.Add(l1Off, l2Table); + _l2TableCache.Add(l1Off, l2Table); } - ulong l2Off = (byteAddress & l2Mask) >> clusterBits; + ulong l2Off = (byteAddress & _l2Mask) >> _clusterBits; ulong offset = l2Table[l2Off]; @@ -204,36 +204,36 @@ namespace Aaru.DiscImages if(offset != 0 && offset != 1) { - if(!clusterCache.TryGetValue(offset, out byte[] cluster)) + if(!_clusterCache.TryGetValue(offset, out byte[] cluster)) { - cluster = new byte[qHdr.cluster_size]; - imageStream.Seek((long)offset, SeekOrigin.Begin); - imageStream.Read(cluster, 0, (int)qHdr.cluster_size); + cluster = new byte[_qHdr.cluster_size]; + _imageStream.Seek((long)offset, SeekOrigin.Begin); + _imageStream.Read(cluster, 0, (int)_qHdr.cluster_size); - if(clusterCache.Count >= maxClusterCache) - clusterCache.Clear(); + if(_clusterCache.Count >= _maxClusterCache) + _clusterCache.Clear(); - clusterCache.Add(offset, cluster); + _clusterCache.Add(offset, cluster); } - Array.Copy(cluster, (int)(byteAddress & sectorMask), sector, 0, 512); + Array.Copy(cluster, (int)(byteAddress & _sectorMask), sector, 0, 512); } - if(sectorCache.Count >= MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count >= MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); diff --git a/Aaru.Images/QED/Write.cs b/Aaru.Images/QED/Write.cs index 576bf4c3d..fbab600aa 100644 --- a/Aaru.Images/QED/Write.cs +++ b/Aaru.Images/QED/Write.cs @@ -71,7 +71,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -80,7 +80,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -89,7 +89,7 @@ namespace Aaru.DiscImages return false; } - qHdr = new QedHeader + _qHdr = new QedHeader { magic = QED_MAGIC, cluster_size = DEFAULT_CLUSTER_SIZE, @@ -99,34 +99,34 @@ namespace Aaru.DiscImages image_size = sectors * sectorSize }; - clusterSectors = qHdr.cluster_size / 512; - tableSize = (qHdr.cluster_size * qHdr.table_size) / 8; + _clusterSectors = _qHdr.cluster_size / 512; + _tableSize = (_qHdr.cluster_size * _qHdr.table_size) / 8; - l1Table = new ulong[tableSize]; - l1Mask = 0; + _l1Table = new ulong[_tableSize]; + _l1Mask = 0; int c = 0; - clusterBits = Ctz32(qHdr.cluster_size); - l2Mask = (tableSize - 1) << clusterBits; - l1Shift = clusterBits + Ctz32(tableSize); + _clusterBits = Ctz32(_qHdr.cluster_size); + _l2Mask = (_tableSize - 1) << _clusterBits; + _l1Shift = _clusterBits + Ctz32(_tableSize); for(int i = 0; i < 64; i++) { - l1Mask <<= 1; + _l1Mask <<= 1; - if(c >= 64 - l1Shift) + if(c >= 64 - _l1Shift) continue; - l1Mask += 1; + _l1Mask += 1; c++; } - sectorMask = 0; + _sectorMask = 0; - for(int i = 0; i < clusterBits; i++) - sectorMask = (sectorMask << 1) + 1; + for(int i = 0; i < _clusterBits; i++) + _sectorMask = (_sectorMask << 1) + 1; - byte[] empty = new byte[qHdr.l1_table_offset + (tableSize * 8)]; - writingStream.Write(empty, 0, empty.Length); + byte[] empty = new byte[_qHdr.l1_table_offset + (_tableSize * 8)]; + _writingStream.Write(empty, 0, empty.Length); IsWriting = true; ErrorMessage = null; @@ -150,14 +150,14 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -170,44 +170,44 @@ namespace Aaru.DiscImages ulong byteAddress = sectorAddress * 512; - ulong l1Off = (byteAddress & l1Mask) >> l1Shift; + ulong l1Off = (byteAddress & _l1Mask) >> _l1Shift; - if((long)l1Off >= l1Table.LongLength) + if((long)l1Off >= _l1Table.LongLength) throw new ArgumentOutOfRangeException(nameof(l1Off), - $"Trying to write past L1 table, position {l1Off} of a max {l1Table.LongLength}"); + $"Trying to write past L1 table, position {l1Off} of a max {_l1Table.LongLength}"); - if(l1Table[l1Off] == 0) + if(_l1Table[l1Off] == 0) { - writingStream.Seek(0, SeekOrigin.End); - l1Table[l1Off] = (ulong)writingStream.Position; - byte[] l2TableB = new byte[tableSize * 8]; - writingStream.Seek(0, SeekOrigin.End); - writingStream.Write(l2TableB, 0, l2TableB.Length); + _writingStream.Seek(0, SeekOrigin.End); + _l1Table[l1Off] = (ulong)_writingStream.Position; + byte[] l2TableB = new byte[_tableSize * 8]; + _writingStream.Seek(0, SeekOrigin.End); + _writingStream.Write(l2TableB, 0, l2TableB.Length); } - writingStream.Position = (long)l1Table[l1Off]; + _writingStream.Position = (long)_l1Table[l1Off]; - ulong l2Off = (byteAddress & l2Mask) >> clusterBits; + ulong l2Off = (byteAddress & _l2Mask) >> _clusterBits; - writingStream.Seek((long)(l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); + _writingStream.Seek((long)(_l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); byte[] entry = new byte[8]; - writingStream.Read(entry, 0, 8); + _writingStream.Read(entry, 0, 8); ulong offset = BitConverter.ToUInt64(entry, 0); if(offset == 0) { - offset = (ulong)writingStream.Length; - byte[] cluster = new byte[qHdr.cluster_size]; + offset = (ulong)_writingStream.Length; + byte[] cluster = new byte[_qHdr.cluster_size]; entry = BitConverter.GetBytes(offset); - writingStream.Seek((long)(l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); - writingStream.Write(entry, 0, 8); - writingStream.Seek(0, SeekOrigin.End); - writingStream.Write(cluster, 0, cluster.Length); + _writingStream.Seek((long)(_l1Table[l1Off] + (l2Off * 8)), SeekOrigin.Begin); + _writingStream.Write(entry, 0, 8); + _writingStream.Seek(0, SeekOrigin.End); + _writingStream.Write(cluster, 0, cluster.Length); } - writingStream.Seek((long)(offset + (byteAddress & sectorMask)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(offset + (byteAddress & _sectorMask)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -224,14 +224,14 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -244,8 +244,8 @@ namespace Aaru.DiscImages for(uint i = 0; i < length; i++) { - byte[] tmp = new byte[imageInfo.SectorSize]; - Array.Copy(data, i * imageInfo.SectorSize, tmp, 0, imageInfo.SectorSize); + byte[] tmp = new byte[_imageInfo.SectorSize]; + Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); if(!WriteSector(tmp, sectorAddress + i)) return false; @@ -280,17 +280,17 @@ namespace Aaru.DiscImages } byte[] hdr = new byte[Marshal.SizeOf()]; - MemoryMarshal.Write(hdr, ref qHdr); + MemoryMarshal.Write(hdr, ref _qHdr); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(hdr, 0, hdr.Length); - writingStream.Seek((long)qHdr.l1_table_offset, SeekOrigin.Begin); - byte[] l1TableB = MemoryMarshal.Cast(l1Table).ToArray(); - writingStream.Write(l1TableB, 0, l1TableB.Length); + _writingStream.Seek((long)_qHdr.l1_table_offset, SeekOrigin.Begin); + byte[] l1TableB = MemoryMarshal.Cast(_l1Table).ToArray(); + _writingStream.Write(l1TableB, 0, l1TableB.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; diff --git a/Aaru.Images/RayDIM/Properties.cs b/Aaru.Images/RayDIM/Properties.cs index 95808ab70..7ce04cffe 100644 --- a/Aaru.Images/RayDIM/Properties.cs +++ b/Aaru.Images/RayDIM/Properties.cs @@ -43,7 +43,7 @@ namespace Aaru.DiscImages { public string Name => "Ray Arachelian's Disk IMage"; public Guid Id => new Guid("F541F4E7-C1E3-4A2D-B07F-D863E87AB961"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Format => "Ray Arachelian's Disk IMage"; public List DumpHardware => null; diff --git a/Aaru.Images/RayDIM/RayDIM.cs b/Aaru.Images/RayDIM/RayDIM.cs index 6f31fb1df..c41457ca3 100644 --- a/Aaru.Images/RayDIM/RayDIM.cs +++ b/Aaru.Images/RayDIM/RayDIM.cs @@ -40,11 +40,11 @@ namespace Aaru.DiscImages { public partial class RayDim : IWritableImage { - MemoryStream disk; - ImageInfo imageInfo; - FileStream writingStream; + MemoryStream _disk; + ImageInfo _imageInfo; + FileStream _writingStream; - public RayDim() => imageInfo = new ImageInfo + public RayDim() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/RayDIM/Read.cs b/Aaru.Images/RayDIM/Read.cs index 2e1e56962..b85918c8d 100644 --- a/Aaru.Images/RayDIM/Read.cs +++ b/Aaru.Images/RayDIM/Read.cs @@ -63,47 +63,47 @@ namespace Aaru.DiscImages if(!sm.Success) return false; - imageInfo.ApplicationVersion = $"{sm.Groups["major"].Value}.{sm.Groups["minor"].Value}"; + _imageInfo.ApplicationVersion = $"{sm.Groups["major"].Value}.{sm.Groups["minor"].Value}"; - imageInfo.Cylinders = (uint)(header.cylinders + 1); - imageInfo.Heads = (uint)(header.heads + 1); - imageInfo.SectorsPerTrack = header.sectorsPerTrack; - imageInfo.Sectors = imageInfo.Cylinders * imageInfo.Heads * imageInfo.SectorsPerTrack; - imageInfo.SectorSize = 512; + _imageInfo.Cylinders = (uint)(header.cylinders + 1); + _imageInfo.Heads = (uint)(header.heads + 1); + _imageInfo.SectorsPerTrack = header.sectorsPerTrack; + _imageInfo.Sectors = _imageInfo.Cylinders * _imageInfo.Heads * _imageInfo.SectorsPerTrack; + _imageInfo.SectorSize = 512; - byte[] sectors = new byte[imageInfo.SectorsPerTrack * imageInfo.SectorSize]; - disk = new MemoryStream(); + byte[] sectors = new byte[_imageInfo.SectorsPerTrack * _imageInfo.SectorSize]; + _disk = new MemoryStream(); - for(int i = 0; i < imageInfo.SectorsPerTrack * imageInfo.SectorSize; i++) + for(int i = 0; i < _imageInfo.SectorsPerTrack * _imageInfo.SectorSize; i++) { stream.Read(sectors, 0, sectors.Length); - stream.Seek(imageInfo.SectorsPerTrack, SeekOrigin.Current); - disk.Write(sectors, 0, sectors.Length); + stream.Seek(_imageInfo.SectorsPerTrack, SeekOrigin.Current); + _disk.Write(sectors, 0, sectors.Length); } - imageInfo.MediaType = Geometry.GetMediaType(((ushort)imageInfo.Cylinders, (byte)imageInfo.Heads, - (ushort)imageInfo.SectorsPerTrack, 512, MediaEncoding.MFM, - false)); + _imageInfo.MediaType = Geometry.GetMediaType(((ushort)_imageInfo.Cylinders, (byte)_imageInfo.Heads, + (ushort)_imageInfo.SectorsPerTrack, 512, MediaEncoding.MFM, + false)); - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.NEC_525_HD when header.diskType == RayDiskTypes.Mf2hd || header.diskType == RayDiskTypes.Mf2ed: - imageInfo.MediaType = MediaType.NEC_35_HD_8; + _imageInfo.MediaType = MediaType.NEC_35_HD_8; break; case MediaType.DOS_525_HD when header.diskType == RayDiskTypes.Mf2hd || header.diskType == RayDiskTypes.Mf2ed: - imageInfo.MediaType = MediaType.NEC_35_HD_15; + _imageInfo.MediaType = MediaType.NEC_35_HD_15; break; case MediaType.RX50 when header.diskType == RayDiskTypes.Md2dd || header.diskType == RayDiskTypes.Md2hd: - imageInfo.MediaType = MediaType.ATARI_35_SS_DD; + _imageInfo.MediaType = MediaType.ATARI_35_SS_DD; break; } - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; return true; } @@ -112,16 +112,16 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - disk.Seek((long)(sectorAddress * imageInfo.SectorSize), SeekOrigin.Begin); - disk.Read(buffer, 0, (int)(length * imageInfo.SectorSize)); + _disk.Seek((long)(sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); + _disk.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); return buffer; } diff --git a/Aaru.Images/RayDIM/Write.cs b/Aaru.Images/RayDIM/Write.cs index 99d1c3204..0c88f8575 100644 --- a/Aaru.Images/RayDIM/Write.cs +++ b/Aaru.Images/RayDIM/Write.cs @@ -72,7 +72,7 @@ namespace Aaru.DiscImages (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding, bool variableSectorsPerTrack, MediaType type) geometry = Geometry.GetGeometry(mediaType); - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -84,7 +84,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -122,17 +122,17 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * imageInfo.SectorSize)), - SeekOrigin.Begin); + _writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * _imageInfo.SectorSize)), + SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -155,17 +155,17 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * imageInfo.SectorSize)), - SeekOrigin.Begin); + _writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * _imageInfo.SectorSize)), + SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -221,10 +221,10 @@ namespace Aaru.DiscImages var header = new RayHdr { signature = Encoding.ASCII.GetBytes(headerSignature), - cylinders = (byte)imageInfo.Cylinders, + cylinders = (byte)_imageInfo.Cylinders, diskType = RayDiskTypes.Mf2ed, - heads = (byte)imageInfo.Heads, - sectorsPerTrack = (byte)imageInfo.SectorsPerTrack + heads = (byte)_imageInfo.Heads, + sectorsPerTrack = (byte)_imageInfo.SectorsPerTrack }; header.signature[0x4A] = 0x00; @@ -235,11 +235,11 @@ namespace Aaru.DiscImages System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(hdr, 0, hdr.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; diff --git a/Aaru.Images/RsIde/Constants.cs b/Aaru.Images/RsIde/Constants.cs index d98634968..35ea72aed 100644 --- a/Aaru.Images/RsIde/Constants.cs +++ b/Aaru.Images/RsIde/Constants.cs @@ -34,7 +34,7 @@ namespace Aaru.DiscImages { public partial class RsIde { - readonly byte[] signature = + readonly byte[] _signature = { 0x52, 0x53, 0x2D, 0x49, 0x44, 0x45, 0x1A }; diff --git a/Aaru.Images/RsIde/Identify.cs b/Aaru.Images/RsIde/Identify.cs index 63eeb6fe7..b6334373e 100644 --- a/Aaru.Images/RsIde/Identify.cs +++ b/Aaru.Images/RsIde/Identify.cs @@ -46,7 +46,7 @@ namespace Aaru.DiscImages byte[] magic = new byte[7]; stream.Read(magic, 0, magic.Length); - return magic.SequenceEqual(signature); + return magic.SequenceEqual(_signature); } } } \ No newline at end of file diff --git a/Aaru.Images/RsIde/Properties.cs b/Aaru.Images/RsIde/Properties.cs index f6d1df955..88994d76b 100644 --- a/Aaru.Images/RsIde/Properties.cs +++ b/Aaru.Images/RsIde/Properties.cs @@ -43,7 +43,7 @@ namespace Aaru.DiscImages { public string Name => "RS-IDE Hard Disk Image"; public Guid Id => new Guid("47C3E78D-2BE2-4BA5-AA6B-FEE27C86FC65"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Format => "RS-IDE disk image"; public List DumpHardware => null; diff --git a/Aaru.Images/RsIde/Read.cs b/Aaru.Images/RsIde/Read.cs index db1327105..2a265c87e 100644 --- a/Aaru.Images/RsIde/Read.cs +++ b/Aaru.Images/RsIde/Read.cs @@ -54,51 +54,51 @@ namespace Aaru.DiscImages RsIdeHeader hdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); - if(!hdr.magic.SequenceEqual(signature)) + if(!hdr.magic.SequenceEqual(_signature)) return false; - dataOff = hdr.dataOff; + _dataOff = hdr.dataOff; - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.SectorSize = (uint)(hdr.flags.HasFlag(RsIdeFlags.HalfSectors) ? 256 : 512); - imageInfo.ImageSize = (ulong)(stream.Length - dataOff); - imageInfo.Sectors = imageInfo.ImageSize / imageInfo.SectorSize; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.Version = $"{hdr.revision >> 8}.{hdr.revision & 0x0F}"; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.SectorSize = (uint)(hdr.flags.HasFlag(RsIdeFlags.HalfSectors) ? 256 : 512); + _imageInfo.ImageSize = (ulong)(stream.Length - _dataOff); + _imageInfo.Sectors = _imageInfo.ImageSize / _imageInfo.SectorSize; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.Version = $"{hdr.revision >> 8}.{hdr.revision & 0x0F}"; if(!ArrayHelpers.ArrayIsNullOrEmpty(hdr.identify)) { - identify = new byte[512]; - Array.Copy(hdr.identify, 0, identify, 0, hdr.identify.Length); - Identify.IdentifyDevice? ataId = CommonTypes.Structs.Devices.ATA.Identify.Decode(identify); + _identify = new byte[512]; + Array.Copy(hdr.identify, 0, _identify, 0, hdr.identify.Length); + Identify.IdentifyDevice? ataId = CommonTypes.Structs.Devices.ATA.Identify.Decode(_identify); if(ataId.HasValue) { - imageInfo.ReadableMediaTags.Add(MediaTagType.ATA_IDENTIFY); - imageInfo.Cylinders = ataId.Value.Cylinders; - imageInfo.Heads = ataId.Value.Heads; - imageInfo.SectorsPerTrack = ataId.Value.SectorsPerCard; - imageInfo.DriveFirmwareRevision = ataId.Value.FirmwareRevision; - imageInfo.DriveModel = ataId.Value.Model; - imageInfo.DriveSerialNumber = ataId.Value.SerialNumber; - imageInfo.MediaSerialNumber = ataId.Value.MediaSerial; - imageInfo.MediaManufacturer = ataId.Value.MediaManufacturer; + _imageInfo.ReadableMediaTags.Add(MediaTagType.ATA_IDENTIFY); + _imageInfo.Cylinders = ataId.Value.Cylinders; + _imageInfo.Heads = ataId.Value.Heads; + _imageInfo.SectorsPerTrack = ataId.Value.SectorsPerCard; + _imageInfo.DriveFirmwareRevision = ataId.Value.FirmwareRevision; + _imageInfo.DriveModel = ataId.Value.Model; + _imageInfo.DriveSerialNumber = ataId.Value.SerialNumber; + _imageInfo.MediaSerialNumber = ataId.Value.MediaSerial; + _imageInfo.MediaManufacturer = ataId.Value.MediaManufacturer; } } - if(imageInfo.Cylinders == 0 || - imageInfo.Heads == 0 || - imageInfo.SectorsPerTrack == 0) + if(_imageInfo.Cylinders == 0 || + _imageInfo.Heads == 0 || + _imageInfo.SectorsPerTrack == 0) { - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; } - rsIdeImageFilter = imageFilter; + _rsIdeImageFilter = imageFilter; return true; } @@ -107,31 +107,31 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Stream stream = rsIdeImageFilter.GetDataForkStream(); + Stream stream = _rsIdeImageFilter.GetDataForkStream(); - stream.Seek((long)(dataOff + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)(_dataOff + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); - stream.Read(buffer, 0, (int)(length * imageInfo.SectorSize)); + stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); return buffer; } public byte[] ReadDiskTag(MediaTagType tag) { - if(!imageInfo.ReadableMediaTags.Contains(tag) || + if(!_imageInfo.ReadableMediaTags.Contains(tag) || tag != MediaTagType.ATA_IDENTIFY) throw new FeatureUnsupportedImageException("Feature not supported by image format"); byte[] buffer = new byte[512]; - Array.Copy(identify, 0, buffer, 0, 512); + Array.Copy(_identify, 0, buffer, 0, 512); return buffer; } diff --git a/Aaru.Images/RsIde/RsIde.cs b/Aaru.Images/RsIde/RsIde.cs index 0a821adc0..280d07ee1 100644 --- a/Aaru.Images/RsIde/RsIde.cs +++ b/Aaru.Images/RsIde/RsIde.cs @@ -40,13 +40,13 @@ namespace Aaru.DiscImages { public partial class RsIde : IWritableImage { - ushort dataOff; - byte[] identify; - ImageInfo imageInfo; - IFilter rsIdeImageFilter; - FileStream writingStream; + ushort _dataOff; + byte[] _identify; + ImageInfo _imageInfo; + IFilter _rsIdeImageFilter; + FileStream _writingStream; - public RsIde() => imageInfo = new ImageInfo + public RsIde() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/RsIde/Write.cs b/Aaru.Images/RsIde/Write.cs index 1b4fc6f0d..cfbe6d28f 100644 --- a/Aaru.Images/RsIde/Write.cs +++ b/Aaru.Images/RsIde/Write.cs @@ -71,7 +71,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -80,7 +80,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -111,8 +111,8 @@ namespace Aaru.DiscImages return false; } - identify = new byte[106]; - Array.Copy(data, 0, identify, 0, 106); + _identify = new byte[106]; + Array.Copy(data, 0, _identify, 0, 106); return true; } @@ -126,24 +126,24 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * imageInfo.SectorSize)), - SeekOrigin.Begin); + _writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * _imageInfo.SectorSize)), + SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -159,24 +159,24 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * imageInfo.SectorSize)), - SeekOrigin.Begin); + _writingStream.Seek((long)((ulong)Marshal.SizeOf() + (sectorAddress * _imageInfo.SectorSize)), + SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -206,44 +206,44 @@ namespace Aaru.DiscImages return false; } - if(imageInfo.Cylinders == 0) + if(_imageInfo.Cylinders == 0) { - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; - while(imageInfo.Cylinders == 0) + while(_imageInfo.Cylinders == 0) { - imageInfo.Heads--; + _imageInfo.Heads--; - if(imageInfo.Heads == 0) + if(_imageInfo.Heads == 0) { - imageInfo.SectorsPerTrack--; - imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack--; + _imageInfo.Heads = 16; } - imageInfo.Cylinders = (uint)(imageInfo.Sectors / imageInfo.Heads / imageInfo.SectorsPerTrack); + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / _imageInfo.Heads / _imageInfo.SectorsPerTrack); - if(imageInfo.Cylinders == 0 && - imageInfo.Heads == 0 && - imageInfo.SectorsPerTrack == 0) + if(_imageInfo.Cylinders == 0 && + _imageInfo.Heads == 0 && + _imageInfo.SectorsPerTrack == 0) break; } } var header = new RsIdeHeader { - magic = signature, + magic = _signature, identify = new byte[106], dataOff = (ushort)Marshal.SizeOf(), revision = 1, reserved = new byte[11] }; - if(imageInfo.SectorSize == 256) + if(_imageInfo.SectorSize == 256) header.flags = RsIdeFlags.HalfSectors; - if(identify == null) + if(_identify == null) { var ataId = new Identify.IdentifyDevice { @@ -252,34 +252,34 @@ namespace Aaru.DiscImages CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit.Fixed | CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit.NotMFM | CommonTypes.Structs.Devices.ATA.Identify.GeneralConfigurationBit.SoftSector, - Cylinders = (ushort)imageInfo.Cylinders, - Heads = (ushort)imageInfo.Heads, - SectorsPerTrack = (ushort)imageInfo.SectorsPerTrack, + Cylinders = (ushort)_imageInfo.Cylinders, + Heads = (ushort)_imageInfo.Heads, + SectorsPerTrack = (ushort)_imageInfo.SectorsPerTrack, VendorWord47 = 0x80, Capabilities = CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.DMASupport | CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.IORDY | CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.LBASupport, ExtendedIdentify = CommonTypes.Structs.Devices.ATA.Identify.ExtendedIdentifyBit.Words54to58Valid, - CurrentCylinders = (ushort)imageInfo.Cylinders, - CurrentHeads = (ushort)imageInfo.Heads, - CurrentSectorsPerTrack = (ushort)imageInfo.SectorsPerTrack, - CurrentSectors = (uint)imageInfo.Sectors, - LBASectors = (uint)imageInfo.Sectors, + CurrentCylinders = (ushort)_imageInfo.Cylinders, + CurrentHeads = (ushort)_imageInfo.Heads, + CurrentSectorsPerTrack = (ushort)_imageInfo.SectorsPerTrack, + CurrentSectors = (uint)_imageInfo.Sectors, + LBASectors = (uint)_imageInfo.Sectors, DMASupported = CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode0, DMAActive = CommonTypes.Structs.Devices.ATA.Identify.TransferMode.Mode0 }; - if(string.IsNullOrEmpty(imageInfo.DriveManufacturer)) - imageInfo.DriveManufacturer = "Aaru"; + if(string.IsNullOrEmpty(_imageInfo.DriveManufacturer)) + _imageInfo.DriveManufacturer = "Aaru"; - if(string.IsNullOrEmpty(imageInfo.DriveModel)) - imageInfo.DriveModel = ""; + if(string.IsNullOrEmpty(_imageInfo.DriveModel)) + _imageInfo.DriveModel = ""; - if(string.IsNullOrEmpty(imageInfo.DriveFirmwareRevision)) + if(string.IsNullOrEmpty(_imageInfo.DriveFirmwareRevision)) Version.GetVersion(); - if(string.IsNullOrEmpty(imageInfo.DriveSerialNumber)) - imageInfo.DriveSerialNumber = $"{new Random().NextDouble():16X}"; + if(string.IsNullOrEmpty(_imageInfo.DriveSerialNumber)) + _imageInfo.DriveSerialNumber = $"{new Random().NextDouble():16X}"; byte[] ataIdBytes = new byte[Marshal.SizeOf()]; IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocHGlobal(512); @@ -290,15 +290,15 @@ namespace Aaru.DiscImages System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr); - Array.Copy(ScrambleAtaString(imageInfo.DriveManufacturer + " " + imageInfo.DriveModel, 40), 0, + Array.Copy(ScrambleAtaString(_imageInfo.DriveManufacturer + " " + _imageInfo.DriveModel, 40), 0, ataIdBytes, 27 * 2, 40); - Array.Copy(ScrambleAtaString(imageInfo.DriveFirmwareRevision, 8), 0, ataIdBytes, 23 * 2, 8); - Array.Copy(ScrambleAtaString(imageInfo.DriveSerialNumber, 20), 0, ataIdBytes, 10 * 2, 20); + Array.Copy(ScrambleAtaString(_imageInfo.DriveFirmwareRevision, 8), 0, ataIdBytes, 23 * 2, 8); + Array.Copy(ScrambleAtaString(_imageInfo.DriveSerialNumber, 20), 0, ataIdBytes, 10 * 2, 20); Array.Copy(ataIdBytes, 0, header.identify, 0, 106); } else - Array.Copy(identify, 0, header.identify, 0, 106); + Array.Copy(_identify, 0, header.identify, 0, 106); byte[] hdr = new byte[Marshal.SizeOf()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); @@ -306,11 +306,11 @@ namespace Aaru.DiscImages System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(hdr, 0, hdr.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -320,10 +320,10 @@ namespace Aaru.DiscImages public bool SetMetadata(ImageInfo metadata) { - imageInfo.DriveManufacturer = metadata.DriveManufacturer; - imageInfo.DriveModel = metadata.DriveModel; - imageInfo.DriveFirmwareRevision = metadata.DriveFirmwareRevision; - imageInfo.DriveSerialNumber = metadata.DriveSerialNumber; + _imageInfo.DriveManufacturer = metadata.DriveManufacturer; + _imageInfo.DriveModel = metadata.DriveModel; + _imageInfo.DriveFirmwareRevision = metadata.DriveFirmwareRevision; + _imageInfo.DriveSerialNumber = metadata.DriveSerialNumber; return true; } @@ -351,9 +351,9 @@ namespace Aaru.DiscImages return false; } - imageInfo.SectorsPerTrack = sectorsPerTrack; - imageInfo.Heads = heads; - imageInfo.Cylinders = cylinders; + _imageInfo.SectorsPerTrack = sectorsPerTrack; + _imageInfo.Heads = heads; + _imageInfo.Cylinders = cylinders; return true; } diff --git a/Aaru.Images/SaveDskF/Identify.cs b/Aaru.Images/SaveDskF/Identify.cs index 8618ab289..5adf17a45 100644 --- a/Aaru.Images/SaveDskF/Identify.cs +++ b/Aaru.Images/SaveDskF/Identify.cs @@ -49,11 +49,11 @@ namespace Aaru.DiscImages byte[] hdr = new byte[40]; stream.Read(hdr, 0, 40); - header = Marshal.ByteArrayToStructureLittleEndian(hdr); + _header = Marshal.ByteArrayToStructureLittleEndian(hdr); - return (header.magic == SDF_MAGIC || header.magic == SDF_MAGIC_COMPRESSED || - header.magic == SDF_MAGIC_OLD) && header.fatCopies <= 2 && header.padding == 0 && - header.commentOffset < stream.Length && header.dataOffset < stream.Length; + return (_header.magic == SDF_MAGIC || _header.magic == SDF_MAGIC_COMPRESSED || + _header.magic == SDF_MAGIC_OLD) && _header.fatCopies <= 2 && _header.padding == 0 && + _header.commentOffset < stream.Length && _header.dataOffset < stream.Length; } } } \ No newline at end of file diff --git a/Aaru.Images/SaveDskF/Properties.cs b/Aaru.Images/SaveDskF/Properties.cs index 72f554cc7..fa3cb784a 100644 --- a/Aaru.Images/SaveDskF/Properties.cs +++ b/Aaru.Images/SaveDskF/Properties.cs @@ -43,7 +43,7 @@ namespace Aaru.DiscImages { public string Name => "IBM SaveDskF"; public Guid Id => new Guid("288CE058-1A51-4034-8C45-5A256CAE1461"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Format => "IBM SaveDskF"; public List DumpHardware => null; diff --git a/Aaru.Images/SaveDskF/Read.cs b/Aaru.Images/SaveDskF/Read.cs index bab128357..16924bd2b 100644 --- a/Aaru.Images/SaveDskF/Read.cs +++ b/Aaru.Images/SaveDskF/Read.cs @@ -52,40 +52,40 @@ namespace Aaru.DiscImages byte[] hdr = new byte[40]; stream.Read(hdr, 0, 40); - header = Marshal.ByteArrayToStructureLittleEndian(hdr); + _header = Marshal.ByteArrayToStructureLittleEndian(hdr); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.magic = 0x{0:X4}", header.magic); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.mediaType = 0x{0:X2}", header.mediaType); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.sectorSize = {0}", header.sectorSize); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.clusterMask = {0}", header.clusterMask); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.clusterShift = {0}", header.clusterShift); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.reservedSectors = {0}", header.reservedSectors); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.fatCopies = {0}", header.fatCopies); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.rootEntries = {0}", header.rootEntries); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.firstCluster = {0}", header.firstCluster); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.clustersCopied = {0}", header.clustersCopied); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.sectorsPerFat = {0}", header.sectorsPerFat); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.checksum = 0x{0:X8}", header.checksum); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.cylinders = {0}", header.cylinders); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.heads = {0}", header.heads); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.sectorsPerTrack = {0}", header.sectorsPerTrack); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.padding = {0}", header.padding); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.sectorsCopied = {0}", header.sectorsCopied); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.commentOffset = {0}", header.commentOffset); - AaruConsole.DebugWriteLine("SaveDskF plugin", "header.dataOffset = {0}", header.dataOffset); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.magic = 0x{0:X4}", _header.magic); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.mediaType = 0x{0:X2}", _header.mediaType); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.sectorSize = {0}", _header.sectorSize); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.clusterMask = {0}", _header.clusterMask); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.clusterShift = {0}", _header.clusterShift); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.reservedSectors = {0}", _header.reservedSectors); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.fatCopies = {0}", _header.fatCopies); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.rootEntries = {0}", _header.rootEntries); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.firstCluster = {0}", _header.firstCluster); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.clustersCopied = {0}", _header.clustersCopied); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.sectorsPerFat = {0}", _header.sectorsPerFat); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.checksum = 0x{0:X8}", _header.checksum); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.cylinders = {0}", _header.cylinders); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.heads = {0}", _header.heads); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.sectorsPerTrack = {0}", _header.sectorsPerTrack); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.padding = {0}", _header.padding); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.sectorsCopied = {0}", _header.sectorsCopied); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.commentOffset = {0}", _header.commentOffset); + AaruConsole.DebugWriteLine("SaveDskF plugin", "header.dataOffset = {0}", _header.dataOffset); - if(header.dataOffset == 0 && - header.magic == SDF_MAGIC_OLD) - header.dataOffset = 512; + if(_header.dataOffset == 0 && + _header.magic == SDF_MAGIC_OLD) + _header.dataOffset = 512; - byte[] cmt = new byte[header.dataOffset - header.commentOffset]; - stream.Seek(header.commentOffset, SeekOrigin.Begin); + byte[] cmt = new byte[_header.dataOffset - _header.commentOffset]; + stream.Seek(_header.commentOffset, SeekOrigin.Begin); stream.Read(cmt, 0, cmt.Length); if(cmt.Length > 1) - imageInfo.Comments = StringHandlers.CToString(cmt, Encoding.GetEncoding("ibm437")); + _imageInfo.Comments = StringHandlers.CToString(cmt, Encoding.GetEncoding("ibm437")); - calculatedChk = 0; + _calculatedChk = 0; stream.Seek(0, SeekOrigin.Begin); int b; @@ -95,43 +95,44 @@ namespace Aaru.DiscImages b = stream.ReadByte(); if(b >= 0) - calculatedChk += (uint)b; + _calculatedChk += (uint)b; } while(b >= 0); - AaruConsole.DebugWriteLine("SaveDskF plugin", "Calculated checksum = 0x{0:X8}, {1}", calculatedChk, - calculatedChk == header.checksum); + AaruConsole.DebugWriteLine("SaveDskF plugin", "Calculated checksum = 0x{0:X8}, {1}", _calculatedChk, + _calculatedChk == _header.checksum); - imageInfo.Application = "SaveDskF"; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = imageFilter.GetFilename(); - imageInfo.ImageSize = (ulong)(stream.Length - header.dataOffset); - imageInfo.Sectors = (ulong)(header.sectorsPerTrack * header.heads * header.cylinders); - imageInfo.SectorSize = header.sectorSize; + _imageInfo.Application = "SaveDskF"; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = imageFilter.GetFilename(); + _imageInfo.ImageSize = (ulong)(stream.Length - _header.dataOffset); + _imageInfo.Sectors = (ulong)(_header.sectorsPerTrack * _header.heads * _header.cylinders); + _imageInfo.SectorSize = _header.sectorSize; - imageInfo.MediaType = Geometry.GetMediaType((header.cylinders, (byte)header.heads, header.sectorsPerTrack, - header.sectorSize, MediaEncoding.MFM, false)); + _imageInfo.MediaType = Geometry.GetMediaType((_header.cylinders, (byte)_header.heads, + _header.sectorsPerTrack, _header.sectorSize, + MediaEncoding.MFM, false)); - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - AaruConsole.VerboseWriteLine("SaveDskF image contains a disk of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("SaveDskF image contains a disk of type {0}", _imageInfo.MediaType); - if(!string.IsNullOrEmpty(imageInfo.Comments)) - AaruConsole.VerboseWriteLine("SaveDskF comments: {0}", imageInfo.Comments); + if(!string.IsNullOrEmpty(_imageInfo.Comments)) + AaruConsole.VerboseWriteLine("SaveDskF comments: {0}", _imageInfo.Comments); // TODO: Support compressed images - if(header.magic == SDF_MAGIC_COMPRESSED) + if(_header.magic == SDF_MAGIC_COMPRESSED) throw new FeatureSupportedButNotImplementedImageException("Compressed SaveDskF images are not supported."); // SaveDskF only ommits ending clusters, leaving no gaps behind, so reading all data we have... - stream.Seek(header.dataOffset, SeekOrigin.Begin); - decodedDisk = new byte[imageInfo.Sectors * imageInfo.SectorSize]; - stream.Read(decodedDisk, 0, (int)(stream.Length - header.dataOffset)); + stream.Seek(_header.dataOffset, SeekOrigin.Begin); + _decodedDisk = new byte[_imageInfo.Sectors * _imageInfo.SectorSize]; + stream.Read(_decodedDisk, 0, (int)(stream.Length - _header.dataOffset)); - imageInfo.Cylinders = header.cylinders; - imageInfo.Heads = header.heads; - imageInfo.SectorsPerTrack = header.sectorsPerTrack; + _imageInfo.Cylinders = _header.cylinders; + _imageInfo.Heads = _header.heads; + _imageInfo.SectorsPerTrack = _header.sectorsPerTrack; return true; } @@ -140,16 +141,16 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Array.Copy(decodedDisk, (int)sectorAddress * imageInfo.SectorSize, buffer, 0, - length * imageInfo.SectorSize); + Array.Copy(_decodedDisk, (int)sectorAddress * _imageInfo.SectorSize, buffer, 0, + length * _imageInfo.SectorSize); return buffer; } diff --git a/Aaru.Images/SaveDskF/SaveDskF.cs b/Aaru.Images/SaveDskF/SaveDskF.cs index d1772e66b..994ad4e28 100644 --- a/Aaru.Images/SaveDskF/SaveDskF.cs +++ b/Aaru.Images/SaveDskF/SaveDskF.cs @@ -40,13 +40,13 @@ namespace Aaru.DiscImages { public partial class SaveDskF : IWritableImage, IVerifiableImage { - uint calculatedChk; - byte[] decodedDisk; - SaveDskFHeader header; - ImageInfo imageInfo; - FileStream writingStream; + uint _calculatedChk; + byte[] _decodedDisk; + SaveDskFHeader _header; + ImageInfo _imageInfo; + FileStream _writingStream; - public SaveDskF() => imageInfo = new ImageInfo + public SaveDskF() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/SaveDskF/Verify.cs b/Aaru.Images/SaveDskF/Verify.cs index b3f495fdb..a7d1f6c2f 100644 --- a/Aaru.Images/SaveDskF/Verify.cs +++ b/Aaru.Images/SaveDskF/Verify.cs @@ -34,6 +34,6 @@ namespace Aaru.DiscImages { public partial class SaveDskF { - public bool? VerifyMediaImage() => calculatedChk == header.checksum; + public bool? VerifyMediaImage() => _calculatedChk == _header.checksum; } } \ No newline at end of file diff --git a/Aaru.Images/SaveDskF/Write.cs b/Aaru.Images/SaveDskF/Write.cs index 74ab2378c..78b8d39ec 100644 --- a/Aaru.Images/SaveDskF/Write.cs +++ b/Aaru.Images/SaveDskF/Write.cs @@ -61,22 +61,22 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(512 + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(512 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -92,22 +92,22 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(512 + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(512 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -137,50 +137,50 @@ namespace Aaru.DiscImages return false; } - if(!string.IsNullOrWhiteSpace(imageInfo.Comments)) + if(!string.IsNullOrWhiteSpace(_imageInfo.Comments)) { - byte[] commentsBytes = Encoding.GetEncoding("ibm437").GetBytes(imageInfo.Comments); - header.commentOffset = (ushort)Marshal.SizeOf(); - writingStream.Seek(header.commentOffset, SeekOrigin.Begin); + byte[] commentsBytes = Encoding.GetEncoding("ibm437").GetBytes(_imageInfo.Comments); + _header.commentOffset = (ushort)Marshal.SizeOf(); + _writingStream.Seek(_header.commentOffset, SeekOrigin.Begin); - writingStream.Write(commentsBytes, 0, - commentsBytes.Length >= 512 - header.commentOffset ? 512 - header.commentOffset - : commentsBytes.Length); + _writingStream.Write(commentsBytes, 0, + commentsBytes.Length >= 512 - _header.commentOffset ? 512 - _header.commentOffset + : commentsBytes.Length); } byte[] hdr = new byte[Marshal.SizeOf()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); - System.Runtime.InteropServices.Marshal.StructureToPtr(header, hdrPtr, true); + System.Runtime.InteropServices.Marshal.StructureToPtr(_header, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(hdr, 0, hdr.Length); - header.checksum = 0; - writingStream.Seek(0, SeekOrigin.Begin); + _header.checksum = 0; + _writingStream.Seek(0, SeekOrigin.Begin); int b; do { - b = writingStream.ReadByte(); + b = _writingStream.ReadByte(); if(b >= 0) - header.checksum += (uint)b; + _header.checksum += (uint)b; } while(b >= 0); hdr = new byte[Marshal.SizeOf()]; hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); - System.Runtime.InteropServices.Marshal.StructureToPtr(header, hdrPtr, true); + System.Runtime.InteropServices.Marshal.StructureToPtr(_header, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(hdr, 0, hdr.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -190,7 +190,7 @@ namespace Aaru.DiscImages public bool SetMetadata(ImageInfo metadata) { - imageInfo.Comments = metadata.Comments; + _imageInfo.Comments = metadata.Comments; return true; } @@ -219,7 +219,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -228,7 +228,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -240,7 +240,7 @@ namespace Aaru.DiscImages (ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding, bool variableSectorsPerTrack, MediaType type) geometry = Geometry.GetGeometry(mediaType); - header = new SaveDskFHeader + _header = new SaveDskFHeader { cylinders = geometry.cylinders, dataOffset = 512, diff --git a/Aaru.Images/SuperCardPro/Constants.cs b/Aaru.Images/SuperCardPro/Constants.cs index ccc8ff520..f9611b456 100644 --- a/Aaru.Images/SuperCardPro/Constants.cs +++ b/Aaru.Images/SuperCardPro/Constants.cs @@ -37,12 +37,12 @@ namespace Aaru.DiscImages /// SuperCardPro footer signature: "FPCS" const uint FOOTER_SIGNATURE = 0x53435046; /// SuperCardPro header signature: "SCP" - readonly byte[] scpSignature = + readonly byte[] _scpSignature = { 0x53, 0x43, 0x50 }; /// SuperCardPro track header signature: "TRK" - readonly byte[] trkSignature = + readonly byte[] _trkSignature = { 0x54, 0x52, 0x4B }; diff --git a/Aaru.Images/SuperCardPro/Identify.cs b/Aaru.Images/SuperCardPro/Identify.cs index 70ca74eda..57cfce2b3 100644 --- a/Aaru.Images/SuperCardPro/Identify.cs +++ b/Aaru.Images/SuperCardPro/Identify.cs @@ -53,7 +53,7 @@ namespace Aaru.DiscImages Header = Marshal.ByteArrayToStructureLittleEndian(hdr); - return scpSignature.SequenceEqual(Header.signature); + return _scpSignature.SequenceEqual(Header.signature); } } } \ No newline at end of file diff --git a/Aaru.Images/SuperCardPro/Properties.cs b/Aaru.Images/SuperCardPro/Properties.cs index e1d350bff..1f10af23e 100644 --- a/Aaru.Images/SuperCardPro/Properties.cs +++ b/Aaru.Images/SuperCardPro/Properties.cs @@ -39,7 +39,7 @@ namespace Aaru.DiscImages { public partial class SuperCardPro { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "SuperCardPro"; public Guid Id => new Guid("C5D3182E-1D45-4767-A205-E6E5C83444DC"); public string Author => "Natalia Portillo"; diff --git a/Aaru.Images/SuperCardPro/Read.cs b/Aaru.Images/SuperCardPro/Read.cs index d7b650dd4..29c96810a 100644 --- a/Aaru.Images/SuperCardPro/Read.cs +++ b/Aaru.Images/SuperCardPro/Read.cs @@ -45,15 +45,15 @@ namespace Aaru.DiscImages { public bool Open(IFilter imageFilter) { - Header = new ScpHeader(); - scpStream = imageFilter.GetDataForkStream(); - scpStream.Seek(0, SeekOrigin.Begin); + Header = new ScpHeader(); + _scpStream = imageFilter.GetDataForkStream(); + _scpStream.Seek(0, SeekOrigin.Begin); - if(scpStream.Length < Marshal.SizeOf()) + if(_scpStream.Length < Marshal.SizeOf()) return false; byte[] hdr = new byte[Marshal.SizeOf()]; - scpStream.Read(hdr, 0, Marshal.SizeOf()); + _scpStream.Read(hdr, 0, Marshal.SizeOf()); Header = Marshal.ByteArrayToStructureLittleEndian(hdr); @@ -73,7 +73,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("SuperCardPro plugin", "header.reserved = {0}", Header.reserved); AaruConsole.DebugWriteLine("SuperCardPro plugin", "header.checksum = 0x{0:X8}", Header.checksum); - if(!scpSignature.SequenceEqual(Header.signature)) + if(!_scpSignature.SequenceEqual(Header.signature)) return false; ScpTracks = new Dictionary(); @@ -83,7 +83,7 @@ namespace Aaru.DiscImages if(t >= Header.offsets.Length) break; - scpStream.Position = Header.offsets[t]; + _scpStream.Position = Header.offsets[t]; var trk = new TrackHeader { @@ -91,10 +91,10 @@ namespace Aaru.DiscImages Entries = new TrackEntry[Header.revolutions] }; - scpStream.Read(trk.Signature, 0, trk.Signature.Length); - trk.TrackNumber = (byte)scpStream.ReadByte(); + _scpStream.Read(trk.Signature, 0, trk.Signature.Length); + trk.TrackNumber = (byte)_scpStream.ReadByte(); - if(!trk.Signature.SequenceEqual(trkSignature)) + if(!trk.Signature.SequenceEqual(_trkSignature)) { AaruConsole.DebugWriteLine("SuperCardPro plugin", "Track header at {0} contains incorrect signature.", Header.offsets[t]); @@ -115,7 +115,7 @@ namespace Aaru.DiscImages for(byte r = 0; r < Header.revolutions; r++) { byte[] rev = new byte[Marshal.SizeOf()]; - scpStream.Read(rev, 0, Marshal.SizeOf()); + _scpStream.Read(rev, 0, Marshal.SizeOf()); trk.Entries[r] = Marshal.ByteArrayToStructureLittleEndian(rev); @@ -128,23 +128,23 @@ namespace Aaru.DiscImages if(Header.flags.HasFlag(ScpFlags.HasFooter)) { - long position = scpStream.Position; - scpStream.Seek(-4, SeekOrigin.End); + long position = _scpStream.Position; + _scpStream.Seek(-4, SeekOrigin.End); - while(scpStream.Position >= position) + while(_scpStream.Position >= position) { byte[] footerSig = new byte[4]; - scpStream.Read(footerSig, 0, 4); + _scpStream.Read(footerSig, 0, 4); uint footerMagic = BitConverter.ToUInt32(footerSig, 0); if(footerMagic == FOOTER_SIGNATURE) { - scpStream.Seek(-Marshal.SizeOf(), SeekOrigin.Current); + _scpStream.Seek(-Marshal.SizeOf(), SeekOrigin.Current); - AaruConsole.DebugWriteLine("SuperCardPro plugin", "Found footer at {0}", scpStream.Position); + AaruConsole.DebugWriteLine("SuperCardPro plugin", "Found footer at {0}", _scpStream.Position); byte[] ftr = new byte[Marshal.SizeOf()]; - scpStream.Read(ftr, 0, Marshal.SizeOf()); + _scpStream.Read(ftr, 0, Marshal.SizeOf()); ScpFooter footer = Marshal.ByteArrayToStructureLittleEndian(ftr); @@ -188,66 +188,66 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("SuperCardPro plugin", "footer.signature = \"{0}\"", StringHandlers.CToString(BitConverter.GetBytes(footer.signature))); - imageInfo.DriveManufacturer = ReadPStringUtf8(scpStream, footer.manufacturerOffset); - imageInfo.DriveModel = ReadPStringUtf8(scpStream, footer.modelOffset); - imageInfo.DriveSerialNumber = ReadPStringUtf8(scpStream, footer.serialOffset); - imageInfo.Creator = ReadPStringUtf8(scpStream, footer.creatorOffset); - imageInfo.Application = ReadPStringUtf8(scpStream, footer.applicationOffset); - imageInfo.Comments = ReadPStringUtf8(scpStream, footer.commentsOffset); + _imageInfo.DriveManufacturer = ReadPStringUtf8(_scpStream, footer.manufacturerOffset); + _imageInfo.DriveModel = ReadPStringUtf8(_scpStream, footer.modelOffset); + _imageInfo.DriveSerialNumber = ReadPStringUtf8(_scpStream, footer.serialOffset); + _imageInfo.Creator = ReadPStringUtf8(_scpStream, footer.creatorOffset); + _imageInfo.Application = ReadPStringUtf8(_scpStream, footer.applicationOffset); + _imageInfo.Comments = ReadPStringUtf8(_scpStream, footer.commentsOffset); AaruConsole.DebugWriteLine("SuperCardPro plugin", "ImageInfo.driveManufacturer = \"{0}\"", - imageInfo.DriveManufacturer); + _imageInfo.DriveManufacturer); AaruConsole.DebugWriteLine("SuperCardPro plugin", "ImageInfo.driveModel = \"{0}\"", - imageInfo.DriveModel); + _imageInfo.DriveModel); AaruConsole.DebugWriteLine("SuperCardPro plugin", "ImageInfo.driveSerialNumber = \"{0}\"", - imageInfo.DriveSerialNumber); + _imageInfo.DriveSerialNumber); AaruConsole.DebugWriteLine("SuperCardPro plugin", "ImageInfo.imageCreator = \"{0}\"", - imageInfo.Creator); + _imageInfo.Creator); AaruConsole.DebugWriteLine("SuperCardPro plugin", "ImageInfo.imageApplication = \"{0}\"", - imageInfo.Application); + _imageInfo.Application); AaruConsole.DebugWriteLine("SuperCardPro plugin", "ImageInfo.imageComments = \"{0}\"", - imageInfo.Comments); + _imageInfo.Comments); - imageInfo.CreationTime = footer.creationTime != 0 - ? DateHandlers.UnixToDateTime(footer.creationTime) - : imageFilter.GetCreationTime(); + _imageInfo.CreationTime = footer.creationTime != 0 + ? DateHandlers.UnixToDateTime(footer.creationTime) + : imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = footer.modificationTime != 0 - ? DateHandlers.UnixToDateTime(footer.modificationTime) - : imageFilter.GetLastWriteTime(); + _imageInfo.LastModificationTime = footer.modificationTime != 0 + ? DateHandlers.UnixToDateTime(footer.modificationTime) + : imageFilter.GetLastWriteTime(); AaruConsole.DebugWriteLine("SuperCardPro plugin", "ImageInfo.imageCreationTime = {0}", - imageInfo.CreationTime); + _imageInfo.CreationTime); AaruConsole.DebugWriteLine("SuperCardPro plugin", "ImageInfo.imageLastModificationTime = {0}", - imageInfo.LastModificationTime); + _imageInfo.LastModificationTime); - imageInfo.ApplicationVersion = + _imageInfo.ApplicationVersion = $"{(footer.applicationVersion & 0xF0) >> 4}.{footer.applicationVersion & 0xF}"; - imageInfo.DriveFirmwareRevision = + _imageInfo.DriveFirmwareRevision = $"{(footer.firmwareVersion & 0xF0) >> 4}.{footer.firmwareVersion & 0xF}"; - imageInfo.Version = $"{(footer.imageVersion & 0xF0) >> 4}.{footer.imageVersion & 0xF}"; + _imageInfo.Version = $"{(footer.imageVersion & 0xF0) >> 4}.{footer.imageVersion & 0xF}"; break; } - scpStream.Seek(-8, SeekOrigin.Current); + _scpStream.Seek(-8, SeekOrigin.Current); } } else { - imageInfo.Application = "SuperCardPro"; - imageInfo.ApplicationVersion = $"{(Header.version & 0xF0) >> 4}.{Header.version & 0xF}"; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.Version = "1.5"; + _imageInfo.Application = "SuperCardPro"; + _imageInfo.ApplicationVersion = $"{(Header.version & 0xF0) >> 4}.{Header.version & 0xF}"; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.Version = "1.5"; } throw new NotImplementedException("Flux decoding is not yet implemented."); diff --git a/Aaru.Images/SuperCardPro/SuperCardPro.cs b/Aaru.Images/SuperCardPro/SuperCardPro.cs index 3a3451d21..52a37610b 100644 --- a/Aaru.Images/SuperCardPro/SuperCardPro.cs +++ b/Aaru.Images/SuperCardPro/SuperCardPro.cs @@ -40,13 +40,14 @@ namespace Aaru.DiscImages { public partial class SuperCardPro : IMediaImage, IVerifiableImage, IVerifiableSectorsImage { + ImageInfo _imageInfo; + Stream _scpStream; + // TODO: These variables have been made public so create-sidecar can access to this information until I define an API >4.0 public ScpHeader Header; - ImageInfo imageInfo; - Stream scpStream; public Dictionary ScpTracks; - public SuperCardPro() => imageInfo = new ImageInfo + public SuperCardPro() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/SuperCardPro/Verify.cs b/Aaru.Images/SuperCardPro/Verify.cs index 7bc49c163..5e8b2deac 100644 --- a/Aaru.Images/SuperCardPro/Verify.cs +++ b/Aaru.Images/SuperCardPro/Verify.cs @@ -42,11 +42,11 @@ namespace Aaru.DiscImages if(Header.flags.HasFlag(ScpFlags.Writable)) return null; - byte[] wholeFile = new byte[scpStream.Length]; + byte[] wholeFile = new byte[_scpStream.Length]; uint sum = 0; - scpStream.Position = 0; - scpStream.Read(wholeFile, 0, wholeFile.Length); + _scpStream.Position = 0; + _scpStream.Read(wholeFile, 0, wholeFile.Length); for(int i = 0x10; i < wholeFile.Length; i++) sum += wholeFile[i]; diff --git a/Aaru.Images/T98/Properties.cs b/Aaru.Images/T98/Properties.cs index 9bf324c06..f46f80e17 100644 --- a/Aaru.Images/T98/Properties.cs +++ b/Aaru.Images/T98/Properties.cs @@ -43,7 +43,7 @@ namespace Aaru.DiscImages { public string Name => "T98 Hard Disk Image"; public Guid Id => new Guid("0410003E-6E7B-40E6-9328-BA5651ADF6B7"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Format => "T98 disk image"; public List DumpHardware => null; diff --git a/Aaru.Images/T98/Read.cs b/Aaru.Images/T98/Read.cs index e3b5250ca..475c2575c 100644 --- a/Aaru.Images/T98/Read.cs +++ b/Aaru.Images/T98/Read.cs @@ -57,20 +57,20 @@ namespace Aaru.DiscImages int cylinders = BitConverter.ToInt32(hdrB, 0); - imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.ImageSize = (ulong)(stream.Length - 256); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = (ulong)((stream.Length / 256) - 1); - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.SectorSize = 256; - imageInfo.Cylinders = (uint)cylinders; - imageInfo.Heads = 8; - imageInfo.SectorsPerTrack = 33; + _imageInfo.ImageSize = (ulong)(stream.Length - 256); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = (ulong)((stream.Length / 256) - 1); + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.SectorSize = 256; + _imageInfo.Cylinders = (uint)cylinders; + _imageInfo.Heads = 8; + _imageInfo.SectorsPerTrack = 33; - t98ImageFilter = imageFilter; + _t98ImageFilter = imageFilter; return true; } @@ -79,19 +79,19 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Stream stream = t98ImageFilter.GetDataForkStream(); + Stream stream = _t98ImageFilter.GetDataForkStream(); - stream.Seek((long)(256 + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)(256 + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); - stream.Read(buffer, 0, (int)(length * imageInfo.SectorSize)); + stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize)); return buffer; } diff --git a/Aaru.Images/T98/T98.cs b/Aaru.Images/T98/T98.cs index 2ac1a2c33..7f46d1b40 100644 --- a/Aaru.Images/T98/T98.cs +++ b/Aaru.Images/T98/T98.cs @@ -40,11 +40,11 @@ namespace Aaru.DiscImages { public partial class T98 : IWritableImage { - ImageInfo imageInfo; - IFilter t98ImageFilter; - FileStream writingStream; + ImageInfo _imageInfo; + IFilter _t98ImageFilter; + FileStream _writingStream; - public T98() => imageInfo = new ImageInfo + public T98() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/T98/Write.cs b/Aaru.Images/T98/Write.cs index 66892ab12..004650bf7 100644 --- a/Aaru.Images/T98/Write.cs +++ b/Aaru.Images/T98/Write.cs @@ -60,7 +60,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -69,7 +69,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -100,22 +100,22 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(256 + (sectorAddress * 256)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(256 + (sectorAddress * 256)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -131,22 +131,22 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(256 + (sectorAddress * 256)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(256 + (sectorAddress * 256)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -176,12 +176,12 @@ namespace Aaru.DiscImages return false; } - int cylinders = (int)(imageInfo.Sectors / 33 / 8); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(BitConverter.GetBytes(cylinders), 0, 4); + int cylinders = (int)(_imageInfo.Sectors / 33 / 8); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(BitConverter.GetBytes(cylinders), 0, 4); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; diff --git a/Aaru.Images/TeleDisk/Helpers.cs b/Aaru.Images/TeleDisk/Helpers.cs index ba142edbb..172501609 100644 --- a/Aaru.Images/TeleDisk/Helpers.cs +++ b/Aaru.Images/TeleDisk/Helpers.cs @@ -42,9 +42,9 @@ namespace Aaru.DiscImages { (ushort cylinder, byte head, byte sector) LbaToChs(ulong lba) { - ushort cylinder = (ushort)(lba / (imageInfo.Heads * imageInfo.SectorsPerTrack)); - byte head = (byte)((lba / imageInfo.SectorsPerTrack) % imageInfo.Heads); - byte sector = (byte)((lba % imageInfo.SectorsPerTrack) + 1); + ushort cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack)); + byte head = (byte)((lba / _imageInfo.SectorsPerTrack) % _imageInfo.Heads); + byte sector = (byte)((lba % _imageInfo.SectorsPerTrack) + 1); return (cylinder, head, sector); } @@ -197,18 +197,18 @@ namespace Aaru.DiscImages MediaType DecodeTeleDiskDiskType() { - switch(header.DriveType) + switch(_header.DriveType) { case DRIVE_TYPE_525_DD: case DRIVE_TYPE_525_HD_DD_DISK: case DRIVE_TYPE_525_HD: { - switch(totalDiskSize) + switch(_totalDiskSize) { case 163840: { // Acorn disk uses 256 bytes/sector - return imageInfo.SectorSize == 256 ? MediaType.ACORN_525_SS_DD_40 + return _imageInfo.SectorSize == 256 ? MediaType.ACORN_525_SS_DD_40 : MediaType.DOS_525_SS_DD_8; // DOS disks use 512 bytes/sector @@ -216,14 +216,14 @@ namespace Aaru.DiscImages case 184320: { // Atari disk uses 256 bytes/sector - return imageInfo.SectorSize == 256 ? MediaType.ATARI_525_DD : MediaType.DOS_525_SS_DD_9; + return _imageInfo.SectorSize == 256 ? MediaType.ATARI_525_DD : MediaType.DOS_525_SS_DD_9; // DOS disks use 512 bytes/sector } case 327680: { // Acorn disk uses 256 bytes/sector - return imageInfo.SectorSize == 256 ? MediaType.ACORN_525_SS_DD_80 + return _imageInfo.SectorSize == 256 ? MediaType.ACORN_525_SS_DD_80 : MediaType.DOS_525_DS_DD_8; // DOS disks use 512 bytes/sector @@ -248,7 +248,7 @@ namespace Aaru.DiscImages default: { AaruConsole.DebugWriteLine("TeleDisk plugin", "Unknown 5,25\" disk with {0} bytes", - totalDiskSize); + _totalDiskSize); return MediaType.Unknown; } @@ -258,7 +258,7 @@ namespace Aaru.DiscImages case DRIVE_TYPE_35_ED: case DRIVE_TYPE_35_HD: { - switch(totalDiskSize) + switch(_totalDiskSize) { case 322560: return MediaType.Apricot_35; case 327680: return MediaType.DOS_35_SS_DD_8; @@ -281,7 +281,7 @@ namespace Aaru.DiscImages default: { AaruConsole.DebugWriteLine("TeleDisk plugin", "Unknown 3,5\" disk with {0} bytes", - totalDiskSize); + _totalDiskSize); return MediaType.Unknown; } @@ -289,7 +289,7 @@ namespace Aaru.DiscImages } case DRIVE_TYPE_8_INCH: { - switch(totalDiskSize) + switch(_totalDiskSize) { case 81664: return MediaType.IBM23FD; case 242944: return MediaType.IBM33FD_128; @@ -306,7 +306,7 @@ namespace Aaru.DiscImages case 512512: { // DEC disk uses 256 bytes/sector - return imageInfo.SectorSize == 256 ? MediaType.RX02 : MediaType.ECMA_59; + return _imageInfo.SectorSize == 256 ? MediaType.RX02 : MediaType.ECMA_59; // ECMA disks use 128 bytes/sector } @@ -317,7 +317,7 @@ namespace Aaru.DiscImages default: { AaruConsole.DebugWriteLine("TeleDisk plugin", "Unknown 8\" disk with {0} bytes", - totalDiskSize); + _totalDiskSize); return MediaType.Unknown; } @@ -326,7 +326,7 @@ namespace Aaru.DiscImages default: { AaruConsole.DebugWriteLine("TeleDisk plugin", "Unknown drive type {1} with {0} bytes", - totalDiskSize, header.DriveType); + _totalDiskSize, _header.DriveType); return MediaType.Unknown; } diff --git a/Aaru.Images/TeleDisk/Identify.cs b/Aaru.Images/TeleDisk/Identify.cs index 72aa5c031..e319e0677 100644 --- a/Aaru.Images/TeleDisk/Identify.cs +++ b/Aaru.Images/TeleDisk/Identify.cs @@ -41,64 +41,64 @@ namespace Aaru.DiscImages { public bool Identify(IFilter imageFilter) { - header = new TeleDiskHeader(); + _header = new TeleDiskHeader(); byte[] headerBytes = new byte[12]; Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); stream.Read(headerBytes, 0, 12); - header.Signature = BitConverter.ToUInt16(headerBytes, 0); + _header.Signature = BitConverter.ToUInt16(headerBytes, 0); - if(header.Signature != TD_MAGIC && - header.Signature != TD_ADV_COMP_MAGIC) + if(_header.Signature != TD_MAGIC && + _header.Signature != TD_ADV_COMP_MAGIC) return false; - header.Sequence = headerBytes[2]; - header.DiskSet = headerBytes[3]; - header.Version = headerBytes[4]; - header.DataRate = headerBytes[5]; - header.DriveType = headerBytes[6]; - header.Stepping = headerBytes[7]; - header.DosAllocation = headerBytes[8]; - header.Sides = headerBytes[9]; - header.Crc = BitConverter.ToUInt16(headerBytes, 10); + _header.Sequence = headerBytes[2]; + _header.DiskSet = headerBytes[3]; + _header.Version = headerBytes[4]; + _header.DataRate = headerBytes[5]; + _header.DriveType = headerBytes[6]; + _header.Stepping = headerBytes[7]; + _header.DosAllocation = headerBytes[8]; + _header.Sides = headerBytes[9]; + _header.Crc = BitConverter.ToUInt16(headerBytes, 10); byte[] headerBytesForCrc = new byte[10]; Array.Copy(headerBytes, headerBytesForCrc, 10); ushort calculatedHeaderCrc = TeleDiskCrc(0x0000, headerBytesForCrc); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.signature = 0x{0:X4}", header.Signature); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.sequence = 0x{0:X2}", header.Sequence); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.diskSet = 0x{0:X2}", header.DiskSet); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.version = 0x{0:X2}", header.Version); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.dataRate = 0x{0:X2}", header.DataRate); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.driveType = 0x{0:X2}", header.DriveType); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.stepping = 0x{0:X2}", header.Stepping); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.dosAllocation = 0x{0:X2}", header.DosAllocation); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.sides = 0x{0:X2}", header.Sides); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.crc = 0x{0:X4}", header.Crc); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.signature = 0x{0:X4}", _header.Signature); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.sequence = 0x{0:X2}", _header.Sequence); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.diskSet = 0x{0:X2}", _header.DiskSet); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.version = 0x{0:X2}", _header.Version); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.dataRate = 0x{0:X2}", _header.DataRate); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.driveType = 0x{0:X2}", _header.DriveType); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.stepping = 0x{0:X2}", _header.Stepping); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.dosAllocation = 0x{0:X2}", _header.DosAllocation); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.sides = 0x{0:X2}", _header.Sides); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.crc = 0x{0:X4}", _header.Crc); AaruConsole.DebugWriteLine("TeleDisk plugin", "calculated header crc = 0x{0:X4}", calculatedHeaderCrc); // We need more checks as the magic is too simply. // This may deny legal images // That would be much of a coincidence - if(header.Crc == calculatedHeaderCrc) + if(_header.Crc == calculatedHeaderCrc) return true; - if(header.Sequence != 0x00) + if(_header.Sequence != 0x00) return false; - if(header.DataRate != DATA_RATE_250KBPS && - header.DataRate != DATA_RATE_300KBPS && - header.DataRate != DATA_RATE_500KBPS) + if(_header.DataRate != DATA_RATE_250KBPS && + _header.DataRate != DATA_RATE_300KBPS && + _header.DataRate != DATA_RATE_500KBPS) return false; - return header.DriveType == DRIVE_TYPE_35_DD || header.DriveType == DRIVE_TYPE_35_ED || - header.DriveType == DRIVE_TYPE_35_HD || header.DriveType == DRIVE_TYPE_525_DD || - header.DriveType == DRIVE_TYPE_525_HD || header.DriveType == DRIVE_TYPE_525_HD_DD_DISK || - header.DriveType == DRIVE_TYPE_8_INCH; + return _header.DriveType == DRIVE_TYPE_35_DD || _header.DriveType == DRIVE_TYPE_35_ED || + _header.DriveType == DRIVE_TYPE_35_HD || _header.DriveType == DRIVE_TYPE_525_DD || + _header.DriveType == DRIVE_TYPE_525_HD || _header.DriveType == DRIVE_TYPE_525_HD_DD_DISK || + _header.DriveType == DRIVE_TYPE_8_INCH; } } } \ No newline at end of file diff --git a/Aaru.Images/TeleDisk/Properties.cs b/Aaru.Images/TeleDisk/Properties.cs index 26530601f..d25e1d120 100644 --- a/Aaru.Images/TeleDisk/Properties.cs +++ b/Aaru.Images/TeleDisk/Properties.cs @@ -39,7 +39,7 @@ namespace Aaru.DiscImages { public partial class TeleDisk { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Sydex TeleDisk"; public Guid Id => new Guid("0240B7B1-E959-4CDC-B0BD-386D6E467B88"); diff --git a/Aaru.Images/TeleDisk/Read.cs b/Aaru.Images/TeleDisk/Read.cs index 601703ca2..b9e16ff1c 100644 --- a/Aaru.Images/TeleDisk/Read.cs +++ b/Aaru.Images/TeleDisk/Read.cs @@ -45,84 +45,84 @@ namespace Aaru.DiscImages { public bool Open(IFilter imageFilter) { - header = new TeleDiskHeader(); + _header = new TeleDiskHeader(); byte[] headerBytes = new byte[12]; - inStream = imageFilter.GetDataForkStream(); + _inStream = imageFilter.GetDataForkStream(); var stream = new MemoryStream(); - inStream.Seek(0, SeekOrigin.Begin); + _inStream.Seek(0, SeekOrigin.Begin); - inStream.Read(headerBytes, 0, 12); + _inStream.Read(headerBytes, 0, 12); stream.Write(headerBytes, 0, 12); - header.Signature = BitConverter.ToUInt16(headerBytes, 0); + _header.Signature = BitConverter.ToUInt16(headerBytes, 0); - if(header.Signature != TD_MAGIC && - header.Signature != TD_ADV_COMP_MAGIC) + if(_header.Signature != TD_MAGIC && + _header.Signature != TD_ADV_COMP_MAGIC) return false; - header.Sequence = headerBytes[2]; - header.DiskSet = headerBytes[3]; - header.Version = headerBytes[4]; - header.DataRate = headerBytes[5]; - header.DriveType = headerBytes[6]; - header.Stepping = headerBytes[7]; - header.DosAllocation = headerBytes[8]; - header.Sides = headerBytes[9]; - header.Crc = BitConverter.ToUInt16(headerBytes, 10); + _header.Sequence = headerBytes[2]; + _header.DiskSet = headerBytes[3]; + _header.Version = headerBytes[4]; + _header.DataRate = headerBytes[5]; + _header.DriveType = headerBytes[6]; + _header.Stepping = headerBytes[7]; + _header.DosAllocation = headerBytes[8]; + _header.Sides = headerBytes[9]; + _header.Crc = BitConverter.ToUInt16(headerBytes, 10); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Version = $"{(header.Version & 0xF0) >> 4}.{header.Version & 0x0F}"; - imageInfo.Application = imageInfo.Version; + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Version = $"{(_header.Version & 0xF0) >> 4}.{_header.Version & 0x0F}"; + _imageInfo.Application = _imageInfo.Version; byte[] headerBytesForCrc = new byte[10]; Array.Copy(headerBytes, headerBytesForCrc, 10); ushort calculatedHeaderCrc = TeleDiskCrc(0x0000, headerBytesForCrc); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.signature = 0x{0:X4}", header.Signature); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.sequence = 0x{0:X2}", header.Sequence); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.diskSet = 0x{0:X2}", header.DiskSet); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.version = 0x{0:X2}", header.Version); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.dataRate = 0x{0:X2}", header.DataRate); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.driveType = 0x{0:X2}", header.DriveType); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.stepping = 0x{0:X2}", header.Stepping); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.dosAllocation = 0x{0:X2}", header.DosAllocation); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.sides = 0x{0:X2}", header.Sides); - AaruConsole.DebugWriteLine("TeleDisk plugin", "header.crc = 0x{0:X4}", header.Crc); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.signature = 0x{0:X4}", _header.Signature); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.sequence = 0x{0:X2}", _header.Sequence); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.diskSet = 0x{0:X2}", _header.DiskSet); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.version = 0x{0:X2}", _header.Version); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.dataRate = 0x{0:X2}", _header.DataRate); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.driveType = 0x{0:X2}", _header.DriveType); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.stepping = 0x{0:X2}", _header.Stepping); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.dosAllocation = 0x{0:X2}", _header.DosAllocation); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.sides = 0x{0:X2}", _header.Sides); + AaruConsole.DebugWriteLine("TeleDisk plugin", "header.crc = 0x{0:X4}", _header.Crc); AaruConsole.DebugWriteLine("TeleDisk plugin", "calculated header crc = 0x{0:X4}", calculatedHeaderCrc); // We need more checks as the magic is too simply. // This may deny legal images // That would be much of a coincidence - if(header.Crc != calculatedHeaderCrc) + if(_header.Crc != calculatedHeaderCrc) { - aDiskCrcHasFailed = true; + _aDiskCrcHasFailed = true; AaruConsole.DebugWriteLine("TeleDisk plugin", "Calculated CRC does not coincide with stored one."); } - if(header.Sequence != 0x00) + if(_header.Sequence != 0x00) return false; - if(header.DataRate != DATA_RATE_250KBPS && - header.DataRate != DATA_RATE_300KBPS && - header.DataRate != DATA_RATE_500KBPS) + if(_header.DataRate != DATA_RATE_250KBPS && + _header.DataRate != DATA_RATE_300KBPS && + _header.DataRate != DATA_RATE_500KBPS) return false; - if(header.DriveType != DRIVE_TYPE_35_DD && - header.DriveType != DRIVE_TYPE_35_ED && - header.DriveType != DRIVE_TYPE_35_HD && - header.DriveType != DRIVE_TYPE_525_DD && - header.DriveType != DRIVE_TYPE_525_HD && - header.DriveType != DRIVE_TYPE_525_HD_DD_DISK && - header.DriveType != DRIVE_TYPE_8_INCH) + if(_header.DriveType != DRIVE_TYPE_35_DD && + _header.DriveType != DRIVE_TYPE_35_ED && + _header.DriveType != DRIVE_TYPE_35_HD && + _header.DriveType != DRIVE_TYPE_525_DD && + _header.DriveType != DRIVE_TYPE_525_HD && + _header.DriveType != DRIVE_TYPE_525_HD_DD_DISK && + _header.DriveType != DRIVE_TYPE_8_INCH) return false; - if(header.Signature == TD_ADV_COMP_MAGIC) + if(_header.Signature == TD_ADV_COMP_MAGIC) { int rd; - inStream.Seek(12, SeekOrigin.Begin); + _inStream.Seek(12, SeekOrigin.Begin); stream.Seek(12, SeekOrigin.Begin); - var lzh = new TeleDiskLzh(inStream); + var lzh = new TeleDiskLzh(_inStream); do if((rd = lzh.Decode(out byte[] obuf, BUFSZ)) > 0) @@ -132,94 +132,94 @@ namespace Aaru.DiscImages else { // Not using Stream.CopyTo() because it's failing with LZIP - byte[] copybuf = new byte[inStream.Length]; - inStream.Seek(0, SeekOrigin.Begin); - inStream.Read(copybuf, 0, copybuf.Length); + byte[] copybuf = new byte[_inStream.Length]; + _inStream.Seek(0, SeekOrigin.Begin); + _inStream.Read(copybuf, 0, copybuf.Length); stream.Seek(0, SeekOrigin.Begin); stream.Write(copybuf, 0, copybuf.Length); } stream.Seek(12, SeekOrigin.Begin); - imageInfo.CreationTime = DateTime.MinValue; + _imageInfo.CreationTime = DateTime.MinValue; - if((header.Stepping & COMMENT_BLOCK_PRESENT) == COMMENT_BLOCK_PRESENT) + if((_header.Stepping & COMMENT_BLOCK_PRESENT) == COMMENT_BLOCK_PRESENT) { - commentHeader = new TeleDiskCommentBlockHeader(); + _commentHeader = new TeleDiskCommentBlockHeader(); byte[] commentHeaderBytes = new byte[10]; stream.Read(commentHeaderBytes, 0, 10); - commentHeader.Crc = BitConverter.ToUInt16(commentHeaderBytes, 0); - commentHeader.Length = BitConverter.ToUInt16(commentHeaderBytes, 2); - commentHeader.Year = commentHeaderBytes[4]; - commentHeader.Month = commentHeaderBytes[5]; - commentHeader.Day = commentHeaderBytes[6]; - commentHeader.Hour = commentHeaderBytes[7]; - commentHeader.Minute = commentHeaderBytes[8]; - commentHeader.Second = commentHeaderBytes[9]; + _commentHeader.Crc = BitConverter.ToUInt16(commentHeaderBytes, 0); + _commentHeader.Length = BitConverter.ToUInt16(commentHeaderBytes, 2); + _commentHeader.Year = commentHeaderBytes[4]; + _commentHeader.Month = commentHeaderBytes[5]; + _commentHeader.Day = commentHeaderBytes[6]; + _commentHeader.Hour = commentHeaderBytes[7]; + _commentHeader.Minute = commentHeaderBytes[8]; + _commentHeader.Second = commentHeaderBytes[9]; - commentBlock = new byte[commentHeader.Length]; - stream.Read(commentBlock, 0, commentHeader.Length); + _commentBlock = new byte[_commentHeader.Length]; + stream.Read(_commentBlock, 0, _commentHeader.Length); - byte[] commentBlockForCrc = new byte[commentHeader.Length + 8]; + byte[] commentBlockForCrc = new byte[_commentHeader.Length + 8]; Array.Copy(commentHeaderBytes, 2, commentBlockForCrc, 0, 8); - Array.Copy(commentBlock, 0, commentBlockForCrc, 8, commentHeader.Length); + Array.Copy(_commentBlock, 0, commentBlockForCrc, 8, _commentHeader.Length); ushort cmtcrc = TeleDiskCrc(0, commentBlockForCrc); AaruConsole.DebugWriteLine("TeleDisk plugin", "Comment header"); - AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.crc = 0x{0:X4}", commentHeader.Crc); + AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.crc = 0x{0:X4}", _commentHeader.Crc); AaruConsole.DebugWriteLine("TeleDisk plugin", "\tCalculated CRC = 0x{0:X4}", cmtcrc); AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.length = {0} bytes", - commentHeader.Length); + _commentHeader.Length); - AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.year = {0}", commentHeader.Year); - AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.month = {0}", commentHeader.Month); - AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.day = {0}", commentHeader.Day); - AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.hour = {0}", commentHeader.Hour); - AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.minute = {0}", commentHeader.Minute); - AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.second = {0}", commentHeader.Second); + AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.year = {0}", _commentHeader.Year); + AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.month = {0}", _commentHeader.Month); + AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.day = {0}", _commentHeader.Day); + AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.hour = {0}", _commentHeader.Hour); + AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.minute = {0}", _commentHeader.Minute); + AaruConsole.DebugWriteLine("TeleDisk plugin", "\tcommentheader.second = {0}", _commentHeader.Second); - aDiskCrcHasFailed |= cmtcrc != commentHeader.Crc; + _aDiskCrcHasFailed |= cmtcrc != _commentHeader.Crc; - for(int i = 0; i < commentBlock.Length; i++) + for(int i = 0; i < _commentBlock.Length; i++) // Replace NULLs, used by TeleDisk as newline markers, with UNIX newline marker - if(commentBlock[i] == 0x00) - commentBlock[i] = 0x0A; + if(_commentBlock[i] == 0x00) + _commentBlock[i] = 0x0A; - imageInfo.Comments = Encoding.ASCII.GetString(commentBlock); + _imageInfo.Comments = Encoding.ASCII.GetString(_commentBlock); AaruConsole.DebugWriteLine("TeleDisk plugin", "Comment"); - AaruConsole.DebugWriteLine("TeleDisk plugin", "{0}", imageInfo.Comments); + AaruConsole.DebugWriteLine("TeleDisk plugin", "{0}", _imageInfo.Comments); - imageInfo.CreationTime = new DateTime(commentHeader.Year + 1900, commentHeader.Month + 1, - commentHeader.Day, commentHeader.Hour, commentHeader.Minute, - commentHeader.Second, DateTimeKind.Unspecified); + _imageInfo.CreationTime = new DateTime(_commentHeader.Year + 1900, _commentHeader.Month + 1, + _commentHeader.Day, _commentHeader.Hour, _commentHeader.Minute, + _commentHeader.Second, DateTimeKind.Unspecified); } - if(imageInfo.CreationTime == DateTime.MinValue) - imageInfo.CreationTime = imageFilter.GetCreationTime(); + if(_imageInfo.CreationTime == DateTime.MinValue) + _imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - AaruConsole.DebugWriteLine("TeleDisk plugin", "Image created on {0}", imageInfo.CreationTime); - AaruConsole.DebugWriteLine("TeleDisk plugin", "Image modified on {0}", imageInfo.LastModificationTime); + AaruConsole.DebugWriteLine("TeleDisk plugin", "Image created on {0}", _imageInfo.CreationTime); + AaruConsole.DebugWriteLine("TeleDisk plugin", "Image modified on {0}", _imageInfo.LastModificationTime); AaruConsole.DebugWriteLine("TeleDisk plugin", "Parsing image"); - totalDiskSize = 0; - imageInfo.ImageSize = 0; + _totalDiskSize = 0; + _imageInfo.ImageSize = 0; int totalCylinders = -1; int totalHeads = -1; int maxSector = -1; int totalSectors = 0; long currentPos = stream.Position; - imageInfo.SectorSize = uint.MaxValue; - imageInfo.SectorsPerTrack = uint.MaxValue; + _imageInfo.SectorSize = uint.MaxValue; + _imageInfo.SectorsPerTrack = uint.MaxValue; // Count cylinders while(true) @@ -268,8 +268,8 @@ namespace Aaru.DiscImages stream.Read(data, 0, teleDiskData.DataSize); } - if(128 << teleDiskSector.SectorSize < imageInfo.SectorSize) - imageInfo.SectorSize = (uint)(128 << teleDiskSector.SectorSize); + if(128 << teleDiskSector.SectorSize < _imageInfo.SectorSize) + _imageInfo.SectorSize = (uint)(128 << teleDiskSector.SectorSize); totalSectors++; } @@ -284,8 +284,8 @@ namespace Aaru.DiscImages bool hasLeadOutOnHead0 = false; bool hasLeadOutOnHead1 = false; - imageInfo.Cylinders = (ushort)totalCylinders; - imageInfo.Heads = (byte)totalHeads; + _imageInfo.Cylinders = (ushort)totalCylinders; + _imageInfo.Heads = (byte)totalHeads; // Count sectors per track stream.Seek(currentPos, SeekOrigin.Begin); @@ -303,17 +303,17 @@ namespace Aaru.DiscImages if(teleDiskTrack.Sectors == 0xFF) // End of disk image break; - if(teleDiskTrack.Sectors < imageInfo.SectorsPerTrack) + if(teleDiskTrack.Sectors < _imageInfo.SectorsPerTrack) if(teleDiskTrack.Cylinder + 1 == totalCylinders) { hasLeadOutOnHead0 |= teleDiskTrack.Head == 0; hasLeadOutOnHead1 |= teleDiskTrack.Head == 1; - if(imageInfo.Cylinders == totalCylinders) - imageInfo.Cylinders--; + if(_imageInfo.Cylinders == totalCylinders) + _imageInfo.Cylinders--; } else - imageInfo.SectorsPerTrack = teleDiskTrack.Sectors; + _imageInfo.SectorsPerTrack = teleDiskTrack.Sectors; for(byte processedSectors = 0; processedSectors < teleDiskTrack.Sectors; processedSectors++) { @@ -341,7 +341,7 @@ namespace Aaru.DiscImages } } - sectorsData = new byte[totalCylinders][][][]; + _sectorsData = new byte[totalCylinders][][][]; // Total sectors per track uint[][] spts = new uint[totalCylinders][]; @@ -353,11 +353,11 @@ namespace Aaru.DiscImages // Create heads for(int i = 0; i < totalCylinders; i++) { - sectorsData[i] = new byte[totalHeads][][]; - spts[i] = new uint[totalHeads]; + _sectorsData[i] = new byte[totalHeads][][]; + spts[i] = new uint[totalHeads]; for(int j = 0; j < totalHeads; j++) - sectorsData[i][j] = new byte[maxSector + 1][]; + _sectorsData[i][j] = new byte[maxSector + 1][]; } // Decode the image @@ -387,14 +387,14 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("TeleDisk plugin", "\tTrack header CRC: 0x{0:X2} (calculated 0x{1:X2})\t", teleDiskTrack.Crc, tdTrackCalculatedCrc); - aDiskCrcHasFailed |= tdTrackCalculatedCrc != teleDiskTrack.Crc; + _aDiskCrcHasFailed |= tdTrackCalculatedCrc != teleDiskTrack.Crc; if(teleDiskTrack.Sectors == 0xFF) // End of disk image { AaruConsole.DebugWriteLine("TeleDisk plugin", "End of disk image arrived"); AaruConsole.DebugWriteLine("TeleDisk plugin", "Total of {0} data sectors, for {1} bytes", - totalSectors, totalDiskSize); + totalSectors, _totalDiskSize); break; } @@ -429,8 +429,8 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("TeleDisk plugin", "\t\tSector CRC (plus headers): 0x{0:X2}", teleDiskSector.Crc); - uint lba = (uint)((teleDiskSector.Cylinder * header.Sides * imageInfo.SectorsPerTrack) + - (teleDiskSector.Head * imageInfo.SectorsPerTrack) + + uint lba = (uint)((teleDiskSector.Cylinder * _header.Sides * _imageInfo.SectorsPerTrack) + + (teleDiskSector.Head * _imageInfo.SectorsPerTrack) + (teleDiskSector.SectorNumber - 1)); if((teleDiskSector.Flags & FLAGS_SECTOR_DATALESS) != FLAGS_SECTOR_DATALESS && @@ -439,7 +439,7 @@ namespace Aaru.DiscImages stream.Read(dataSizeBytes, 0, 2); teleDiskData.DataSize = BitConverter.ToUInt16(dataSizeBytes, 0); teleDiskData.DataSize--; // Sydex decided to including dataEncoding byte as part of it - imageInfo.ImageSize += teleDiskData.DataSize; + _imageInfo.ImageSize += teleDiskData.DataSize; teleDiskData.DataEncoding = (byte)stream.ReadByte(); byte[] data = new byte[teleDiskData.DataSize]; stream.Read(data, 0, teleDiskData.DataSize); @@ -463,7 +463,7 @@ namespace Aaru.DiscImages teleDiskSector.SectorNumber); if((teleDiskSector.Flags & FLAGS_SECTOR_NO_ID) != FLAGS_SECTOR_NO_ID) - sectorsWhereCrcHasFailed.Add(lba); + _sectorsWhereCrcHasFailed.Add(lba); } } else @@ -474,7 +474,7 @@ namespace Aaru.DiscImages if((teleDiskSector.Flags & FLAGS_SECTOR_NO_ID) == FLAGS_SECTOR_NO_ID) continue; - if(sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] != null) + if(_sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] != null) AaruConsole.DebugWriteLine("TeleDisk plugin", (teleDiskSector.Flags & FLAGS_SECTOR_DUPLICATE) == FLAGS_SECTOR_DUPLICATE @@ -484,10 +484,10 @@ namespace Aaru.DiscImages teleDiskSector.Head); else { - sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] = + _sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] = decodedData; - totalDiskSize += (uint)decodedData.Length; + _totalDiskSize += (uint)decodedData.Length; } } } @@ -495,34 +495,34 @@ namespace Aaru.DiscImages var leadOutMs = new MemoryStream(); if(hasLeadOutOnHead0) - for(int i = 0; i < sectorsData[totalCylinders - 1][0].Length; i++) - if(sectorsData[totalCylinders - 1][0][i] != null) - leadOutMs.Write(sectorsData[totalCylinders - 1][0][i], 0, - sectorsData[totalCylinders - 1][0][i].Length); + for(int i = 0; i < _sectorsData[totalCylinders - 1][0].Length; i++) + if(_sectorsData[totalCylinders - 1][0][i] != null) + leadOutMs.Write(_sectorsData[totalCylinders - 1][0][i], 0, + _sectorsData[totalCylinders - 1][0][i].Length); if(hasLeadOutOnHead1) - for(int i = 0; i < sectorsData[totalCylinders - 1][1].Length; i++) - if(sectorsData[totalCylinders - 1][1][i] != null) - leadOutMs.Write(sectorsData[totalCylinders - 1][1][i], 0, - sectorsData[totalCylinders - 1][1][i].Length); + for(int i = 0; i < _sectorsData[totalCylinders - 1][1].Length; i++) + if(_sectorsData[totalCylinders - 1][1][i] != null) + leadOutMs.Write(_sectorsData[totalCylinders - 1][1][i], 0, + _sectorsData[totalCylinders - 1][1][i].Length); if(leadOutMs.Length != 0) { - leadOut = leadOutMs.ToArray(); - imageInfo.ReadableMediaTags.Add(MediaTagType.Floppy_LeadOut); + _leadOut = leadOutMs.ToArray(); + _imageInfo.ReadableMediaTags.Add(MediaTagType.Floppy_LeadOut); } - imageInfo.Sectors = imageInfo.Cylinders * imageInfo.Heads * imageInfo.SectorsPerTrack; - imageInfo.MediaType = DecodeTeleDiskDiskType(); + _imageInfo.Sectors = _imageInfo.Cylinders * _imageInfo.Heads * _imageInfo.SectorsPerTrack; + _imageInfo.MediaType = DecodeTeleDiskDiskType(); - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - AaruConsole.VerboseWriteLine("TeleDisk image contains a disk of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("TeleDisk image contains a disk of type {0}", _imageInfo.MediaType); - if(!string.IsNullOrEmpty(imageInfo.Comments)) - AaruConsole.VerboseWriteLine("TeleDisk comments: {0}", imageInfo.Comments); + if(!string.IsNullOrEmpty(_imageInfo.Comments)) + AaruConsole.VerboseWriteLine("TeleDisk comments: {0}", _imageInfo.Comments); - inStream.Dispose(); + _inStream.Dispose(); stream.Dispose(); return true; @@ -532,31 +532,31 @@ namespace Aaru.DiscImages { (ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress); - if(cylinder >= sectorsData.Length) + if(cylinder >= _sectorsData.Length) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(head >= sectorsData[cylinder].Length) + if(head >= _sectorsData[cylinder].Length) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sector > sectorsData[cylinder][head].Length) + if(sector > _sectorsData[cylinder][head].Length) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - return sectorsData[cylinder][head][sector]; + return _sectorsData[cylinder][head][sector]; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var buffer = new MemoryStream(); for(uint i = 0; i < length; i++) { - byte[] sector = ReadSector(sectorAddress + i) ?? new byte[imageInfo.SectorSize]; + byte[] sector = ReadSector(sectorAddress + i) ?? new byte[_imageInfo.SectorSize]; buffer.Write(sector, 0, sector.Length); } @@ -572,8 +572,8 @@ namespace Aaru.DiscImages if(tag != MediaTagType.Floppy_LeadOut) throw new FeatureUnsupportedImageException("Feature not supported by image format"); - if(leadOut != null) - return leadOut; + if(_leadOut != null) + return _leadOut; throw new FeatureNotPresentImageException("Lead-out not present in disk image"); } diff --git a/Aaru.Images/TeleDisk/TeleDisk.cs b/Aaru.Images/TeleDisk/TeleDisk.cs index 2155ced5b..5035baefc 100644 --- a/Aaru.Images/TeleDisk/TeleDisk.cs +++ b/Aaru.Images/TeleDisk/TeleDisk.cs @@ -42,24 +42,24 @@ namespace Aaru.DiscImages // http://www.classiccmp.org/dunfield/img54306/td0notes.txt public partial class TeleDisk : IMediaImage, IVerifiableImage, IVerifiableSectorsImage { - readonly List sectorsWhereCrcHasFailed; - bool aDiskCrcHasFailed; - byte[] commentBlock; - TeleDiskCommentBlockHeader commentHeader; - TeleDiskHeader header; - ImageInfo imageInfo; - Stream inStream; - byte[] leadOut; + readonly List _sectorsWhereCrcHasFailed; + bool _aDiskCrcHasFailed; + byte[] _commentBlock; + TeleDiskCommentBlockHeader _commentHeader; + TeleDiskHeader _header; + ImageInfo _imageInfo; + Stream _inStream; + byte[] _leadOut; // Cylinder by head, sector data matrix - byte[][][][] sectorsData; + byte[][][][] _sectorsData; // LBA, data - uint totalDiskSize; + uint _totalDiskSize; public TeleDisk() { - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), @@ -81,8 +81,8 @@ namespace Aaru.DiscImages DriveFirmwareRevision = null }; - aDiskCrcHasFailed = false; - sectorsWhereCrcHasFailed = new List(); + _aDiskCrcHasFailed = false; + _sectorsWhereCrcHasFailed = new List(); } } } \ No newline at end of file diff --git a/Aaru.Images/TeleDisk/Verify.cs b/Aaru.Images/TeleDisk/Verify.cs index b27a208c3..5595eb3df 100644 --- a/Aaru.Images/TeleDisk/Verify.cs +++ b/Aaru.Images/TeleDisk/Verify.cs @@ -36,9 +36,9 @@ namespace Aaru.DiscImages { public partial class TeleDisk { - public bool? VerifyMediaImage() => aDiskCrcHasFailed; + public bool? VerifyMediaImage() => _aDiskCrcHasFailed; - public bool? VerifySector(ulong sectorAddress) => !sectorsWhereCrcHasFailed.Contains(sectorAddress); + public bool? VerifySector(ulong sectorAddress) => !_sectorsWhereCrcHasFailed.Contains(sectorAddress); public bool? VerifySectors(ulong sectorAddress, uint length, out List failingLbas, out List unknownLbas) @@ -47,7 +47,7 @@ namespace Aaru.DiscImages unknownLbas = new List(); for(ulong i = sectorAddress; i < sectorAddress + length; i++) - if(sectorsWhereCrcHasFailed.Contains(sectorAddress)) + if(_sectorsWhereCrcHasFailed.Contains(sectorAddress)) failingLbas.Add(sectorAddress); return failingLbas.Count <= 0; diff --git a/Aaru.Images/UDIF/Identify.cs b/Aaru.Images/UDIF/Identify.cs index 22c7b58b4..96fe06bb2 100644 --- a/Aaru.Images/UDIF/Identify.cs +++ b/Aaru.Images/UDIF/Identify.cs @@ -49,9 +49,9 @@ namespace Aaru.DiscImages byte[] footerB = new byte[Marshal.SizeOf()]; stream.Read(footerB, 0, Marshal.SizeOf()); - footer = Marshal.ByteArrayToStructureBigEndian(footerB); + _footer = Marshal.ByteArrayToStructureBigEndian(footerB); - if(footer.signature == UDIF_SIGNATURE) + if(_footer.signature == UDIF_SIGNATURE) return true; // Old UDIF as created by DiskCopy 6.5 using "OBSOLETE" format. (DiskCopy 5 rumored format?) @@ -59,9 +59,9 @@ namespace Aaru.DiscImages byte[] headerB = new byte[Marshal.SizeOf()]; stream.Read(headerB, 0, Marshal.SizeOf()); - footer = Marshal.ByteArrayToStructureBigEndian(headerB); + _footer = Marshal.ByteArrayToStructureBigEndian(headerB); - return footer.signature == UDIF_SIGNATURE; + return _footer.signature == UDIF_SIGNATURE; } } } \ No newline at end of file diff --git a/Aaru.Images/UDIF/Properties.cs b/Aaru.Images/UDIF/Properties.cs index 7da183f6b..c560cc25a 100644 --- a/Aaru.Images/UDIF/Properties.cs +++ b/Aaru.Images/UDIF/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class Udif { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Apple Universal Disk Image Format"; public Guid Id => new Guid("5BEB9002-CF3D-429C-8E06-9A96F49203FF"); diff --git a/Aaru.Images/UDIF/Read.cs b/Aaru.Images/UDIF/Read.cs index 6c0056b78..a1d66b94c 100644 --- a/Aaru.Images/UDIF/Read.cs +++ b/Aaru.Images/UDIF/Read.cs @@ -65,71 +65,71 @@ namespace Aaru.DiscImages byte[] footerB = new byte[Marshal.SizeOf()]; stream.Read(footerB, 0, Marshal.SizeOf()); - footer = Marshal.ByteArrayToStructureBigEndian(footerB); + _footer = Marshal.ByteArrayToStructureBigEndian(footerB); - if(footer.signature != UDIF_SIGNATURE) + if(_footer.signature != UDIF_SIGNATURE) { stream.Seek(0, SeekOrigin.Begin); footerB = new byte[Marshal.SizeOf()]; stream.Read(footerB, 0, Marshal.SizeOf()); - footer = Marshal.ByteArrayToStructureBigEndian(footerB); + _footer = Marshal.ByteArrayToStructureBigEndian(footerB); - if(footer.signature != UDIF_SIGNATURE) + if(_footer.signature != UDIF_SIGNATURE) throw new Exception("Unable to find UDIF signature."); AaruConsole.VerboseWriteLine("Found obsolete UDIF format."); } - AaruConsole.DebugWriteLine("UDIF plugin", "footer.signature = 0x{0:X8}", footer.signature); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.version = {0}", footer.version); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.headerSize = {0}", footer.headerSize); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.flags = {0}", footer.flags); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.runningDataForkOff = {0}", footer.runningDataForkOff); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.dataForkOff = {0}", footer.dataForkOff); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.dataForkLen = {0}", footer.dataForkLen); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.rsrcForkOff = {0}", footer.rsrcForkOff); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.rsrcForkLen = {0}", footer.rsrcForkLen); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.segmentNumber = {0}", footer.segmentNumber); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.segmentCount = {0}", footer.segmentCount); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.segmentId = {0}", footer.segmentId); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.dataForkChkType = {0}", footer.dataForkChkType); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.dataForkLen = {0}", footer.dataForkLen); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.dataForkChk = 0x{0:X8}", footer.dataForkChk); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.plistOff = {0}", footer.plistOff); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.plistLen = {0}", footer.plistLen); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.masterChkType = {0}", footer.masterChkType); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.masterChkLen = {0}", footer.masterChkLen); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.masterChk = 0x{0:X8}", footer.masterChk); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.imageVariant = {0}", footer.imageVariant); - AaruConsole.DebugWriteLine("UDIF plugin", "footer.sectorCount = {0}", footer.sectorCount); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.signature = 0x{0:X8}", _footer.signature); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.version = {0}", _footer.version); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.headerSize = {0}", _footer.headerSize); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.flags = {0}", _footer.flags); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.runningDataForkOff = {0}", _footer.runningDataForkOff); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.dataForkOff = {0}", _footer.dataForkOff); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.dataForkLen = {0}", _footer.dataForkLen); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.rsrcForkOff = {0}", _footer.rsrcForkOff); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.rsrcForkLen = {0}", _footer.rsrcForkLen); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.segmentNumber = {0}", _footer.segmentNumber); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.segmentCount = {0}", _footer.segmentCount); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.segmentId = {0}", _footer.segmentId); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.dataForkChkType = {0}", _footer.dataForkChkType); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.dataForkLen = {0}", _footer.dataForkLen); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.dataForkChk = 0x{0:X8}", _footer.dataForkChk); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.plistOff = {0}", _footer.plistOff); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.plistLen = {0}", _footer.plistLen); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.masterChkType = {0}", _footer.masterChkType); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.masterChkLen = {0}", _footer.masterChkLen); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.masterChk = 0x{0:X8}", _footer.masterChk); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.imageVariant = {0}", _footer.imageVariant); + AaruConsole.DebugWriteLine("UDIF plugin", "footer.sectorCount = {0}", _footer.sectorCount); AaruConsole.DebugWriteLine("UDIF plugin", "footer.reserved1 is empty? = {0}", - ArrayHelpers.ArrayIsNullOrEmpty(footer.reserved1)); + ArrayHelpers.ArrayIsNullOrEmpty(_footer.reserved1)); AaruConsole.DebugWriteLine("UDIF plugin", "footer.reserved2 is empty? = {0}", - ArrayHelpers.ArrayIsNullOrEmpty(footer.reserved2)); + ArrayHelpers.ArrayIsNullOrEmpty(_footer.reserved2)); AaruConsole.DebugWriteLine("UDIF plugin", "footer.reserved3 is empty? = {0}", - ArrayHelpers.ArrayIsNullOrEmpty(footer.reserved3)); + ArrayHelpers.ArrayIsNullOrEmpty(_footer.reserved3)); AaruConsole.DebugWriteLine("UDIF plugin", "footer.reserved4 is empty? = {0}", - ArrayHelpers.ArrayIsNullOrEmpty(footer.reserved4)); + ArrayHelpers.ArrayIsNullOrEmpty(_footer.reserved4)); // Block chunks and headers List blkxList = new List(); - chunks = new Dictionary(); + _chunks = new Dictionary(); bool fakeBlockChunks = false; byte[] vers = null; - if(footer.plistLen == 0 && - footer.rsrcForkLen != 0) + if(_footer.plistLen == 0 && + _footer.rsrcForkLen != 0) { AaruConsole.DebugWriteLine("UDIF plugin", "Reading resource fork."); - byte[] rsrcB = new byte[footer.rsrcForkLen]; - stream.Seek((long)footer.rsrcForkOff, SeekOrigin.Begin); + byte[] rsrcB = new byte[_footer.rsrcForkLen]; + stream.Seek((long)_footer.rsrcForkOff, SeekOrigin.Begin); stream.Read(rsrcB, 0, rsrcB.Length); var rsrc = new ResourceFork(rsrcB); @@ -155,11 +155,11 @@ namespace Aaru.DiscImages if(versRez != null) vers = versRez.GetResource(versRez.GetIds()[0]); } - else if(footer.plistLen != 0) + else if(_footer.plistLen != 0) { AaruConsole.DebugWriteLine("UDIF plugin", "Reading property list."); - byte[] plistB = new byte[footer.plistLen]; - stream.Seek((long)footer.plistOff, SeekOrigin.Begin); + byte[] plistB = new byte[_footer.plistLen]; + stream.Seek((long)_footer.plistOff, SeekOrigin.Begin); stream.Read(plistB, 0, plistB.Length); AaruConsole.DebugWriteLine("UDIF plugin", "Parsing property list."); @@ -203,16 +203,16 @@ namespace Aaru.DiscImages // So let's falsify a block chunk var bChnk = new BlockChunk { - length = footer.dataForkLen, - offset = footer.dataForkOff, + length = _footer.dataForkLen, + offset = _footer.dataForkOff, sector = 0, - sectors = footer.sectorCount, + sectors = _footer.sectorCount, type = CHUNK_TYPE_COPY }; - imageInfo.Sectors = footer.sectorCount; - chunks.Add(bChnk.sector, bChnk); - buffersize = 2048 * SECTOR_SIZE; + _imageInfo.Sectors = _footer.sectorCount; + _chunks.Add(bChnk.sector, bChnk); + _buffersize = 2048 * SECTOR_SIZE; fakeBlockChunks = true; } @@ -253,22 +253,22 @@ namespace Aaru.DiscImages if(dev != null) pre = $"{version.PreReleaseVersion}"; - imageInfo.ApplicationVersion = $"{major}{minor}{release}{dev}{pre}"; - imageInfo.Application = version.VersionString; - imageInfo.Comments = version.VersionMessage; + _imageInfo.ApplicationVersion = $"{major}{minor}{release}{dev}{pre}"; + _imageInfo.Application = version.VersionString; + _imageInfo.Comments = version.VersionMessage; if(version.MajorVersion == 3) - imageInfo.Application = "ShrinkWrap™"; + _imageInfo.Application = "ShrinkWrap™"; else if(version.MajorVersion == 6) - imageInfo.Application = "DiskCopy"; + _imageInfo.Application = "DiskCopy"; } else - imageInfo.Application = "DiskCopy"; + _imageInfo.Application = "DiskCopy"; - AaruConsole.DebugWriteLine("UDIF plugin", "Image application = {0} version {1}", imageInfo.Application, - imageInfo.ApplicationVersion); + AaruConsole.DebugWriteLine("UDIF plugin", "Image application = {0} version {1}", _imageInfo.Application, + _imageInfo.ApplicationVersion); - imageInfo.Sectors = 0; + _imageInfo.Sectors = 0; if(!fakeBlockChunks) { @@ -276,7 +276,7 @@ namespace Aaru.DiscImages throw new ImageNotSupportedException("Could not retrieve block chunks. Please fill an issue and send it to us."); - buffersize = 0; + _buffersize = 0; foreach(byte[] blkxBytes in blkxList) { @@ -306,8 +306,8 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("UDIF plugin", "bHdr.reservedChk is empty? = {0}", ArrayHelpers.ArrayIsNullOrEmpty(bHdr.reservedChk)); - if(bHdr.buffers > buffersize) - buffersize = bHdr.buffers * SECTOR_SIZE; + if(bHdr.buffers > _buffersize) + _buffersize = bHdr.buffers * SECTOR_SIZE; for(int i = 0; i < bHdr.chunks; i++) { @@ -329,7 +329,7 @@ namespace Aaru.DiscImages if(bChnk.type == CHUNK_TYPE_END) break; - imageInfo.Sectors += bChnk.sectors; + _imageInfo.Sectors += bChnk.sectors; // Chunk offset is relative bChnk.sector += bHdr.sectorStart; @@ -357,46 +357,46 @@ namespace Aaru.DiscImages throw new ImageNotSupportedException($"Unsupported chunk type 0x{bChnk.type:X8} found"); if(bChnk.sectors > 0) - chunks.Add(bChnk.sector, bChnk); + _chunks.Add(bChnk.sector, bChnk); } } } - sectorCache = new Dictionary(); - chunkCache = new Dictionary(); - currentChunkCacheSize = 0; - imageStream = stream; + _sectorCache = new Dictionary(); + _chunkCache = new Dictionary(); + _currentChunkCacheSize = 0; + _imageStream = stream; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.SectorSize = SECTOR_SIZE; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.ImageSize = imageInfo.Sectors * SECTOR_SIZE; - imageInfo.Version = $"{footer.version}"; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.SectorSize = SECTOR_SIZE; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.ImageSize = _imageInfo.Sectors * SECTOR_SIZE; + _imageInfo.Version = $"{_footer.version}"; - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; return true; } public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector; var readChunk = new BlockChunk(); bool chunkFound = false; ulong chunkStartSector = 0; - foreach(KeyValuePair kvp in chunks.Where(kvp => sectorAddress >= kvp.Key)) + foreach(KeyValuePair kvp in _chunks.Where(kvp => sectorAddress >= kvp.Key)) { readChunk = kvp.Value; chunkFound = true; @@ -415,11 +415,11 @@ namespace Aaru.DiscImages if((readChunk.type & CHUNK_TYPE_COMPRESSED_MASK) == CHUNK_TYPE_COMPRESSED_MASK) { - if(!chunkCache.TryGetValue(chunkStartSector, out byte[] buffer)) + if(!_chunkCache.TryGetValue(chunkStartSector, out byte[] buffer)) { byte[] cmpBuffer = new byte[readChunk.length]; - imageStream.Seek((long)readChunk.offset, SeekOrigin.Begin); - imageStream.Read(cmpBuffer, 0, cmpBuffer.Length); + _imageStream.Seek((long)readChunk.offset, SeekOrigin.Begin); + _imageStream.Read(cmpBuffer, 0, cmpBuffer.Length); var cmpMs = new MemoryStream(cmpBuffer); Stream decStream = null; @@ -455,27 +455,27 @@ namespace Aaru.DiscImages case CHUNK_TYPE_ADC: case CHUNK_TYPE_ZLIB: case CHUNK_TYPE_BZIP: - tmpBuffer = new byte[buffersize]; - realSize = decStream.Read(tmpBuffer, 0, (int)buffersize); + tmpBuffer = new byte[_buffersize]; + realSize = decStream.Read(tmpBuffer, 0, (int)_buffersize); buffer = new byte[realSize]; Array.Copy(tmpBuffer, 0, buffer, 0, realSize); - if(currentChunkCacheSize + realSize > MAX_CACHE_SIZE) + if(_currentChunkCacheSize + realSize > MAX_CACHE_SIZE) { - chunkCache.Clear(); - currentChunkCacheSize = 0; + _chunkCache.Clear(); + _currentChunkCacheSize = 0; } - chunkCache.Add(chunkStartSector, buffer); - currentChunkCacheSize += (uint)realSize; + _chunkCache.Add(chunkStartSector, buffer); + _currentChunkCacheSize += (uint)realSize; break; case CHUNK_TYPE_RLE: - tmpBuffer = new byte[buffersize]; + tmpBuffer = new byte[_buffersize]; realSize = 0; var rle = new AppleRle(cmpMs); - for(int i = 0; i < buffersize; i++) + for(int i = 0; i < _buffersize; i++) { int b = rle.ProduceByte(); @@ -505,10 +505,10 @@ namespace Aaru.DiscImages sector = new byte[SECTOR_SIZE]; Array.Copy(buffer, relOff, sector, 0, SECTOR_SIZE); - if(sectorCache.Count >= MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count >= MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } @@ -519,21 +519,21 @@ namespace Aaru.DiscImages case CHUNK_TYPE_ZERO: sector = new byte[SECTOR_SIZE]; - if(sectorCache.Count >= MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count >= MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; case CHUNK_TYPE_COPY: - imageStream.Seek((long)readChunk.offset + relOff, SeekOrigin.Begin); + _imageStream.Seek((long)readChunk.offset + relOff, SeekOrigin.Begin); sector = new byte[SECTOR_SIZE]; - imageStream.Read(sector, 0, sector.Length); + _imageStream.Read(sector, 0, sector.Length); - if(sectorCache.Count >= MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count >= MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } @@ -543,11 +543,11 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); diff --git a/Aaru.Images/UDIF/UDIF.cs b/Aaru.Images/UDIF/UDIF.cs index cbd1c5ed9..ffd0de97c 100644 --- a/Aaru.Images/UDIF/UDIF.cs +++ b/Aaru.Images/UDIF/UDIF.cs @@ -43,21 +43,21 @@ namespace Aaru.DiscImages { public partial class Udif : IWritableImage { - uint buffersize; - Dictionary chunkCache; - Dictionary chunks; - BlockChunk currentChunk; - uint currentChunkCacheSize; - ulong currentSector; - Crc32Context dataForkChecksum; - UdifFooter footer; - ImageInfo imageInfo; - Stream imageStream; - Crc32Context masterChecksum; - Dictionary sectorCache; - FileStream writingStream; + uint _buffersize; + Dictionary _chunkCache; + Dictionary _chunks; + BlockChunk _currentChunk; + uint _currentChunkCacheSize; + ulong _currentSector; + Crc32Context _dataForkChecksum; + UdifFooter _footer; + ImageInfo _imageInfo; + Stream _imageStream; + Crc32Context _masterChecksum; + Dictionary _sectorCache; + FileStream _writingStream; - public Udif() => imageInfo = new ImageInfo + public Udif() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/UDIF/Write.cs b/Aaru.Images/UDIF/Write.cs index 6610c60eb..c6beb217a 100644 --- a/Aaru.Images/UDIF/Write.cs +++ b/Aaru.Images/UDIF/Write.cs @@ -64,7 +64,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -73,7 +73,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -82,11 +82,11 @@ namespace Aaru.DiscImages return false; } - chunks = new Dictionary(); - currentChunk = new BlockChunk(); - currentSector = 0; - dataForkChecksum = new Crc32Context(); - masterChecksum = new Crc32Context(); + _chunks = new Dictionary(); + _currentChunk = new BlockChunk(); + _currentSector = 0; + _dataForkChecksum = new Crc32Context(); + _masterChecksum = new Crc32Context(); IsWriting = true; ErrorMessage = null; @@ -110,59 +110,59 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - if(sectorAddress < currentSector) + if(sectorAddress < _currentSector) { ErrorMessage = "Tried to rewind, this format rewinded on writing"; return false; } - masterChecksum.Update(data); + _masterChecksum.Update(data); bool isEmpty = ArrayHelpers.ArrayIsNullOrEmpty(data); - switch(currentChunk.type) + switch(_currentChunk.type) { case CHUNK_TYPE_ZERO: - currentChunk.type = isEmpty ? CHUNK_TYPE_NOCOPY : CHUNK_TYPE_COPY; + _currentChunk.type = isEmpty ? CHUNK_TYPE_NOCOPY : CHUNK_TYPE_COPY; break; case CHUNK_TYPE_NOCOPY when !isEmpty: case CHUNK_TYPE_COPY when isEmpty: - chunks.Add(currentChunk.sector, currentChunk); + _chunks.Add(_currentChunk.sector, _currentChunk); - currentChunk = new BlockChunk + _currentChunk = new BlockChunk { type = isEmpty ? CHUNK_TYPE_NOCOPY : CHUNK_TYPE_COPY, - sector = currentSector, - offset = (ulong)(isEmpty ? 0 : writingStream.Position) + sector = _currentSector, + offset = (ulong)(isEmpty ? 0 : _writingStream.Position) }; break; } - currentChunk.sectors++; - currentChunk.length += (ulong)(isEmpty ? 0 : 512); - currentSector++; + _currentChunk.sectors++; + _currentChunk.length += (ulong)(isEmpty ? 0 : 512); + _currentSector++; if(!isEmpty) { - dataForkChecksum.Update(data); - writingStream.Write(data, 0, data.Length); + _dataForkChecksum.Update(data); + _writingStream.Write(data, 0, data.Length); } ErrorMessage = ""; @@ -180,14 +180,14 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -197,20 +197,20 @@ namespace Aaru.DiscImages // Ignore empty sectors if(ArrayHelpers.ArrayIsNullOrEmpty(data)) { - if(currentChunk.type == CHUNK_TYPE_COPY) + if(_currentChunk.type == CHUNK_TYPE_COPY) { - chunks.Add(currentChunk.sector, currentChunk); + _chunks.Add(_currentChunk.sector, _currentChunk); - currentChunk = new BlockChunk + _currentChunk = new BlockChunk { type = CHUNK_TYPE_NOCOPY, - sector = currentSector + sector = _currentSector }; } - currentChunk.sectors += (ulong)(data.Length / imageInfo.SectorSize); - currentSector += (ulong)(data.Length / imageInfo.SectorSize); - masterChecksum.Update(data); + _currentChunk.sectors += (ulong)(data.Length / _imageInfo.SectorSize); + _currentSector += (ulong)(data.Length / _imageInfo.SectorSize); + _masterChecksum.Update(data); ErrorMessage = ""; @@ -219,8 +219,8 @@ namespace Aaru.DiscImages for(uint i = 0; i < length; i++) { - byte[] tmp = new byte[imageInfo.SectorSize]; - Array.Copy(data, i * imageInfo.SectorSize, tmp, 0, imageInfo.SectorSize); + byte[] tmp = new byte[_imageInfo.SectorSize]; + Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); if(!WriteSector(tmp, sectorAddress + i)) return false; @@ -254,26 +254,26 @@ namespace Aaru.DiscImages return false; } - if(currentChunk.type != CHUNK_TYPE_NOCOPY) - currentChunk.length = currentChunk.sectors * 512; + if(_currentChunk.type != CHUNK_TYPE_NOCOPY) + _currentChunk.length = _currentChunk.sectors * 512; - chunks.Add(currentChunk.sector, currentChunk); + _chunks.Add(_currentChunk.sector, _currentChunk); - chunks.Add(imageInfo.Sectors, new BlockChunk + _chunks.Add(_imageInfo.Sectors, new BlockChunk { type = CHUNK_TYPE_END, - sector = imageInfo.Sectors + sector = _imageInfo.Sectors }); var bHdr = new BlockHeader { signature = CHUNK_SIGNATURE, version = 1, - sectorCount = imageInfo.Sectors, + sectorCount = _imageInfo.Sectors, checksumType = UDIF_CHECKSUM_TYPE_CRC32, checksumLen = 32, - checksum = BitConverter.ToUInt32(dataForkChecksum.Final().Reverse().ToArray(), 0), - chunks = (uint)chunks.Count + checksum = BitConverter.ToUInt32(_dataForkChecksum.Final().Reverse().ToArray(), 0), + chunks = (uint)_chunks.Count }; var chunkMs = new MemoryStream(); @@ -296,7 +296,7 @@ namespace Aaru.DiscImages chunkMs.Write(new byte[124], 0, 124); chunkMs.Write(BigEndianBitConverter.GetBytes(bHdr.chunks), 0, 4); - foreach(BlockChunk chunk in chunks.Values) + foreach(BlockChunk chunk in _chunks.Values) { chunkMs.Write(BigEndianBitConverter.GetBytes(chunk.type), 0, 4); chunkMs.Write(BigEndianBitConverter.GetBytes(chunk.comment), 0, 4); @@ -338,20 +338,20 @@ namespace Aaru.DiscImages } }.ToXmlPropertyList()); - footer = new UdifFooter + _footer = new UdifFooter { signature = UDIF_SIGNATURE, version = 4, headerSize = 512, flags = 1, - dataForkLen = (ulong)writingStream.Length, + dataForkLen = (ulong)_writingStream.Length, segmentNumber = 1, segmentCount = 1, segmentId = Guid.NewGuid(), dataForkChkType = UDIF_CHECKSUM_TYPE_CRC32, dataForkChkLen = 32, - dataForkChk = BitConverter.ToUInt32(dataForkChecksum.Final().Reverse().ToArray(), 0), - plistOff = (ulong)writingStream.Length, + dataForkChk = BitConverter.ToUInt32(_dataForkChecksum.Final().Reverse().ToArray(), 0), + plistOff = (ulong)_writingStream.Length, plistLen = (ulong)plist.Length, // TODO: Find how is this calculated @@ -359,40 +359,40 @@ namespace Aaru.DiscImages masterChkLen = 32, masterChk = BitConverter.ToUInt32(masterChecksum.Final().Reverse().ToArray(), 0),*/ imageVariant = 2, - sectorCount = imageInfo.Sectors + sectorCount = _imageInfo.Sectors }; - writingStream.Seek(0, SeekOrigin.End); - writingStream.Write(plist, 0, plist.Length); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.signature), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.version), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.headerSize), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.flags), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.runningDataForkOff), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.dataForkOff), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.dataForkLen), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.rsrcForkOff), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.rsrcForkLen), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.segmentNumber), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.segmentCount), 0, 4); - writingStream.Write(footer.segmentId.ToByteArray(), 0, 16); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.dataForkChkType), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.dataForkChkLen), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.dataForkChk), 0, 4); - writingStream.Write(new byte[124], 0, 124); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.plistOff), 0, 8); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.plistLen), 0, 8); - writingStream.Write(new byte[120], 0, 120); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.masterChkType), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.masterChkLen), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.masterChk), 0, 4); - writingStream.Write(new byte[124], 0, 124); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.imageVariant), 0, 4); - writingStream.Write(BigEndianBitConverter.GetBytes(footer.sectorCount), 0, 8); - writingStream.Write(new byte[12], 0, 12); + _writingStream.Seek(0, SeekOrigin.End); + _writingStream.Write(plist, 0, plist.Length); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.signature), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.version), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.headerSize), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.flags), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.runningDataForkOff), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.dataForkOff), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.dataForkLen), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.rsrcForkOff), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.rsrcForkLen), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.segmentNumber), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.segmentCount), 0, 4); + _writingStream.Write(_footer.segmentId.ToByteArray(), 0, 16); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.dataForkChkType), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.dataForkChkLen), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.dataForkChk), 0, 4); + _writingStream.Write(new byte[124], 0, 124); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.plistOff), 0, 8); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.plistLen), 0, 8); + _writingStream.Write(new byte[120], 0, 120); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.masterChkType), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.masterChkLen), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.masterChk), 0, 4); + _writingStream.Write(new byte[124], 0, 124); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.imageVariant), 0, 4); + _writingStream.Write(BigEndianBitConverter.GetBytes(_footer.sectorCount), 0, 8); + _writingStream.Write(new byte[12], 0, 12); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; diff --git a/Aaru.Images/UkvFdi/Constants.cs b/Aaru.Images/UkvFdi/Constants.cs index 776a461ef..f357cbb8e 100644 --- a/Aaru.Images/UkvFdi/Constants.cs +++ b/Aaru.Images/UkvFdi/Constants.cs @@ -34,7 +34,7 @@ namespace Aaru.DiscImages { public partial class UkvFdi { - readonly byte[] signature = + readonly byte[] _signature = { 0x46, 0x44, 0x49 }; diff --git a/Aaru.Images/UkvFdi/Helpers.cs b/Aaru.Images/UkvFdi/Helpers.cs index d002b36b2..2366be9b1 100644 --- a/Aaru.Images/UkvFdi/Helpers.cs +++ b/Aaru.Images/UkvFdi/Helpers.cs @@ -36,9 +36,9 @@ namespace Aaru.DiscImages { (ushort cylinder, byte head, byte sector) LbaToChs(ulong lba) { - ushort cylinder = (ushort)(lba / (imageInfo.Heads * imageInfo.SectorsPerTrack)); - byte head = (byte)((lba / imageInfo.SectorsPerTrack) % imageInfo.Heads); - byte sector = (byte)((lba % imageInfo.SectorsPerTrack) + 1); + ushort cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack)); + byte head = (byte)((lba / _imageInfo.SectorsPerTrack) % _imageInfo.Heads); + byte sector = (byte)((lba % _imageInfo.SectorsPerTrack) + 1); return (cylinder, head, sector); } diff --git a/Aaru.Images/UkvFdi/Identify.cs b/Aaru.Images/UkvFdi/Identify.cs index 538996fcb..185abfcc5 100644 --- a/Aaru.Images/UkvFdi/Identify.cs +++ b/Aaru.Images/UkvFdi/Identify.cs @@ -53,7 +53,7 @@ namespace Aaru.DiscImages stream.Read(hdrB, 0, hdrB.Length); hdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); - return hdr.magic.SequenceEqual(signature); + return hdr.magic.SequenceEqual(_signature); } } } \ No newline at end of file diff --git a/Aaru.Images/UkvFdi/Properties.cs b/Aaru.Images/UkvFdi/Properties.cs index 0ec309a53..6c2b8ffff 100644 --- a/Aaru.Images/UkvFdi/Properties.cs +++ b/Aaru.Images/UkvFdi/Properties.cs @@ -43,7 +43,7 @@ namespace Aaru.DiscImages public Guid Id => new Guid("DADFC9B2-67C1-42A3-B124-825528163FC0"); public string Format => "Spectrum floppy disk image"; public string Author => "Natalia Portillo"; - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public List DumpHardware => null; public CICMMetadataType CicmMetadata => null; } diff --git a/Aaru.Images/UkvFdi/Read.cs b/Aaru.Images/UkvFdi/Read.cs index 626c0bd25..034e91aba 100644 --- a/Aaru.Images/UkvFdi/Read.cs +++ b/Aaru.Images/UkvFdi/Read.cs @@ -67,24 +67,24 @@ namespace Aaru.DiscImages stream.Seek(hdr.descOff, SeekOrigin.Begin); byte[] description = new byte[hdr.dataOff - hdr.descOff]; stream.Read(description, 0, description.Length); - imageInfo.Comments = StringHandlers.CToString(description); + _imageInfo.Comments = StringHandlers.CToString(description); - AaruConsole.DebugWriteLine("UkvFdi plugin", "hdr.description = \"{0}\"", imageInfo.Comments); + AaruConsole.DebugWriteLine("UkvFdi plugin", "hdr.description = \"{0}\"", _imageInfo.Comments); stream.Seek(0xE + hdr.addInfoLen, SeekOrigin.Begin); long spt = long.MaxValue; uint[][][] sectorsOff = new uint[hdr.cylinders][][]; - sectorsData = new byte[hdr.cylinders][][][]; + _sectorsData = new byte[hdr.cylinders][][][]; - imageInfo.Cylinders = hdr.cylinders; - imageInfo.Heads = hdr.heads; + _imageInfo.Cylinders = hdr.cylinders; + _imageInfo.Heads = hdr.heads; // Read track descriptors for(ushort cyl = 0; cyl < hdr.cylinders; cyl++) { - sectorsOff[cyl] = new uint[hdr.heads][]; - sectorsData[cyl] = new byte[hdr.heads][][]; + sectorsOff[cyl] = new uint[hdr.heads][]; + _sectorsData[cyl] = new byte[hdr.heads][][]; for(ushort head = 0; head < hdr.heads; head++) { @@ -99,8 +99,8 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("UkvFdi plugin", "trkhdr.sectors = {0}", sectors); AaruConsole.DebugWriteLine("UkvFdi plugin", "trkhdr.off = {0}", trkOff); - sectorsOff[cyl][head] = new uint[sectors]; - sectorsData[cyl][head] = new byte[sectors][]; + sectorsOff[cyl][head] = new uint[sectors]; + _sectorsData[cyl][head] = new byte[sectors][]; if(sectors < spt && sectors > 0) @@ -127,11 +127,11 @@ namespace Aaru.DiscImages secOff + trkOff + hdr.dataOff); // TODO: This assumes sequential sectors. - sectorsOff[cyl][head][sec] = secOff + trkOff + hdr.dataOff; - sectorsData[cyl][head][sec] = new byte[128 << n]; + sectorsOff[cyl][head][sec] = secOff + trkOff + hdr.dataOff; + _sectorsData[cyl][head][sec] = new byte[128 << n]; - if(128 << n > imageInfo.SectorSize) - imageInfo.SectorSize = (uint)(128 << n); + if(128 << n > _imageInfo.SectorSize) + _imageInfo.SectorSize = (uint)(128 << n); } } } @@ -146,7 +146,7 @@ namespace Aaru.DiscImages for(ushort sec = 0; sec < sectorsOff[cyl][head].Length; sec++) { stream.Seek(sectorsOff[cyl][head][sec], SeekOrigin.Begin); - stream.Read(sectorsData[cyl][head][sec], 0, sectorsData[cyl][head][sec].Length); + stream.Read(_sectorsData[cyl][head][sec], 0, _sectorsData[cyl][head][sec].Length); } // For empty cylinders @@ -162,26 +162,26 @@ namespace Aaru.DiscImages // Create empty sectors else { - sectorsData[cyl][head] = new byte[spt][]; + _sectorsData[cyl][head] = new byte[spt][]; for(int i = 0; i < spt; i++) - sectorsData[cyl][head][i] = new byte[imageInfo.SectorSize]; + _sectorsData[cyl][head][i] = new byte[_imageInfo.SectorSize]; } } if(emptyCyl) - imageInfo.Cylinders--; + _imageInfo.Cylinders--; } // TODO: What about double sided, half track pitch compact floppies? - imageInfo.MediaType = MediaType.CompactFloppy; - imageInfo.ImageSize = (ulong)stream.Length - hdr.dataOff; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.SectorsPerTrack = (uint)spt; - imageInfo.Sectors = imageInfo.Cylinders * imageInfo.Heads * imageInfo.SectorsPerTrack; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.MediaType = MediaType.CompactFloppy; + _imageInfo.ImageSize = (ulong)stream.Length - hdr.dataOff; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.SectorsPerTrack = (uint)spt; + _imageInfo.Sectors = _imageInfo.Cylinders * _imageInfo.Heads * _imageInfo.SectorsPerTrack; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; return true; } @@ -190,24 +190,24 @@ namespace Aaru.DiscImages { (ushort cylinder, byte head, byte sector) = LbaToChs(sectorAddress); - if(cylinder >= sectorsData.Length) + if(cylinder >= _sectorsData.Length) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(head >= sectorsData[cylinder].Length) + if(head >= _sectorsData[cylinder].Length) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sector > sectorsData[cylinder][head].Length) + if(sector > _sectorsData[cylinder][head].Length) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - return sectorsData[cylinder][head][sector - 1]; + return _sectorsData[cylinder][head][sector - 1]; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var buffer = new MemoryStream(); diff --git a/Aaru.Images/UkvFdi/UkvFdi.cs b/Aaru.Images/UkvFdi/UkvFdi.cs index 80b414797..f68b25f55 100644 --- a/Aaru.Images/UkvFdi/UkvFdi.cs +++ b/Aaru.Images/UkvFdi/UkvFdi.cs @@ -39,12 +39,12 @@ namespace Aaru.DiscImages { public partial class UkvFdi : IMediaImage { - ImageInfo imageInfo; + ImageInfo _imageInfo; // Cylinder by head, sector data matrix - byte[][][][] sectorsData; + byte[][][][] _sectorsData; - public UkvFdi() => imageInfo = new ImageInfo + public UkvFdi() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/VDI/Identify.cs b/Aaru.Images/VDI/Identify.cs index 360decf8f..c003d3172 100644 --- a/Aaru.Images/VDI/Identify.cs +++ b/Aaru.Images/VDI/Identify.cs @@ -48,9 +48,9 @@ namespace Aaru.DiscImages byte[] vHdrB = new byte[Marshal.SizeOf()]; stream.Read(vHdrB, 0, Marshal.SizeOf()); - vHdr = Marshal.ByteArrayToStructureLittleEndian(vHdrB); + _vHdr = Marshal.ByteArrayToStructureLittleEndian(vHdrB); - return vHdr.magic == VDI_MAGIC; + return _vHdr.magic == VDI_MAGIC; } } } \ No newline at end of file diff --git a/Aaru.Images/VDI/Properties.cs b/Aaru.Images/VDI/Properties.cs index 1d8fda53f..0f8190370 100644 --- a/Aaru.Images/VDI/Properties.cs +++ b/Aaru.Images/VDI/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class Vdi { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "VirtualBox Disk Image"; public Guid Id => new Guid("E314DE35-C103-48A3-AD36-990F68523C46"); diff --git a/Aaru.Images/VDI/Read.cs b/Aaru.Images/VDI/Read.cs index 96944cae3..d743bc0f0 100644 --- a/Aaru.Images/VDI/Read.cs +++ b/Aaru.Images/VDI/Read.cs @@ -55,146 +55,146 @@ namespace Aaru.DiscImages byte[] vHdrB = new byte[Marshal.SizeOf()]; stream.Read(vHdrB, 0, Marshal.SizeOf()); - vHdr = Marshal.ByteArrayToStructureLittleEndian(vHdrB); + _vHdr = Marshal.ByteArrayToStructureLittleEndian(vHdrB); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.creator = {0}", vHdr.creator); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.magic = {0}", vHdr.magic); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.creator = {0}", _vHdr.creator); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.magic = {0}", _vHdr.magic); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.version = {0}.{1}", vHdr.majorVersion, - vHdr.minorVersion); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.version = {0}.{1}", _vHdr.majorVersion, + _vHdr.minorVersion); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.headerSize = {0}", vHdr.headerSize); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.imageType = {0}", vHdr.imageType); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.imageFlags = {0}", vHdr.imageFlags); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.description = {0}", vHdr.comments); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.offsetBlocks = {0}", vHdr.offsetBlocks); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.offsetData = {0}", vHdr.offsetData); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.cylinders = {0}", vHdr.cylinders); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.heads = {0}", vHdr.heads); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.spt = {0}", vHdr.spt); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.sectorSize = {0}", vHdr.sectorSize); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.size = {0}", vHdr.size); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.blockSize = {0}", vHdr.blockSize); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.blockExtraData = {0}", vHdr.blockExtraData); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.blocks = {0}", vHdr.blocks); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.allocatedBlocks = {0}", vHdr.allocatedBlocks); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.uuid = {0}", vHdr.uuid); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.snapshotUuid = {0}", vHdr.snapshotUuid); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.linkUuid = {0}", vHdr.linkUuid); - AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.parentUuid = {0}", vHdr.parentUuid); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.headerSize = {0}", _vHdr.headerSize); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.imageType = {0}", _vHdr.imageType); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.imageFlags = {0}", _vHdr.imageFlags); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.description = {0}", _vHdr.comments); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.offsetBlocks = {0}", _vHdr.offsetBlocks); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.offsetData = {0}", _vHdr.offsetData); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.cylinders = {0}", _vHdr.cylinders); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.heads = {0}", _vHdr.heads); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.spt = {0}", _vHdr.spt); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.sectorSize = {0}", _vHdr.sectorSize); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.size = {0}", _vHdr.size); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.blockSize = {0}", _vHdr.blockSize); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.blockExtraData = {0}", _vHdr.blockExtraData); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.blocks = {0}", _vHdr.blocks); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.allocatedBlocks = {0}", _vHdr.allocatedBlocks); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.uuid = {0}", _vHdr.uuid); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.snapshotUuid = {0}", _vHdr.snapshotUuid); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.linkUuid = {0}", _vHdr.linkUuid); + AaruConsole.DebugWriteLine("VirtualBox plugin", "vHdr.parentUuid = {0}", _vHdr.parentUuid); - if(vHdr.imageType != VdiImageType.Normal) + if(_vHdr.imageType != VdiImageType.Normal) throw new - FeatureSupportedButNotImplementedImageException($"Support for image type {vHdr.imageType} not yet implemented"); + FeatureSupportedButNotImplementedImageException($"Support for image type {_vHdr.imageType} not yet implemented"); DateTime start = DateTime.UtcNow; AaruConsole.DebugWriteLine("VirtualBox plugin", "Reading Image Block Map"); - stream.Seek(vHdr.offsetBlocks, SeekOrigin.Begin); - byte[] ibmB = new byte[vHdr.blocks * 4]; + stream.Seek(_vHdr.offsetBlocks, SeekOrigin.Begin); + byte[] ibmB = new byte[_vHdr.blocks * 4]; stream.Read(ibmB, 0, ibmB.Length); - ibm = MemoryMarshal.Cast(ibmB).ToArray(); + _ibm = MemoryMarshal.Cast(ibmB).ToArray(); DateTime end = DateTime.UtcNow; AaruConsole.DebugWriteLine("VirtualBox plugin", "Reading Image Block Map took {0} ms", (end - start).TotalMilliseconds); - sectorCache = new Dictionary(); + _sectorCache = new Dictionary(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = vHdr.size / vHdr.sectorSize; - imageInfo.ImageSize = vHdr.size; - imageInfo.SectorSize = vHdr.sectorSize; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.Comments = vHdr.comments; - imageInfo.Version = $"{vHdr.majorVersion}.{vHdr.minorVersion}"; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = _vHdr.size / _vHdr.sectorSize; + _imageInfo.ImageSize = _vHdr.size; + _imageInfo.SectorSize = _vHdr.sectorSize; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.Comments = _vHdr.comments; + _imageInfo.Version = $"{_vHdr.majorVersion}.{_vHdr.minorVersion}"; - switch(vHdr.creator) + switch(_vHdr.creator) { case SUN_VDI: - imageInfo.Application = "Sun VirtualBox"; + _imageInfo.Application = "Sun VirtualBox"; break; case SUN_OLD_VDI: - imageInfo.Application = "Sun xVM"; + _imageInfo.Application = "Sun xVM"; break; case ORACLE_VDI: - imageInfo.Application = "Oracle VirtualBox"; + _imageInfo.Application = "Oracle VirtualBox"; break; case QEMUVDI: - imageInfo.Application = "QEMU"; + _imageInfo.Application = "QEMU"; break; case INNOTEK_VDI: case INNOTEK_OLD_VDI: - imageInfo.Application = "innotek VirtualBox"; + _imageInfo.Application = "innotek VirtualBox"; break; case DIC_VDI: - imageInfo.Application = "DiscImageChef"; + _imageInfo.Application = "DiscImageChef"; break; case DIC_AARU: - imageInfo.Application = "Aaru"; + _imageInfo.Application = "Aaru"; break; } - imageStream = stream; + _imageStream = stream; - imageInfo.Cylinders = vHdr.cylinders; - imageInfo.Heads = vHdr.heads; - imageInfo.SectorsPerTrack = vHdr.spt; + _imageInfo.Cylinders = _vHdr.cylinders; + _imageInfo.Heads = _vHdr.heads; + _imageInfo.SectorsPerTrack = _vHdr.spt; return true; } public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector; - ulong index = (sectorAddress * vHdr.sectorSize) / vHdr.blockSize; - ulong secOff = (sectorAddress * vHdr.sectorSize) % vHdr.blockSize; + ulong index = (sectorAddress * _vHdr.sectorSize) / _vHdr.blockSize; + ulong secOff = (sectorAddress * _vHdr.sectorSize) % _vHdr.blockSize; - uint ibmOff = ibm[(int)index]; + uint ibmOff = _ibm[(int)index]; if(ibmOff == VDI_EMPTY) - return new byte[vHdr.sectorSize]; + return new byte[_vHdr.sectorSize]; - ulong imageOff = vHdr.offsetData + (ibmOff * vHdr.blockSize); + ulong imageOff = _vHdr.offsetData + (ibmOff * _vHdr.blockSize); - byte[] cluster = new byte[vHdr.blockSize]; - imageStream.Seek((long)imageOff, SeekOrigin.Begin); - imageStream.Read(cluster, 0, (int)vHdr.blockSize); - sector = new byte[vHdr.sectorSize]; - Array.Copy(cluster, (int)secOff, sector, 0, vHdr.sectorSize); + byte[] cluster = new byte[_vHdr.blockSize]; + _imageStream.Seek((long)imageOff, SeekOrigin.Begin); + _imageStream.Read(cluster, 0, (int)_vHdr.blockSize); + sector = new byte[_vHdr.sectorSize]; + Array.Copy(cluster, (int)secOff, sector, 0, _vHdr.sectorSize); - if(sectorCache.Count > MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count > MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), - $"Requested more sectors ({sectorAddress} + {length}) than available ({imageInfo.Sectors})"); + $"Requested more sectors ({sectorAddress} + {length}) than available ({_imageInfo.Sectors})"); var ms = new MemoryStream(); diff --git a/Aaru.Images/VDI/VDI.cs b/Aaru.Images/VDI/VDI.cs index de2e02e25..f94e00826 100644 --- a/Aaru.Images/VDI/VDI.cs +++ b/Aaru.Images/VDI/VDI.cs @@ -43,15 +43,15 @@ namespace Aaru.DiscImages // TODO: Support version 1.2 geometry public partial class Vdi : IWritableImage { - uint currentWritingPosition; - uint[] ibm; - ImageInfo imageInfo; - Stream imageStream; - Dictionary sectorCache; - VdiHeader vHdr; - FileStream writingStream; + uint _currentWritingPosition; + uint[] _ibm; + ImageInfo _imageInfo; + Stream _imageStream; + Dictionary _sectorCache; + VdiHeader _vHdr; + FileStream _writingStream; - public Vdi() => imageInfo = new ImageInfo + public Vdi() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/VDI/Write.cs b/Aaru.Images/VDI/Write.cs index cdffe6fae..fcb091a51 100644 --- a/Aaru.Images/VDI/Write.cs +++ b/Aaru.Images/VDI/Write.cs @@ -70,7 +70,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -79,7 +79,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -98,10 +98,10 @@ namespace Aaru.DiscImages if((ibmEntries * 4) % sectorSize != 0) headerSectors++; - ibm = new uint[ibmEntries]; - currentWritingPosition = headerSectors * sectorSize; + _ibm = new uint[ibmEntries]; + _currentWritingPosition = headerSectors * sectorSize; - vHdr = new VdiHeader + _vHdr = new VdiHeader { creator = DIC_AARU, magic = VDI_MAGIC, @@ -110,7 +110,7 @@ namespace Aaru.DiscImages headerSize = Marshal.SizeOf() - 72, imageType = VdiImageType.Normal, offsetBlocks = sectorSize, - offsetData = currentWritingPosition, + offsetData = _currentWritingPosition, sectorSize = sectorSize, size = sectors * sectorSize, blockSize = DEFAULT_BLOCK_SIZE, @@ -120,7 +120,7 @@ namespace Aaru.DiscImages }; for(uint i = 0; i < ibmEntries; i++) - ibm[i] = VDI_EMPTY; + _ibm[i] = VDI_EMPTY; IsWriting = true; ErrorMessage = null; @@ -144,14 +144,14 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -162,24 +162,24 @@ namespace Aaru.DiscImages if(ArrayHelpers.ArrayIsNullOrEmpty(data)) return true; - ulong index = (sectorAddress * vHdr.sectorSize) / vHdr.blockSize; - ulong secOff = (sectorAddress * vHdr.sectorSize) % vHdr.blockSize; + ulong index = (sectorAddress * _vHdr.sectorSize) / _vHdr.blockSize; + ulong secOff = (sectorAddress * _vHdr.sectorSize) % _vHdr.blockSize; - uint ibmOff = ibm[index]; + uint ibmOff = _ibm[index]; if(ibmOff == VDI_EMPTY) { - ibmOff = (currentWritingPosition - vHdr.offsetData) / vHdr.blockSize; - ibm[index] = ibmOff; - currentWritingPosition += vHdr.blockSize; - vHdr.allocatedBlocks++; + ibmOff = (_currentWritingPosition - _vHdr.offsetData) / _vHdr.blockSize; + _ibm[index] = ibmOff; + _currentWritingPosition += _vHdr.blockSize; + _vHdr.allocatedBlocks++; } - ulong imageOff = vHdr.offsetData + (ibmOff * vHdr.blockSize); + ulong imageOff = _vHdr.offsetData + (ibmOff * _vHdr.blockSize); - writingStream.Seek((long)imageOff, SeekOrigin.Begin); - writingStream.Seek((long)secOff, SeekOrigin.Current); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)imageOff, SeekOrigin.Begin); + _writingStream.Seek((long)secOff, SeekOrigin.Current); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -196,14 +196,14 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; @@ -216,8 +216,8 @@ namespace Aaru.DiscImages for(uint i = 0; i < length; i++) { - byte[] tmp = new byte[imageInfo.SectorSize]; - Array.Copy(data, i * imageInfo.SectorSize, tmp, 0, imageInfo.SectorSize); + byte[] tmp = new byte[_imageInfo.SectorSize]; + Array.Copy(data, i * _imageInfo.SectorSize, tmp, 0, _imageInfo.SectorSize); if(!WriteSector(tmp, sectorAddress + i)) return false; @@ -251,49 +251,49 @@ namespace Aaru.DiscImages return false; } - if(!string.IsNullOrEmpty(imageInfo.Comments)) - vHdr.comments = imageInfo.Comments.Length > 255 ? imageInfo.Comments.Substring(0, 255) - : imageInfo.Comments; + if(!string.IsNullOrEmpty(_imageInfo.Comments)) + _vHdr.comments = _imageInfo.Comments.Length > 255 ? _imageInfo.Comments.Substring(0, 255) + : _imageInfo.Comments; - if(vHdr.cylinders == 0) + if(_vHdr.cylinders == 0) { - vHdr.cylinders = (uint)(imageInfo.Sectors / 16 / 63); - vHdr.heads = 16; - vHdr.spt = 63; + _vHdr.cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _vHdr.heads = 16; + _vHdr.spt = 63; - while(vHdr.cylinders == 0) + while(_vHdr.cylinders == 0) { - vHdr.heads--; + _vHdr.heads--; - if(vHdr.heads == 0) + if(_vHdr.heads == 0) { - vHdr.spt--; - vHdr.heads = 16; + _vHdr.spt--; + _vHdr.heads = 16; } - vHdr.cylinders = (uint)(imageInfo.Sectors / vHdr.heads / vHdr.spt); + _vHdr.cylinders = (uint)(_imageInfo.Sectors / _vHdr.heads / _vHdr.spt); - if(vHdr.cylinders == 0 && - vHdr.heads == 0 && - vHdr.spt == 0) + if(_vHdr.cylinders == 0 && + _vHdr.heads == 0 && + _vHdr.spt == 0) break; } } byte[] hdr = new byte[Marshal.SizeOf()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); - System.Runtime.InteropServices.Marshal.StructureToPtr(vHdr, hdrPtr, true); + System.Runtime.InteropServices.Marshal.StructureToPtr(_vHdr, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(hdr, 0, hdr.Length); - writingStream.Seek(vHdr.offsetBlocks, SeekOrigin.Begin); - writingStream.Write(MemoryMarshal.Cast(ibm).ToArray(), 0, 4 * ibm.Length); + _writingStream.Seek(_vHdr.offsetBlocks, SeekOrigin.Begin); + _writingStream.Write(MemoryMarshal.Cast(_ibm).ToArray(), 0, 4 * _ibm.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -303,16 +303,16 @@ namespace Aaru.DiscImages public bool SetMetadata(ImageInfo metadata) { - imageInfo.Comments = metadata.Comments; + _imageInfo.Comments = metadata.Comments; return true; } public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack) { - vHdr.cylinders = cylinders; - vHdr.heads = heads; - vHdr.spt = sectorsPerTrack; + _vHdr.cylinders = cylinders; + _vHdr.heads = heads; + _vHdr.spt = sectorsPerTrack; return true; } diff --git a/Aaru.Images/VHD/Properties.cs b/Aaru.Images/VHD/Properties.cs index 0ded1baa2..1540002a7 100644 --- a/Aaru.Images/VHD/Properties.cs +++ b/Aaru.Images/VHD/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class Vhd { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "VirtualPC"; public Guid Id => new Guid("8014d88f-64cd-4484-9441-7635c632958a"); @@ -51,7 +51,7 @@ namespace Aaru.DiscImages { get { - switch(thisFooter.DiskType) + switch(_thisFooter.DiskType) { case TYPE_FIXED: return "Virtual PC fixed size disk image"; case TYPE_DYNAMIC: return "Virtual PC dynamic size disk image"; diff --git a/Aaru.Images/VHD/Read.cs b/Aaru.Images/VHD/Read.cs index 026b22665..0f52937e6 100644 --- a/Aaru.Images/VHD/Read.cs +++ b/Aaru.Images/VHD/Read.cs @@ -110,7 +110,7 @@ namespace Aaru.DiscImages throw new ImageNotSupportedException("(VirtualPC plugin): Both header and footer are corrupt, image cannot be opened."); - thisFooter = new HardDiskFooter + _thisFooter = new HardDiskFooter { Cookie = BigEndianBitConverter.ToUInt64(usableHeader, 0x00), Features = BigEndianBitConverter.ToUInt32(usableHeader, 0x08), @@ -130,86 +130,86 @@ namespace Aaru.DiscImages Reserved = new byte[usableHeader.Length - 0x55] }; - Array.Copy(usableHeader, 0x55, thisFooter.Reserved, 0, usableHeader.Length - 0x55); + Array.Copy(usableHeader, 0x55, _thisFooter.Reserved, 0, usableHeader.Length - 0x55); - thisDateTime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc); - thisDateTime = thisDateTime.AddSeconds(thisFooter.Timestamp); + _thisDateTime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc); + _thisDateTime = _thisDateTime.AddSeconds(_thisFooter.Timestamp); var sha1Ctx = new Sha1Context(); - sha1Ctx.Update(thisFooter.Reserved); + sha1Ctx.Update(_thisFooter.Reserved); - AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.cookie = 0x{0:X8}", thisFooter.Cookie); - AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.features = 0x{0:X8}", thisFooter.Features); - AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.version = 0x{0:X8}", thisFooter.Version); - AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.offset = {0}", thisFooter.Offset); + AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.cookie = 0x{0:X8}", _thisFooter.Cookie); + AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.features = 0x{0:X8}", _thisFooter.Features); + AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.version = 0x{0:X8}", _thisFooter.Version); + AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.offset = {0}", _thisFooter.Offset); - AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.timestamp = 0x{0:X8} ({1})", thisFooter.Timestamp, - thisDateTime); + AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.timestamp = 0x{0:X8} ({1})", _thisFooter.Timestamp, + _thisDateTime); AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.creatorApplication = 0x{0:X8} (\"{1}\")", - thisFooter.CreatorApplication, - Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter. + _thisFooter.CreatorApplication, + Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(_thisFooter. CreatorApplication))); AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.creatorVersion = 0x{0:X8}", - thisFooter.CreatorVersion); + _thisFooter.CreatorVersion); AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.creatorHostOS = 0x{0:X8} (\"{1}\")", - thisFooter.CreatorHostOs, + _thisFooter.CreatorHostOs, Encoding.ASCII.GetString(BigEndianBitConverter. - GetBytes(thisFooter.CreatorHostOs))); + GetBytes(_thisFooter.CreatorHostOs))); - AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.originalSize = {0}", thisFooter.OriginalSize); - AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.currentSize = {0}", thisFooter.CurrentSize); + AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.originalSize = {0}", _thisFooter.OriginalSize); + AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.currentSize = {0}", _thisFooter.CurrentSize); AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.diskGeometry = 0x{0:X8} (C/H/S: {1}/{2}/{3})", - thisFooter.DiskGeometry, (thisFooter.DiskGeometry & 0xFFFF0000) >> 16, - (thisFooter.DiskGeometry & 0xFF00) >> 8, thisFooter.DiskGeometry & 0xFF); + _thisFooter.DiskGeometry, (_thisFooter.DiskGeometry & 0xFFFF0000) >> 16, + (_thisFooter.DiskGeometry & 0xFF00) >> 8, _thisFooter.DiskGeometry & 0xFF); - AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.diskType = 0x{0:X8}", thisFooter.DiskType); - AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.checksum = 0x{0:X8}", thisFooter.Checksum); - AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.uniqueId = {0}", thisFooter.UniqueId); - AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.savedState = 0x{0:X2}", thisFooter.SavedState); + AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.diskType = 0x{0:X8}", _thisFooter.DiskType); + AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.checksum = 0x{0:X8}", _thisFooter.Checksum); + AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.uniqueId = {0}", _thisFooter.UniqueId); + AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.savedState = 0x{0:X2}", _thisFooter.SavedState); AaruConsole.DebugWriteLine("VirtualPC plugin", "footer.reserved's SHA1 = 0x{0}", sha1Ctx.End()); - if(thisFooter.Version == VERSION1) - imageInfo.Version = "1.0"; + if(_thisFooter.Version == VERSION1) + _imageInfo.Version = "1.0"; else throw new - ImageNotSupportedException($"(VirtualPC plugin): Unknown image type {thisFooter.DiskType} found. Please submit a bug with an example image."); + ImageNotSupportedException($"(VirtualPC plugin): Unknown image type {_thisFooter.DiskType} found. Please submit a bug with an example image."); - switch(thisFooter.CreatorApplication) + switch(_thisFooter.CreatorApplication) { case CREATOR_QEMU: { - imageInfo.Application = "QEMU"; + _imageInfo.Application = "QEMU"; // QEMU always set same version - imageInfo.ApplicationVersion = "Unknown"; + _imageInfo.ApplicationVersion = "Unknown"; break; } case CREATOR_VIRTUAL_BOX: { - imageInfo.ApplicationVersion = - $"{(thisFooter.CreatorVersion & 0xFFFF0000) >> 16}.{thisFooter.CreatorVersion & 0x0000FFFF:D2}"; + _imageInfo.ApplicationVersion = + $"{(_thisFooter.CreatorVersion & 0xFFFF0000) >> 16}.{_thisFooter.CreatorVersion & 0x0000FFFF:D2}"; - switch(thisFooter.CreatorHostOs) + switch(_thisFooter.CreatorHostOs) { case CREATOR_MACINTOSH: case CREATOR_MACINTOSH_OLD: - imageInfo.Application = "VirtualBox for Mac"; + _imageInfo.Application = "VirtualBox for Mac"; break; case CREATOR_WINDOWS: // VirtualBox uses Windows creator for any other OS - imageInfo.Application = "VirtualBox"; + _imageInfo.Application = "VirtualBox"; break; default: - imageInfo.Application = - $"VirtualBox for unknown OS \"{Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.CreatorHostOs))}\""; + _imageInfo.Application = + $"VirtualBox for unknown OS \"{Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(_thisFooter.CreatorHostOs))}\""; break; } @@ -219,16 +219,16 @@ namespace Aaru.DiscImages case CREATOR_VIRTUAL_SERVER: { - imageInfo.Application = "Microsoft Virtual Server"; + _imageInfo.Application = "Microsoft Virtual Server"; - switch(thisFooter.CreatorVersion) + switch(_thisFooter.CreatorVersion) { case VERSION_VIRTUAL_SERVER2004: - imageInfo.ApplicationVersion = "2004"; + _imageInfo.ApplicationVersion = "2004"; break; default: - imageInfo.ApplicationVersion = $"Unknown version 0x{thisFooter.CreatorVersion:X8}"; + _imageInfo.ApplicationVersion = $"Unknown version 0x{_thisFooter.CreatorVersion:X8}"; break; } @@ -238,54 +238,56 @@ namespace Aaru.DiscImages case CREATOR_VIRTUAL_PC: { - switch(thisFooter.CreatorHostOs) + switch(_thisFooter.CreatorHostOs) { case CREATOR_MACINTOSH: case CREATOR_MACINTOSH_OLD: - switch(thisFooter.CreatorVersion) + switch(_thisFooter.CreatorVersion) { case VERSION_VIRTUAL_PC_MAC: - imageInfo.Application = "Connectix Virtual PC"; - imageInfo.ApplicationVersion = "5, 6 or 7"; + _imageInfo.Application = "Connectix Virtual PC"; + _imageInfo.ApplicationVersion = "5, 6 or 7"; break; default: - imageInfo.ApplicationVersion = $"Unknown version 0x{thisFooter.CreatorVersion:X8}"; + _imageInfo.ApplicationVersion = + $"Unknown version 0x{_thisFooter.CreatorVersion:X8}"; break; } break; case CREATOR_WINDOWS: - switch(thisFooter.CreatorVersion) + switch(_thisFooter.CreatorVersion) { case VERSION_VIRTUAL_PC_MAC: - imageInfo.Application = "Connectix Virtual PC"; - imageInfo.ApplicationVersion = "5, 6 or 7"; + _imageInfo.Application = "Connectix Virtual PC"; + _imageInfo.ApplicationVersion = "5, 6 or 7"; break; case VERSION_VIRTUAL_PC2004: - imageInfo.Application = "Microsoft Virtual PC"; - imageInfo.ApplicationVersion = "2004"; + _imageInfo.Application = "Microsoft Virtual PC"; + _imageInfo.ApplicationVersion = "2004"; break; case VERSION_VIRTUAL_PC2007: - imageInfo.Application = "Microsoft Virtual PC"; - imageInfo.ApplicationVersion = "2007"; + _imageInfo.Application = "Microsoft Virtual PC"; + _imageInfo.ApplicationVersion = "2007"; break; default: - imageInfo.ApplicationVersion = $"Unknown version 0x{thisFooter.CreatorVersion:X8}"; + _imageInfo.ApplicationVersion = + $"Unknown version 0x{_thisFooter.CreatorVersion:X8}"; break; } break; default: - imageInfo.Application = - $"Virtual PC for unknown OS \"{Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.CreatorHostOs))}\""; + _imageInfo.Application = + $"Virtual PC for unknown OS \"{Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(_thisFooter.CreatorHostOs))}\""; - imageInfo.ApplicationVersion = $"Unknown version 0x{thisFooter.CreatorVersion:X8}"; + _imageInfo.ApplicationVersion = $"Unknown version 0x{_thisFooter.CreatorVersion:X8}"; break; } @@ -295,51 +297,51 @@ namespace Aaru.DiscImages case CREATOR_DISCIMAGECHEF: { - imageInfo.Application = "DiscImageChef"; + _imageInfo.Application = "DiscImageChef"; - imageInfo.ApplicationVersion = - $"{(thisFooter.CreatorVersion & 0xFF000000) >> 24}.{(thisFooter.CreatorVersion & 0xFF0000) >> 16}.{(thisFooter.CreatorVersion & 0xFF00) >> 8}.{thisFooter.CreatorVersion & 0xFF}"; + _imageInfo.ApplicationVersion = + $"{(_thisFooter.CreatorVersion & 0xFF000000) >> 24}.{(_thisFooter.CreatorVersion & 0xFF0000) >> 16}.{(_thisFooter.CreatorVersion & 0xFF00) >> 8}.{_thisFooter.CreatorVersion & 0xFF}"; } break; case CREATOR_AARU: { - imageInfo.Application = "Aaru"; + _imageInfo.Application = "Aaru"; - imageInfo.ApplicationVersion = - $"{(thisFooter.CreatorVersion & 0xFF000000) >> 24}.{(thisFooter.CreatorVersion & 0xFF0000) >> 16}.{(thisFooter.CreatorVersion & 0xFF00) >> 8}.{thisFooter.CreatorVersion & 0xFF}"; + _imageInfo.ApplicationVersion = + $"{(_thisFooter.CreatorVersion & 0xFF000000) >> 24}.{(_thisFooter.CreatorVersion & 0xFF0000) >> 16}.{(_thisFooter.CreatorVersion & 0xFF00) >> 8}.{_thisFooter.CreatorVersion & 0xFF}"; } break; default: { - imageInfo.Application = - $"Unknown application \"{Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisFooter.CreatorHostOs))}\""; + _imageInfo.Application = + $"Unknown application \"{Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(_thisFooter.CreatorHostOs))}\""; - imageInfo.ApplicationVersion = $"Unknown version 0x{thisFooter.CreatorVersion:X8}"; + _imageInfo.ApplicationVersion = $"Unknown version 0x{_thisFooter.CreatorVersion:X8}"; break; } } - thisFilter = imageFilter; - imageInfo.ImageSize = thisFooter.CurrentSize; - imageInfo.Sectors = thisFooter.CurrentSize / 512; - imageInfo.SectorSize = 512; + _thisFilter = imageFilter; + _imageInfo.ImageSize = _thisFooter.CurrentSize; + _imageInfo.Sectors = _thisFooter.CurrentSize / 512; + _imageInfo.SectorSize = 512; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = thisDateTime; - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = _thisDateTime; + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Cylinders = (thisFooter.DiskGeometry & 0xFFFF0000) >> 16; - imageInfo.Heads = (thisFooter.DiskGeometry & 0xFF00) >> 8; - imageInfo.SectorsPerTrack = thisFooter.DiskGeometry & 0xFF; + _imageInfo.Cylinders = (_thisFooter.DiskGeometry & 0xFFFF0000) >> 16; + _imageInfo.Heads = (_thisFooter.DiskGeometry & 0xFF00) >> 8; + _imageInfo.SectorsPerTrack = _thisFooter.DiskGeometry & 0xFF; - if(thisFooter.DiskType == TYPE_DYNAMIC || - thisFooter.DiskType == TYPE_DIFFERENCING) + if(_thisFooter.DiskType == TYPE_DYNAMIC || + _thisFooter.DiskType == TYPE_DIFFERENCING) { - imageStream.Seek((long)thisFooter.Offset, SeekOrigin.Begin); + imageStream.Seek((long)_thisFooter.Offset, SeekOrigin.Begin); byte[] dynamicBytes = new byte[1024]; imageStream.Read(dynamicBytes, 0, 1024); @@ -360,143 +362,143 @@ namespace Aaru.DiscImages throw new ImageNotSupportedException("(VirtualPC plugin): Both header and footer are corrupt, image cannot be opened."); - thisDynamic = new DynamicDiskHeader + _thisDynamic = new DynamicDiskHeader { LocatorEntries = new ParentLocatorEntry[8], Reserved2 = new byte[256] }; for(int i = 0; i < 8; i++) - thisDynamic.LocatorEntries[i] = new ParentLocatorEntry(); + _thisDynamic.LocatorEntries[i] = new ParentLocatorEntry(); - thisDynamic.Cookie = BigEndianBitConverter.ToUInt64(dynamicBytes, 0x00); - thisDynamic.DataOffset = BigEndianBitConverter.ToUInt64(dynamicBytes, 0x08); - thisDynamic.TableOffset = BigEndianBitConverter.ToUInt64(dynamicBytes, 0x10); - thisDynamic.HeaderVersion = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x18); - thisDynamic.MaxTableEntries = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x1C); - thisDynamic.BlockSize = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x20); - thisDynamic.Checksum = dynamicChecksum; - thisDynamic.ParentId = BigEndianBitConverter.ToGuid(dynamicBytes, 0x28); - thisDynamic.ParentTimestamp = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x38); - thisDynamic.Reserved = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x3C); - thisDynamic.ParentName = Encoding.BigEndianUnicode.GetString(dynamicBytes, 0x40, 512); + _thisDynamic.Cookie = BigEndianBitConverter.ToUInt64(dynamicBytes, 0x00); + _thisDynamic.DataOffset = BigEndianBitConverter.ToUInt64(dynamicBytes, 0x08); + _thisDynamic.TableOffset = BigEndianBitConverter.ToUInt64(dynamicBytes, 0x10); + _thisDynamic.HeaderVersion = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x18); + _thisDynamic.MaxTableEntries = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x1C); + _thisDynamic.BlockSize = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x20); + _thisDynamic.Checksum = dynamicChecksum; + _thisDynamic.ParentId = BigEndianBitConverter.ToGuid(dynamicBytes, 0x28); + _thisDynamic.ParentTimestamp = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x38); + _thisDynamic.Reserved = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x3C); + _thisDynamic.ParentName = Encoding.BigEndianUnicode.GetString(dynamicBytes, 0x40, 512); for(int i = 0; i < 8; i++) { - thisDynamic.LocatorEntries[i].PlatformCode = + _thisDynamic.LocatorEntries[i].PlatformCode = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x240 + 0x00 + (24 * i)); - thisDynamic.LocatorEntries[i].PlatformDataSpace = + _thisDynamic.LocatorEntries[i].PlatformDataSpace = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x240 + 0x04 + (24 * i)); - thisDynamic.LocatorEntries[i].PlatformDataLength = + _thisDynamic.LocatorEntries[i].PlatformDataLength = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x240 + 0x08 + (24 * i)); - thisDynamic.LocatorEntries[i].Reserved = + _thisDynamic.LocatorEntries[i].Reserved = BigEndianBitConverter.ToUInt32(dynamicBytes, 0x240 + 0x0C + (24 * i)); - thisDynamic.LocatorEntries[i].PlatformDataOffset = + _thisDynamic.LocatorEntries[i].PlatformDataOffset = BigEndianBitConverter.ToUInt64(dynamicBytes, 0x240 + 0x10 + (24 * i)); } - Array.Copy(dynamicBytes, 0x300, thisDynamic.Reserved2, 0, 256); + Array.Copy(dynamicBytes, 0x300, _thisDynamic.Reserved2, 0, 256); - parentDateTime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc); - parentDateTime = parentDateTime.AddSeconds(thisDynamic.ParentTimestamp); + _parentDateTime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc); + _parentDateTime = _parentDateTime.AddSeconds(_thisDynamic.ParentTimestamp); sha1Ctx = new Sha1Context(); - sha1Ctx.Update(thisDynamic.Reserved2); + sha1Ctx.Update(_thisDynamic.Reserved2); - AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.cookie = 0x{0:X8}", thisDynamic.Cookie); - AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.dataOffset = {0}", thisDynamic.DataOffset); - AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.tableOffset = {0}", thisDynamic.TableOffset); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.cookie = 0x{0:X8}", _thisDynamic.Cookie); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.dataOffset = {0}", _thisDynamic.DataOffset); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.tableOffset = {0}", _thisDynamic.TableOffset); AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.headerVersion = 0x{0:X8}", - thisDynamic.HeaderVersion); + _thisDynamic.HeaderVersion); AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.maxTableEntries = {0}", - thisDynamic.MaxTableEntries); + _thisDynamic.MaxTableEntries); - AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.blockSize = {0}", thisDynamic.BlockSize); - AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.checksum = 0x{0:X8}", thisDynamic.Checksum); - AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.parentID = {0}", thisDynamic.ParentId); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.blockSize = {0}", _thisDynamic.BlockSize); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.checksum = 0x{0:X8}", _thisDynamic.Checksum); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.parentID = {0}", _thisDynamic.ParentId); AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.parentTimestamp = 0x{0:X8} ({1})", - thisDynamic.ParentTimestamp, parentDateTime); + _thisDynamic.ParentTimestamp, _parentDateTime); - AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.reserved = 0x{0:X8}", thisDynamic.Reserved); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.reserved = 0x{0:X8}", _thisDynamic.Reserved); for(int i = 0; i < 8; i++) { AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}].platformCode = 0x{1:X8} (\"{2}\")", i, - thisDynamic.LocatorEntries[i].PlatformCode, - Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(thisDynamic. + _thisDynamic.LocatorEntries[i].PlatformCode, + Encoding.ASCII.GetString(BigEndianBitConverter.GetBytes(_thisDynamic. LocatorEntries [i]. PlatformCode))); AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}].platformDataSpace = {1}", i, - thisDynamic.LocatorEntries[i].PlatformDataSpace); + _thisDynamic.LocatorEntries[i].PlatformDataSpace); AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}].platformDataLength = {1}", i, - thisDynamic.LocatorEntries[i].PlatformDataLength); + _thisDynamic.LocatorEntries[i].PlatformDataLength); AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}].reserved = 0x{1:X8}", i, - thisDynamic.LocatorEntries[i].Reserved); + _thisDynamic.LocatorEntries[i].Reserved); AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}].platformDataOffset = {1}", i, - thisDynamic.LocatorEntries[i].PlatformDataOffset); + _thisDynamic.LocatorEntries[i].PlatformDataOffset); } - AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.parentName = \"{0}\"", thisDynamic.ParentName); + AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.parentName = \"{0}\"", _thisDynamic.ParentName); AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.reserved2's SHA1 = 0x{0}", sha1Ctx.End()); - if(thisDynamic.HeaderVersion != VERSION1) + if(_thisDynamic.HeaderVersion != VERSION1) throw new - ImageNotSupportedException($"(VirtualPC plugin): Unknown image type {thisFooter.DiskType} found. Please submit a bug with an example image."); + ImageNotSupportedException($"(VirtualPC plugin): Unknown image type {_thisFooter.DiskType} found. Please submit a bug with an example image."); DateTime startTime = DateTime.UtcNow; - blockAllocationTable = new uint[thisDynamic.MaxTableEntries]; + _blockAllocationTable = new uint[_thisDynamic.MaxTableEntries]; // How many sectors uses the BAT - int batSectorCount = (int)Math.Ceiling(((double)thisDynamic.MaxTableEntries * 4) / 512); + int batSectorCount = (int)Math.Ceiling(((double)_thisDynamic.MaxTableEntries * 4) / 512); - byte[] bat = new byte[thisDynamic.MaxTableEntries * 4]; - imageStream.Seek((long)thisDynamic.TableOffset, SeekOrigin.Begin); + byte[] bat = new byte[_thisDynamic.MaxTableEntries * 4]; + imageStream.Seek((long)_thisDynamic.TableOffset, SeekOrigin.Begin); imageStream.Read(bat, 0, batSectorCount); ReadOnlySpan span = bat; - blockAllocationTable = - MemoryMarshal.Cast(span).Slice(0, (int)thisDynamic.MaxTableEntries).ToArray(); + _blockAllocationTable = MemoryMarshal. + Cast(span).Slice(0, (int)_thisDynamic.MaxTableEntries).ToArray(); - for(int i = 0; i < blockAllocationTable.Length; i++) - blockAllocationTable[i] = Swapping.Swap(blockAllocationTable[i]); + for(int i = 0; i < _blockAllocationTable.Length; i++) + _blockAllocationTable[i] = Swapping.Swap(_blockAllocationTable[i]); DateTime endTime = DateTime.UtcNow; AaruConsole.DebugWriteLine("VirtualPC plugin", "Filling the BAT took {0} seconds", (endTime - startTime).TotalSeconds); - bitmapSize = (uint)Math.Ceiling((double)thisDynamic.BlockSize / 512 + _bitmapSize = (uint)Math.Ceiling((double)_thisDynamic.BlockSize / 512 - // 1 bit per sector on the bitmap - / 8 + // 1 bit per sector on the bitmap + / 8 - // and aligned to 512 byte boundary - / 512); + // and aligned to 512 byte boundary + / 512); - AaruConsole.DebugWriteLine("VirtualPC plugin", "Bitmap is {0} sectors", bitmapSize); + AaruConsole.DebugWriteLine("VirtualPC plugin", "Bitmap is {0} sectors", _bitmapSize); } - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - switch(thisFooter.DiskType) + switch(_thisFooter.DiskType) { case TYPE_FIXED: case TYPE_DYNAMIC: @@ -507,24 +509,24 @@ namespace Aaru.DiscImages case TYPE_DIFFERENCING: { - locatorEntriesData = new byte[8][]; + _locatorEntriesData = new byte[8][]; for(int i = 0; i < 8; i++) - if(thisDynamic.LocatorEntries[i].PlatformCode != 0x00000000) + if(_thisDynamic.LocatorEntries[i].PlatformCode != 0x00000000) { - locatorEntriesData[i] = new byte[thisDynamic.LocatorEntries[i].PlatformDataLength]; - imageStream.Seek((long)thisDynamic.LocatorEntries[i].PlatformDataOffset, SeekOrigin.Begin); + _locatorEntriesData[i] = new byte[_thisDynamic.LocatorEntries[i].PlatformDataLength]; + imageStream.Seek((long)_thisDynamic.LocatorEntries[i].PlatformDataOffset, SeekOrigin.Begin); - imageStream.Read(locatorEntriesData[i], 0, - (int)thisDynamic.LocatorEntries[i].PlatformDataLength); + imageStream.Read(_locatorEntriesData[i], 0, + (int)_thisDynamic.LocatorEntries[i].PlatformDataLength); - switch(thisDynamic.LocatorEntries[i].PlatformCode) + switch(_thisDynamic.LocatorEntries[i].PlatformCode) { case PLATFORM_CODE_WINDOWS_ABSOLUTE: case PLATFORM_CODE_WINDOWS_RELATIVE: AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}] = \"{1}\"", i, - Encoding.ASCII.GetString(locatorEntriesData[i])); + Encoding.ASCII.GetString(_locatorEntriesData[i])); break; case PLATFORM_CODE_WINDOWS_ABSOLUTE_U: @@ -532,18 +534,18 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}] = \"{1}\"", i, Encoding.BigEndianUnicode. - GetString(locatorEntriesData[i])); + GetString(_locatorEntriesData[i])); break; case PLATFORM_CODE_MACINTOSH_URI: AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}] = \"{1}\"", i, - Encoding.UTF8.GetString(locatorEntriesData[i])); + Encoding.UTF8.GetString(_locatorEntriesData[i])); break; default: AaruConsole.DebugWriteLine("VirtualPC plugin", "dynamic.locatorEntries[{0}] =", i); - PrintHex.PrintHexArray(locatorEntriesData[i], 64); + PrintHex.PrintHexArray(_locatorEntriesData[i], 64); break; } @@ -556,21 +558,22 @@ namespace Aaru.DiscImages while(!locatorFound && currentLocator < 8) { - switch(thisDynamic.LocatorEntries[currentLocator].PlatformCode) + switch(_thisDynamic.LocatorEntries[currentLocator].PlatformCode) { case PLATFORM_CODE_WINDOWS_ABSOLUTE: case PLATFORM_CODE_WINDOWS_RELATIVE: - parentPath = Encoding.ASCII.GetString(locatorEntriesData[currentLocator]); + parentPath = Encoding.ASCII.GetString(_locatorEntriesData[currentLocator]); break; case PLATFORM_CODE_WINDOWS_ABSOLUTE_U: case PLATFORM_CODE_WINDOWS_RELATIVE_U: - parentPath = Encoding.BigEndianUnicode.GetString(locatorEntriesData[currentLocator]); + parentPath = Encoding.BigEndianUnicode.GetString(_locatorEntriesData[currentLocator]); break; case PLATFORM_CODE_MACINTOSH_URI: parentPath = - Uri.UnescapeDataString(Encoding.UTF8.GetString(locatorEntriesData[currentLocator])); + Uri.UnescapeDataString(Encoding.UTF8.GetString(_locatorEntriesData + [currentLocator])); if(parentPath.StartsWith("file://localhost", StringComparison.InvariantCulture)) parentPath = parentPath.Remove(0, 16); @@ -608,7 +611,7 @@ namespace Aaru.DiscImages FileNotFoundException("(VirtualPC plugin): Cannot find parent file for differencing disk image"); { - parentImage = new Vhd(); + _parentImage = new Vhd(); IFilter parentFilter = new FiltersList().GetFilter(Path.Combine(imageFilter.GetParentFolder(), parentPath)); @@ -620,11 +623,11 @@ namespace Aaru.DiscImages if (!plugins.ImagePluginsList.TryGetValue(Name.ToLower(), out parentImage)) throw new SystemException("(VirtualPC plugin): Unable to open myself");*/ - if(!parentImage.Identify(parentFilter)) + if(!_parentImage.Identify(parentFilter)) throw new ImageNotSupportedException("(VirtualPC plugin): Parent image is not a Virtual PC disk image"); - if(!parentImage.Open(parentFilter)) + if(!_parentImage.Open(parentFilter)) throw new ImageNotSupportedException("(VirtualPC plugin): Cannot open parent disk image"); // While specification says that parent and child disk images should contain UUID relationship @@ -632,7 +635,7 @@ namespace Aaru.DiscImages // the parent never stored itself. So the only real way to know that images are related is // because the parent IS found and SAME SIZE. Ugly... // More funny even, tested parent images show an empty host OS, and child images a correct one. - if(parentImage.Info.Sectors != imageInfo.Sectors) + if(_parentImage.Info.Sectors != _imageInfo.Sectors) throw new ImageNotSupportedException("(VirtualPC plugin): Parent image is of different size"); } @@ -651,38 +654,38 @@ namespace Aaru.DiscImages default: { throw new - ImageNotSupportedException($"(VirtualPC plugin): Unknown image type {thisFooter.DiskType} found. Please submit a bug with an example image."); + ImageNotSupportedException($"(VirtualPC plugin): Unknown image type {_thisFooter.DiskType} found. Please submit a bug with an example image."); } } } public byte[] ReadSector(ulong sectorAddress) { - switch(thisFooter.DiskType) + switch(_thisFooter.DiskType) { case TYPE_DIFFERENCING: { // Block number for BAT searching - uint blockNumber = (uint)Math.Floor(sectorAddress / (thisDynamic.BlockSize / 512.0)); + uint blockNumber = (uint)Math.Floor(sectorAddress / (_thisDynamic.BlockSize / 512.0)); // Sector number inside of block - uint sectorInBlock = (uint)(sectorAddress % (thisDynamic.BlockSize / 512)); + uint sectorInBlock = (uint)(sectorAddress % (_thisDynamic.BlockSize / 512)); - if(blockAllocationTable[blockNumber] == 0xFFFFFFFF) + if(_blockAllocationTable[blockNumber] == 0xFFFFFFFF) return new byte[512]; - byte[] bitmap = new byte[bitmapSize * 512]; + byte[] bitmap = new byte[_bitmapSize * 512]; // Offset of block in file - uint blockOffset = blockAllocationTable[blockNumber] * 512; + uint blockOffset = _blockAllocationTable[blockNumber] * 512; int bitmapByte = (int)Math.Floor((double)sectorInBlock / 8); int bitmapBit = (int)(sectorInBlock % 8); - Stream thisStream = thisFilter.GetDataForkStream(); + Stream thisStream = _thisFilter.GetDataForkStream(); thisStream.Seek(blockOffset, SeekOrigin.Begin); - thisStream.Read(bitmap, 0, (int)bitmapSize * 512); + thisStream.Read(bitmap, 0, (int)_bitmapSize * 512); byte mask = (byte)(1 << (7 - bitmapBit)); bool dirty = (bitmap[bitmapByte] & mask) == mask; @@ -702,14 +705,14 @@ namespace Aaru.DiscImages // Sector has been written, read from child image if(!dirty) - return parentImage.ReadSector(sectorAddress); + return _parentImage.ReadSector(sectorAddress); /* Too noisy AaruConsole.DebugWriteLine("VirtualPC plugin", "Sector {0} is dirty", sectorAddress); */ byte[] data = new byte[512]; - uint sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock; - thisStream = thisFilter.GetDataForkStream(); + uint sectorOffset = _blockAllocationTable[blockNumber] + _bitmapSize + sectorInBlock; + thisStream = _thisFilter.GetDataForkStream(); thisStream.Seek(sectorOffset * 512, SeekOrigin.Begin); thisStream.Read(data, 0, 512); @@ -729,12 +732,12 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - switch(thisFooter.DiskType) + switch(_thisFooter.DiskType) { case TYPE_FIXED: { byte[] data = new byte[512 * length]; - Stream thisStream = thisFilter.GetDataForkStream(); + Stream thisStream = _thisFilter.GetDataForkStream(); thisStream.Seek((long)(sectorAddress * 512), SeekOrigin.Begin); thisStream.Read(data, 0, (int)(512 * length)); @@ -749,13 +752,13 @@ namespace Aaru.DiscImages case TYPE_DYNAMIC: { // Block number for BAT searching - uint blockNumber = (uint)Math.Floor(sectorAddress / (thisDynamic.BlockSize / 512.0)); + uint blockNumber = (uint)Math.Floor(sectorAddress / (_thisDynamic.BlockSize / 512.0)); // Sector number inside of block - uint sectorInBlock = (uint)(sectorAddress % (thisDynamic.BlockSize / 512)); + uint sectorInBlock = (uint)(sectorAddress % (_thisDynamic.BlockSize / 512)); // How many sectors before reaching end of block - uint remainingInBlock = (thisDynamic.BlockSize / 512) - sectorInBlock; + uint remainingInBlock = (_thisDynamic.BlockSize / 512) - sectorInBlock; // Data that needs to be read from another block byte[] suffix = null; @@ -773,15 +776,15 @@ namespace Aaru.DiscImages sectorsToReadHere = length; // Offset of sector in file - uint sectorOffset = blockAllocationTable[blockNumber] + bitmapSize + sectorInBlock; + uint sectorOffset = _blockAllocationTable[blockNumber] + _bitmapSize + sectorInBlock; // Data that can be read in this block byte[] prefix = new byte[sectorsToReadHere * 512]; // 0xFFFFFFFF means unallocated - if(blockAllocationTable[blockNumber] != 0xFFFFFFFF) + if(_blockAllocationTable[blockNumber] != 0xFFFFFFFF) { - Stream thisStream = thisFilter.GetDataForkStream(); + Stream thisStream = _thisFilter.GetDataForkStream(); thisStream.Seek(sectorOffset * 512, SeekOrigin.Begin); thisStream.Read(prefix, 0, (int)(512 * sectorsToReadHere)); } @@ -827,7 +830,7 @@ namespace Aaru.DiscImages default: { throw new - ImageNotSupportedException($"(VirtualPC plugin): Unknown image type {thisFooter.DiskType} found. Please submit a bug with an example image."); + ImageNotSupportedException($"(VirtualPC plugin): Unknown image type {_thisFooter.DiskType} found. Please submit a bug with an example image."); } } } diff --git a/Aaru.Images/VHD/VHD.cs b/Aaru.Images/VHD/VHD.cs index 366defaab..0b2de2751 100644 --- a/Aaru.Images/VHD/VHD.cs +++ b/Aaru.Images/VHD/VHD.cs @@ -47,19 +47,19 @@ namespace Aaru.DiscImages /// public partial class Vhd : IWritableImage { - uint bitmapSize; - uint[] blockAllocationTable; - ImageInfo imageInfo; - byte[][] locatorEntriesData; - DateTime parentDateTime; - IMediaImage parentImage; - DateTime thisDateTime; - DynamicDiskHeader thisDynamic; - IFilter thisFilter; - HardDiskFooter thisFooter; - FileStream writingStream; + uint _bitmapSize; + uint[] _blockAllocationTable; + ImageInfo _imageInfo; + byte[][] _locatorEntriesData; + DateTime _parentDateTime; + IMediaImage _parentImage; + DateTime _thisDateTime; + DynamicDiskHeader _thisDynamic; + IFilter _thisFilter; + HardDiskFooter _thisFooter; + FileStream _writingStream; - public Vhd() => imageInfo = new ImageInfo + public Vhd() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/VHD/Write.cs b/Aaru.Images/VHD/Write.cs index 72d7a1202..6723fcc81 100644 --- a/Aaru.Images/VHD/Write.cs +++ b/Aaru.Images/VHD/Write.cs @@ -64,7 +64,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -73,7 +73,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -111,15 +111,15 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(0 + (sectorAddress * 512)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(0 + (sectorAddress * 512)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -143,15 +143,15 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(0 + (sectorAddress * 512)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(0 + (sectorAddress * 512)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -183,27 +183,27 @@ namespace Aaru.DiscImages Version thisVersion = GetType().Assembly.GetName().Version; - if(imageInfo.Cylinders == 0) + if(_imageInfo.Cylinders == 0) { - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; - while(imageInfo.Cylinders == 0) + while(_imageInfo.Cylinders == 0) { - imageInfo.Heads--; + _imageInfo.Heads--; - if(imageInfo.Heads == 0) + if(_imageInfo.Heads == 0) { - imageInfo.SectorsPerTrack--; - imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack--; + _imageInfo.Heads = 16; } - imageInfo.Cylinders = (uint)(imageInfo.Sectors / imageInfo.Heads / imageInfo.SectorsPerTrack); + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / _imageInfo.Heads / _imageInfo.SectorsPerTrack); - if(imageInfo.Cylinders == 0 && - imageInfo.Heads == 0 && - imageInfo.SectorsPerTrack == 0) + if(_imageInfo.Cylinders == 0 && + _imageInfo.Heads == 0 && + _imageInfo.SectorsPerTrack == 0) break; } } @@ -220,10 +220,10 @@ namespace Aaru.DiscImages CreatorHostOs = DetectOS.GetRealPlatformID() == PlatformID.MacOSX ? CREATOR_MACINTOSH : CREATOR_WINDOWS, DiskType = TYPE_FIXED, UniqueId = Guid.NewGuid(), - DiskGeometry = ((imageInfo.Cylinders & 0xFFFF) << 16) + ((imageInfo.Heads & 0xFF) << 8) + - (imageInfo.SectorsPerTrack & 0xFF), - OriginalSize = imageInfo.Sectors * 512, - CurrentSize = imageInfo.Sectors * 512 + DiskGeometry = ((_imageInfo.Cylinders & 0xFFFF) << 16) + ((_imageInfo.Heads & 0xFF) << 8) + + (_imageInfo.SectorsPerTrack & 0xFF), + OriginalSize = _imageInfo.Sectors * 512, + CurrentSize = _imageInfo.Sectors * 512 }; footer.Offset = footer.DiskType == TYPE_FIXED ? ulong.MaxValue : 512; @@ -246,11 +246,11 @@ namespace Aaru.DiscImages footer.Checksum = VhdChecksum(footerBytes); Array.Copy(BigEndianBitConverter.GetBytes(footer.Checksum), 0, footerBytes, 0x40, 4); - writingStream.Seek((long)(footer.DiskType == TYPE_FIXED ? footer.OriginalSize : 0), SeekOrigin.Begin); - writingStream.Write(footerBytes, 0, 512); + _writingStream.Seek((long)(footer.DiskType == TYPE_FIXED ? footer.OriginalSize : 0), SeekOrigin.Begin); + _writingStream.Write(footerBytes, 0, 512); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -283,9 +283,9 @@ namespace Aaru.DiscImages return false; } - imageInfo.SectorsPerTrack = sectorsPerTrack; - imageInfo.Heads = heads; - imageInfo.Cylinders = cylinders; + _imageInfo.SectorsPerTrack = sectorsPerTrack; + _imageInfo.Heads = heads; + _imageInfo.Cylinders = cylinders; return true; } diff --git a/Aaru.Images/VHDX/Constants.cs b/Aaru.Images/VHDX/Constants.cs index 445729b51..3c7bf4d91 100644 --- a/Aaru.Images/VHDX/Constants.cs +++ b/Aaru.Images/VHDX/Constants.cs @@ -78,15 +78,15 @@ namespace Aaru.DiscImages const ulong BAT_FLAGS_MASK = 0x7; const ulong BAT_RESERVED_MASK = 0x3FFF8; - const int MAX_CACHE_SIZE = 16777216; - readonly Guid batGuid = new Guid("2DC27766-F623-4200-9D64-115E9BFD4A08"); - readonly Guid fileParametersGuid = new Guid("CAA16737-FA36-4D43-B3B6-33F0AA44E76B"); - readonly Guid logicalSectorSizeGuid = new Guid("8141BF1D-A96F-4709-BA47-F233A8FAAB5F"); - readonly Guid metadataGuid = new Guid("8B7CA206-4790-4B9A-B8FE-575F050F886E"); - readonly Guid page83DataGuid = new Guid("BECA12AB-B2E6-4523-93EF-C309E000C746"); - readonly Guid parentLocatorGuid = new Guid("A8D35F2D-B30B-454D-ABF7-D3D84834AB0C"); - readonly Guid parentTypeVhdxGuid = new Guid("B04AEFB7-D19E-4A81-B789-25B8E9445913"); - readonly Guid physicalSectorSizeGuid = new Guid("CDA348C7-445D-4471-9CC9-E9885251C556"); - readonly Guid virtualDiskSizeGuid = new Guid("2FA54224-CD1B-4876-B211-5DBED83BF4B8"); + const int MAX_CACHE_SIZE = 16777216; + readonly Guid _batGuid = new Guid("2DC27766-F623-4200-9D64-115E9BFD4A08"); + readonly Guid _fileParametersGuid = new Guid("CAA16737-FA36-4D43-B3B6-33F0AA44E76B"); + readonly Guid _logicalSectorSizeGuid = new Guid("8141BF1D-A96F-4709-BA47-F233A8FAAB5F"); + readonly Guid _metadataGuid = new Guid("8B7CA206-4790-4B9A-B8FE-575F050F886E"); + readonly Guid _page83DataGuid = new Guid("BECA12AB-B2E6-4523-93EF-C309E000C746"); + readonly Guid _parentLocatorGuid = new Guid("A8D35F2D-B30B-454D-ABF7-D3D84834AB0C"); + readonly Guid _parentTypeVhdxGuid = new Guid("B04AEFB7-D19E-4A81-B789-25B8E9445913"); + readonly Guid _physicalSectorSizeGuid = new Guid("CDA348C7-445D-4471-9CC9-E9885251C556"); + readonly Guid _virtualDiskSizeGuid = new Guid("2FA54224-CD1B-4876-B211-5DBED83BF4B8"); } } \ No newline at end of file diff --git a/Aaru.Images/VHDX/Helpers.cs b/Aaru.Images/VHDX/Helpers.cs index 5712c6668..a314c34a5 100644 --- a/Aaru.Images/VHDX/Helpers.cs +++ b/Aaru.Images/VHDX/Helpers.cs @@ -43,10 +43,10 @@ namespace Aaru.DiscImages int shift = (int)(sectorAddress % 8); byte val = (byte)(1 << shift); - if(index > sectorBitmap.LongLength) + if(index > _sectorBitmap.LongLength) return false; - return (sectorBitmap[index] & val) == val; + return (_sectorBitmap[index] & val) == val; } static uint VhdxChecksum(IEnumerable data) diff --git a/Aaru.Images/VHDX/Identify.cs b/Aaru.Images/VHDX/Identify.cs index ed4572117..b5404d7cf 100644 --- a/Aaru.Images/VHDX/Identify.cs +++ b/Aaru.Images/VHDX/Identify.cs @@ -48,9 +48,9 @@ namespace Aaru.DiscImages byte[] vhdxIdB = new byte[Marshal.SizeOf()]; stream.Read(vhdxIdB, 0, Marshal.SizeOf()); - vhdxId = Marshal.ByteArrayToStructureLittleEndian(vhdxIdB); + _vhdxId = Marshal.ByteArrayToStructureLittleEndian(vhdxIdB); - return vhdxId.signature == VHDX_SIGNATURE; + return _vhdxId.signature == VHDX_SIGNATURE; } } } \ No newline at end of file diff --git a/Aaru.Images/VHDX/Properties.cs b/Aaru.Images/VHDX/Properties.cs index 90aed5c80..6d7a616e8 100644 --- a/Aaru.Images/VHDX/Properties.cs +++ b/Aaru.Images/VHDX/Properties.cs @@ -39,7 +39,7 @@ namespace Aaru.DiscImages { public partial class Vhdx { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Microsoft VHDX"; public Guid Id => new Guid("536B141B-D09C-4799-AB70-34631286EB9D"); diff --git a/Aaru.Images/VHDX/Read.cs b/Aaru.Images/VHDX/Read.cs index e73a0b71b..1c0eabe7f 100644 --- a/Aaru.Images/VHDX/Read.cs +++ b/Aaru.Images/VHDX/Read.cs @@ -55,109 +55,109 @@ namespace Aaru.DiscImages byte[] vhdxIdB = new byte[Marshal.SizeOf()]; stream.Read(vhdxIdB, 0, Marshal.SizeOf()); - vhdxId = Marshal.ByteArrayToStructureLittleEndian(vhdxIdB); + _vhdxId = Marshal.ByteArrayToStructureLittleEndian(vhdxIdB); - if(vhdxId.signature != VHDX_SIGNATURE) + if(_vhdxId.signature != VHDX_SIGNATURE) return false; - imageInfo.Application = Encoding.Unicode.GetString(vhdxId.creator); + _imageInfo.Application = Encoding.Unicode.GetString(_vhdxId.creator); stream.Seek(64 * 1024, SeekOrigin.Begin); byte[] vHdrB = new byte[Marshal.SizeOf()]; stream.Read(vHdrB, 0, Marshal.SizeOf()); - vHdr = Marshal.ByteArrayToStructureLittleEndian(vHdrB); + _vHdr = Marshal.ByteArrayToStructureLittleEndian(vHdrB); - if(vHdr.Signature != VHDX_HEADER_SIG) + if(_vHdr.Signature != VHDX_HEADER_SIG) { stream.Seek(128 * 1024, SeekOrigin.Begin); vHdrB = new byte[Marshal.SizeOf()]; stream.Read(vHdrB, 0, Marshal.SizeOf()); - vHdr = Marshal.ByteArrayToStructureLittleEndian(vHdrB); + _vHdr = Marshal.ByteArrayToStructureLittleEndian(vHdrB); - if(vHdr.Signature != VHDX_HEADER_SIG) + if(_vHdr.Signature != VHDX_HEADER_SIG) throw new ImageNotSupportedException("VHDX header not found"); } stream.Seek(192 * 1024, SeekOrigin.Begin); byte[] vRegTableB = new byte[Marshal.SizeOf()]; stream.Read(vRegTableB, 0, Marshal.SizeOf()); - vRegHdr = Marshal.ByteArrayToStructureLittleEndian(vRegTableB); + _vRegHdr = Marshal.ByteArrayToStructureLittleEndian(vRegTableB); - if(vRegHdr.signature != VHDX_REGION_SIG) + if(_vRegHdr.signature != VHDX_REGION_SIG) { stream.Seek(256 * 1024, SeekOrigin.Begin); vRegTableB = new byte[Marshal.SizeOf()]; stream.Read(vRegTableB, 0, Marshal.SizeOf()); - vRegHdr = Marshal.ByteArrayToStructureLittleEndian(vRegTableB); + _vRegHdr = Marshal.ByteArrayToStructureLittleEndian(vRegTableB); - if(vRegHdr.signature != VHDX_REGION_SIG) + if(_vRegHdr.signature != VHDX_REGION_SIG) throw new ImageNotSupportedException("VHDX region table not found"); } - vRegs = new VhdxRegionTableEntry[vRegHdr.entries]; + _vRegs = new VhdxRegionTableEntry[_vRegHdr.entries]; - for(int i = 0; i < vRegs.Length; i++) + for(int i = 0; i < _vRegs.Length; i++) { - byte[] vRegB = new byte[System.Runtime.InteropServices.Marshal.SizeOf(vRegs[i])]; - stream.Read(vRegB, 0, System.Runtime.InteropServices.Marshal.SizeOf(vRegs[i])); - vRegs[i] = Marshal.ByteArrayToStructureLittleEndian(vRegB); + byte[] vRegB = new byte[System.Runtime.InteropServices.Marshal.SizeOf(_vRegs[i])]; + stream.Read(vRegB, 0, System.Runtime.InteropServices.Marshal.SizeOf(_vRegs[i])); + _vRegs[i] = Marshal.ByteArrayToStructureLittleEndian(vRegB); - if(vRegs[i].guid == batGuid) - batOffset = (long)vRegs[i].offset; - else if(vRegs[i].guid == metadataGuid) - metadataOffset = (long)vRegs[i].offset; - else if((vRegs[i].flags & REGION_FLAGS_REQUIRED) == REGION_FLAGS_REQUIRED) + if(_vRegs[i].guid == _batGuid) + _batOffset = (long)_vRegs[i].offset; + else if(_vRegs[i].guid == _metadataGuid) + _metadataOffset = (long)_vRegs[i].offset; + else if((_vRegs[i].flags & REGION_FLAGS_REQUIRED) == REGION_FLAGS_REQUIRED) throw new - ImageNotSupportedException($"Found unsupported and required region Guid {vRegs[i].guid}, not proceeding with image."); + ImageNotSupportedException($"Found unsupported and required region Guid {_vRegs[i].guid}, not proceeding with image."); } - if(batOffset == 0) + if(_batOffset == 0) throw new Exception("BAT not found, cannot continue."); - if(metadataOffset == 0) + if(_metadataOffset == 0) throw new Exception("Metadata not found, cannot continue."); uint fileParamsOff = 0, vdSizeOff = 0, p83Off = 0, logOff = 0, physOff = 0, parentOff = 0; - stream.Seek(metadataOffset, SeekOrigin.Begin); + stream.Seek(_metadataOffset, SeekOrigin.Begin); byte[] metTableB = new byte[Marshal.SizeOf()]; stream.Read(metTableB, 0, Marshal.SizeOf()); - vMetHdr = Marshal.ByteArrayToStructureLittleEndian(metTableB); + _vMetHdr = Marshal.ByteArrayToStructureLittleEndian(metTableB); - vMets = new VhdxMetadataTableEntry[vMetHdr.entries]; + _vMets = new VhdxMetadataTableEntry[_vMetHdr.entries]; - for(int i = 0; i < vMets.Length; i++) + for(int i = 0; i < _vMets.Length; i++) { - byte[] vMetB = new byte[System.Runtime.InteropServices.Marshal.SizeOf(vMets[i])]; - stream.Read(vMetB, 0, System.Runtime.InteropServices.Marshal.SizeOf(vMets[i])); - vMets[i] = Marshal.ByteArrayToStructureLittleEndian(vMetB); + byte[] vMetB = new byte[System.Runtime.InteropServices.Marshal.SizeOf(_vMets[i])]; + stream.Read(vMetB, 0, System.Runtime.InteropServices.Marshal.SizeOf(_vMets[i])); + _vMets[i] = Marshal.ByteArrayToStructureLittleEndian(vMetB); - if(vMets[i].itemId == fileParametersGuid) - fileParamsOff = vMets[i].offset; - else if(vMets[i].itemId == virtualDiskSizeGuid) - vdSizeOff = vMets[i].offset; - else if(vMets[i].itemId == page83DataGuid) - p83Off = vMets[i].offset; - else if(vMets[i].itemId == logicalSectorSizeGuid) - logOff = vMets[i].offset; - else if(vMets[i].itemId == physicalSectorSizeGuid) - physOff = vMets[i].offset; - else if(vMets[i].itemId == parentLocatorGuid) - parentOff = vMets[i].offset; - else if((vMets[i].flags & METADATA_FLAGS_REQUIRED) == METADATA_FLAGS_REQUIRED) + if(_vMets[i].itemId == _fileParametersGuid) + fileParamsOff = _vMets[i].offset; + else if(_vMets[i].itemId == _virtualDiskSizeGuid) + vdSizeOff = _vMets[i].offset; + else if(_vMets[i].itemId == _page83DataGuid) + p83Off = _vMets[i].offset; + else if(_vMets[i].itemId == _logicalSectorSizeGuid) + logOff = _vMets[i].offset; + else if(_vMets[i].itemId == _physicalSectorSizeGuid) + physOff = _vMets[i].offset; + else if(_vMets[i].itemId == _parentLocatorGuid) + parentOff = _vMets[i].offset; + else if((_vMets[i].flags & METADATA_FLAGS_REQUIRED) == METADATA_FLAGS_REQUIRED) throw new - ImageNotSupportedException($"Found unsupported and required metadata Guid {vMets[i].itemId}, not proceeding with image."); + ImageNotSupportedException($"Found unsupported and required metadata Guid {_vMets[i].itemId}, not proceeding with image."); } byte[] tmp; if(fileParamsOff != 0) { - stream.Seek(fileParamsOff + metadataOffset, SeekOrigin.Begin); + stream.Seek(fileParamsOff + _metadataOffset, SeekOrigin.Begin); tmp = new byte[8]; stream.Read(tmp, 0, 8); - vFileParms = new VhdxFileParameters + _vFileParms = new VhdxFileParameters { blockSize = BitConverter.ToUInt32(tmp, 0), flags = BitConverter.ToUInt32(tmp, 4) @@ -168,75 +168,75 @@ namespace Aaru.DiscImages if(vdSizeOff != 0) { - stream.Seek(vdSizeOff + metadataOffset, SeekOrigin.Begin); + stream.Seek(vdSizeOff + _metadataOffset, SeekOrigin.Begin); tmp = new byte[8]; stream.Read(tmp, 0, 8); - virtualDiskSize = BitConverter.ToUInt64(tmp, 0); + _virtualDiskSize = BitConverter.ToUInt64(tmp, 0); } else throw new Exception("Virtual disk size not found."); if(p83Off != 0) { - stream.Seek(p83Off + metadataOffset, SeekOrigin.Begin); + stream.Seek(p83Off + _metadataOffset, SeekOrigin.Begin); tmp = new byte[16]; stream.Read(tmp, 0, 16); - page83Data = new Guid(tmp); + _page83Data = new Guid(tmp); } if(logOff != 0) { - stream.Seek(logOff + metadataOffset, SeekOrigin.Begin); + stream.Seek(logOff + _metadataOffset, SeekOrigin.Begin); tmp = new byte[4]; stream.Read(tmp, 0, 4); - logicalSectorSize = BitConverter.ToUInt32(tmp, 0); + _logicalSectorSize = BitConverter.ToUInt32(tmp, 0); } else throw new Exception("Logical sector size not found."); if(physOff != 0) { - stream.Seek(physOff + metadataOffset, SeekOrigin.Begin); + stream.Seek(physOff + _metadataOffset, SeekOrigin.Begin); tmp = new byte[4]; stream.Read(tmp, 0, 4); - physicalSectorSize = BitConverter.ToUInt32(tmp, 0); + _physicalSectorSize = BitConverter.ToUInt32(tmp, 0); } else throw new Exception("Physical sector size not found."); - if(parentOff != 0 && - (vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT) + if(parentOff != 0 && + (_vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT) { - stream.Seek(parentOff + metadataOffset, SeekOrigin.Begin); + stream.Seek(parentOff + _metadataOffset, SeekOrigin.Begin); byte[] vParHdrB = new byte[Marshal.SizeOf()]; stream.Read(vParHdrB, 0, Marshal.SizeOf()); - vParHdr = Marshal.ByteArrayToStructureLittleEndian(vParHdrB); + _vParHdr = Marshal.ByteArrayToStructureLittleEndian(vParHdrB); - if(vParHdr.locatorType != parentTypeVhdxGuid) + if(_vParHdr.locatorType != _parentTypeVhdxGuid) throw new - ImageNotSupportedException($"Found unsupported and required parent locator type {vParHdr.locatorType}, not proceeding with image."); + ImageNotSupportedException($"Found unsupported and required parent locator type {_vParHdr.locatorType}, not proceeding with image."); - vPars = new VhdxParentLocatorEntry[vParHdr.keyValueCount]; + _vPars = new VhdxParentLocatorEntry[_vParHdr.keyValueCount]; - for(int i = 0; i < vPars.Length; i++) + for(int i = 0; i < _vPars.Length; i++) { - byte[] vParB = new byte[System.Runtime.InteropServices.Marshal.SizeOf(vPars[i])]; - stream.Read(vParB, 0, System.Runtime.InteropServices.Marshal.SizeOf(vPars[i])); - vPars[i] = Marshal.ByteArrayToStructureLittleEndian(vParB); + byte[] vParB = new byte[System.Runtime.InteropServices.Marshal.SizeOf(_vPars[i])]; + stream.Read(vParB, 0, System.Runtime.InteropServices.Marshal.SizeOf(_vPars[i])); + _vPars[i] = Marshal.ByteArrayToStructureLittleEndian(vParB); } } - else if((vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT) + else if((_vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT) throw new Exception("Parent locator not found."); - if((vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT && - vParHdr.locatorType == parentTypeVhdxGuid) + if((_vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT && + _vParHdr.locatorType == _parentTypeVhdxGuid) { - parentImage = new Vhdx(); + _parentImage = new Vhdx(); bool parentWorks = false; - foreach(VhdxParentLocatorEntry parentEntry in vPars) + foreach(VhdxParentLocatorEntry parentEntry in _vPars) { - stream.Seek(parentEntry.keyOffset + metadataOffset, SeekOrigin.Begin); + stream.Seek(parentEntry.keyOffset + _metadataOffset, SeekOrigin.Begin); byte[] tmpKey = new byte[parentEntry.keyLength]; stream.Read(tmpKey, 0, tmpKey.Length); string entryType = Encoding.Unicode.GetString(tmpKey); @@ -245,7 +245,7 @@ namespace Aaru.DiscImages if(string.Compare(entryType, RELATIVE_PATH_KEY, StringComparison.OrdinalIgnoreCase) == 0) { - stream.Seek(parentEntry.valueOffset + metadataOffset, SeekOrigin.Begin); + stream.Seek(parentEntry.valueOffset + _metadataOffset, SeekOrigin.Begin); byte[] tmpVal = new byte[parentEntry.valueLength]; stream.Read(tmpVal, 0, tmpVal.Length); string entryValue = Encoding.Unicode.GetString(tmpVal); @@ -256,7 +256,7 @@ namespace Aaru.DiscImages new FiltersList().GetFilter(Path.Combine(imageFilter.GetParentFolder(), entryValue)); if(parentFilter != null && - parentImage.Open(parentFilter)) + _parentImage.Open(parentFilter)) { parentWorks = true; @@ -276,7 +276,7 @@ namespace Aaru.DiscImages new FiltersList().GetFilter(Path.Combine(imageFilter.GetParentFolder(), relEntry)); if(parentFilter == null || - !parentImage.Open(parentFilter)) + !_parentImage.Open(parentFilter)) continue; parentWorks = true; @@ -291,7 +291,7 @@ namespace Aaru.DiscImages else if(string.Compare(entryType, VOLUME_PATH_KEY, StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(entryType, ABSOLUTE_WIN32_PATH_KEY, StringComparison.OrdinalIgnoreCase) == 0) { - stream.Seek(parentEntry.valueOffset + metadataOffset, SeekOrigin.Begin); + stream.Seek(parentEntry.valueOffset + _metadataOffset, SeekOrigin.Begin); byte[] tmpVal = new byte[parentEntry.valueLength]; stream.Read(tmpVal, 0, tmpVal.Length); string entryValue = Encoding.Unicode.GetString(tmpVal); @@ -302,7 +302,7 @@ namespace Aaru.DiscImages new FiltersList().GetFilter(Path.Combine(imageFilter.GetParentFolder(), entryValue)); if(parentFilter == null || - !parentImage.Open(parentFilter)) + !_parentImage.Open(parentFilter)) continue; parentWorks = true; @@ -319,63 +319,63 @@ namespace Aaru.DiscImages if(!parentWorks) throw new Exception("Image is differential but parent cannot be opened."); - hasParent = true; + _hasParent = true; } - chunkRatio = (long)((Math.Pow(2, 23) * logicalSectorSize) / vFileParms.blockSize); - dataBlocks = virtualDiskSize / vFileParms.blockSize; + _chunkRatio = (long)((Math.Pow(2, 23) * _logicalSectorSize) / _vFileParms.blockSize); + _dataBlocks = _virtualDiskSize / _vFileParms.blockSize; - if(virtualDiskSize % vFileParms.blockSize > 0) - dataBlocks++; + if(_virtualDiskSize % _vFileParms.blockSize > 0) + _dataBlocks++; long batEntries; - if(hasParent) + if(_hasParent) { - long sectorBitmapBlocks = (long)dataBlocks / chunkRatio; + long sectorBitmapBlocks = (long)_dataBlocks / _chunkRatio; - if(dataBlocks % (ulong)chunkRatio > 0) + if(_dataBlocks % (ulong)_chunkRatio > 0) sectorBitmapBlocks++; - sectorBitmapPointers = new ulong[sectorBitmapBlocks]; + _sectorBitmapPointers = new ulong[sectorBitmapBlocks]; - batEntries = sectorBitmapBlocks * (chunkRatio - 1); + batEntries = sectorBitmapBlocks * (_chunkRatio - 1); } else - batEntries = (long)(dataBlocks + ((dataBlocks - 1) / (ulong)chunkRatio)); + batEntries = (long)(_dataBlocks + ((_dataBlocks - 1) / (ulong)_chunkRatio)); AaruConsole.DebugWriteLine("VHDX plugin", "Reading BAT"); long readChunks = 0; - blockAllocationTable = new ulong[dataBlocks]; + _blockAllocationTable = new ulong[_dataBlocks]; byte[] batB = new byte[batEntries * 8]; - stream.Seek(batOffset, SeekOrigin.Begin); + stream.Seek(_batOffset, SeekOrigin.Begin); stream.Read(batB, 0, batB.Length); ulong skipSize = 0; - for(ulong i = 0; i < dataBlocks; i++) - if(readChunks == chunkRatio) + for(ulong i = 0; i < _dataBlocks; i++) + if(readChunks == _chunkRatio) { - if(hasParent) - sectorBitmapPointers[skipSize / 8] = BitConverter.ToUInt64(batB, (int)((i * 8) + skipSize)); + if(_hasParent) + _sectorBitmapPointers[skipSize / 8] = BitConverter.ToUInt64(batB, (int)((i * 8) + skipSize)); readChunks = 0; skipSize += 8; } else { - blockAllocationTable[i] = BitConverter.ToUInt64(batB, (int)((i * 8) + skipSize)); + _blockAllocationTable[i] = BitConverter.ToUInt64(batB, (int)((i * 8) + skipSize)); readChunks++; } - if(hasParent) + if(_hasParent) { AaruConsole.DebugWriteLine("VHDX plugin", "Reading Sector Bitmap"); var sectorBmpMs = new MemoryStream(); - foreach(ulong pt in sectorBitmapPointers) + foreach(ulong pt in _sectorBitmapPointers) switch(pt & BAT_FLAGS_MASK) { case SECTOR_BITMAP_NOT_PRESENT: @@ -397,50 +397,50 @@ namespace Aaru.DiscImages break; } - sectorBitmap = sectorBmpMs.ToArray(); + _sectorBitmap = sectorBmpMs.ToArray(); sectorBmpMs.Close(); } - maxBlockCache = (int)(MAX_CACHE_SIZE / vFileParms.blockSize); - maxSectorCache = (int)(MAX_CACHE_SIZE / logicalSectorSize); + _maxBlockCache = (int)(MAX_CACHE_SIZE / _vFileParms.blockSize); + _maxSectorCache = (int)(MAX_CACHE_SIZE / _logicalSectorSize); - imageStream = stream; + _imageStream = stream; - sectorCache = new Dictionary(); - blockCache = new Dictionary(); + _sectorCache = new Dictionary(); + _blockCache = new Dictionary(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.SectorSize = logicalSectorSize; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.ImageSize = virtualDiskSize; - imageInfo.Sectors = imageInfo.ImageSize / imageInfo.SectorSize; - imageInfo.DriveSerialNumber = page83Data.ToString(); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.SectorSize = _logicalSectorSize; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.ImageSize = _virtualDiskSize; + _imageInfo.Sectors = _imageInfo.ImageSize / _imageInfo.SectorSize; + _imageInfo.DriveSerialNumber = _page83Data.ToString(); // TODO: Separate image application from version, need several samples. - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; return true; } public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector; - ulong index = (sectorAddress * logicalSectorSize) / vFileParms.blockSize; - ulong secOff = (sectorAddress * logicalSectorSize) % vFileParms.blockSize; + ulong index = (sectorAddress * _logicalSectorSize) / _vFileParms.blockSize; + ulong secOff = (sectorAddress * _logicalSectorSize) % _vFileParms.blockSize; - ulong blkPtr = blockAllocationTable[index]; + ulong blkPtr = _blockAllocationTable[index]; ulong blkFlags = blkPtr & BAT_FLAGS_MASK; if((blkPtr & BAT_RESERVED_MASK) != 0) @@ -450,52 +450,52 @@ namespace Aaru.DiscImages switch(blkFlags & BAT_FLAGS_MASK) { case PAYLOAD_BLOCK_NOT_PRESENT: - return hasParent ? parentImage.ReadSector(sectorAddress) : new byte[logicalSectorSize]; + return _hasParent ? _parentImage.ReadSector(sectorAddress) : new byte[_logicalSectorSize]; case PAYLOAD_BLOCK_UNDEFINED: case PAYLOAD_BLOCK_ZERO: - case PAYLOAD_BLOCK_UNMAPPER: return new byte[logicalSectorSize]; + case PAYLOAD_BLOCK_UNMAPPER: return new byte[_logicalSectorSize]; } bool partialBlock; partialBlock = (blkFlags & BAT_FLAGS_MASK) == PAYLOAD_BLOCK_PARTIALLY_PRESENT; if(partialBlock && - hasParent && + _hasParent && !CheckBitmap(sectorAddress)) - return parentImage.ReadSector(sectorAddress); + return _parentImage.ReadSector(sectorAddress); - if(!blockCache.TryGetValue(blkPtr & BAT_FILE_OFFSET_MASK, out byte[] block)) + if(!_blockCache.TryGetValue(blkPtr & BAT_FILE_OFFSET_MASK, out byte[] block)) { - block = new byte[vFileParms.blockSize]; - imageStream.Seek((long)(blkPtr & BAT_FILE_OFFSET_MASK), SeekOrigin.Begin); - imageStream.Read(block, 0, block.Length); + block = new byte[_vFileParms.blockSize]; + _imageStream.Seek((long)(blkPtr & BAT_FILE_OFFSET_MASK), SeekOrigin.Begin); + _imageStream.Read(block, 0, block.Length); - if(blockCache.Count >= maxBlockCache) - blockCache.Clear(); + if(_blockCache.Count >= _maxBlockCache) + _blockCache.Clear(); - blockCache.Add(blkPtr & BAT_FILE_OFFSET_MASK, block); + _blockCache.Add(blkPtr & BAT_FILE_OFFSET_MASK, block); } - sector = new byte[logicalSectorSize]; + sector = new byte[_logicalSectorSize]; Array.Copy(block, (int)secOff, sector, 0, sector.Length); - if(sectorCache.Count >= maxSectorCache) - sectorCache.Clear(); + if(_sectorCache.Count >= _maxSectorCache) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), - $"Requested more sectors ({sectorAddress + length}) than available ({imageInfo.Sectors})"); + $"Requested more sectors ({sectorAddress + length}) than available ({_imageInfo.Sectors})"); var ms = new MemoryStream(); diff --git a/Aaru.Images/VHDX/VHDX.cs b/Aaru.Images/VHDX/VHDX.cs index 053ffb0c8..ee000a8e9 100644 --- a/Aaru.Images/VHDX/VHDX.cs +++ b/Aaru.Images/VHDX/VHDX.cs @@ -43,36 +43,36 @@ namespace Aaru.DiscImages { public partial class Vhdx : IMediaImage { - long batOffset; - ulong[] blockAllocationTable; - Dictionary blockCache; - long chunkRatio; - ulong dataBlocks; - bool hasParent; - ImageInfo imageInfo; - Stream imageStream; - uint logicalSectorSize; - int maxBlockCache; - int maxSectorCache; - long metadataOffset; - Guid page83Data; - IMediaImage parentImage; - uint physicalSectorSize; - byte[] sectorBitmap; - ulong[] sectorBitmapPointers; - Dictionary sectorCache; - VhdxFileParameters vFileParms; - VhdxHeader vHdr; - VhdxIdentifier vhdxId; - ulong virtualDiskSize; - VhdxMetadataTableHeader vMetHdr; - VhdxMetadataTableEntry[] vMets; - VhdxParentLocatorHeader vParHdr; - VhdxParentLocatorEntry[] vPars; - VhdxRegionTableHeader vRegHdr; - VhdxRegionTableEntry[] vRegs; + long _batOffset; + ulong[] _blockAllocationTable; + Dictionary _blockCache; + long _chunkRatio; + ulong _dataBlocks; + bool _hasParent; + ImageInfo _imageInfo; + Stream _imageStream; + uint _logicalSectorSize; + int _maxBlockCache; + int _maxSectorCache; + long _metadataOffset; + Guid _page83Data; + IMediaImage _parentImage; + uint _physicalSectorSize; + byte[] _sectorBitmap; + ulong[] _sectorBitmapPointers; + Dictionary _sectorCache; + VhdxFileParameters _vFileParms; + VhdxHeader _vHdr; + VhdxIdentifier _vhdxId; + ulong _virtualDiskSize; + VhdxMetadataTableHeader _vMetHdr; + VhdxMetadataTableEntry[] _vMets; + VhdxParentLocatorHeader _vParHdr; + VhdxParentLocatorEntry[] _vPars; + VhdxRegionTableHeader _vRegHdr; + VhdxRegionTableEntry[] _vRegs; - public Vhdx() => imageInfo = new ImageInfo + public Vhdx() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/VMware/Constants.cs b/Aaru.Images/VMware/Constants.cs index ca1b4290b..f7617a3ef 100644 --- a/Aaru.Images/VMware/Constants.cs +++ b/Aaru.Images/VMware/Constants.cs @@ -86,7 +86,7 @@ namespace Aaru.DiscImages const uint MAX_CACHE_SIZE = 16777216; const uint SECTOR_SIZE = 512; const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / SECTOR_SIZE; - readonly byte[] ddfMagicBytes = + readonly byte[] _ddfMagicBytes = { 0x23, 0x20, 0x44, 0x69, 0x73, 0x6B, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6F, 0x72, 0x46, 0x69, 0x6C, 0x65 diff --git a/Aaru.Images/VMware/Identify.cs b/Aaru.Images/VMware/Identify.cs index c773513cc..74c6aa7fa 100644 --- a/Aaru.Images/VMware/Identify.cs +++ b/Aaru.Images/VMware/Identify.cs @@ -50,30 +50,30 @@ namespace Aaru.DiscImages stream.Seek(0, SeekOrigin.Begin); byte[] vmEHdrB = new byte[Marshal.SizeOf()]; stream.Read(vmEHdrB, 0, Marshal.SizeOf()); - vmEHdr = Marshal.ByteArrayToStructureLittleEndian(vmEHdrB); + _vmEHdr = Marshal.ByteArrayToStructureLittleEndian(vmEHdrB); stream.Seek(0, SeekOrigin.Begin); stream.Read(ddfMagic, 0, 0x15); - vmCHdr = new VMwareCowHeader(); + _vmCHdr = new VMwareCowHeader(); if(stream.Length <= Marshal.SizeOf()) - return ddfMagicBytes.SequenceEqual(ddfMagic) || vmEHdr.magic == VMWARE_EXTENT_MAGIC || - vmCHdr.magic == VMWARE_COW_MAGIC; + return _ddfMagicBytes.SequenceEqual(ddfMagic) || _vmEHdr.magic == VMWARE_EXTENT_MAGIC || + _vmCHdr.magic == VMWARE_COW_MAGIC; stream.Seek(0, SeekOrigin.Begin); byte[] vmCHdrB = new byte[Marshal.SizeOf()]; stream.Read(vmCHdrB, 0, Marshal.SizeOf()); - vmCHdr = Marshal.ByteArrayToStructureLittleEndian(vmCHdrB); + _vmCHdr = Marshal.ByteArrayToStructureLittleEndian(vmCHdrB); - return ddfMagicBytes.SequenceEqual(ddfMagic) || vmEHdr.magic == VMWARE_EXTENT_MAGIC || - vmCHdr.magic == VMWARE_COW_MAGIC; + return _ddfMagicBytes.SequenceEqual(ddfMagic) || _vmEHdr.magic == VMWARE_EXTENT_MAGIC || + _vmCHdr.magic == VMWARE_COW_MAGIC; } stream.Seek(0, SeekOrigin.Begin); stream.Read(ddfMagic, 0, 0x15); - return ddfMagicBytes.SequenceEqual(ddfMagic); + return _ddfMagicBytes.SequenceEqual(ddfMagic); } } } \ No newline at end of file diff --git a/Aaru.Images/VMware/Properties.cs b/Aaru.Images/VMware/Properties.cs index e5f749c5e..c35cd3885 100644 --- a/Aaru.Images/VMware/Properties.cs +++ b/Aaru.Images/VMware/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class VMware { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "VMware disk image"; public Guid Id => new Guid("E314DE35-C103-48A3-AD36-990F68523C46"); diff --git a/Aaru.Images/VMware/Read.cs b/Aaru.Images/VMware/Read.cs index 63e31eba3..10e631526 100644 --- a/Aaru.Images/VMware/Read.cs +++ b/Aaru.Images/VMware/Read.cs @@ -52,8 +52,8 @@ namespace Aaru.DiscImages { Stream stream = imageFilter.GetDataForkStream(); - vmEHdr = new VMwareExtentHeader(); - vmCHdr = new VMwareCowHeader(); + _vmEHdr = new VMwareExtentHeader(); + _vmCHdr = new VMwareCowHeader(); bool embedded = false; if(stream.Length > Marshal.SizeOf()) @@ -61,7 +61,7 @@ namespace Aaru.DiscImages stream.Seek(0, SeekOrigin.Begin); byte[] vmEHdrB = new byte[Marshal.SizeOf()]; stream.Read(vmEHdrB, 0, Marshal.SizeOf()); - vmEHdr = Marshal.ByteArrayToStructureLittleEndian(vmEHdrB); + _vmEHdr = Marshal.ByteArrayToStructureLittleEndian(vmEHdrB); } if(stream.Length > Marshal.SizeOf()) @@ -69,34 +69,34 @@ namespace Aaru.DiscImages stream.Seek(0, SeekOrigin.Begin); byte[] vmCHdrB = new byte[Marshal.SizeOf()]; stream.Read(vmCHdrB, 0, Marshal.SizeOf()); - vmCHdr = Marshal.ByteArrayToStructureLittleEndian(vmCHdrB); + _vmCHdr = Marshal.ByteArrayToStructureLittleEndian(vmCHdrB); } var ddfStream = new MemoryStream(); bool vmEHdrSet = false; bool cowD = false; - if(vmEHdr.magic == VMWARE_EXTENT_MAGIC) + if(_vmEHdr.magic == VMWARE_EXTENT_MAGIC) { vmEHdrSet = true; - gdFilter = imageFilter; + _gdFilter = imageFilter; - if(vmEHdr.descriptorOffset == 0 || - vmEHdr.descriptorSize == 0) + if(_vmEHdr.descriptorOffset == 0 || + _vmEHdr.descriptorSize == 0) throw new Exception("Please open VMDK descriptor."); - byte[] ddfEmbed = new byte[vmEHdr.descriptorSize * SECTOR_SIZE]; + byte[] ddfEmbed = new byte[_vmEHdr.descriptorSize * SECTOR_SIZE]; - stream.Seek((long)(vmEHdr.descriptorOffset * SECTOR_SIZE), SeekOrigin.Begin); + stream.Seek((long)(_vmEHdr.descriptorOffset * SECTOR_SIZE), SeekOrigin.Begin); stream.Read(ddfEmbed, 0, ddfEmbed.Length); ddfStream.Write(ddfEmbed, 0, ddfEmbed.Length); embedded = true; } - else if(vmCHdr.magic == VMWARE_COW_MAGIC) + else if(_vmCHdr.magic == VMWARE_COW_MAGIC) { - gdFilter = imageFilter; - cowD = true; + _gdFilter = imageFilter; + cowD = true; } else { @@ -104,7 +104,7 @@ namespace Aaru.DiscImages stream.Seek(0, SeekOrigin.Begin); stream.Read(ddfMagic, 0, 0x15); - if(!ddfMagicBytes.SequenceEqual(ddfMagic)) + if(!_ddfMagicBytes.SequenceEqual(ddfMagic)) throw new Exception("Not a descriptor."); stream.Seek(0, SeekOrigin.Begin); @@ -113,7 +113,7 @@ namespace Aaru.DiscImages ddfStream.Write(ddfExternal, 0, ddfExternal.Length); } - extents = new Dictionary(); + _extents = new Dictionary(); ulong currentSector = 0; bool matchedCyls = false, matchedHds = false, matchedSpt = false; @@ -163,7 +163,7 @@ namespace Aaru.DiscImages newExtent.Sectors, newExtent.Type, newExtent.Filename, newExtent.Offset); - extents.Add(currentSector, newExtent); + _extents.Add(currentSector, newExtent); currentSector += newExtent.Sectors; } else @@ -172,7 +172,7 @@ namespace Aaru.DiscImages cowCount++; } - imageType = VM_TYPE_SPLIT_SPARSE; + _imageType = VM_TYPE_SPLIT_SPARSE; } else { @@ -206,23 +206,23 @@ namespace Aaru.DiscImages if(matchVersion.Success) { - uint.TryParse(matchVersion.Groups["version"].Value, out version); - AaruConsole.DebugWriteLine("VMware plugin", "version = {0}", version); + uint.TryParse(matchVersion.Groups["version"].Value, out _version); + AaruConsole.DebugWriteLine("VMware plugin", "version = {0}", _version); } else if(matchCid.Success) { - cid = Convert.ToUInt32(matchCid.Groups["cid"].Value, 16); - AaruConsole.DebugWriteLine("VMware plugin", "cid = {0:x8}", cid); + _cid = Convert.ToUInt32(matchCid.Groups["cid"].Value, 16); + AaruConsole.DebugWriteLine("VMware plugin", "cid = {0:x8}", _cid); } else if(matchParentCid.Success) { - parentCid = Convert.ToUInt32(matchParentCid.Groups["cid"].Value, 16); - AaruConsole.DebugWriteLine("VMware plugin", "parentCID = {0:x8}", parentCid); + _parentCid = Convert.ToUInt32(matchParentCid.Groups["cid"].Value, 16); + AaruConsole.DebugWriteLine("VMware plugin", "parentCID = {0:x8}", _parentCid); } else if(matchType.Success) { - imageType = matchType.Groups["type"].Value; - AaruConsole.DebugWriteLine("VMware plugin", "createType = \"{0}\"", imageType); + _imageType = matchType.Groups["type"].Value; + AaruConsole.DebugWriteLine("VMware plugin", "createType = \"{0}\"", _imageType); } else if(matchExtent.Success) { @@ -247,37 +247,37 @@ namespace Aaru.DiscImages newExtent.Sectors, newExtent.Type, newExtent.Filename, newExtent.Offset); - extents.Add(currentSector, newExtent); + _extents.Add(currentSector, newExtent); currentSector += newExtent.Sectors; } else if(matchParent.Success) { - parentName = matchParent.Groups["filename"].Value; - AaruConsole.DebugWriteLine("VMware plugin", "parentFileNameHint = \"{0}\"", parentName); - hasParent = true; + _parentName = matchParent.Groups["filename"].Value; + AaruConsole.DebugWriteLine("VMware plugin", "parentFileNameHint = \"{0}\"", _parentName); + _hasParent = true; } else if(matchCylinders.Success) { - uint.TryParse(matchCylinders.Groups["cylinders"].Value, out imageInfo.Cylinders); + uint.TryParse(matchCylinders.Groups["cylinders"].Value, out _imageInfo.Cylinders); matchedCyls = true; } else if(matchHeads.Success) { - uint.TryParse(matchHeads.Groups["heads"].Value, out imageInfo.Heads); + uint.TryParse(matchHeads.Groups["heads"].Value, out _imageInfo.Heads); matchedHds = true; } else if(matchSectors.Success) { - uint.TryParse(matchSectors.Groups["sectors"].Value, out imageInfo.SectorsPerTrack); + uint.TryParse(matchSectors.Groups["sectors"].Value, out _imageInfo.SectorsPerTrack); matchedSpt = true; } } } - if(extents.Count == 0) + if(_extents.Count == 0) throw new Exception("Did not find any extent"); - switch(imageType) + switch(_imageType) { case VM_TYPE_MONO_SPARSE: //"monolithicSparse"; case VM_TYPE_MONO_FLAT: //"monolithicFlat"; @@ -299,12 +299,12 @@ namespace Aaru.DiscImages case VMFS_TYPE_RAW: //"vmfsRaw"; throw new ImageNotSupportedException("Raw device image files are not supported, try accessing the device directly."); - default: throw new ImageNotSupportedException($"Dunno how to handle \"{imageType}\" extents."); + default: throw new ImageNotSupportedException($"Dunno how to handle \"{_imageType}\" extents."); } bool oneNoFlat = cowD; - foreach(VMwareExtent extent in extents.Values) + foreach(VMwareExtent extent in _extents.Values) { if(extent.Filter == null) throw new Exception($"Extent file {extent.Filename} not found."); @@ -341,8 +341,8 @@ namespace Aaru.DiscImages if(!vmEHdrSet) { - vmEHdr = extentHdr; - gdFilter = extent.Filter; + _vmEHdr = extentHdr; + _gdFilter = extent.Filter; vmEHdrSet = true; } @@ -355,7 +355,7 @@ namespace Aaru.DiscImages throw new Exception("There are sparse extents but there is no header to find the grain tables, cannot proceed."); - imageInfo.Sectors = currentSector; + _imageInfo.Sectors = currentSector; uint grains = 0; uint gdEntries = 0; @@ -364,72 +364,74 @@ namespace Aaru.DiscImages if(oneNoFlat && !cowD) { - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.magic = 0x{0:X8}", vmEHdr.magic); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.version = {0}", vmEHdr.version); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.flags = 0x{0:X8}", vmEHdr.flags); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.capacity = {0}", vmEHdr.capacity); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.grainSize = {0}", vmEHdr.grainSize); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.descriptorOffset = {0}", vmEHdr.descriptorOffset); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.descriptorSize = {0}", vmEHdr.descriptorSize); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.GTEsPerGT = {0}", vmEHdr.GTEsPerGT); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.rgdOffset = {0}", vmEHdr.rgdOffset); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.gdOffset = {0}", vmEHdr.gdOffset); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.overhead = {0}", vmEHdr.overhead); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.uncleanShutdown = {0}", vmEHdr.uncleanShutdown); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.magic = 0x{0:X8}", _vmEHdr.magic); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.version = {0}", _vmEHdr.version); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.flags = 0x{0:X8}", _vmEHdr.flags); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.capacity = {0}", _vmEHdr.capacity); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.grainSize = {0}", _vmEHdr.grainSize); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.descriptorOffset = {0}", _vmEHdr.descriptorOffset); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.descriptorSize = {0}", _vmEHdr.descriptorSize); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.GTEsPerGT = {0}", _vmEHdr.GTEsPerGT); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.rgdOffset = {0}", _vmEHdr.rgdOffset); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.gdOffset = {0}", _vmEHdr.gdOffset); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.overhead = {0}", _vmEHdr.overhead); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.uncleanShutdown = {0}", _vmEHdr.uncleanShutdown); AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.singleEndLineChar = 0x{0:X2}", - vmEHdr.singleEndLineChar); + _vmEHdr.singleEndLineChar); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.nonEndLineChar = 0x{0:X2}", vmEHdr.nonEndLineChar); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.nonEndLineChar = 0x{0:X2}", _vmEHdr.nonEndLineChar); AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.doubleEndLineChar1 = 0x{0:X2}", - vmEHdr.doubleEndLineChar1); + _vmEHdr.doubleEndLineChar1); AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.doubleEndLineChar2 = 0x{0:X2}", - vmEHdr.doubleEndLineChar2); + _vmEHdr.doubleEndLineChar2); - AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.compression = 0x{0:X4}", vmEHdr.compression); + AaruConsole.DebugWriteLine("VMware plugin", "vmEHdr.compression = 0x{0:X4}", _vmEHdr.compression); - grainSize = vmEHdr.grainSize; - grains = (uint)(imageInfo.Sectors / vmEHdr.grainSize) + 1; - gdEntries = grains / vmEHdr.GTEsPerGT; - gtEsPerGt = vmEHdr.GTEsPerGT; + _grainSize = _vmEHdr.grainSize; + grains = (uint)(_imageInfo.Sectors / _vmEHdr.grainSize) + 1; + gdEntries = grains / _vmEHdr.GTEsPerGT; + gtEsPerGt = _vmEHdr.GTEsPerGT; - if((vmEHdr.flags & FLAGS_USE_REDUNDANT_TABLE) == FLAGS_USE_REDUNDANT_TABLE) - gdOffset = (long)vmEHdr.rgdOffset; + if((_vmEHdr.flags & FLAGS_USE_REDUNDANT_TABLE) == FLAGS_USE_REDUNDANT_TABLE) + gdOffset = (long)_vmEHdr.rgdOffset; else - gdOffset = (long)vmEHdr.gdOffset; + gdOffset = (long)_vmEHdr.gdOffset; } else if(oneNoFlat && cowD) { - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.magic = 0x{0:X8}", vmCHdr.magic); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.version = {0}", vmCHdr.version); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.flags = 0x{0:X8}", vmCHdr.flags); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.sectors = {0}", vmCHdr.sectors); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.grainSize = {0}", vmCHdr.grainSize); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.gdOffset = {0}", vmCHdr.gdOffset); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.numGDEntries = {0}", vmCHdr.numGDEntries); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.freeSector = {0}", vmCHdr.freeSector); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.cylinders = {0}", vmCHdr.cylinders); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.heads = {0}", vmCHdr.heads); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.spt = {0}", vmCHdr.spt); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.generation = {0}", vmCHdr.generation); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.name = {0}", StringHandlers.CToString(vmCHdr.name)); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.magic = 0x{0:X8}", _vmCHdr.magic); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.version = {0}", _vmCHdr.version); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.flags = 0x{0:X8}", _vmCHdr.flags); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.sectors = {0}", _vmCHdr.sectors); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.grainSize = {0}", _vmCHdr.grainSize); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.gdOffset = {0}", _vmCHdr.gdOffset); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.numGDEntries = {0}", _vmCHdr.numGDEntries); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.freeSector = {0}", _vmCHdr.freeSector); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.cylinders = {0}", _vmCHdr.cylinders); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.heads = {0}", _vmCHdr.heads); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.spt = {0}", _vmCHdr.spt); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.generation = {0}", _vmCHdr.generation); + + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.name = {0}", + StringHandlers.CToString(_vmCHdr.name)); AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.description = {0}", - StringHandlers.CToString(vmCHdr.description)); + StringHandlers.CToString(_vmCHdr.description)); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.savedGeneration = {0}", vmCHdr.savedGeneration); - AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.uncleanShutdown = {0}", vmCHdr.uncleanShutdown); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.savedGeneration = {0}", _vmCHdr.savedGeneration); + AaruConsole.DebugWriteLine("VMware plugin", "vmCHdr.uncleanShutdown = {0}", _vmCHdr.uncleanShutdown); - grainSize = vmCHdr.grainSize; - grains = (uint)(imageInfo.Sectors / vmCHdr.grainSize) + 1; - gdEntries = vmCHdr.numGDEntries; - gdOffset = vmCHdr.gdOffset; - gtEsPerGt = grains / gdEntries; - imageInfo.MediaTitle = StringHandlers.CToString(vmCHdr.name); - imageInfo.Comments = StringHandlers.CToString(vmCHdr.description); - version = vmCHdr.version; + _grainSize = _vmCHdr.grainSize; + grains = (uint)(_imageInfo.Sectors / _vmCHdr.grainSize) + 1; + gdEntries = _vmCHdr.numGDEntries; + gdOffset = _vmCHdr.gdOffset; + gtEsPerGt = grains / gdEntries; + _imageInfo.MediaTitle = StringHandlers.CToString(_vmCHdr.name); + _imageInfo.Comments = StringHandlers.CToString(_vmCHdr.description); + _version = _vmCHdr.version; } if(oneNoFlat) @@ -439,9 +441,9 @@ namespace Aaru.DiscImages throw new Exception("Some error ocurred setting GD sizes"); AaruConsole.DebugWriteLine("VMware plugin", "{0} sectors in {1} grains in {2} tables", - imageInfo.Sectors, grains, gdEntries); + _imageInfo.Sectors, grains, gdEntries); - Stream gdStream = gdFilter.GetDataForkStream(); + Stream gdStream = _gdFilter.GetDataForkStream(); gdStream.Seek(gdOffset * SECTOR_SIZE, SeekOrigin.Begin); @@ -452,7 +454,7 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("VMware plugin", "Reading grain tables"); uint currentGrain = 0; - gTable = new uint[grains]; + _gTable = new uint[grains]; foreach(uint gtOff in gd) { @@ -461,7 +463,7 @@ namespace Aaru.DiscImages gdStream.Read(gtBytes, 0, gtBytes.Length); uint[] currentGt = MemoryMarshal.Cast(gtBytes).ToArray(); - Array.Copy(currentGt, 0, gTable, currentGrain, gtEsPerGt); + Array.Copy(currentGt, 0, _gTable, currentGrain, gtEsPerGt); currentGrain += gtEsPerGt; // TODO: Check speed here @@ -474,51 +476,51 @@ namespace Aaru.DiscImages */ } - maxCachedGrains = (uint)(MAX_CACHE_SIZE / (grainSize * SECTOR_SIZE)); + _maxCachedGrains = (uint)(MAX_CACHE_SIZE / (_grainSize * SECTOR_SIZE)); - grainCache = new Dictionary(); + _grainCache = new Dictionary(); } - if(hasParent) + if(_hasParent) { IFilter parentFilter = - new FiltersList().GetFilter(Path.Combine(imageFilter.GetParentFolder(), parentName)); + new FiltersList().GetFilter(Path.Combine(imageFilter.GetParentFolder(), _parentName)); if(parentFilter == null) - throw new Exception($"Cannot find parent \"{parentName}\"."); + throw new Exception($"Cannot find parent \"{_parentName}\"."); - parentImage = new VMware(); + _parentImage = new VMware(); - if(!parentImage.Open(parentFilter)) - throw new Exception($"Cannot open parent \"{parentName}\"."); + if(!_parentImage.Open(parentFilter)) + throw new Exception($"Cannot open parent \"{_parentName}\"."); } - sectorCache = new Dictionary(); + _sectorCache = new Dictionary(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.SectorSize = SECTOR_SIZE; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.ImageSize = imageInfo.Sectors * SECTOR_SIZE; + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.SectorSize = SECTOR_SIZE; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.ImageSize = _imageInfo.Sectors * SECTOR_SIZE; // VMDK version 1 started on VMware 4, so there is a previous version, "COWD" - imageInfo.Version = cowD ? $"{version}" : $"{version + 3}"; + _imageInfo.Version = cowD ? $"{_version}" : $"{_version + 3}"; if(cowD) { - imageInfo.Cylinders = vmCHdr.cylinders; - imageInfo.Heads = vmCHdr.heads; - imageInfo.SectorsPerTrack = vmCHdr.spt; + _imageInfo.Cylinders = _vmCHdr.cylinders; + _imageInfo.Heads = _vmCHdr.heads; + _imageInfo.SectorsPerTrack = _vmCHdr.spt; } else if(!matchedCyls || !matchedHds || !matchedSpt) { - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; } return true; @@ -526,18 +528,18 @@ namespace Aaru.DiscImages public byte[] ReadSector(ulong sectorAddress) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) + if(_sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector; var currentExtent = new VMwareExtent(); bool extentFound = false; ulong extentStartSector = 0; - foreach(KeyValuePair kvp in extents.Where(kvp => sectorAddress >= kvp.Key)) + foreach(KeyValuePair kvp in _extents.Where(kvp => sectorAddress >= kvp.Key)) { currentExtent = kvp.Value; extentFound = true; @@ -555,10 +557,10 @@ namespace Aaru.DiscImages case "ZERO": sector = new byte[SECTOR_SIZE]; - if(sectorCache.Count >= MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count >= MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; case "FLAT": @@ -571,66 +573,66 @@ namespace Aaru.DiscImages sector = new byte[SECTOR_SIZE]; dataStream.Read(sector, 0, sector.Length); - if(sectorCache.Count >= MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count >= MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } - ulong index = sectorAddress / grainSize; - ulong secOff = (sectorAddress % grainSize) * SECTOR_SIZE; + ulong index = sectorAddress / _grainSize; + ulong secOff = (sectorAddress % _grainSize) * SECTOR_SIZE; - uint grainOff = gTable[index]; + uint grainOff = _gTable[index]; - if(grainOff == 0 && hasParent) - return parentImage.ReadSector(sectorAddress); + if(grainOff == 0 && _hasParent) + return _parentImage.ReadSector(sectorAddress); if(grainOff == 0 || grainOff == 1) { sector = new byte[SECTOR_SIZE]; - if(sectorCache.Count >= MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count >= MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } - if(!grainCache.TryGetValue(grainOff, out byte[] grain)) + if(!_grainCache.TryGetValue(grainOff, out byte[] grain)) { - grain = new byte[SECTOR_SIZE * grainSize]; + grain = new byte[SECTOR_SIZE * _grainSize]; dataStream = currentExtent.Filter.GetDataForkStream(); dataStream.Seek((long)((grainOff - extentStartSector) * SECTOR_SIZE), SeekOrigin.Begin); dataStream.Read(grain, 0, grain.Length); - if(grainCache.Count >= maxCachedGrains) - grainCache.Clear(); + if(_grainCache.Count >= _maxCachedGrains) + _grainCache.Clear(); - grainCache.Add(grainOff, grain); + _grainCache.Add(grainOff, grain); } sector = new byte[SECTOR_SIZE]; Array.Copy(grain, (int)secOff, sector, 0, SECTOR_SIZE); - if(sectorCache.Count > MAX_CACHED_SECTORS) - sectorCache.Clear(); + if(_sectorCache.Count > MAX_CACHED_SECTORS) + _sectorCache.Clear(); - sectorCache.Add(sectorAddress, sector); + _sectorCache.Add(sectorAddress, sector); return sector; } public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), $"Sector address {sectorAddress} not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); var ms = new MemoryStream(); diff --git a/Aaru.Images/VMware/VMware.cs b/Aaru.Images/VMware/VMware.cs index b38bb26b5..a2b4daff4 100644 --- a/Aaru.Images/VMware/VMware.cs +++ b/Aaru.Images/VMware/VMware.cs @@ -40,30 +40,30 @@ namespace Aaru.DiscImages { public partial class VMware : IWritableImage { - string adapter_type; - uint cid; - StreamWriter descriptorStream; - Dictionary extents; - IFilter gdFilter; - Dictionary grainCache; - ulong grainSize; - uint[] gTable; - bool hasParent; - uint hwversion; - ImageInfo imageInfo; - string imageType; - uint maxCachedGrains; - uint parentCid; - IMediaImage parentImage; - string parentName; - Dictionary sectorCache; - uint version; - VMwareCowHeader vmCHdr; - VMwareExtentHeader vmEHdr; - string writingBaseName; - FileStream writingStream; + string _adapterType; + uint _cid; + StreamWriter _descriptorStream; + Dictionary _extents; + IFilter _gdFilter; + Dictionary _grainCache; + ulong _grainSize; + uint[] _gTable; + bool _hasParent; + uint _hwversion; + ImageInfo _imageInfo; + string _imageType; + uint _maxCachedGrains; + uint _parentCid; + IMediaImage _parentImage; + string _parentName; + Dictionary _sectorCache; + uint _version; + VMwareCowHeader _vmCHdr; + VMwareExtentHeader _vmEHdr; + string _writingBaseName; + FileStream _writingStream; - public VMware() => imageInfo = new ImageInfo + public VMware() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/VMware/Write.cs b/Aaru.Images/VMware/Write.cs index fa1e8ed13..d6d0681e7 100644 --- a/Aaru.Images/VMware/Write.cs +++ b/Aaru.Images/VMware/Write.cs @@ -49,30 +49,30 @@ namespace Aaru.DiscImages { if(options != null) { - if(options.TryGetValue("adapter", out adapter_type)) - switch(adapter_type.ToLowerInvariant()) + if(options.TryGetValue("adapter", out _adapterType)) + switch(_adapterType.ToLowerInvariant()) { case "ide": case "lsilogic": case "buslogic": - adapter_type = adapter_type.ToLowerInvariant(); + _adapterType = _adapterType.ToLowerInvariant(); break; case "legacyesx": - adapter_type = "legacyESX"; + _adapterType = "legacyESX"; break; default: - ErrorMessage = $"Invalid adapter type {adapter_type}"; + ErrorMessage = $"Invalid adapter type {_adapterType}"; return false; } else - adapter_type = "ide"; + _adapterType = "ide"; if(options.TryGetValue("hwversion", out string tmpValue)) { - if(!uint.TryParse(tmpValue, out hwversion)) + if(!uint.TryParse(tmpValue, out _hwversion)) { ErrorMessage = "Invalid value for hwversion option"; @@ -80,7 +80,7 @@ namespace Aaru.DiscImages } } else - hwversion = 4; + _hwversion = 4; if(options.TryGetValue("split", out tmpValue)) { @@ -118,8 +118,8 @@ namespace Aaru.DiscImages } else { - adapter_type = "ide"; - hwversion = 4; + _adapterType = "ide"; + _hwversion = 4; } if(sectorSize != 512) @@ -136,7 +136,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -145,12 +145,12 @@ namespace Aaru.DiscImages try { - writingBaseName = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)); - descriptorStream = new StreamWriter(path, false, Encoding.ASCII); + _writingBaseName = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)); + _descriptorStream = new StreamWriter(path, false, Encoding.ASCII); // TODO: Support split - writingStream = new FileStream(writingBaseName + "-flat.vmdk", FileMode.OpenOrCreate, - FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(_writingBaseName + "-flat.vmdk", FileMode.OpenOrCreate, + FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -188,15 +188,15 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(sectorAddress * 512), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(sectorAddress * 512), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -220,15 +220,15 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(sectorAddress * 512), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(sectorAddress * 512), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -259,54 +259,54 @@ namespace Aaru.DiscImages return false; } - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); - if(imageInfo.Cylinders == 0) + if(_imageInfo.Cylinders == 0) { - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; - while(imageInfo.Cylinders == 0) + while(_imageInfo.Cylinders == 0) { - imageInfo.Heads--; + _imageInfo.Heads--; - if(imageInfo.Heads == 0) + if(_imageInfo.Heads == 0) { - imageInfo.SectorsPerTrack--; - imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack--; + _imageInfo.Heads = 16; } - imageInfo.Cylinders = (uint)(imageInfo.Sectors / imageInfo.Heads / imageInfo.SectorsPerTrack); + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / _imageInfo.Heads / _imageInfo.SectorsPerTrack); - if(imageInfo.Cylinders == 0 && - imageInfo.Heads == 0 && - imageInfo.SectorsPerTrack == 0) + if(_imageInfo.Cylinders == 0 && + _imageInfo.Heads == 0 && + _imageInfo.SectorsPerTrack == 0) break; } } - descriptorStream.WriteLine("# Disk DescriptorFile"); - descriptorStream.WriteLine("version=1"); - descriptorStream.WriteLine($"CID={new Random().Next(int.MinValue, int.MaxValue):x8}"); - descriptorStream.WriteLine("parentCID=ffffffff"); - descriptorStream.WriteLine("createType=\"monolithicFlat\""); - descriptorStream.WriteLine(); - descriptorStream.WriteLine("# Extent description"); - descriptorStream.WriteLine($"RW {imageInfo.Sectors} FLAT \"{writingBaseName + "-flat.vmdk"}\" 0"); - descriptorStream.WriteLine(); - descriptorStream.WriteLine("# The Disk Data Base"); - descriptorStream.WriteLine("#DDB"); - descriptorStream.WriteLine(); - descriptorStream.WriteLine($"ddb.virtualHWVersion = \"{hwversion}\""); - descriptorStream.WriteLine($"ddb.geometry.cylinders = \"{imageInfo.Cylinders}\""); - descriptorStream.WriteLine($"ddb.geometry.heads = \"{imageInfo.Heads}\""); - descriptorStream.WriteLine($"ddb.geometry.sectors = \"{imageInfo.SectorsPerTrack}\""); - descriptorStream.WriteLine($"ddb.adapterType = \"{adapter_type}\""); + _descriptorStream.WriteLine("# Disk DescriptorFile"); + _descriptorStream.WriteLine("version=1"); + _descriptorStream.WriteLine($"CID={new Random().Next(int.MinValue, int.MaxValue):x8}"); + _descriptorStream.WriteLine("parentCID=ffffffff"); + _descriptorStream.WriteLine("createType=\"monolithicFlat\""); + _descriptorStream.WriteLine(); + _descriptorStream.WriteLine("# Extent description"); + _descriptorStream.WriteLine($"RW {_imageInfo.Sectors} FLAT \"{_writingBaseName + "-flat.vmdk"}\" 0"); + _descriptorStream.WriteLine(); + _descriptorStream.WriteLine("# The Disk Data Base"); + _descriptorStream.WriteLine("#DDB"); + _descriptorStream.WriteLine(); + _descriptorStream.WriteLine($"ddb.virtualHWVersion = \"{_hwversion}\""); + _descriptorStream.WriteLine($"ddb.geometry.cylinders = \"{_imageInfo.Cylinders}\""); + _descriptorStream.WriteLine($"ddb.geometry.heads = \"{_imageInfo.Heads}\""); + _descriptorStream.WriteLine($"ddb.geometry.sectors = \"{_imageInfo.SectorsPerTrack}\""); + _descriptorStream.WriteLine($"ddb.adapterType = \"{_adapterType}\""); - descriptorStream.Flush(); - descriptorStream.Close(); + _descriptorStream.Flush(); + _descriptorStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -339,9 +339,9 @@ namespace Aaru.DiscImages return false; } - imageInfo.SectorsPerTrack = sectorsPerTrack; - imageInfo.Heads = heads; - imageInfo.Cylinders = cylinders; + _imageInfo.SectorsPerTrack = sectorsPerTrack; + _imageInfo.Heads = heads; + _imageInfo.Cylinders = cylinders; return true; } diff --git a/Aaru.Images/Virtual98/Constants.cs b/Aaru.Images/Virtual98/Constants.cs index 8ab946db0..2db2e44df 100644 --- a/Aaru.Images/Virtual98/Constants.cs +++ b/Aaru.Images/Virtual98/Constants.cs @@ -34,7 +34,7 @@ namespace Aaru.DiscImages { public partial class Virtual98 { - readonly byte[] signature = + readonly byte[] _signature = { 0x56, 0x48, 0x44, 0x31, 0x2E, 0x30, 0x30, 0x00 }; diff --git a/Aaru.Images/Virtual98/Identify.cs b/Aaru.Images/Virtual98/Identify.cs index e7aec460f..089dafe50 100644 --- a/Aaru.Images/Virtual98/Identify.cs +++ b/Aaru.Images/Virtual98/Identify.cs @@ -55,24 +55,24 @@ namespace Aaru.DiscImages byte[] hdrB = new byte[Marshal.SizeOf()]; stream.Read(hdrB, 0, hdrB.Length); - v98Hdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); + _v98Hdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); - if(!v98Hdr.signature.SequenceEqual(signature)) + if(!_v98Hdr.signature.SequenceEqual(_signature)) return false; AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.signature = \"{0}\"", - StringHandlers.CToString(v98Hdr.signature, shiftjis)); + StringHandlers.CToString(_v98Hdr.signature, shiftjis)); AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.comment = \"{0}\"", - StringHandlers.CToString(v98Hdr.comment, shiftjis)); + StringHandlers.CToString(_v98Hdr.comment, shiftjis)); - AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.padding = {0}", v98Hdr.padding); - AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.mbsize = {0}", v98Hdr.mbsize); - AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.sectorsize = {0}", v98Hdr.sectorsize); - AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.sectors = {0}", v98Hdr.sectors); - AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.surfaces = {0}", v98Hdr.surfaces); - AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.cylinders = {0}", v98Hdr.cylinders); - AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.totals = {0}", v98Hdr.totals); + AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.padding = {0}", _v98Hdr.padding); + AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.mbsize = {0}", _v98Hdr.mbsize); + AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.sectorsize = {0}", _v98Hdr.sectorsize); + AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.sectors = {0}", _v98Hdr.sectors); + AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.surfaces = {0}", _v98Hdr.surfaces); + AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.cylinders = {0}", _v98Hdr.cylinders); + AaruConsole.DebugWriteLine("Virtual98 plugin", "v98hdr.totals = {0}", _v98Hdr.totals); return true; } diff --git a/Aaru.Images/Virtual98/Properties.cs b/Aaru.Images/Virtual98/Properties.cs index 1a3bad9cd..f50b92a53 100644 --- a/Aaru.Images/Virtual98/Properties.cs +++ b/Aaru.Images/Virtual98/Properties.cs @@ -41,7 +41,7 @@ namespace Aaru.DiscImages { public partial class Virtual98 { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "Virtual98 Disk Image"; public Guid Id => new Guid("C0CDE13D-04D0-4913-8740-AFAA44D0A107"); public string Author => "Natalia Portillo"; diff --git a/Aaru.Images/Virtual98/Read.cs b/Aaru.Images/Virtual98/Read.cs index 107c2e46d..2fde43b86 100644 --- a/Aaru.Images/Virtual98/Read.cs +++ b/Aaru.Images/Virtual98/Read.cs @@ -56,23 +56,23 @@ namespace Aaru.DiscImages byte[] hdrB = new byte[Marshal.SizeOf()]; stream.Read(hdrB, 0, hdrB.Length); - v98Hdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); + _v98Hdr = Marshal.ByteArrayToStructureLittleEndian(hdrB); - imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.MediaType = MediaType.GENERIC_HDD; - imageInfo.ImageSize = (ulong)(stream.Length - 0xDC); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.Sectors = v98Hdr.totals; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.SectorSize = v98Hdr.sectorsize; - imageInfo.Cylinders = v98Hdr.cylinders; - imageInfo.Heads = v98Hdr.surfaces; - imageInfo.SectorsPerTrack = v98Hdr.sectors; - imageInfo.Comments = StringHandlers.CToString(v98Hdr.comment, shiftjis); + _imageInfo.ImageSize = (ulong)(stream.Length - 0xDC); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.Sectors = _v98Hdr.totals; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.SectorSize = _v98Hdr.sectorsize; + _imageInfo.Cylinders = _v98Hdr.cylinders; + _imageInfo.Heads = _v98Hdr.surfaces; + _imageInfo.SectorsPerTrack = _v98Hdr.sectors; + _imageInfo.Comments = StringHandlers.CToString(_v98Hdr.comment, shiftjis); - nhdImageFilter = imageFilter; + _nhdImageFilter = imageFilter; return true; } @@ -81,23 +81,23 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - byte[] buffer = new byte[length * imageInfo.SectorSize]; + byte[] buffer = new byte[length * _imageInfo.SectorSize]; - Stream stream = nhdImageFilter.GetDataForkStream(); + Stream stream = _nhdImageFilter.GetDataForkStream(); // V98 are lazy allocated - if((long)(0xDC + (sectorAddress * imageInfo.SectorSize)) >= stream.Length) + if((long)(0xDC + (sectorAddress * _imageInfo.SectorSize)) >= stream.Length) return buffer; - stream.Seek((long)(0xDC + (sectorAddress * imageInfo.SectorSize)), SeekOrigin.Begin); + stream.Seek((long)(0xDC + (sectorAddress * _imageInfo.SectorSize)), SeekOrigin.Begin); - int toRead = (int)(length * imageInfo.SectorSize); + int toRead = (int)(length * _imageInfo.SectorSize); if(toRead + stream.Position > stream.Length) toRead = (int)(stream.Length - stream.Position); diff --git a/Aaru.Images/Virtual98/Virtual98.cs b/Aaru.Images/Virtual98/Virtual98.cs index 73bb74f2e..2f6d5ab40 100644 --- a/Aaru.Images/Virtual98/Virtual98.cs +++ b/Aaru.Images/Virtual98/Virtual98.cs @@ -41,12 +41,12 @@ namespace Aaru.DiscImages // Info from Neko Project II emulator public partial class Virtual98 : IWritableImage { - ImageInfo imageInfo; - IFilter nhdImageFilter; - Virtual98Header v98Hdr; - FileStream writingStream; + ImageInfo _imageInfo; + IFilter _nhdImageFilter; + Virtual98Header _v98Hdr; + FileStream _writingStream; - public Virtual98() => imageInfo = new ImageInfo + public Virtual98() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/Virtual98/Write.cs b/Aaru.Images/Virtual98/Write.cs index 0e4b04c4c..72f551857 100644 --- a/Aaru.Images/Virtual98/Write.cs +++ b/Aaru.Images/Virtual98/Write.cs @@ -69,7 +69,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -78,7 +78,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -116,15 +116,15 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(0xDC + (sectorAddress * 512)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(0xDC + (sectorAddress * 512)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -147,15 +147,15 @@ namespace Aaru.DiscImages return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(0xDC + (sectorAddress * 512)), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(0xDC + (sectorAddress * 512)), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -185,63 +185,63 @@ namespace Aaru.DiscImages return false; } - if(imageInfo.Cylinders == 0) + if(_imageInfo.Cylinders == 0) { - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; - while(imageInfo.Cylinders == 0) + while(_imageInfo.Cylinders == 0) { - imageInfo.Heads--; + _imageInfo.Heads--; - if(imageInfo.Heads == 0) + if(_imageInfo.Heads == 0) { - imageInfo.SectorsPerTrack--; - imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack--; + _imageInfo.Heads = 16; } - imageInfo.Cylinders = (uint)(imageInfo.Sectors / imageInfo.Heads / imageInfo.SectorsPerTrack); + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / _imageInfo.Heads / _imageInfo.SectorsPerTrack); - if(imageInfo.Cylinders == 0 && - imageInfo.Heads == 0 && - imageInfo.SectorsPerTrack == 0) + if(_imageInfo.Cylinders == 0 && + _imageInfo.Heads == 0 && + _imageInfo.SectorsPerTrack == 0) break; } } byte[] commentsBytes = null; - if(!string.IsNullOrEmpty(imageInfo.Comments)) - commentsBytes = Encoding.GetEncoding("shift_jis").GetBytes(imageInfo.Comments); + if(!string.IsNullOrEmpty(_imageInfo.Comments)) + commentsBytes = Encoding.GetEncoding("shift_jis").GetBytes(_imageInfo.Comments); - v98Hdr = new Virtual98Header + _v98Hdr = new Virtual98Header { comment = new byte[128], - cylinders = (ushort)imageInfo.Cylinders, + cylinders = (ushort)_imageInfo.Cylinders, padding2 = new byte[0x44], - sectors = (byte)imageInfo.SectorsPerTrack, - sectorsize = (ushort)imageInfo.SectorSize, - signature = signature, - surfaces = (byte)imageInfo.Heads, - totals = (uint)imageInfo.Sectors + sectors = (byte)_imageInfo.SectorsPerTrack, + sectorsize = (ushort)_imageInfo.SectorSize, + signature = _signature, + surfaces = (byte)_imageInfo.Heads, + totals = (uint)_imageInfo.Sectors }; if(commentsBytes != null) - Array.Copy(commentsBytes, 0, v98Hdr.comment, 0, + Array.Copy(commentsBytes, 0, _v98Hdr.comment, 0, commentsBytes.Length >= 128 ? 128 : commentsBytes.Length); byte[] hdr = new byte[Marshal.SizeOf()]; IntPtr hdrPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(Marshal.SizeOf()); - System.Runtime.InteropServices.Marshal.StructureToPtr(v98Hdr, hdrPtr, true); + System.Runtime.InteropServices.Marshal.StructureToPtr(_v98Hdr, hdrPtr, true); System.Runtime.InteropServices.Marshal.Copy(hdrPtr, hdr, 0, hdr.Length); System.Runtime.InteropServices.Marshal.FreeHGlobal(hdrPtr); - writingStream.Seek(0, SeekOrigin.Begin); - writingStream.Write(hdr, 0, hdr.Length); + _writingStream.Seek(0, SeekOrigin.Begin); + _writingStream.Write(hdr, 0, hdr.Length); - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; ErrorMessage = ""; @@ -251,7 +251,7 @@ namespace Aaru.DiscImages public bool SetMetadata(ImageInfo metadata) { - imageInfo.Comments = metadata.Comments; + _imageInfo.Comments = metadata.Comments; return true; } @@ -279,9 +279,9 @@ namespace Aaru.DiscImages return false; } - imageInfo.SectorsPerTrack = sectorsPerTrack; - imageInfo.Heads = heads; - imageInfo.Cylinders = cylinders; + _imageInfo.SectorsPerTrack = sectorsPerTrack; + _imageInfo.Heads = heads; + _imageInfo.Cylinders = cylinders; return true; } diff --git a/Aaru.Images/WCDiskImage/Identify.cs b/Aaru.Images/WCDiskImage/Identify.cs index 64b9226aa..003e85ad9 100644 --- a/Aaru.Images/WCDiskImage/Identify.cs +++ b/Aaru.Images/WCDiskImage/Identify.cs @@ -51,10 +51,10 @@ namespace Aaru.DiscImages byte[] header = new byte[32]; stream.Read(header, 0, 32); - WCDiskImageFileHeader fheader = Marshal.ByteArrayToStructureLittleEndian(header); + WcDiskImageFileHeader fheader = Marshal.ByteArrayToStructureLittleEndian(header); /* check the signature */ - if(Encoding.ASCII.GetString(fheader.signature).TrimEnd('\x00') != fileSignature) + if(Encoding.ASCII.GetString(fheader.signature).TrimEnd('\x00') != _fileSignature) return false; /* Some sanity checks on the values we just read. */ diff --git a/Aaru.Images/WCDiskImage/Properties.cs b/Aaru.Images/WCDiskImage/Properties.cs index 8d5f45cf5..af131e4f1 100644 --- a/Aaru.Images/WCDiskImage/Properties.cs +++ b/Aaru.Images/WCDiskImage/Properties.cs @@ -40,7 +40,7 @@ namespace Aaru.DiscImages { public partial class WCDiskImage { - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Name => "d2f disk image"; public Guid Id => new Guid("DDE01493-BCA2-41C2-A269-7E56D3716D2F"); diff --git a/Aaru.Images/WCDiskImage/Read.cs b/Aaru.Images/WCDiskImage/Read.cs index 724b64d86..08b41143e 100644 --- a/Aaru.Images/WCDiskImage/Read.cs +++ b/Aaru.Images/WCDiskImage/Read.cs @@ -54,33 +54,33 @@ namespace Aaru.DiscImages byte[] header = new byte[32]; stream.Read(header, 0, 32); - WCDiskImageFileHeader fheader = Marshal.ByteArrayToStructureLittleEndian(header); + WcDiskImageFileHeader fheader = Marshal.ByteArrayToStructureLittleEndian(header); AaruConsole.DebugWriteLine("d2f plugin", "Detected WC DISK IMAGE with {0} heads, {1} tracks and {2} sectors per track.", fheader.heads, fheader.cylinders, fheader.sectorsPerTrack); - imageInfo.Cylinders = fheader.cylinders; - imageInfo.SectorsPerTrack = fheader.sectorsPerTrack; - imageInfo.SectorSize = 512; // only 512 bytes per sector supported - imageInfo.Heads = fheader.heads; - imageInfo.Sectors = imageInfo.Heads * imageInfo.Cylinders * imageInfo.SectorsPerTrack; - imageInfo.ImageSize = imageInfo.Sectors * imageInfo.SectorSize; + _imageInfo.Cylinders = fheader.cylinders; + _imageInfo.SectorsPerTrack = fheader.sectorsPerTrack; + _imageInfo.SectorSize = 512; // only 512 bytes per sector supported + _imageInfo.Heads = fheader.heads; + _imageInfo.Sectors = _imageInfo.Heads * _imageInfo.Cylinders * _imageInfo.SectorsPerTrack; + _imageInfo.ImageSize = _imageInfo.Sectors * _imageInfo.SectorSize; - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - imageInfo.MediaType = Geometry.GetMediaType(((ushort)imageInfo.Cylinders, (byte)imageInfo.Heads, - (ushort)imageInfo.SectorsPerTrack, 512, MediaEncoding.MFM, - false)); + _imageInfo.MediaType = Geometry.GetMediaType(((ushort)_imageInfo.Cylinders, (byte)_imageInfo.Heads, + (ushort)_imageInfo.SectorsPerTrack, 512, MediaEncoding.MFM, + false)); /* buffer the entire disk in memory */ - for(int cyl = 0; cyl < imageInfo.Cylinders; cyl++) + for(int cyl = 0; cyl < _imageInfo.Cylinders; cyl++) { - for(int head = 0; head < imageInfo.Heads; head++) + for(int head = 0; head < _imageInfo.Heads; head++) ReadTrack(stream, cyl, head); } @@ -88,35 +88,35 @@ namespace Aaru.DiscImages if(fheader.extraTracks[0] == 1) { AaruConsole.DebugWriteLine("d2f plugin", "Extra track 1 (head 0) present, reading"); - ReadTrack(stream, (int)imageInfo.Cylinders, 0); + ReadTrack(stream, (int)_imageInfo.Cylinders, 0); } if(fheader.extraTracks[1] == 1) { AaruConsole.DebugWriteLine("d2f plugin", "Extra track 1 (head 1) present, reading"); - ReadTrack(stream, (int)imageInfo.Cylinders, 1); + ReadTrack(stream, (int)_imageInfo.Cylinders, 1); } if(fheader.extraTracks[2] == 1) { AaruConsole.DebugWriteLine("d2f plugin", "Extra track 2 (head 0) present, reading"); - ReadTrack(stream, (int)imageInfo.Cylinders + 1, 0); + ReadTrack(stream, (int)_imageInfo.Cylinders + 1, 0); } if(fheader.extraTracks[3] == 1) { AaruConsole.DebugWriteLine("d2f plugin", "Extra track 2 (head 1) present, reading"); - ReadTrack(stream, (int)imageInfo.Cylinders + 1, 1); + ReadTrack(stream, (int)_imageInfo.Cylinders + 1, 1); } /* adjust number of cylinders */ if(fheader.extraTracks[0] == 1 || fheader.extraTracks[1] == 1) - imageInfo.Cylinders++; + _imageInfo.Cylinders++; if(fheader.extraTracks[2] == 1 || fheader.extraTracks[3] == 1) - imageInfo.Cylinders++; + _imageInfo.Cylinders++; /* read the comment and directory data if present */ if(fheader.extraFlags.HasFlag(ExtraFlag.Comment)) @@ -125,8 +125,8 @@ namespace Aaru.DiscImages byte[] sheaderBuffer = new byte[6]; stream.Read(sheaderBuffer, 0, 6); - WCDiskImageSectorHeader sheader = - Marshal.ByteArrayToStructureLittleEndian(sheaderBuffer); + WcDiskImageSectorHeader sheader = + Marshal.ByteArrayToStructureLittleEndian(sheaderBuffer); if(sheader.flag != SectorFlag.Comment) throw new InvalidDataException(string.Format("Invalid sector type '{0}' encountered", @@ -143,8 +143,8 @@ namespace Aaru.DiscImages byte[] sheaderBuffer = new byte[6]; stream.Read(sheaderBuffer, 0, 6); - WCDiskImageSectorHeader sheader = - Marshal.ByteArrayToStructureLittleEndian(sheaderBuffer); + WcDiskImageSectorHeader sheader = + Marshal.ByteArrayToStructureLittleEndian(sheaderBuffer); if(sheader.flag != SectorFlag.Directory) throw new InvalidDataException(string.Format("Invalid sector type '{0}' encountered", @@ -156,21 +156,21 @@ namespace Aaru.DiscImages } if(comments.Length > 0) - imageInfo.Comments = comments; + _imageInfo.Comments = comments; // save some variables for later use - fileHeader = fheader; - wcImageFilter = imageFilter; + _fileHeader = fheader; + _wcImageFilter = imageFilter; return true; } public byte[] ReadSector(ulong sectorAddress) { - int sectorNumber = (int)(sectorAddress % imageInfo.SectorsPerTrack) + 1; - int trackNumber = (int)(sectorAddress / imageInfo.SectorsPerTrack); - int headNumber = imageInfo.Heads > 1 ? trackNumber % 2 : 0; - int cylinderNumber = imageInfo.Heads > 1 ? trackNumber / 2 : trackNumber; + int sectorNumber = (int)(sectorAddress % _imageInfo.SectorsPerTrack) + 1; + int trackNumber = (int)(sectorAddress / _imageInfo.SectorsPerTrack); + int headNumber = _imageInfo.Heads > 1 ? trackNumber % 2 : 0; + int cylinderNumber = _imageInfo.Heads > 1 ? trackNumber / 2 : trackNumber; if(badSectors[(cylinderNumber, headNumber, sectorNumber)]) { @@ -190,13 +190,13 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - byte[] result = new byte[length * imageInfo.SectorSize]; + byte[] result = new byte[length * _imageInfo.SectorSize]; - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); for(int i = 0; i < length; i++) - ReadSector(sectorAddress + (ulong)i).CopyTo(result, i * imageInfo.SectorSize); + ReadSector(sectorAddress + (ulong)i).CopyTo(result, i * _imageInfo.SectorSize); return result; } @@ -211,14 +211,14 @@ namespace Aaru.DiscImages byte[] crc; short calculatedCRC; - for(int sect = 1; sect < imageInfo.SectorsPerTrack + 1; sect++) + for(int sect = 1; sect < _imageInfo.SectorsPerTrack + 1; sect++) { /* read the sector header */ byte[] sheaderBuffer = new byte[6]; stream.Read(sheaderBuffer, 0, 6); - WCDiskImageSectorHeader sheader = - Marshal.ByteArrayToStructureLittleEndian(sheaderBuffer); + WcDiskImageSectorHeader sheader = + Marshal.ByteArrayToStructureLittleEndian(sheaderBuffer); /* validate the sector header */ if(sheader.cylinder != cyl || diff --git a/Aaru.Images/WCDiskImage/Structs.cs b/Aaru.Images/WCDiskImage/Structs.cs index 693d297e5..1ccd7d314 100644 --- a/Aaru.Images/WCDiskImage/Structs.cs +++ b/Aaru.Images/WCDiskImage/Structs.cs @@ -38,11 +38,11 @@ namespace Aaru.DiscImages public partial class WCDiskImage { /// The expected signature of a proper image file. - const string fileSignature = "WC DISK IMAGE\x1a\x1a"; + const string _fileSignature = "WC DISK IMAGE\x1a\x1a"; /// The global header of a WCDiskImage file [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct WCDiskImageFileHeader + struct WcDiskImageFileHeader { /// The signature should be "WC DISK IMAGE\0x1a\0x1a\0x00" [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] @@ -87,7 +87,7 @@ namespace Aaru.DiscImages /// The Sector header that precedes each sector [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct WCDiskImageSectorHeader + struct WcDiskImageSectorHeader { /// The sector flag (i.e. type) public readonly SectorFlag flag; diff --git a/Aaru.Images/WCDiskImage/WCDiskImage.cs b/Aaru.Images/WCDiskImage/WCDiskImage.cs index 9dc05a33d..e4c3d2f67 100644 --- a/Aaru.Images/WCDiskImage/WCDiskImage.cs +++ b/Aaru.Images/WCDiskImage/WCDiskImage.cs @@ -45,17 +45,17 @@ namespace Aaru.DiscImages public Dictionary<(int cylinder, int head, int sector), bool> badSectors = new Dictionary<(int cylinder, int head, int sector), bool>(); /// The file header after the image has been opened - WCDiskImageFileHeader fileHeader; - ImageInfo imageInfo; + WcDiskImageFileHeader _fileHeader; + ImageInfo _imageInfo; /* the sectors are cached here */ public Dictionary<(int cylinder, int head, int sector), byte[]> sectorCache = new Dictionary<(int cylinder, int head, int sector), byte[]>(); /// The ImageFilter we're reading from, after the file has been opened - IFilter wcImageFilter; + IFilter _wcImageFilter; - public WCDiskImage() => imageInfo = new ImageInfo + public WCDiskImage() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Images/ZZZRawImage/Constants.cs b/Aaru.Images/ZZZRawImage/Constants.cs index d6626fe32..1565710ea 100644 --- a/Aaru.Images/ZZZRawImage/Constants.cs +++ b/Aaru.Images/ZZZRawImage/Constants.cs @@ -36,11 +36,11 @@ namespace Aaru.DiscImages { public partial class ZZZRawImage { - readonly byte[] cdSync = + readonly byte[] _cdSync = { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 }; - readonly (MediaTagType tag, string name)[] readWriteSidecars = + readonly (MediaTagType tag, string name)[] _readWriteSidecars = { (MediaTagType.ATA_IDENTIFY, ".identify.bin"), (MediaTagType.BD_DI, ".di.bin"), (MediaTagType.CD_ATIP, ".atip.bin"), (MediaTagType.CD_FullTOC, ".toc.bin"), @@ -60,7 +60,7 @@ namespace Aaru.DiscImages (MediaTagType.Xbox_SecuritySector, ".ss.bin") }; - readonly (MediaTagType tag, string name)[] writeOnlySidecars = + readonly (MediaTagType tag, string name)[] _writeOnlySidecars = { (MediaTagType.ATAPI_IDENTIFY, ".identify.bin"), (MediaTagType.BD_BCA, ".bca.bin"), (MediaTagType.BD_DDS, ".dds.bin"), (MediaTagType.BD_DI, ".di.bin"), (MediaTagType.BD_SpareArea, ".sai.bin"), diff --git a/Aaru.Images/ZZZRawImage/Helpers.cs b/Aaru.Images/ZZZRawImage/Helpers.cs index 809ad58c1..6017844eb 100644 --- a/Aaru.Images/ZZZRawImage/Helpers.cs +++ b/Aaru.Images/ZZZRawImage/Helpers.cs @@ -38,36 +38,36 @@ namespace Aaru.DiscImages { MediaType CalculateDiskType() { - if(imageInfo.SectorSize == 2048) + if(_imageInfo.SectorSize == 2048) { - if(imageInfo.Sectors == 58620544) + if(_imageInfo.Sectors == 58620544) return MediaType.REV120; - if(imageInfo.Sectors == 17090880) + if(_imageInfo.Sectors == 17090880) return MediaType.REV35; - if(imageInfo.Sectors <= 360000) + if(_imageInfo.Sectors <= 360000) return MediaType.CD; - if(imageInfo.Sectors <= 2295104) + if(_imageInfo.Sectors <= 2295104) return MediaType.DVDPR; - if(imageInfo.Sectors <= 2298496) + if(_imageInfo.Sectors <= 2298496) return MediaType.DVDR; - if(imageInfo.Sectors <= 4171712) + if(_imageInfo.Sectors <= 4171712) return MediaType.DVDRDL; - if(imageInfo.Sectors <= 4173824) + if(_imageInfo.Sectors <= 4173824) return MediaType.DVDPRDL; - if(imageInfo.Sectors <= 24438784) + if(_imageInfo.Sectors <= 24438784) return MediaType.BDR; - return imageInfo.Sectors <= 62500864 ? MediaType.BDRXL : MediaType.Unknown; + return _imageInfo.Sectors <= 62500864 ? MediaType.BDRXL : MediaType.Unknown; } - switch(imageInfo.ImageSize) + switch(_imageInfo.ImageSize) { case 80384: return MediaType.ECMA_66; case 81664: return MediaType.IBM23FD; @@ -77,7 +77,7 @@ namespace Aaru.DiscImages case 133120: return MediaType.ATARI_525_ED; case 143360: return MediaType.Apple33SS; case 163840: - if(imageInfo.SectorSize == 256) + if(_imageInfo.SectorSize == 256) return MediaType.ACORN_525_SS_DD_40; return MediaType.DOS_525_SS_DD_8; @@ -92,17 +92,17 @@ namespace Aaru.DiscImages case 322560: return MediaType.Apricot_35; case 325632: return MediaType.ECMA_70; case 327680: - if(imageInfo.SectorSize == 256) + if(_imageInfo.SectorSize == 256) return MediaType.ACORN_525_SS_DD_80; return MediaType.DOS_525_DS_DD_8; case 368640: - if(extension == ".st") + if(_extension == ".st") return MediaType.DOS_35_SS_DD_9; return MediaType.DOS_525_DS_DD_9; case 409600: - if(extension == ".st") + if(_extension == ".st") return MediaType.ATARI_35_SS_DD; return MediaType.AppleSonySS; @@ -113,60 +113,60 @@ namespace Aaru.DiscImages case 655360: return MediaType.ACORN_525_DS_DD; case 737280: return MediaType.DOS_35_DS_DD_9; case 819200: - if(imageInfo.SectorSize == 256) + if(_imageInfo.SectorSize == 256) return MediaType.CBM_35_DD; - if((extension == ".adf" || extension == ".adl") && - imageInfo.SectorSize == 1024) + if((_extension == ".adf" || _extension == ".adl") && + _imageInfo.SectorSize == 1024) return MediaType.ACORN_35_DS_DD; - if(extension == ".st") + if(_extension == ".st") return MediaType.ATARI_35_DS_DD; return MediaType.AppleSonyDS; case 839680: return MediaType.FDFORMAT_35_DD; case 901120: - if(extension == ".st") + if(_extension == ".st") return MediaType.ATARI_35_DS_DD_11; return MediaType.CBM_AMIGA_35_DD; - case 988416: return MediaType.IBM43FD_256; - case 995072: return MediaType.IBM53FD_256; - case 1021696: return MediaType.ECMA_99_26; - case 1146624: return MediaType.IBM53FD_512; - case 1177344: return MediaType.ECMA_99_15; - case 1222400: return MediaType.IBM53FD_1024; - case 1228800: return MediaType.DOS_525_HD; - case 1255168: return MediaType.ECMA_69_8; - case 1261568: return MediaType.NEC_525_HD; - case 1304320: return MediaType.ECMA_99_8; - case 1427456: return MediaType.FDFORMAT_525_HD; - case 1474560: return MediaType.DOS_35_HD; - case 1638400: return MediaType.ACORN_35_DS_HD; - case 1720320: return MediaType.DMF; - case 1763328: return MediaType.FDFORMAT_35_HD; - case 1802240: return MediaType.CBM_AMIGA_35_HD; - case 1880064: return MediaType.XDF_35; - case 1884160: return MediaType.XDF_35; - case 2949120: return MediaType.DOS_35_ED; - case 9338880: return MediaType.NEC_35_TD; - case 20818944: return MediaType.Floptical; - case 33554432: return MediaType.FD32MB; - case 40387584: return MediaType.PocketZip; - case 100663296: return MediaType.ZIP100; - case 126222336: return MediaType.LS120; - case 127398912: return MediaType.ECMA_154; - case 201410560: return MediaType.HiFD; - case 228518400: return MediaType.ECMA_201; - case 240386048: return MediaType.LS240; - case 250640384: return MediaType.ZIP250; - case 481520640: return MediaType.ECMA_183_512; - case 533403648: return MediaType.ECMA_183; - case 596787200: return MediaType.ECMA_184_512; - case 654540800: return MediaType.ECMA_184; - case 656310272 when imageInfo.SectorSize == 512: return MediaType.PD650; - case 664829952 when imageInfo.SectorSize == 512: return MediaType.PD650; - case 1070617600: return MediaType.Jaz; + case 988416: return MediaType.IBM43FD_256; + case 995072: return MediaType.IBM53FD_256; + case 1021696: return MediaType.ECMA_99_26; + case 1146624: return MediaType.IBM53FD_512; + case 1177344: return MediaType.ECMA_99_15; + case 1222400: return MediaType.IBM53FD_1024; + case 1228800: return MediaType.DOS_525_HD; + case 1255168: return MediaType.ECMA_69_8; + case 1261568: return MediaType.NEC_525_HD; + case 1304320: return MediaType.ECMA_99_8; + case 1427456: return MediaType.FDFORMAT_525_HD; + case 1474560: return MediaType.DOS_35_HD; + case 1638400: return MediaType.ACORN_35_DS_HD; + case 1720320: return MediaType.DMF; + case 1763328: return MediaType.FDFORMAT_35_HD; + case 1802240: return MediaType.CBM_AMIGA_35_HD; + case 1880064: return MediaType.XDF_35; + case 1884160: return MediaType.XDF_35; + case 2949120: return MediaType.DOS_35_ED; + case 9338880: return MediaType.NEC_35_TD; + case 20818944: return MediaType.Floptical; + case 33554432: return MediaType.FD32MB; + case 40387584: return MediaType.PocketZip; + case 100663296: return MediaType.ZIP100; + case 126222336: return MediaType.LS120; + case 127398912: return MediaType.ECMA_154; + case 201410560: return MediaType.HiFD; + case 228518400: return MediaType.ECMA_201; + case 240386048: return MediaType.LS240; + case 250640384: return MediaType.ZIP250; + case 481520640: return MediaType.ECMA_183_512; + case 533403648: return MediaType.ECMA_183; + case 596787200: return MediaType.ECMA_184_512; + case 654540800: return MediaType.ECMA_184; + case 656310272 when _imageInfo.SectorSize == 512: return MediaType.PD650; + case 664829952 when _imageInfo.SectorSize == 512: return MediaType.PD650; + case 1070617600: return MediaType.Jaz; #region Commodore case 174848: diff --git a/Aaru.Images/ZZZRawImage/Identify.cs b/Aaru.Images/ZZZRawImage/Identify.cs index 3bc30f79d..38b635f1b 100644 --- a/Aaru.Images/ZZZRawImage/Identify.cs +++ b/Aaru.Images/ZZZRawImage/Identify.cs @@ -44,9 +44,9 @@ namespace Aaru.DiscImages if(imageFilter.GetDataForkLength() % 512 == 0) return true; - extension = Path.GetExtension(imageFilter.GetFilename())?.ToLower(); + _extension = Path.GetExtension(imageFilter.GetFilename())?.ToLower(); - if(extension == ".hdf" && + if(_extension == ".hdf" && imageFilter.GetDataForkLength() % 256 == 0) return true; @@ -59,7 +59,7 @@ namespace Aaru.DiscImages stream.Position = 0; stream.Read(sync, 0, 12); - return cdSync.SequenceEqual(sync); + return _cdSync.SequenceEqual(sync); } // Check known disk sizes with sectors smaller than 512 diff --git a/Aaru.Images/ZZZRawImage/Properties.cs b/Aaru.Images/ZZZRawImage/Properties.cs index 1a54b5f99..e95bdfe86 100644 --- a/Aaru.Images/ZZZRawImage/Properties.cs +++ b/Aaru.Images/ZZZRawImage/Properties.cs @@ -52,7 +52,7 @@ namespace Aaru.DiscImages // Non-random UUID to recognize this specific plugin public Guid Id => new Guid("12345678-AAAA-BBBB-CCCC-123456789000"); - public ImageInfo Info => imageInfo; + public ImageInfo Info => _imageInfo; public string Author => "Natalia Portillo"; public string Format => "Raw disk image (sector by sector copy)"; @@ -60,25 +60,26 @@ namespace Aaru.DiscImages { get { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) return null; var trk = new Track { - TrackBytesPerSector = rawCompactDisc ? mode2 - ? 2336 - : 2048 : (int)imageInfo.SectorSize, - TrackEndSector = imageInfo.Sectors - 1, - TrackFile = rawImageFilter.GetFilename(), - TrackFileOffset = 0, - TrackFileType = "BINARY", - TrackRawBytesPerSector = rawCompactDisc ? 2352 : (int)imageInfo.SectorSize, - TrackSequence = 1, - TrackStartSector = 0, - TrackSubchannelType = hasSubchannel ? TrackSubchannelType.RawInterleaved : TrackSubchannelType.None, - TrackType = rawCompactDisc ? mode2 - ? TrackType.CdMode2Formless - : TrackType.CdMode1 : TrackType.Data, + TrackBytesPerSector = _rawCompactDisc ? _mode2 + ? 2336 + : 2048 : (int)_imageInfo.SectorSize, + TrackEndSector = _imageInfo.Sectors - 1, + TrackFile = _rawImageFilter.GetFilename(), + TrackFileOffset = 0, + TrackFileType = "BINARY", + TrackRawBytesPerSector = _rawCompactDisc ? 2352 : (int)_imageInfo.SectorSize, + TrackSequence = 1, + TrackStartSector = 0, + TrackSubchannelType = + _hasSubchannel ? TrackSubchannelType.RawInterleaved : TrackSubchannelType.None, + TrackType = _rawCompactDisc ? _mode2 + ? TrackType.CdMode2Formless + : TrackType.CdMode1 : TrackType.Data, TrackSession = 1 }; @@ -95,12 +96,12 @@ namespace Aaru.DiscImages { get { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureUnsupportedImageException("Feature not supported by image format"); var sess = new Session { - EndSector = imageInfo.Sectors - 1, + EndSector = _imageInfo.Sectors - 1, EndTrack = 1, SessionSequence = 1, StartSector = 0, @@ -120,7 +121,7 @@ namespace Aaru.DiscImages { get { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) return null; List parts = new List(); @@ -128,17 +129,17 @@ namespace Aaru.DiscImages var part = new Partition { Start = 0, - Length = imageInfo.Sectors, + Length = _imageInfo.Sectors, Offset = 0, Sequence = 0, - Type = rawCompactDisc - ? mode2 + Type = _rawCompactDisc + ? _mode2 ? "MODE2/2352" : "MODE1/2352" - : imageInfo.MediaType == MediaType.PD650 || imageInfo.MediaType == MediaType.PD650_WORM + : _imageInfo.MediaType == MediaType.PD650 || _imageInfo.MediaType == MediaType.PD650_WORM ? "DATA/512" : "MODE1/2048", - Size = imageInfo.Sectors * imageInfo.SectorSize + Size = _imageInfo.Sectors * _imageInfo.SectorSize }; parts.Add(part); @@ -149,8 +150,8 @@ namespace Aaru.DiscImages public List DumpHardware => null; public CICMMetadataType CicmMetadata { get; private set; } - public IEnumerable SupportedMediaTags => readWriteSidecars. - Concat(writeOnlySidecars).OrderBy(t => t.tag). + public IEnumerable SupportedMediaTags => _readWriteSidecars. + Concat(_writeOnlySidecars).OrderBy(t => t.tag). Select(t => t.tag).ToArray(); public IEnumerable SupportedSectorTags => new SectorTagType[] diff --git a/Aaru.Images/ZZZRawImage/Read.cs b/Aaru.Images/ZZZRawImage/Read.cs index 188c2f726..e0aeb7b63 100644 --- a/Aaru.Images/ZZZRawImage/Read.cs +++ b/Aaru.Images/ZZZRawImage/Read.cs @@ -62,26 +62,26 @@ namespace Aaru.DiscImages Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); - extension = Path.GetExtension(imageFilter.GetFilename())?.ToLower(); + _extension = Path.GetExtension(imageFilter.GetFilename())?.ToLower(); - switch(extension) + switch(_extension) { case ".iso" when imageFilter.GetDataForkLength() % 2048 == 0: - imageInfo.SectorSize = 2048; + _imageInfo.SectorSize = 2048; break; case ".d81" when imageFilter.GetDataForkLength() == 819200: - imageInfo.SectorSize = 256; + _imageInfo.SectorSize = 256; break; default: - if((extension == ".adf" || extension == ".adl" || extension == ".ssd" || extension == ".dsd") && + if((_extension == ".adf" || _extension == ".adl" || _extension == ".ssd" || _extension == ".dsd") && (imageFilter.GetDataForkLength() == 163840 || imageFilter.GetDataForkLength() == 327680 || imageFilter.GetDataForkLength() == 655360)) - imageInfo.SectorSize = 256; - else if((extension == ".adf" || extension == ".adl") && + _imageInfo.SectorSize = 256; + else if((_extension == ".adf" || _extension == ".adl") && imageFilter.GetDataForkLength() == 819200) - imageInfo.SectorSize = 1024; + _imageInfo.SectorSize = 1024; else switch(imageFilter.GetDataForkLength()) { @@ -90,7 +90,7 @@ namespace Aaru.DiscImages case 495872: case 92160: case 133120: - imageInfo.SectorSize = 128; + _imageInfo.SectorSize = 128; break; case 116480: @@ -119,17 +119,17 @@ namespace Aaru.DiscImages case 822400: #endregion Commodore - imageInfo.SectorSize = 256; + _imageInfo.SectorSize = 256; break; case 81664: - imageInfo.SectorSize = 319; + _imageInfo.SectorSize = 319; break; case 306432: // T0S0 = 128bps case 1146624: // T0S0 = 128bps, T0S1 = 256bps case 1177344: // T0S0 = 128bps, T0S1 = 256bps - imageInfo.SectorSize = 512; + _imageInfo.SectorSize = 512; break; case 1222400: // T0S0 = 128bps, T0S1 = 256bps @@ -137,15 +137,15 @@ namespace Aaru.DiscImages case 1255168: // T0S0 = 128bps, T0S1 = 256bps case 1261568: case 1638400: - imageInfo.SectorSize = 1024; + _imageInfo.SectorSize = 1024; break; case 35002122240: - imageInfo.SectorSize = 2048; + _imageInfo.SectorSize = 2048; break; default: - imageInfo.SectorSize = 512; + _imageInfo.SectorSize = 512; break; } @@ -153,132 +153,132 @@ namespace Aaru.DiscImages break; } - imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); - imageInfo.CreationTime = imageFilter.GetCreationTime(); - imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); - imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); - differentTrackZeroSize = false; - rawImageFilter = imageFilter; + _imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); + _imageInfo.CreationTime = imageFilter.GetCreationTime(); + _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); + _imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); + _differentTrackZeroSize = false; + _rawImageFilter = imageFilter; switch(imageFilter.GetDataForkLength()) { case 242944: - imageInfo.Sectors = 1898; + _imageInfo.Sectors = 1898; break; case 256256: - imageInfo.Sectors = 2002; + _imageInfo.Sectors = 2002; break; case 495872: - imageInfo.Sectors = 3874; + _imageInfo.Sectors = 3874; break; case 116480: - imageInfo.Sectors = 455; + _imageInfo.Sectors = 455; break; case 287488: // T0S0 = 128bps - imageInfo.Sectors = 1136; - differentTrackZeroSize = true; + _imageInfo.Sectors = 1136; + _differentTrackZeroSize = true; break; case 988416: // T0S0 = 128bps - imageInfo.Sectors = 3874; - differentTrackZeroSize = true; + _imageInfo.Sectors = 3874; + _differentTrackZeroSize = true; break; case 995072: // T0S0 = 128bps, T0S1 = 256bps - imageInfo.Sectors = 3900; - differentTrackZeroSize = true; + _imageInfo.Sectors = 3900; + _differentTrackZeroSize = true; break; case 1021696: // T0S0 = 128bps, T0S1 = 256bps - imageInfo.Sectors = 4004; - differentTrackZeroSize = true; + _imageInfo.Sectors = 4004; + _differentTrackZeroSize = true; break; case 81664: - imageInfo.Sectors = 256; + _imageInfo.Sectors = 256; break; case 306432: // T0S0 = 128bps - imageInfo.Sectors = 618; - differentTrackZeroSize = true; + _imageInfo.Sectors = 618; + _differentTrackZeroSize = true; break; case 1146624: // T0S0 = 128bps, T0S1 = 256bps - imageInfo.Sectors = 2272; - differentTrackZeroSize = true; + _imageInfo.Sectors = 2272; + _differentTrackZeroSize = true; break; case 1177344: // T0S0 = 128bps, T0S1 = 256bps - imageInfo.Sectors = 2332; - differentTrackZeroSize = true; + _imageInfo.Sectors = 2332; + _differentTrackZeroSize = true; break; case 1222400: // T0S0 = 128bps, T0S1 = 256bps - imageInfo.Sectors = 1236; - differentTrackZeroSize = true; + _imageInfo.Sectors = 1236; + _differentTrackZeroSize = true; break; case 1304320: // T0S0 = 128bps, T0S1 = 256bps - imageInfo.Sectors = 1316; - differentTrackZeroSize = true; + _imageInfo.Sectors = 1316; + _differentTrackZeroSize = true; break; case 1255168: // T0S0 = 128bps, T0S1 = 256bps - imageInfo.Sectors = 1268; - differentTrackZeroSize = true; + _imageInfo.Sectors = 1268; + _differentTrackZeroSize = true; break; case 80384: // T0S0 = 128bps - imageInfo.Sectors = 322; - differentTrackZeroSize = true; + _imageInfo.Sectors = 322; + _differentTrackZeroSize = true; break; case 325632: // T0S0 = 128bps, T0S1 = 256bps - imageInfo.Sectors = 1280; - differentTrackZeroSize = true; + _imageInfo.Sectors = 1280; + _differentTrackZeroSize = true; break; case 653312: // T0S0 = 128bps, T0S1 = 256bps - imageInfo.Sectors = 2560; - differentTrackZeroSize = true; + _imageInfo.Sectors = 2560; + _differentTrackZeroSize = true; break; case 1880064: // IBM XDF, 3,5", real number of sectors - imageInfo.Sectors = 670; - imageInfo.SectorSize = 8192; // Biggest sector size - differentTrackZeroSize = true; + _imageInfo.Sectors = 670; + _imageInfo.SectorSize = 8192; // Biggest sector size + _differentTrackZeroSize = true; break; case 175531: - imageInfo.Sectors = 683; + _imageInfo.Sectors = 683; break; case 197375: - imageInfo.Sectors = 768; + _imageInfo.Sectors = 768; break; case 351062: - imageInfo.Sectors = 1366; + _imageInfo.Sectors = 1366; break; case 822400: - imageInfo.Sectors = 3200; + _imageInfo.Sectors = 3200; break; default: - imageInfo.Sectors = imageInfo.ImageSize / imageInfo.SectorSize; + _imageInfo.Sectors = _imageInfo.ImageSize / _imageInfo.SectorSize; break; } - imageInfo.MediaType = CalculateDiskType(); + _imageInfo.MediaType = CalculateDiskType(); - if(imageInfo.ImageSize % 2352 == 0 || - imageInfo.ImageSize % 2448 == 0) + if(_imageInfo.ImageSize % 2352 == 0 || + _imageInfo.ImageSize % 2448 == 0) { byte[] sync = new byte[12]; byte[] header = new byte[4]; @@ -286,33 +286,33 @@ namespace Aaru.DiscImages stream.Read(sync, 0, 12); stream.Read(header, 0, 4); - if(cdSync.SequenceEqual(sync)) + if(_cdSync.SequenceEqual(sync)) { - rawCompactDisc = true; - hasSubchannel = imageInfo.ImageSize % 2448 == 0; - imageInfo.Sectors = imageInfo.ImageSize / (ulong)(hasSubchannel ? 2448 : 2352); - imageInfo.MediaType = MediaType.CD; - mode2 = header[3] == 0x02; - imageInfo.SectorSize = (uint)(mode2 ? 2336 : 2048); + _rawCompactDisc = true; + _hasSubchannel = _imageInfo.ImageSize % 2448 == 0; + _imageInfo.Sectors = _imageInfo.ImageSize / (ulong)(_hasSubchannel ? 2448 : 2352); + _imageInfo.MediaType = MediaType.CD; + _mode2 = header[3] == 0x02; + _imageInfo.SectorSize = (uint)(_mode2 ? 2336 : 2048); } } // Sharp X68000 SASI hard disks - if(extension == ".hdf") - if(imageInfo.ImageSize % 256 == 0) + if(_extension == ".hdf") + if(_imageInfo.ImageSize % 256 == 0) { - imageInfo.SectorSize = 256; - imageInfo.Sectors = imageInfo.ImageSize / imageInfo.SectorSize; - imageInfo.MediaType = MediaType.GENERIC_HDD; + _imageInfo.SectorSize = 256; + _imageInfo.Sectors = _imageInfo.ImageSize / _imageInfo.SectorSize; + _imageInfo.MediaType = MediaType.GENERIC_HDD; } // Search for known tags string basename = imageFilter.GetBasePath(); - basename = basename.Substring(0, basename.Length - extension.Length); + basename = basename.Substring(0, basename.Length - _extension.Length); - mediaTags = new Dictionary(); + _mediaTags = new Dictionary(); - foreach((MediaTagType tag, string name) sidecar in readWriteSidecars) + foreach((MediaTagType tag, string name) sidecar in _readWriteSidecars) try { var filters = new FiltersList(); @@ -325,593 +325,593 @@ namespace Aaru.DiscImages AaruConsole.DebugWriteLine("ZZZRawImage Plugin", "Found media tag {0}", sidecar.tag); byte[] data = new byte[filter.GetDataForkLength()]; filter.GetDataForkStream().Read(data, 0, data.Length); - mediaTags.Add(sidecar.tag, data); + _mediaTags.Add(sidecar.tag, data); } catch(IOException) {} // If there are INQUIRY and IDENTIFY tags, it's ATAPI - if(mediaTags.ContainsKey(MediaTagType.SCSI_INQUIRY)) - if(mediaTags.TryGetValue(MediaTagType.ATA_IDENTIFY, out byte[] tag)) + if(_mediaTags.ContainsKey(MediaTagType.SCSI_INQUIRY)) + if(_mediaTags.TryGetValue(MediaTagType.ATA_IDENTIFY, out byte[] tag)) { - mediaTags.Remove(MediaTagType.ATA_IDENTIFY); - mediaTags.Add(MediaTagType.ATAPI_IDENTIFY, tag); + _mediaTags.Remove(MediaTagType.ATA_IDENTIFY); + _mediaTags.Add(MediaTagType.ATAPI_IDENTIFY, tag); } // It is a blu-ray - if(mediaTags.ContainsKey(MediaTagType.BD_DI)) + if(_mediaTags.ContainsKey(MediaTagType.BD_DI)) { - imageInfo.MediaType = MediaType.BDROM; + _imageInfo.MediaType = MediaType.BDROM; - if(mediaTags.TryGetValue(MediaTagType.DVD_BCA, out byte[] bca)) + if(_mediaTags.TryGetValue(MediaTagType.DVD_BCA, out byte[] bca)) { - mediaTags.Remove(MediaTagType.DVD_BCA); - mediaTags.Add(MediaTagType.BD_BCA, bca); + _mediaTags.Remove(MediaTagType.DVD_BCA); + _mediaTags.Add(MediaTagType.BD_BCA, bca); } - if(mediaTags.TryGetValue(MediaTagType.DVDRAM_DDS, out byte[] dds)) + if(_mediaTags.TryGetValue(MediaTagType.DVDRAM_DDS, out byte[] dds)) { - imageInfo.MediaType = MediaType.BDRE; - mediaTags.Remove(MediaTagType.DVDRAM_DDS); - mediaTags.Add(MediaTagType.BD_DDS, dds); + _imageInfo.MediaType = MediaType.BDRE; + _mediaTags.Remove(MediaTagType.DVDRAM_DDS); + _mediaTags.Add(MediaTagType.BD_DDS, dds); } - if(mediaTags.TryGetValue(MediaTagType.DVDRAM_SpareArea, out byte[] sai)) + if(_mediaTags.TryGetValue(MediaTagType.DVDRAM_SpareArea, out byte[] sai)) { - imageInfo.MediaType = MediaType.BDRE; - mediaTags.Remove(MediaTagType.DVDRAM_SpareArea); - mediaTags.Add(MediaTagType.BD_SpareArea, sai); + _imageInfo.MediaType = MediaType.BDRE; + _mediaTags.Remove(MediaTagType.DVDRAM_SpareArea); + _mediaTags.Add(MediaTagType.BD_SpareArea, sai); } } // It is a DVD - if(mediaTags.TryGetValue(MediaTagType.DVD_PFI, out byte[] pfi)) + if(_mediaTags.TryGetValue(MediaTagType.DVD_PFI, out byte[] pfi)) { PFI.PhysicalFormatInformation decPfi = PFI.Decode(pfi).Value; switch(decPfi.DiskCategory) { case DiskCategory.DVDPR: - imageInfo.MediaType = MediaType.DVDPR; + _imageInfo.MediaType = MediaType.DVDPR; break; case DiskCategory.DVDPRDL: - imageInfo.MediaType = MediaType.DVDPRDL; + _imageInfo.MediaType = MediaType.DVDPRDL; break; case DiskCategory.DVDPRW: - imageInfo.MediaType = MediaType.DVDPRW; + _imageInfo.MediaType = MediaType.DVDPRW; break; case DiskCategory.DVDPRWDL: - imageInfo.MediaType = MediaType.DVDPRWDL; + _imageInfo.MediaType = MediaType.DVDPRWDL; break; case DiskCategory.DVDR: - imageInfo.MediaType = decPfi.PartVersion == 6 ? MediaType.DVDRDL : MediaType.DVDR; + _imageInfo.MediaType = decPfi.PartVersion == 6 ? MediaType.DVDRDL : MediaType.DVDR; break; case DiskCategory.DVDRAM: - imageInfo.MediaType = MediaType.DVDRAM; + _imageInfo.MediaType = MediaType.DVDRAM; break; default: - imageInfo.MediaType = MediaType.DVDROM; + _imageInfo.MediaType = MediaType.DVDROM; break; case DiskCategory.DVDRW: - imageInfo.MediaType = decPfi.PartVersion == 3 ? MediaType.DVDRWDL : MediaType.DVDRW; + _imageInfo.MediaType = decPfi.PartVersion == 3 ? MediaType.DVDRWDL : MediaType.DVDRW; break; case DiskCategory.HDDVDR: - imageInfo.MediaType = MediaType.HDDVDR; + _imageInfo.MediaType = MediaType.HDDVDR; break; case DiskCategory.HDDVDRAM: - imageInfo.MediaType = MediaType.HDDVDRAM; + _imageInfo.MediaType = MediaType.HDDVDRAM; break; case DiskCategory.HDDVDROM: - imageInfo.MediaType = MediaType.HDDVDROM; + _imageInfo.MediaType = MediaType.HDDVDROM; break; case DiskCategory.HDDVDRW: - imageInfo.MediaType = MediaType.HDDVDRW; + _imageInfo.MediaType = MediaType.HDDVDRW; break; case DiskCategory.Nintendo: - imageInfo.MediaType = decPfi.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD; + _imageInfo.MediaType = decPfi.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD; break; case DiskCategory.UMD: - imageInfo.MediaType = MediaType.UMD; + _imageInfo.MediaType = MediaType.UMD; break; } - if((imageInfo.MediaType == MediaType.DVDR || imageInfo.MediaType == MediaType.DVDRW || - imageInfo.MediaType == MediaType.HDDVDR) && - mediaTags.TryGetValue(MediaTagType.DVD_MediaIdentifier, out byte[] mid)) + if((_imageInfo.MediaType == MediaType.DVDR || _imageInfo.MediaType == MediaType.DVDRW || + _imageInfo.MediaType == MediaType.HDDVDR) && + _mediaTags.TryGetValue(MediaTagType.DVD_MediaIdentifier, out byte[] mid)) { - mediaTags.Remove(MediaTagType.DVD_MediaIdentifier); - mediaTags.Add(MediaTagType.DVDR_MediaIdentifier, mid); + _mediaTags.Remove(MediaTagType.DVD_MediaIdentifier); + _mediaTags.Add(MediaTagType.DVDR_MediaIdentifier, mid); } // Check for Xbox - if(mediaTags.TryGetValue(MediaTagType.DVD_DMI, out byte[] dmi)) + if(_mediaTags.TryGetValue(MediaTagType.DVD_DMI, out byte[] dmi)) if(DMI.IsXbox(dmi) || DMI.IsXbox360(dmi)) if(DMI.IsXbox(dmi)) { - imageInfo.MediaType = MediaType.XGD; + _imageInfo.MediaType = MediaType.XGD; } else if(DMI.IsXbox360(dmi)) { - imageInfo.MediaType = MediaType.XGD2; + _imageInfo.MediaType = MediaType.XGD2; // All XGD3 all have the same number of blocks - if(imageInfo.Sectors == 25063 || // Locked (or non compatible drive) - imageInfo.Sectors == 4229664 || // Xtreme unlock - imageInfo.Sectors == 4246304) // Wxripper unlock - imageInfo.MediaType = MediaType.XGD3; + if(_imageInfo.Sectors == 25063 || // Locked (or non compatible drive) + _imageInfo.Sectors == 4229664 || // Xtreme unlock + _imageInfo.Sectors == 4246304) // Wxripper unlock + _imageInfo.MediaType = MediaType.XGD3; } } // It's MultiMediaCard or SecureDigital - if(mediaTags.ContainsKey(MediaTagType.SD_CID) || - mediaTags.ContainsKey(MediaTagType.SD_CSD) || - mediaTags.ContainsKey(MediaTagType.SD_OCR)) + if(_mediaTags.ContainsKey(MediaTagType.SD_CID) || + _mediaTags.ContainsKey(MediaTagType.SD_CSD) || + _mediaTags.ContainsKey(MediaTagType.SD_OCR)) { - imageInfo.MediaType = MediaType.SecureDigital; + _imageInfo.MediaType = MediaType.SecureDigital; - if(mediaTags.ContainsKey(MediaTagType.MMC_ExtendedCSD) || - !mediaTags.ContainsKey(MediaTagType.SD_SCR)) + if(_mediaTags.ContainsKey(MediaTagType.MMC_ExtendedCSD) || + !_mediaTags.ContainsKey(MediaTagType.SD_SCR)) { - imageInfo.MediaType = MediaType.MMC; + _imageInfo.MediaType = MediaType.MMC; - if(mediaTags.TryGetValue(MediaTagType.SD_CID, out byte[] cid)) + if(_mediaTags.TryGetValue(MediaTagType.SD_CID, out byte[] cid)) { - mediaTags.Remove(MediaTagType.SD_CID); - mediaTags.Add(MediaTagType.MMC_CID, cid); + _mediaTags.Remove(MediaTagType.SD_CID); + _mediaTags.Add(MediaTagType.MMC_CID, cid); } - if(mediaTags.TryGetValue(MediaTagType.SD_CSD, out byte[] csd)) + if(_mediaTags.TryGetValue(MediaTagType.SD_CSD, out byte[] csd)) { - mediaTags.Remove(MediaTagType.SD_CSD); - mediaTags.Add(MediaTagType.MMC_CSD, csd); + _mediaTags.Remove(MediaTagType.SD_CSD); + _mediaTags.Add(MediaTagType.MMC_CSD, csd); } - if(mediaTags.TryGetValue(MediaTagType.SD_OCR, out byte[] ocr)) + if(_mediaTags.TryGetValue(MediaTagType.SD_OCR, out byte[] ocr)) { - mediaTags.Remove(MediaTagType.SD_OCR); - mediaTags.Add(MediaTagType.MMC_OCR, ocr); + _mediaTags.Remove(MediaTagType.SD_OCR); + _mediaTags.Add(MediaTagType.MMC_OCR, ocr); } } } // It's a compact disc - if(mediaTags.ContainsKey(MediaTagType.CD_FullTOC)) + if(_mediaTags.ContainsKey(MediaTagType.CD_FullTOC)) { - imageInfo.MediaType = imageInfo.Sectors > 360000 ? MediaType.DDCD : MediaType.CD; + _imageInfo.MediaType = _imageInfo.Sectors > 360000 ? MediaType.DDCD : MediaType.CD; // Only CD-R and CD-RW have ATIP - if(mediaTags.TryGetValue(MediaTagType.CD_ATIP, out byte[] atipBuf)) + if(_mediaTags.TryGetValue(MediaTagType.CD_ATIP, out byte[] atipBuf)) { ATIP.CDATIP? atip = ATIP.Decode(atipBuf); if(atip.HasValue) - imageInfo.MediaType = atip.Value.DiscType ? MediaType.CDRW : MediaType.CDR; + _imageInfo.MediaType = atip.Value.DiscType ? MediaType.CDRW : MediaType.CDR; } - if(mediaTags.TryGetValue(MediaTagType.Floppy_LeadOut, out byte[] leadout)) + if(_mediaTags.TryGetValue(MediaTagType.Floppy_LeadOut, out byte[] leadout)) { - mediaTags.Remove(MediaTagType.Floppy_LeadOut); - mediaTags.Add(MediaTagType.CD_LeadOut, leadout); + _mediaTags.Remove(MediaTagType.Floppy_LeadOut); + _mediaTags.Add(MediaTagType.CD_LeadOut, leadout); } } - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.ACORN_35_DS_DD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 5; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 5; break; case MediaType.ACORN_35_DS_HD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 10; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 10; break; case MediaType.ACORN_525_DS_DD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 16; break; case MediaType.ACORN_525_SS_DD_40: - imageInfo.Cylinders = 40; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 16; break; case MediaType.ACORN_525_SS_DD_80: - imageInfo.Cylinders = 80; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 16; break; case MediaType.ACORN_525_SS_SD_40: - imageInfo.Cylinders = 40; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 10; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 10; break; case MediaType.ACORN_525_SS_SD_80: - imageInfo.Cylinders = 80; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 10; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 10; break; case MediaType.Apple32DS: - imageInfo.Cylinders = 35; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 13; + _imageInfo.Cylinders = 35; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 13; break; case MediaType.Apple32SS: - imageInfo.Cylinders = 36; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 13; + _imageInfo.Cylinders = 36; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 13; break; case MediaType.Apple33DS: - imageInfo.Cylinders = 35; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 35; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 16; break; case MediaType.Apple33SS: - imageInfo.Cylinders = 35; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 35; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 16; break; case MediaType.AppleSonyDS: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 10; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 10; break; case MediaType.AppleSonySS: - imageInfo.Cylinders = 80; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 10; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 10; break; case MediaType.ATARI_35_DS_DD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 10; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 10; break; case MediaType.ATARI_35_DS_DD_11: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 11; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 11; break; case MediaType.ATARI_35_SS_DD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 10; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 10; break; case MediaType.ATARI_35_SS_DD_11: - imageInfo.Cylinders = 80; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 11; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 11; break; case MediaType.ATARI_525_ED: - imageInfo.Cylinders = 40; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 26; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 26; break; case MediaType.ATARI_525_SD: - imageInfo.Cylinders = 40; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 18; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 18; break; case MediaType.CBM_35_DD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 10; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 10; break; case MediaType.CBM_AMIGA_35_DD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 11; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 11; break; case MediaType.CBM_AMIGA_35_HD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 22; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 22; break; case MediaType.DMF: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 21; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 21; break; case MediaType.DOS_35_DS_DD_9: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 9; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 9; break; case MediaType.Apricot_35: - imageInfo.Cylinders = 70; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 9; + _imageInfo.Cylinders = 70; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 9; break; case MediaType.DOS_35_ED: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 36; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 36; break; case MediaType.DOS_35_HD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 18; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 18; break; case MediaType.DOS_35_SS_DD_9: - imageInfo.Cylinders = 80; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 9; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 9; break; case MediaType.DOS_525_DS_DD_8: - imageInfo.Cylinders = 40; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 8; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 8; break; case MediaType.DOS_525_DS_DD_9: - imageInfo.Cylinders = 40; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 9; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 9; break; case MediaType.DOS_525_HD: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 15; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 15; break; case MediaType.DOS_525_SS_DD_8: - imageInfo.Cylinders = 40; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 8; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 8; break; case MediaType.DOS_525_SS_DD_9: - imageInfo.Cylinders = 40; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 9; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 9; break; case MediaType.ECMA_54: - imageInfo.Cylinders = 77; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 26; + _imageInfo.Cylinders = 77; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 26; break; case MediaType.ECMA_59: - imageInfo.Cylinders = 77; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 26; + _imageInfo.Cylinders = 77; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 26; break; case MediaType.ECMA_66: - imageInfo.Cylinders = 35; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 9; + _imageInfo.Cylinders = 35; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 9; break; case MediaType.ECMA_69_8: - imageInfo.Cylinders = 77; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 8; + _imageInfo.Cylinders = 77; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 8; break; case MediaType.ECMA_70: - imageInfo.Cylinders = 40; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 40; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 16; break; case MediaType.ECMA_78: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 16; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 16; break; case MediaType.ECMA_99_15: - imageInfo.Cylinders = 77; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 15; + _imageInfo.Cylinders = 77; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 15; break; case MediaType.ECMA_99_26: - imageInfo.Cylinders = 77; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 26; + _imageInfo.Cylinders = 77; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 26; break; case MediaType.ECMA_99_8: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 8; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 8; break; case MediaType.FDFORMAT_35_DD: - imageInfo.Cylinders = 82; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 10; + _imageInfo.Cylinders = 82; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 10; break; case MediaType.FDFORMAT_35_HD: - imageInfo.Cylinders = 82; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 21; + _imageInfo.Cylinders = 82; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 21; break; case MediaType.FDFORMAT_525_HD: - imageInfo.Cylinders = 82; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 17; + _imageInfo.Cylinders = 82; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 17; break; case MediaType.IBM23FD: - imageInfo.Cylinders = 32; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 8; + _imageInfo.Cylinders = 32; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 8; break; case MediaType.IBM33FD_128: - imageInfo.Cylinders = 73; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 26; + _imageInfo.Cylinders = 73; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 26; break; case MediaType.IBM33FD_256: - imageInfo.Cylinders = 74; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 15; + _imageInfo.Cylinders = 74; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 15; break; case MediaType.IBM33FD_512: - imageInfo.Cylinders = 74; - imageInfo.Heads = 1; - imageInfo.SectorsPerTrack = 8; + _imageInfo.Cylinders = 74; + _imageInfo.Heads = 1; + _imageInfo.SectorsPerTrack = 8; break; case MediaType.IBM43FD_128: - imageInfo.Cylinders = 74; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 26; + _imageInfo.Cylinders = 74; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 26; break; case MediaType.IBM43FD_256: - imageInfo.Cylinders = 74; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 15; + _imageInfo.Cylinders = 74; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 15; break; case MediaType.IBM53FD_1024: - imageInfo.Cylinders = 74; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 8; + _imageInfo.Cylinders = 74; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 8; break; case MediaType.IBM53FD_256: - imageInfo.Cylinders = 74; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 26; + _imageInfo.Cylinders = 74; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 26; break; case MediaType.IBM53FD_512: - imageInfo.Cylinders = 74; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 15; + _imageInfo.Cylinders = 74; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 15; break; case MediaType.NEC_35_TD: - imageInfo.Cylinders = 240; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 38; + _imageInfo.Cylinders = 240; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 38; break; case MediaType.NEC_525_HD: - imageInfo.Cylinders = 77; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 8; + _imageInfo.Cylinders = 77; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 8; break; case MediaType.XDF_35: - imageInfo.Cylinders = 80; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 23; + _imageInfo.Cylinders = 80; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 23; break; // Following ones are what the device itself report, not the physical geometry case MediaType.Jaz: - imageInfo.Cylinders = 1021; - imageInfo.Heads = 64; - imageInfo.SectorsPerTrack = 32; + _imageInfo.Cylinders = 1021; + _imageInfo.Heads = 64; + _imageInfo.SectorsPerTrack = 32; break; case MediaType.PocketZip: - imageInfo.Cylinders = 154; - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 32; + _imageInfo.Cylinders = 154; + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 32; break; case MediaType.LS120: - imageInfo.Cylinders = 963; - imageInfo.Heads = 8; - imageInfo.SectorsPerTrack = 32; + _imageInfo.Cylinders = 963; + _imageInfo.Heads = 8; + _imageInfo.SectorsPerTrack = 32; break; case MediaType.LS240: - imageInfo.Cylinders = 262; - imageInfo.Heads = 32; - imageInfo.SectorsPerTrack = 56; + _imageInfo.Cylinders = 262; + _imageInfo.Heads = 32; + _imageInfo.SectorsPerTrack = 56; break; case MediaType.FD32MB: - imageInfo.Cylinders = 1024; - imageInfo.Heads = 2; - imageInfo.SectorsPerTrack = 32; + _imageInfo.Cylinders = 1024; + _imageInfo.Heads = 2; + _imageInfo.SectorsPerTrack = 32; break; case MediaType.ZIP100: - imageInfo.Cylinders = 96; - imageInfo.Heads = 64; - imageInfo.SectorsPerTrack = 32; + _imageInfo.Cylinders = 96; + _imageInfo.Heads = 64; + _imageInfo.SectorsPerTrack = 32; break; case MediaType.ZIP250: - imageInfo.Cylinders = 239; - imageInfo.Heads = 64; - imageInfo.SectorsPerTrack = 32; + _imageInfo.Cylinders = 239; + _imageInfo.Heads = 64; + _imageInfo.SectorsPerTrack = 32; break; default: - imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63); - imageInfo.Heads = 16; - imageInfo.SectorsPerTrack = 63; + _imageInfo.Cylinders = (uint)(_imageInfo.Sectors / 16 / 63); + _imageInfo.Heads = 16; + _imageInfo.SectorsPerTrack = 63; break; } // It's SCSI, check tags - if(mediaTags.ContainsKey(MediaTagType.SCSI_INQUIRY)) + if(_mediaTags.ContainsKey(MediaTagType.SCSI_INQUIRY)) { PeripheralDeviceTypes devType = PeripheralDeviceTypes.DirectAccess; Inquiry? scsiInq = null; - if(mediaTags.TryGetValue(MediaTagType.SCSI_INQUIRY, out byte[] inq)) + if(_mediaTags.TryGetValue(MediaTagType.SCSI_INQUIRY, out byte[] inq)) { scsiInq = Inquiry.Decode(inq); devType = (PeripheralDeviceTypes)(inq[0] & 0x1F); @@ -919,9 +919,9 @@ namespace Aaru.DiscImages Modes.DecodedMode? decMode = null; - if(mediaTags.TryGetValue(MediaTagType.SCSI_MODESENSE_6, out byte[] mode6)) + if(_mediaTags.TryGetValue(MediaTagType.SCSI_MODESENSE_6, out byte[] mode6)) decMode = Modes.DecodeMode6(mode6, devType); - else if(mediaTags.TryGetValue(MediaTagType.SCSI_MODESENSE_10, out byte[] mode10)) + else if(_mediaTags.TryGetValue(MediaTagType.SCSI_MODESENSE_10, out byte[] mode10)) decMode = Modes.DecodeMode10(mode10, devType); byte mediumType = 0; @@ -942,10 +942,10 @@ namespace Aaru.DiscImages if(page.Page == 0x2A && page.Subpage == 0) { - if(mediaTags.ContainsKey(MediaTagType.SCSI_MODEPAGE_2A)) - mediaTags.Remove(MediaTagType.SCSI_MODEPAGE_2A); + if(_mediaTags.ContainsKey(MediaTagType.SCSI_MODEPAGE_2A)) + _mediaTags.Remove(MediaTagType.SCSI_MODEPAGE_2A); - mediaTags.Add(MediaTagType.SCSI_MODEPAGE_2A, page.PageResponse); + _mediaTags.Add(MediaTagType.SCSI_MODEPAGE_2A, page.PageResponse); } // Rigid Disk page @@ -957,11 +957,11 @@ namespace Aaru.DiscImages if(!mode04.HasValue) continue; - imageInfo.Cylinders = mode04.Value.Cylinders; - imageInfo.Heads = mode04.Value.Heads; + _imageInfo.Cylinders = mode04.Value.Cylinders; + _imageInfo.Heads = mode04.Value.Heads; - imageInfo.SectorsPerTrack = - (uint)(imageInfo.Sectors / (mode04.Value.Cylinders * mode04.Value.Heads)); + _imageInfo.SectorsPerTrack = + (uint)(_imageInfo.Sectors / (mode04.Value.Cylinders * mode04.Value.Heads)); } // Flexible Disk Page @@ -973,60 +973,61 @@ namespace Aaru.DiscImages if(!mode05.HasValue) continue; - imageInfo.Cylinders = mode05.Value.Cylinders; - imageInfo.Heads = mode05.Value.Heads; - imageInfo.SectorsPerTrack = mode05.Value.SectorsPerTrack; + _imageInfo.Cylinders = mode05.Value.Cylinders; + _imageInfo.Heads = mode05.Value.Heads; + _imageInfo.SectorsPerTrack = mode05.Value.SectorsPerTrack; } } if(scsiInq.HasValue) { - imageInfo.DriveManufacturer = + _imageInfo.DriveManufacturer = VendorString.Prettify(StringHandlers.CToString(scsiInq.Value.VendorIdentification).Trim()); - imageInfo.DriveModel = StringHandlers.CToString(scsiInq.Value.ProductIdentification).Trim(); + _imageInfo.DriveModel = StringHandlers.CToString(scsiInq.Value.ProductIdentification).Trim(); - imageInfo.DriveFirmwareRevision = + _imageInfo.DriveFirmwareRevision = StringHandlers.CToString(scsiInq.Value.ProductRevisionLevel).Trim(); - imageInfo.MediaType = MediaTypeFromDevice.GetFromScsi((byte)devType, imageInfo.DriveManufacturer, - imageInfo.DriveModel, mediumType, densityCode, - imageInfo.Sectors, imageInfo.SectorSize); + _imageInfo.MediaType = MediaTypeFromDevice.GetFromScsi((byte)devType, _imageInfo.DriveManufacturer, + _imageInfo.DriveModel, mediumType, + densityCode, _imageInfo.Sectors, + _imageInfo.SectorSize); } - if(imageInfo.MediaType == MediaType.Unknown) - imageInfo.MediaType = devType == PeripheralDeviceTypes.OpticalDevice ? MediaType.UnknownMO - : MediaType.GENERIC_HDD; + if(_imageInfo.MediaType == MediaType.Unknown) + _imageInfo.MediaType = devType == PeripheralDeviceTypes.OpticalDevice ? MediaType.UnknownMO + : MediaType.GENERIC_HDD; } // It's ATA, check tags - if(mediaTags.TryGetValue(MediaTagType.ATA_IDENTIFY, out byte[] identifyBuf)) + if(_mediaTags.TryGetValue(MediaTagType.ATA_IDENTIFY, out byte[] identifyBuf)) { Identify.IdentifyDevice? ataId = CommonTypes.Structs.Devices.ATA.Identify.Decode(identifyBuf); if(ataId.HasValue) { - imageInfo.MediaType = (ushort)ataId.Value.GeneralConfiguration == 0x848A ? MediaType.CompactFlash - : MediaType.GENERIC_HDD; + _imageInfo.MediaType = (ushort)ataId.Value.GeneralConfiguration == 0x848A ? MediaType.CompactFlash + : MediaType.GENERIC_HDD; if(ataId.Value.Cylinders == 0 || ataId.Value.Heads == 0 || ataId.Value.SectorsPerTrack == 0) { - imageInfo.Cylinders = ataId.Value.CurrentCylinders; - imageInfo.Heads = ataId.Value.CurrentHeads; - imageInfo.SectorsPerTrack = ataId.Value.CurrentSectorsPerTrack; + _imageInfo.Cylinders = ataId.Value.CurrentCylinders; + _imageInfo.Heads = ataId.Value.CurrentHeads; + _imageInfo.SectorsPerTrack = ataId.Value.CurrentSectorsPerTrack; } else { - imageInfo.Cylinders = ataId.Value.Cylinders; - imageInfo.Heads = ataId.Value.Heads; - imageInfo.SectorsPerTrack = ataId.Value.SectorsPerTrack; + _imageInfo.Cylinders = ataId.Value.Cylinders; + _imageInfo.Heads = ataId.Value.Heads; + _imageInfo.SectorsPerTrack = ataId.Value.SectorsPerTrack; } } } - switch(imageInfo.MediaType) + switch(_imageInfo.MediaType) { case MediaType.CD: case MediaType.CDRW: @@ -1057,22 +1058,22 @@ namespace Aaru.DiscImages case MediaType.XGD3: case MediaType.PD650: case MediaType.PD650_WORM: - imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; + _imageInfo.XmlMediaType = XmlMediaType.OpticalDisc; break; default: - imageInfo.XmlMediaType = XmlMediaType.BlockMedia; + _imageInfo.XmlMediaType = XmlMediaType.BlockMedia; break; } - if(imageInfo.XmlMediaType == XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType == XmlMediaType.OpticalDisc) { - imageInfo.HasSessions = true; - imageInfo.HasPartitions = true; + _imageInfo.HasSessions = true; + _imageInfo.HasPartitions = true; } - AaruConsole.VerboseWriteLine("Raw disk image contains a disk of type {0}", imageInfo.MediaType); + AaruConsole.VerboseWriteLine("Raw disk image contains a disk of type {0}", _imageInfo.MediaType); var sidecarXs = new XmlSerializer(typeof(CICMMetadataType)); @@ -1088,51 +1089,51 @@ namespace Aaru.DiscImages // Do nothing. } - imageInfo.ReadableMediaTags = new List(mediaTags.Keys); + _imageInfo.ReadableMediaTags = new List(_mediaTags.Keys); - if(!rawCompactDisc) + if(!_rawCompactDisc) return true; - if(hasSubchannel) - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); + if(_hasSubchannel) + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); - if(mode2) + if(_mode2) { - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); } else { - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); - if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) - imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); + if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc)) + _imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); } return true; @@ -1142,29 +1143,29 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length) { - if(differentTrackZeroSize) + if(_differentTrackZeroSize) throw new NotImplementedException("Not yet implemented"); - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - Stream stream = rawImageFilter.GetDataForkStream(); + Stream stream = _rawImageFilter.GetDataForkStream(); uint sectorOffset = 0; - uint sectorSize = imageInfo.SectorSize; + uint sectorSize = _imageInfo.SectorSize; uint sectorSkip = 0; - if(rawCompactDisc) + if(_rawCompactDisc) { - sectorOffset = (uint)(mode2 ? 0 : 16); - sectorSize = (uint)(mode2 ? 2352 : 2048); - sectorSkip = (uint)(mode2 ? 0 : 288); + sectorOffset = (uint)(_mode2 ? 0 : 16); + sectorSize = (uint)(_mode2 ? 2352 : 2048); + sectorSkip = (uint)(_mode2 ? 0 : 288); } - if(hasSubchannel) + if(_hasSubchannel) sectorSkip += 96; byte[] buffer = new byte[sectorSize * length]; @@ -1172,7 +1173,7 @@ namespace Aaru.DiscImages var br = new BinaryReader(stream); br.BaseStream.Seek((long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), SeekOrigin.Begin); - if(mode2) + if(_mode2) { var mode2Ms = new MemoryStream((int)(sectorSize * length)); @@ -1205,7 +1206,7 @@ namespace Aaru.DiscImages public List GetSessionTracks(Session session) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureUnsupportedImageException("Feature not supported by image format"); if(session.SessionSequence != 1) @@ -1213,13 +1214,13 @@ namespace Aaru.DiscImages var trk = new Track { - TrackBytesPerSector = (int)imageInfo.SectorSize, - TrackEndSector = imageInfo.Sectors - 1, - TrackFilter = rawImageFilter, - TrackFile = rawImageFilter.GetFilename(), + TrackBytesPerSector = (int)_imageInfo.SectorSize, + TrackEndSector = _imageInfo.Sectors - 1, + TrackFilter = _rawImageFilter, + TrackFile = _rawImageFilter.GetFilename(), TrackFileOffset = 0, TrackFileType = "BINARY", - TrackRawBytesPerSector = (int)imageInfo.SectorSize, + TrackRawBytesPerSector = (int)_imageInfo.SectorSize, TrackSequence = 1, TrackStartSector = 0, TrackSubchannelType = TrackSubchannelType.None, @@ -1237,7 +1238,7 @@ namespace Aaru.DiscImages public List GetSessionTracks(ushort session) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureUnsupportedImageException("Feature not supported by image format"); if(session != 1) @@ -1245,13 +1246,13 @@ namespace Aaru.DiscImages var trk = new Track { - TrackBytesPerSector = (int)imageInfo.SectorSize, - TrackEndSector = imageInfo.Sectors - 1, - TrackFilter = rawImageFilter, - TrackFile = rawImageFilter.GetFilename(), + TrackBytesPerSector = (int)_imageInfo.SectorSize, + TrackEndSector = _imageInfo.Sectors - 1, + TrackFilter = _rawImageFilter, + TrackFile = _rawImageFilter.GetFilename(), TrackFileOffset = 0, TrackFileType = "BINARY", - TrackRawBytesPerSector = (int)imageInfo.SectorSize, + TrackRawBytesPerSector = (int)_imageInfo.SectorSize, TrackSequence = 1, TrackStartSector = 0, TrackSubchannelType = TrackSubchannelType.None, @@ -1269,7 +1270,7 @@ namespace Aaru.DiscImages public byte[] ReadSector(ulong sectorAddress, uint track) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureUnsupportedImageException("Feature not supported by image format"); if(track != 1) @@ -1280,7 +1281,7 @@ namespace Aaru.DiscImages public byte[] ReadSectors(ulong sectorAddress, uint length, uint track) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureUnsupportedImageException("Feature not supported by image format"); if(track != 1) @@ -1291,7 +1292,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorLong(ulong sectorAddress, uint track) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureUnsupportedImageException("Feature not supported by image format"); if(track != 1) @@ -1302,7 +1303,7 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc) throw new FeatureUnsupportedImageException("Feature not supported by image format"); if(track != 1) @@ -1313,8 +1314,8 @@ namespace Aaru.DiscImages public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || - !rawCompactDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || + !_rawCompactDisc) throw new FeatureUnsupportedImageException("Feature not supported by image format"); return ReadSectorsTag(sectorAddress, 1, tag); @@ -1322,26 +1323,26 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || - !rawCompactDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || + !_rawCompactDisc) throw new FeatureUnsupportedImageException("Feature not supported by image format"); - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); uint sectorOffset; uint sectorSize; uint sectorSkip = 0; - if(!hasSubchannel && + if(!_hasSubchannel && tag == SectorTagType.CdSectorSubchannel) throw new ArgumentException("No tags in image for requested track", nameof(tag)); // Requires reading sector - if(mode2) + if(_mode2) { if(tag != SectorTagType.CdSectorSubchannel) throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented"); @@ -1423,7 +1424,7 @@ namespace Aaru.DiscImages byte[] buffer = new byte[sectorSize * length]; - Stream stream = rawImageFilter.GetDataForkStream(); + Stream stream = _rawImageFilter.GetDataForkStream(); var br = new BinaryReader(stream); br.BaseStream.Seek((long)(sectorAddress * (sectorOffset + sectorSize + sectorSkip)), SeekOrigin.Begin); @@ -1446,25 +1447,25 @@ namespace Aaru.DiscImages public byte[] ReadSectorsLong(ulong sectorAddress, uint length) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || - !rawCompactDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || + !_rawCompactDisc) throw new FeatureUnsupportedImageException("Feature not supported by image format"); - if(sectorAddress > imageInfo.Sectors - 1) + if(sectorAddress > _imageInfo.Sectors - 1) throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); const uint SECTOR_SIZE = 2352; uint sectorSkip = 0; - if(hasSubchannel) + if(_hasSubchannel) sectorSkip += 96; byte[] buffer = new byte[SECTOR_SIZE * length]; - Stream stream = rawImageFilter.GetDataForkStream(); + Stream stream = _rawImageFilter.GetDataForkStream(); var br = new BinaryReader(stream); br.BaseStream.Seek((long)(sectorAddress * (SECTOR_SIZE + sectorSkip)), SeekOrigin.Begin); @@ -1485,7 +1486,7 @@ namespace Aaru.DiscImages public byte[] ReadDiskTag(MediaTagType tag) { - if(mediaTags.TryGetValue(tag, out byte[] data)) + if(_mediaTags.TryGetValue(tag, out byte[] data)) return data; throw new FeatureNotPresentImageException("Requested tag is not present in image"); @@ -1493,8 +1494,8 @@ namespace Aaru.DiscImages public byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || - !rawCompactDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || + !_rawCompactDisc) throw new FeatureUnsupportedImageException("Feature not supported by image format"); if(track != 1) @@ -1505,8 +1506,8 @@ namespace Aaru.DiscImages public byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag) { - if(imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || - !rawCompactDisc) + if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc || + !_rawCompactDisc) throw new FeatureUnsupportedImageException("Feature not supported by image format"); if(track != 1) diff --git a/Aaru.Images/ZZZRawImage/Verify.cs b/Aaru.Images/ZZZRawImage/Verify.cs index 88667975b..9fa7c8b18 100644 --- a/Aaru.Images/ZZZRawImage/Verify.cs +++ b/Aaru.Images/ZZZRawImage/Verify.cs @@ -40,7 +40,7 @@ namespace Aaru.DiscImages { public bool? VerifySector(ulong sectorAddress) { - if(!rawCompactDisc) + if(!_rawCompactDisc) return null; byte[] buffer = ReadSectorLong(sectorAddress); @@ -51,7 +51,7 @@ namespace Aaru.DiscImages public bool? VerifySectors(ulong sectorAddress, uint length, out List failingLbas, out List unknownLbas) { - if(!rawCompactDisc) + if(!_rawCompactDisc) { failingLbas = new List(); unknownLbas = new List(); @@ -95,7 +95,7 @@ namespace Aaru.DiscImages public bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List failingLbas, out List unknownLbas) { - if(!rawCompactDisc) + if(!_rawCompactDisc) { failingLbas = new List(); unknownLbas = new List(); @@ -138,7 +138,7 @@ namespace Aaru.DiscImages public bool? VerifySector(ulong sectorAddress, uint track) { - if(!rawCompactDisc) + if(!_rawCompactDisc) return null; byte[] buffer = ReadSectorLong(sectorAddress, track); diff --git a/Aaru.Images/ZZZRawImage/Write.cs b/Aaru.Images/ZZZRawImage/Write.cs index 266b32ae9..ff79ee66e 100644 --- a/Aaru.Images/ZZZRawImage/Write.cs +++ b/Aaru.Images/ZZZRawImage/Write.cs @@ -59,7 +59,7 @@ namespace Aaru.DiscImages return false; } - imageInfo = new ImageInfo + _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, @@ -68,7 +68,7 @@ namespace Aaru.DiscImages try { - writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + _writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch(IOException e) { @@ -77,8 +77,8 @@ namespace Aaru.DiscImages return false; } - basepath = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)); - mediaTags = new Dictionary(); + _basepath = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)); + _mediaTags = new Dictionary(); IsWriting = true; ErrorMessage = null; @@ -115,10 +115,10 @@ namespace Aaru.DiscImages return false; } - if(mediaTags.ContainsKey(tag)) - mediaTags.Remove(tag); + if(_mediaTags.ContainsKey(tag)) + _mediaTags.Remove(tag); - mediaTags.Add(tag, data); + _mediaTags.Add(tag, data); return true; } @@ -132,22 +132,22 @@ namespace Aaru.DiscImages return false; } - if(data.Length != imageInfo.SectorSize) + if(data.Length != _imageInfo.SectorSize) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress >= imageInfo.Sectors) + if(sectorAddress >= _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(sectorAddress * imageInfo.SectorSize), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -163,22 +163,22 @@ namespace Aaru.DiscImages return false; } - if(data.Length % imageInfo.SectorSize != 0) + if(data.Length % _imageInfo.SectorSize != 0) { ErrorMessage = "Incorrect data size"; return false; } - if(sectorAddress + length > imageInfo.Sectors) + if(sectorAddress + length > _imageInfo.Sectors) { ErrorMessage = "Tried to write past image size"; return false; } - writingStream.Seek((long)(sectorAddress * imageInfo.SectorSize), SeekOrigin.Begin); - writingStream.Write(data, 0, data.Length); + _writingStream.Seek((long)(sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin); + _writingStream.Write(data, 0, data.Length); ErrorMessage = ""; @@ -218,19 +218,19 @@ namespace Aaru.DiscImages return false; } - writingStream.Flush(); - writingStream.Close(); + _writingStream.Flush(); + _writingStream.Close(); IsWriting = false; - foreach(KeyValuePair tag in mediaTags) + foreach(KeyValuePair tag in _mediaTags) { - string suffix = readWriteSidecars.Concat(writeOnlySidecars).Where(t => t.tag == tag.Key). - Select(t => t.name).FirstOrDefault(); + string suffix = _readWriteSidecars.Concat(_writeOnlySidecars).Where(t => t.tag == tag.Key). + Select(t => t.name).FirstOrDefault(); if(suffix == null) continue; - var tagStream = new FileStream(basepath + suffix, FileMode.Create, FileAccess.ReadWrite, + var tagStream = new FileStream(_basepath + suffix, FileMode.Create, FileAccess.ReadWrite, FileShare.None); tagStream.Write(tag.Value, 0, tag.Value.Length); diff --git a/Aaru.Images/ZZZRawImage/ZZZRawImage.cs b/Aaru.Images/ZZZRawImage/ZZZRawImage.cs index 06bdfb8be..dfc1f5962 100644 --- a/Aaru.Images/ZZZRawImage/ZZZRawImage.cs +++ b/Aaru.Images/ZZZRawImage/ZZZRawImage.cs @@ -40,18 +40,18 @@ namespace Aaru.DiscImages { public partial class ZZZRawImage : IWritableOpticalImage { - string basepath; - bool differentTrackZeroSize; - string extension; - bool hasSubchannel; - ImageInfo imageInfo; - Dictionary mediaTags; - bool mode2; - bool rawCompactDisc; - IFilter rawImageFilter; - FileStream writingStream; + string _basepath; + bool _differentTrackZeroSize; + string _extension; + bool _hasSubchannel; + ImageInfo _imageInfo; + Dictionary _mediaTags; + bool _mode2; + bool _rawCompactDisc; + IFilter _rawImageFilter; + FileStream _writingStream; - public ZZZRawImage() => imageInfo = new ImageInfo + public ZZZRawImage() => _imageInfo = new ImageInfo { ReadableSectorTags = new List(), ReadableMediaTags = new List(), diff --git a/Aaru.Tests.Devices/Aaru.Tests.Devices.csproj.DotSettings b/Aaru.Tests.Devices/Aaru.Tests.Devices.csproj.DotSettings new file mode 100644 index 000000000..1d765d2a9 --- /dev/null +++ b/Aaru.Tests.Devices/Aaru.Tests.Devices.csproj.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/Aaru.Tests/Checksums/Adler32.cs b/Aaru.Tests/Checksums/Adler32.cs index b123dfa37..9b8b81dfd 100644 --- a/Aaru.Tests/Checksums/Adler32.cs +++ b/Aaru.Tests/Checksums/Adler32.cs @@ -36,11 +36,11 @@ namespace Aaru.Tests.Checksums [TestFixture] public class Adler32 { - static readonly byte[] ExpectedEmpty = + static readonly byte[] _expectedEmpty = { 0x00, 0xf0, 0x00, 0x01 }; - static readonly byte[] ExpectedRandom = + static readonly byte[] _expectedRandom = { 0x37, 0x28, 0xd1, 0x86 }; @@ -50,21 +50,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Adler32Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] public void Adler32EmptyFile() { - byte[] result = Adler32Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty")); - Assert.AreEqual(ExpectedEmpty, result); + byte[] result = Adler32Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty")); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -72,7 +72,7 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); @@ -81,7 +81,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Adler32Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -89,21 +89,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Adler32Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } [Test] public void Adler32RandomFile() { - byte[] result = Adler32Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random")); - Assert.AreEqual(ExpectedRandom, result); + byte[] result = Adler32Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random")); + Assert.AreEqual(_expectedRandom, result); } [Test] @@ -111,8 +111,8 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); @@ -120,7 +120,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Adler32Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } } } \ No newline at end of file diff --git a/Aaru.Tests/Checksums/CRC16.cs b/Aaru.Tests/Checksums/CRC16.cs index 378f1aee9..2b9fc4621 100644 --- a/Aaru.Tests/Checksums/CRC16.cs +++ b/Aaru.Tests/Checksums/CRC16.cs @@ -36,11 +36,11 @@ namespace Aaru.Tests.Checksums [TestFixture] public class Crc16 { - static readonly byte[] ExpectedEmpty = + static readonly byte[] _expectedEmpty = { 0x00, 0x00 }; - static readonly byte[] ExpectedRandom = + static readonly byte[] _expectedRandom = { 0x2d, 0x6d }; @@ -50,21 +50,23 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); CRC16CCITTContext.Data(data, out byte[] result); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] public void Crc16EmptyFile() { - byte[] result = CRC16CCITTContext.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty")); - Assert.AreEqual(ExpectedEmpty, result); + byte[] result = + CRC16CCITTContext.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty")); + + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -72,7 +74,7 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); @@ -81,7 +83,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new CRC16CCITTContext(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -89,21 +91,23 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); CRC16CCITTContext.Data(data, out byte[] result); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } [Test] public void Crc16RandomFile() { - byte[] result = CRC16CCITTContext.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random")); - Assert.AreEqual(ExpectedRandom, result); + byte[] result = + CRC16CCITTContext.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random")); + + Assert.AreEqual(_expectedRandom, result); } [Test] @@ -111,8 +115,8 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); @@ -120,7 +124,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new CRC16CCITTContext(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } } } \ No newline at end of file diff --git a/Aaru.Tests/Checksums/CRC32.cs b/Aaru.Tests/Checksums/CRC32.cs index a2a6aa479..5939566f9 100644 --- a/Aaru.Tests/Checksums/CRC32.cs +++ b/Aaru.Tests/Checksums/CRC32.cs @@ -36,11 +36,11 @@ namespace Aaru.Tests.Checksums [TestFixture] public class Crc32 { - static readonly byte[] ExpectedEmpty = + static readonly byte[] _expectedEmpty = { 0xa7, 0x38, 0xea, 0x1c }; - static readonly byte[] ExpectedRandom = + static readonly byte[] _expectedRandom = { 0x2b, 0x6e, 0x68, 0x54 }; @@ -50,21 +50,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Crc32Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] public void Crc32EmptyFile() { - byte[] result = Crc32Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty")); - Assert.AreEqual(ExpectedEmpty, result); + byte[] result = Crc32Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty")); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -72,7 +72,7 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); @@ -81,7 +81,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Crc32Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -89,21 +89,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Crc32Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } [Test] public void Crc32RandomFile() { - byte[] result = Crc32Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random")); - Assert.AreEqual(ExpectedRandom, result); + byte[] result = Crc32Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random")); + Assert.AreEqual(_expectedRandom, result); } [Test] @@ -111,8 +111,8 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); @@ -120,7 +120,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Crc32Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } } } \ No newline at end of file diff --git a/Aaru.Tests/Checksums/CRC64.cs b/Aaru.Tests/Checksums/CRC64.cs index 376288933..0bf185fa4 100644 --- a/Aaru.Tests/Checksums/CRC64.cs +++ b/Aaru.Tests/Checksums/CRC64.cs @@ -36,11 +36,11 @@ namespace Aaru.Tests.Checksums [TestFixture] public class Crc64 { - static readonly byte[] ExpectedEmpty = + static readonly byte[] _expectedEmpty = { 0x60, 0x6b, 0x70, 0xa2, 0x3e, 0xba, 0xf6, 0xc2 }; - static readonly byte[] ExpectedRandom = + static readonly byte[] _expectedRandom = { 0xbf, 0x09, 0x99, 0x2c, 0xc5, 0xed, 0xe3, 0x8e }; @@ -50,21 +50,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Crc64Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] public void Crc64EmptyFile() { - byte[] result = Crc64Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty")); - Assert.AreEqual(ExpectedEmpty, result); + byte[] result = Crc64Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty")); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -72,7 +72,7 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); @@ -81,7 +81,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Crc64Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -89,21 +89,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Crc64Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } [Test] public void Crc64RandomFile() { - byte[] result = Crc64Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random")); - Assert.AreEqual(ExpectedRandom, result); + byte[] result = Crc64Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random")); + Assert.AreEqual(_expectedRandom, result); } [Test] @@ -111,8 +111,8 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); @@ -120,7 +120,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Crc64Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } } } \ No newline at end of file diff --git a/Aaru.Tests/Checksums/MD5.cs b/Aaru.Tests/Checksums/MD5.cs index f044557f2..7741ed7c9 100644 --- a/Aaru.Tests/Checksums/MD5.cs +++ b/Aaru.Tests/Checksums/MD5.cs @@ -36,11 +36,11 @@ namespace Aaru.Tests.Checksums [TestFixture] public class Md5 { - static readonly byte[] ExpectedEmpty = + static readonly byte[] _expectedEmpty = { 0xb6, 0xd8, 0x1b, 0x36, 0x0a, 0x56, 0x72, 0xd8, 0x0c, 0x27, 0x43, 0x0f, 0x39, 0x15, 0x3e, 0x2c }; - static readonly byte[] ExpectedRandom = + static readonly byte[] _expectedRandom = { 0xd7, 0x8f, 0x0e, 0xec, 0x41, 0x7b, 0xe3, 0x86, 0x21, 0x9b, 0x21, 0xb7, 0x00, 0x04, 0x4b, 0x95 }; @@ -50,21 +50,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Md5Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] public void Md5EmptyFile() { - byte[] result = Md5Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty")); - Assert.AreEqual(ExpectedEmpty, result); + byte[] result = Md5Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty")); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -72,7 +72,7 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); @@ -81,7 +81,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Md5Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -89,21 +89,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Md5Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } [Test] public void Md5RandomFile() { - byte[] result = Md5Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random")); - Assert.AreEqual(ExpectedRandom, result); + byte[] result = Md5Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random")); + Assert.AreEqual(_expectedRandom, result); } [Test] @@ -111,8 +111,8 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); @@ -120,7 +120,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Md5Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } } } \ No newline at end of file diff --git a/Aaru.Tests/Checksums/SHA1.cs b/Aaru.Tests/Checksums/SHA1.cs index cb7cb583c..74e8f6546 100644 --- a/Aaru.Tests/Checksums/SHA1.cs +++ b/Aaru.Tests/Checksums/SHA1.cs @@ -36,12 +36,12 @@ namespace Aaru.Tests.Checksums [TestFixture] public class Sha1 { - static readonly byte[] ExpectedEmpty = + static readonly byte[] _expectedEmpty = { 0x3b, 0x71, 0xf4, 0x3f, 0xf3, 0x0f, 0x4b, 0x15, 0xb5, 0xcd, 0x85, 0xdd, 0x9e, 0x95, 0xeb, 0xc7, 0xe8, 0x4e, 0xb5, 0xa3 }; - static readonly byte[] ExpectedRandom = + static readonly byte[] _expectedRandom = { 0x72, 0x0d, 0x3b, 0x71, 0x7d, 0xe0, 0xc7, 0x4c, 0x77, 0xdd, 0x9c, 0xaa, 0x9e, 0xba, 0x50, 0x60, 0xdc, 0xbd, 0x28, 0x8d @@ -52,21 +52,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Sha1Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] public void Sha1EmptyFile() { - byte[] result = Sha1Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty")); - Assert.AreEqual(ExpectedEmpty, result); + byte[] result = Sha1Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty")); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -74,7 +74,7 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); @@ -83,7 +83,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Sha1Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -91,21 +91,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Sha1Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } [Test] public void Sha1RandomFile() { - byte[] result = Sha1Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random")); - Assert.AreEqual(ExpectedRandom, result); + byte[] result = Sha1Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random")); + Assert.AreEqual(_expectedRandom, result); } [Test] @@ -113,8 +113,8 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); @@ -122,7 +122,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Sha1Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } } } \ No newline at end of file diff --git a/Aaru.Tests/Checksums/SHA256.cs b/Aaru.Tests/Checksums/SHA256.cs index 600edbcc3..83fec80a0 100644 --- a/Aaru.Tests/Checksums/SHA256.cs +++ b/Aaru.Tests/Checksums/SHA256.cs @@ -36,12 +36,12 @@ namespace Aaru.Tests.Checksums [TestFixture] public class Sha256 { - static readonly byte[] ExpectedEmpty = + static readonly byte[] _expectedEmpty = { 0x30, 0xe1, 0x49, 0x55, 0xeb, 0xf1, 0x35, 0x22, 0x66, 0xdc, 0x2f, 0xf8, 0x06, 0x7e, 0x68, 0x10, 0x46, 0x07, 0xe7, 0x50, 0xab, 0xb9, 0xd3, 0xb3, 0x65, 0x82, 0xb8, 0xaf, 0x90, 0x9f, 0xcb, 0x58 }; - static readonly byte[] ExpectedRandom = + static readonly byte[] _expectedRandom = { 0x4d, 0x1a, 0x6b, 0x8a, 0x54, 0x67, 0x00, 0xc4, 0x8e, 0xda, 0x70, 0xd3, 0x39, 0x1c, 0x8f, 0x15, 0x8a, 0x8d, 0x12, 0xb2, 0x38, 0x92, 0x89, 0x29, 0x50, 0x47, 0x8c, 0x41, 0x8e, 0x25, 0xcc, 0x39 @@ -52,21 +52,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Sha256Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] public void Sha256EmptyFile() { - byte[] result = Sha256Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty")); - Assert.AreEqual(ExpectedEmpty, result); + byte[] result = Sha256Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty")); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -74,7 +74,7 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); @@ -83,7 +83,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Sha256Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -91,21 +91,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Sha256Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } [Test] public void Sha256RandomFile() { - byte[] result = Sha256Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random")); - Assert.AreEqual(ExpectedRandom, result); + byte[] result = Sha256Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random")); + Assert.AreEqual(_expectedRandom, result); } [Test] @@ -113,8 +113,8 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); @@ -122,7 +122,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Sha256Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } } } \ No newline at end of file diff --git a/Aaru.Tests/Checksums/SHA384.cs b/Aaru.Tests/Checksums/SHA384.cs index b0256dabe..d7eb729e5 100644 --- a/Aaru.Tests/Checksums/SHA384.cs +++ b/Aaru.Tests/Checksums/SHA384.cs @@ -36,13 +36,13 @@ namespace Aaru.Tests.Checksums [TestFixture] public class Sha384 { - static readonly byte[] ExpectedEmpty = + static readonly byte[] _expectedEmpty = { 0x31, 0x64, 0x67, 0x3a, 0x8a, 0xc2, 0x75, 0x76, 0xab, 0x5f, 0xc0, 0x6b, 0x9a, 0xdc, 0x4c, 0xe0, 0xac, 0xa5, 0xbd, 0x30, 0x25, 0x38, 0x4b, 0x1c, 0xf2, 0x12, 0x8a, 0x87, 0x95, 0xe7, 0x47, 0xc4, 0x31, 0xe8, 0x82, 0x78, 0x5a, 0x0b, 0xf8, 0xdc, 0x70, 0xb4, 0x29, 0x95, 0xdb, 0x38, 0x85, 0x75 }; - static readonly byte[] ExpectedRandom = + static readonly byte[] _expectedRandom = { 0xdb, 0x53, 0x0e, 0x17, 0x9b, 0x81, 0xfe, 0x5f, 0x6d, 0x20, 0x41, 0x04, 0x6e, 0x77, 0xd9, 0x85, 0xf2, 0x85, 0x8a, 0x66, 0xca, 0xd3, 0x8d, 0x1a, 0xd5, 0xac, 0x67, 0xa9, 0x74, 0xe1, 0xef, 0x3f, 0x4d, 0xdf, 0x94, 0x15, @@ -54,21 +54,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Sha384Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] public void Sha384EmptyFile() { - byte[] result = Sha384Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty")); - Assert.AreEqual(ExpectedEmpty, result); + byte[] result = Sha384Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty")); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -76,7 +76,7 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); @@ -85,7 +85,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Sha384Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -93,21 +93,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Sha384Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } [Test] public void Sha384RandomFile() { - byte[] result = Sha384Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random")); - Assert.AreEqual(ExpectedRandom, result); + byte[] result = Sha384Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random")); + Assert.AreEqual(_expectedRandom, result); } [Test] @@ -115,8 +115,8 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); @@ -124,7 +124,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Sha384Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } } } \ No newline at end of file diff --git a/Aaru.Tests/Checksums/SHA512.cs b/Aaru.Tests/Checksums/SHA512.cs index 968ffd443..3450b25d6 100644 --- a/Aaru.Tests/Checksums/SHA512.cs +++ b/Aaru.Tests/Checksums/SHA512.cs @@ -36,14 +36,14 @@ namespace Aaru.Tests.Checksums [TestFixture] public class Sha512 { - static readonly byte[] ExpectedEmpty = + static readonly byte[] _expectedEmpty = { 0xd6, 0x29, 0x26, 0x85, 0xb3, 0x80, 0xe3, 0x38, 0xe0, 0x25, 0xb3, 0x41, 0x5a, 0x90, 0xfe, 0x8f, 0x9d, 0x39, 0xa4, 0x6e, 0x7b, 0xdb, 0xa8, 0xcb, 0x78, 0xc5, 0x0a, 0x33, 0x8c, 0xef, 0xca, 0x74, 0x1f, 0x69, 0xe4, 0xe4, 0x64, 0x11, 0xc3, 0x2d, 0xe1, 0xaf, 0xde, 0xdf, 0xb2, 0x68, 0xe5, 0x79, 0xa5, 0x1f, 0x81, 0xff, 0x85, 0xe5, 0x6f, 0x55, 0xb0, 0xee, 0x7c, 0x33, 0xfe, 0x8c, 0x25, 0xc9 }; - static readonly byte[] ExpectedRandom = + static readonly byte[] _expectedRandom = { 0x6a, 0x0a, 0x18, 0xc2, 0xad, 0xf8, 0x83, 0xac, 0x58, 0xe6, 0x21, 0x96, 0xdb, 0x8d, 0x3d, 0x0e, 0xb9, 0x87, 0xd1, 0x49, 0x24, 0x97, 0xdb, 0x15, 0xb9, 0xfc, 0xcc, 0xb0, 0x36, 0xdf, 0x64, 0xae, 0xdb, 0x3e, 0x82, 0xa0, @@ -56,21 +56,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Sha512Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] public void Sha512EmptyFile() { - byte[] result = Sha512Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty")); - Assert.AreEqual(ExpectedEmpty, result); + byte[] result = Sha512Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty")); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -78,7 +78,7 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); @@ -87,7 +87,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Sha512Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedEmpty, result); + Assert.AreEqual(_expectedEmpty, result); } [Test] @@ -95,21 +95,21 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); Sha512Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } [Test] public void Sha512RandomFile() { - byte[] result = Sha512Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random")); - Assert.AreEqual(ExpectedRandom, result); + byte[] result = Sha512Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random")); + Assert.AreEqual(_expectedRandom, result); } [Test] @@ -117,8 +117,8 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); @@ -126,7 +126,7 @@ namespace Aaru.Tests.Checksums IChecksum ctx = new Sha512Context(); ctx.Update(data); byte[] result = ctx.Final(); - Assert.AreEqual(ExpectedRandom, result); + Assert.AreEqual(_expectedRandom, result); } } } \ No newline at end of file diff --git a/Aaru.Tests/Checksums/SpamSum.cs b/Aaru.Tests/Checksums/SpamSum.cs index c3f395ac4..8f9b2ea06 100644 --- a/Aaru.Tests/Checksums/SpamSum.cs +++ b/Aaru.Tests/Checksums/SpamSum.cs @@ -44,7 +44,7 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); @@ -59,7 +59,7 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); @@ -76,8 +76,8 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); @@ -91,8 +91,8 @@ namespace Aaru.Tests.Checksums { byte[] data = new byte[1048576]; - var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, - FileAccess.Read); + var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), + FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); diff --git a/Aaru.Tests/Consts.cs b/Aaru.Tests/Consts.cs index 346342f01..cf4babd91 100644 --- a/Aaru.Tests/Consts.cs +++ b/Aaru.Tests/Consts.cs @@ -30,6 +30,6 @@ namespace Aaru.Tests { internal static class Consts { - public const string TestFilesRoot = "/mnt/DiscImageChef"; + public const string TEST_FILES_ROOT = "/mnt/DiscImageChef"; } } \ No newline at end of file diff --git a/Aaru.Tests/Devices/IomegaJaz.cs b/Aaru.Tests/Devices/IomegaJaz.cs index 4bf9af6c2..b8f49c442 100644 --- a/Aaru.Tests/Devices/IomegaJaz.cs +++ b/Aaru.Tests/Devices/IomegaJaz.cs @@ -38,22 +38,22 @@ namespace Aaru.Tests.Devices [TestFixture] public class IomegaJaz { - readonly string[] testfiles = + readonly string[] _testfiles = { "jaz1.bin.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.Jaz }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 2091050 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; @@ -61,16 +61,16 @@ namespace Aaru.Tests.Devices [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Device test dumps", "JAZ", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Device test dumps", "JAZ", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); } } } diff --git a/Aaru.Tests/Devices/LS120.cs b/Aaru.Tests/Devices/LS120.cs index f7398d3db..298b8e3d7 100644 --- a/Aaru.Tests/Devices/LS120.cs +++ b/Aaru.Tests/Devices/LS120.cs @@ -38,22 +38,22 @@ namespace Aaru.Tests.Devices [TestFixture] public class Ls120 { - readonly string[] testfiles = + readonly string[] _testfiles = { "ls120.bin.lz", "mf2dd.bin.lz", "mf2hd.bin.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.LS120, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 246528, 1440, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512 }; @@ -61,16 +61,16 @@ namespace Aaru.Tests.Devices [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Device test dumps", "LS-120", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Device test dumps", "LS-120", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); } } } diff --git a/Aaru.Tests/Devices/PocketZip.cs b/Aaru.Tests/Devices/PocketZip.cs index 9919818a1..7bfa324a4 100644 --- a/Aaru.Tests/Devices/PocketZip.cs +++ b/Aaru.Tests/Devices/PocketZip.cs @@ -38,22 +38,22 @@ namespace Aaru.Tests.Devices [TestFixture] public class PocketZip { - readonly string[] testfiles = + readonly string[] _testfiles = { "clik!.bin.lz", "pocketzip.bin.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.PocketZip, MediaType.PocketZip }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 78882, 78882 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; @@ -61,16 +61,16 @@ namespace Aaru.Tests.Devices [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Device test dumps", "PocketZIP", testfiles[i]); - IFilter filter = new LZip(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Device test dumps", "PocketZIP", _testfiles[i]); + IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/ADFS.cs b/Aaru.Tests/Filesystems/ADFS.cs index e3d01d459..f1c34f66b 100644 --- a/Aaru.Tests/Filesystems/ADFS.cs +++ b/Aaru.Tests/Filesystems/ADFS.cs @@ -39,50 +39,50 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Adfs { - readonly string[] testfiles = + readonly string[] _testfiles = { "adfs_d.adf.lz", "adfs_e.adf.lz", "adfs_f.adf.lz", "adfs_e+.adf.lz", "adfs_f+.adf.lz", "adfs_s.adf.lz", "adfs_m.adf.lz", "adfs_l.adf.lz", "hdd_old.hdf.lz", "hdd_new.hdf.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.ACORN_35_DS_DD, MediaType.ACORN_35_DS_DD, MediaType.ACORN_35_DS_HD, MediaType.ACORN_35_DS_DD, MediaType.ACORN_35_DS_HD, MediaType.ACORN_525_SS_DD_40, MediaType.ACORN_525_SS_DD_80, MediaType.ACORN_525_DS_DD, MediaType.GENERIC_HDD, MediaType.GENERIC_HDD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 800, 800, 1600, 800, 1600, 640, 1280, 2560, 78336, 78336 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 1024, 1024, 1024, 1024, 1024, 256, 256, 256, 256, 256 }; - readonly bool[] bootable = + readonly bool[] _bootable = { false, false, false, false, false, false, false, false, false, false }; - readonly long[] clusters = + readonly long[] _clusters = { 800, 800, 1600, 800, 1600, 640, 1280, 2560, 78336, 78336 }; - readonly uint[] clustersize = + readonly uint[] _clustersize = { 1024, 1024, 1024, 1024, 1024, 256, 256, 256, 256, 256 }; - readonly string[] volumename = + readonly string[] _volumename = { "ADFSD", "ADFSE ", null, "ADFSE+ ", null, "$", "$", "$", "VolLablOld", null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "3E48", "E13A", null, "1142", null, "F20D", "D6CA", "0CA6", "080E", null }; @@ -90,18 +90,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Acorn Advanced Disc Filing System", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", + "Acorn Advanced Disc Filing System", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new AcornADFS(); var wholePart = new Partition @@ -111,14 +111,14 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(bootable[i], fs.XmlFsType.Bootable, testfiles[i]); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Acorn Advanced Disc Filing System", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_bootable[i], fs.XmlFsType.Bootable, _testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Acorn Advanced Disc Filing System", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/AFFS.cs b/Aaru.Tests/Filesystems/AFFS.cs index a80ee7b6e..2a8df27f4 100644 --- a/Aaru.Tests/Filesystems/AFFS.cs +++ b/Aaru.Tests/Filesystems/AFFS.cs @@ -40,42 +40,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Affs { - readonly string[] testfiles = + readonly string[] _testfiles = { "amigaos_3.9.adf.lz", "amigaos_3.9_intl.adf.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.CBM_AMIGA_35_DD, MediaType.CBM_AMIGA_35_DD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1760, 1760 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1760, 1760 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "A5D9FAE2", "A5DA0CC9" }; @@ -83,18 +83,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Amiga Fast File System", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new AmigaDOSPlugin(); var wholePart = new Partition @@ -104,13 +104,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Amiga FFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Amiga FFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -118,37 +118,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class AffsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "aros.aif", "aros_intl.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 409600, 409600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 408240, 408240 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "A582DCA4", "A582BC91" }; @@ -156,17 +156,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Amiga Fast File System (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AmigaDOSPlugin(); int part = -1; @@ -180,14 +180,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Amiga FFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Amiga FFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -195,37 +195,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class AffsMbrRdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "aros.aif", "aros_intl.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 409600, 409600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 406224, 406224 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "A58348CE", "A5833CD0" }; @@ -233,17 +233,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (MBR+RDB)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", + "Amiga Fast File System (MBR+RDB)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AmigaDOSPlugin(); int part = -1; @@ -257,14 +257,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Amiga FFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Amiga FFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -272,39 +272,39 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class AffsRdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "amigaos_3.9.aif", "amigaos_3.9_intl.aif", "aros.aif", "aros_intl.aif", "amigaos_4.0.aif", "amigaos_4.0_intl.aif", "amigaos_4.0_cache.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024128, 1024128, 409600, 409600, 1024128, 1024128, 1024128 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 510032, 510032, 407232, 407232, 511040, 511040, 511040 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 512, 512, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "A56D0F5C", "A56D049C", "A58307A9", "A58304BE", "A56CC7EE", "A56CDDC4", "A56CC133" }; @@ -312,17 +312,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (RDB)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Amiga Fast File System (RDB)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AmigaDOSPlugin(); int part = -1; @@ -337,14 +337,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Amiga FFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Amiga FFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/AFFS2.cs b/Aaru.Tests/Filesystems/AFFS2.cs index 324e69df3..673570cac 100644 --- a/Aaru.Tests/Filesystems/AFFS2.cs +++ b/Aaru.Tests/Filesystems/AFFS2.cs @@ -40,37 +40,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Affs2Rdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "amigaos_4.0.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024128 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 511040 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "611D85E5" }; @@ -78,17 +78,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System 2 (RDB)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Amiga Fast File System 2 (RDB)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AmigaDOSPlugin(); int part = -1; @@ -101,14 +101,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Amiga FFS2", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Amiga FFS2", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/AFS.cs b/Aaru.Tests/Filesystems/AFS.cs index 3199d03ea..146aff82c 100644 --- a/Aaru.Tests/Filesystems/AFS.cs +++ b/Aaru.Tests/Filesystems/AFS.cs @@ -40,49 +40,49 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Afs { - readonly string[] testfiles = + readonly string[] _testfiles = { "scoopenserver_5.0.7hw_dmf.img.lz", "scoopenserver_5.0.7hw_dshd.img.lz", "scoopenserver_5.0.7hw_mf2dd.img.lz", "scoopenserver_5.0.7hw_mf2ed.img.lz", "scoopenserver_5.0.7hw_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DMF, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 3360, 2400, 1440, 5760, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1680, 1200, 720, 2880, 1440 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "", "", "", "", "" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null }; - readonly string[] type = + readonly string[] _type = { "Acer Fast Filesystem", "Acer Fast Filesystem", "Acer Fast Filesystem", "Acer Fast Filesystem", "Acer Fast Filesystem" @@ -91,16 +91,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Acer File System", testfiles[i]); - IFilter filter = new LZip(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Acer File System", + _testfiles[i]); + + IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new SysVfs(); var wholePart = new Partition @@ -110,13 +112,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -124,42 +126,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class AfsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "scoopenserver_5.0.7hw.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 510048 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null }; - readonly string[] type = + readonly string[] _type = { "Acer Fast Filesystem" }; @@ -167,17 +169,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Acer File System (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Acer File System (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new SysVfs(); int part = -1; @@ -190,14 +192,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/AOFS.cs b/Aaru.Tests/Filesystems/AOFS.cs index 2c0bc88a2..434297c49 100644 --- a/Aaru.Tests/Filesystems/AOFS.cs +++ b/Aaru.Tests/Filesystems/AOFS.cs @@ -40,42 +40,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Aofs { - readonly string[] testfiles = + readonly string[] _testfiles = { "amigaos_3.9.adf.lz", "amigaos_3.9_intl.adf.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.CBM_AMIGA_35_DD, MediaType.CBM_AMIGA_35_DD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1760, 1760 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1760, 1760 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "A5D9FE71", "A5D9F14F" }; @@ -83,18 +83,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Old File System", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Amiga Old File System", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new AmigaDOSPlugin(); var wholePart = new Partition @@ -104,13 +104,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Amiga OFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Amiga OFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -118,37 +118,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class AofsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "aros.aif", "aros_intl.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 409600, 409600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 408240, 408240 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "A582C90C", "A582CE0D" }; @@ -156,17 +156,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Old File System (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Amiga Old File System (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AmigaDOSPlugin(); int part = -1; @@ -179,14 +179,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Amiga OFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Amiga OFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -194,37 +194,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class AofsMbrRdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "aros.aif", "aros_intl.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 409600, 409600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 406224, 406224 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "A5833C5B", "A5833085" }; @@ -232,17 +232,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Old File System (MBR+RDB)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Amiga Old File System (MBR+RDB)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AmigaDOSPlugin(); int part = -1; @@ -255,14 +255,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Amiga OFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Amiga OFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -270,37 +270,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class AofsRdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "amigaos_3.9.aif", "amigaos_3.9_intl.aif", "aros.aif", "aros_intl.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024128, 1024128, 409600, 409600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 510032, 510032, 407232, 407232 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label", "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "A56D13BB", "A56D0415", "A582F3A0", "A5830B06" }; @@ -308,17 +308,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Old File System (RDB)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Amiga Old File System (RDB)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AmigaDOSPlugin(); int part = -1; @@ -333,14 +333,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Amiga OFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Amiga OFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/Atheos.cs b/Aaru.Tests/Filesystems/Atheos.cs index 7a8b80744..c78071972 100644 --- a/Aaru.Tests/Filesystems/Atheos.cs +++ b/Aaru.Tests/Filesystems/Atheos.cs @@ -40,37 +40,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class AtheosMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "syllable_0.6.7.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 4194304 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 2097120 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; @@ -78,15 +78,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "AtheOS (MBR)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "AtheOS (MBR)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AtheOS(); int part = -1; @@ -99,14 +99,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("AtheOS filesystem", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("AtheOS filesystem", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/BeFS.cs b/Aaru.Tests/Filesystems/BeFS.cs index 758e8159f..0c607dd40 100644 --- a/Aaru.Tests/Filesystems/BeFS.cs +++ b/Aaru.Tests/Filesystems/BeFS.cs @@ -40,47 +40,47 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class BeFs { - readonly string[] testfiles = + readonly string[] _testfiles = { "beos_r3.1.img.lz", "beos_r4.5.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DOS_35_HD, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 2880, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1440, 1440 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null }; - readonly string[] oemid = + readonly string[] _oemid = { null, null }; @@ -88,16 +88,16 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Be File System", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Be File System", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new BeFS(); var wholePart = new Partition @@ -107,14 +107,14 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("BeFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("BeFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -122,42 +122,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class BeFsApm { - readonly string[] testfiles = + readonly string[] _testfiles = { "beos_r3.1.aif", "beos_r4.5.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1572864, 1572864 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 786336, 786336 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null }; - readonly string[] oemid = + readonly string[] _oemid = { null, null }; @@ -165,17 +165,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Be File System (APM)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Be File System (APM)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new BeFS(); int part = -1; @@ -188,15 +188,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("BeFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("BeFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -204,37 +204,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class BeFsGpt { - readonly string[] testfiles = + readonly string[] _testfiles = { "haiku_hrev51259.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 8388608 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 2096640 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 2048 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null }; @@ -242,17 +242,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Be File System (GPT)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Be File System (GPT)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new BeFS(); int part = -1; @@ -265,14 +265,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("BeFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("BeFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -280,37 +280,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class BeFsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "beos_r3.1.aif", "beos_r4.5.aif", "haiku_hrev51259.aif", "syllable_0.6.7.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1572864, 1572864, 8388608, 2097152 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 786400, 785232, 2096640, 524272 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 2048, 2048 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label", "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null }; @@ -318,17 +318,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Be File System (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Be File System (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new BeFS(); int part = -1; @@ -341,14 +341,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("BeFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("BeFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/COHERENT.cs b/Aaru.Tests/Filesystems/COHERENT.cs index 7c389b611..2d87f7b5b 100644 --- a/Aaru.Tests/Filesystems/COHERENT.cs +++ b/Aaru.Tests/Filesystems/COHERENT.cs @@ -40,48 +40,48 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Coherent { - readonly string[] testfiles = + readonly string[] _testfiles = { "coherentunix_4.2.10_dsdd.img.lz", "coherentunix_4.2.10_dshd.img.lz", "coherentunix_4.2.10_mf2dd.img.lz", "coherentunix_4.2.10_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DOS_525_DS_DD_9, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 720, 2400, 1440, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 720, 2400, 1440, 2880 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512, 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "noname", "noname", "noname", "noname" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null }; - readonly string[] type = + readonly string[] _type = { "Coherent fs", "Coherent fs", "Coherent fs", "Coherent fs" }; @@ -89,18 +89,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "COHERENT filesystem", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "COHERENT filesystem", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new SysVfs(); var wholePart = new Partition @@ -110,13 +110,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -124,42 +124,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class CoherentMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "coherentunix_4.2.10.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 510048 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; - readonly string[] type = + readonly string[] _type = { "Coherent fs" }; @@ -167,17 +167,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "COHERENT filesystem (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "COHERENT filesystem (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new SysVfs(); int part = -1; @@ -190,14 +190,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/DTFS.cs b/Aaru.Tests/Filesystems/DTFS.cs index a41b5a2f4..7018f0d6a 100644 --- a/Aaru.Tests/Filesystems/DTFS.cs +++ b/Aaru.Tests/Filesystems/DTFS.cs @@ -40,49 +40,49 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Dtfs { - readonly string[] testfiles = + readonly string[] _testfiles = { "scoopenserver_5.0.7hw_dmf.img.lz", "scoopenserver_5.0.7hw_dshd.img.lz", "scoopenserver_5.0.7hw_mf2dd.img.lz", "scoopenserver_5.0.7hw_mf2ed.img.lz", "scoopenserver_5.0.7hw_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DMF, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 3360, 2400, 1440, 5760, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1680, 1200, 720, 2880, 1440 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "", "", "", "", "" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null }; - readonly string[] type = + readonly string[] _type = { "DTFS", "DTFS", "DTFS", "DTFS", "DTFS" }; @@ -90,16 +90,16 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "DTFS", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "DTFS", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new SysVfs(); var wholePart = new Partition @@ -109,13 +109,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -123,42 +123,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class DtfsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "scoopenserver_5.0.7hw.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 510048 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; - readonly string[] type = + readonly string[] _type = { "DTFS" }; @@ -166,15 +166,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "DTFS (MBR)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "DTFS (MBR)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new SysVfs(); int part = -1; @@ -187,14 +187,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/EAFS.cs b/Aaru.Tests/Filesystems/EAFS.cs index fa7c2fdd6..53671631d 100644 --- a/Aaru.Tests/Filesystems/EAFS.cs +++ b/Aaru.Tests/Filesystems/EAFS.cs @@ -40,49 +40,49 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Eafs { - readonly string[] testfiles = + readonly string[] _testfiles = { "scoopenserver_5.0.7hw_dmf.img.lz", "scoopenserver_5.0.7hw_dshd.img.lz", "scoopenserver_5.0.7hw_mf2dd.img.lz", "scoopenserver_5.0.7hw_mf2ed.img.lz", "scoopenserver_5.0.7hw_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DMF, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 3360, 2400, 1440, 5760, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1680, 1200, 720, 2880, 1440 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "", "", "", "", "" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null }; - readonly string[] type = + readonly string[] _type = { "Extended Acer Fast Filesystem", "Extended Acer Fast Filesystem", "Extended Acer Fast Filesystem", "Extended Acer Fast Filesystem", "Extended Acer Fast Filesystem" @@ -91,16 +91,16 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "EAFS", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "EAFS", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new SysVfs(); var wholePart = new Partition @@ -110,13 +110,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -124,42 +124,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class EafsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "scoopenserver_5.0.7hw.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 510048 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; - readonly string[] type = + readonly string[] _type = { "Extended Acer Fast Filesystem" }; @@ -167,15 +167,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "EAFS (MBR)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "EAFS (MBR)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new SysVfs(); int part = -1; @@ -188,14 +188,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/F2FS.cs b/Aaru.Tests/Filesystems/F2FS.cs index ede852922..ed672c5b6 100644 --- a/Aaru.Tests/Filesystems/F2FS.cs +++ b/Aaru.Tests/Filesystems/F2FS.cs @@ -41,37 +41,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class F2Fs { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif", "linux_4.19_f2fs_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144, 2097152 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 32512, 261888 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { "VolumeLabel", "DicSetter" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "81bd3a4e-de0c-484c-becc-aaa479b2070a", "422bd2a8-68ab-6f45-9a04-9c264d07dd6e" }; @@ -79,17 +79,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "F2FS", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "F2FS", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IPartition parts = new MBR(); - Assert.AreEqual(true, parts.GetInformation(image, out List partitions, 0), testfiles[i]); + Assert.AreEqual(true, parts.GetInformation(image, out List partitions, 0), _testfiles[i]); IFilesystem fs = new F2FS(); int part = -1; @@ -101,14 +101,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("F2FS filesystem", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("F2FS filesystem", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/FAT12.cs b/Aaru.Tests/Filesystems/FAT12.cs index 35d8db753..01ba72488 100644 --- a/Aaru.Tests/Filesystems/FAT12.cs +++ b/Aaru.Tests/Filesystems/FAT12.cs @@ -40,7 +40,7 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat12 { - readonly string[] testfiles = + readonly string[] _testfiles = { // Concurrent DOS 6.00 "concurrentdos_6.00_dshd.img.lz", "concurrentdos_6.00_mf2dd.img.lz", "concurrentdos_6.00_mf2hd.img.lz", @@ -375,7 +375,7 @@ namespace Aaru.Tests.Filesystems "geos41_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { // Concurrent DOS 6.00 MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD, @@ -693,7 +693,7 @@ namespace Aaru.Tests.Filesystems MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { // Concurrent DOS 6.00 2400, 1440, 2880, @@ -963,7 +963,7 @@ namespace Aaru.Tests.Filesystems 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { // Concurrent DOS 6.00 512, 512, 512, @@ -1233,7 +1233,7 @@ namespace Aaru.Tests.Filesystems 512 }; - readonly long[] clusters = + readonly long[] _clusters = { // Concurrent DOS 6.00 2400, 720, 2880, @@ -1503,7 +1503,7 @@ namespace Aaru.Tests.Filesystems 2880 }; - readonly int[] clustersize = + readonly int[] _clustersize = { // Concurrent DOS 6.00 512, 1024, 512, @@ -1773,7 +1773,7 @@ namespace Aaru.Tests.Filesystems 512 }; - readonly string[] volumename = + readonly string[] _volumename = { // Concurrent DOS 6.00 null, null, null, @@ -2049,7 +2049,7 @@ namespace Aaru.Tests.Filesystems "GEOS41" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { // Concurrent DOS 6.00 null, null, null, @@ -2319,7 +2319,7 @@ namespace Aaru.Tests.Filesystems "8D684C67" }; - readonly string[] oemid = + readonly string[] _oemid = { // Concurrent DOS 6.00 "DIGITAL ", "DIGITAL ", "DIGITAL ", @@ -2592,16 +2592,16 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT12", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT12", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new FAT(); var wholePart = new Partition @@ -2611,14 +2611,14 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT12", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT12", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -2626,42 +2626,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat12Apm { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 16384 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 4076 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 2048 }; - readonly string[] volumename = + readonly string[] _volumename = { "VOLUMELABEL" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "32181F09" }; - readonly string[] oemid = + readonly string[] _oemid = { "BSD 4.4" }; @@ -2669,15 +2669,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT12 (APM)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT12 (APM)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FAT(); int part = -1; @@ -2690,15 +2690,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT12", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT12", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -2706,42 +2706,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat12Gpt { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 16384 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 4076 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 2048 }; - readonly string[] volumename = + readonly string[] _volumename = { "VOLUMELABEL" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "66901F1B" }; - readonly string[] oemid = + readonly string[] _oemid = { "BSD 4.4" }; @@ -2749,15 +2749,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT12 (GPT)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT12 (GPT)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FAT(); int part = -1; @@ -2770,15 +2770,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT12", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT12", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -2786,7 +2786,7 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat12Mbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "compaqmsdos331.aif", "drdos_3.40.aif", "drdos_3.41.aif", "drdos_5.00.aif", "drdos_6.00.aif", "drdos_7.02.aif", "drdos_7.03.aif", "drdos_8.00.aif", "msdos331.aif", "msdos401.aif", "msdos500.aif", @@ -2801,7 +2801,7 @@ namespace Aaru.Tests.Filesystems "winvista.aif", "beos_r4.5.aif", "linux.aif", "freebsd_6.1.aif", "freebsd_7.0.aif", "freebsd_8.2.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 8192, 30720, 28672, 28672, 28672, 28672, 28672, 28672, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 16384, 28672, 28672, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 8192, @@ -2810,14 +2810,14 @@ namespace Aaru.Tests.Filesystems 16384, 16384 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1000, 3654, 3520, 3520, 3520, 3520, 3520, 3520, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 2008, 3520, 3520, 4024, 4031, 4031, 4024, 4024, 4024, 4024, 4024, 4024, 4024, 4024, 1000, 1000, 2008, 2008, 2008, 2008, @@ -2825,7 +2825,7 @@ namespace Aaru.Tests.Filesystems 2044, 2044, 4016, 3072, 2040, 3584, 2044, 2044, 2044 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, @@ -2833,7 +2833,7 @@ namespace Aaru.Tests.Filesystems 4096, 4096, 2048, 2048, 4096, 2048, 4096, 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { null, "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", @@ -2846,7 +2846,7 @@ namespace Aaru.Tests.Filesystems "VolumeLabel", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null, null, null, "1BFB1273", null, "407D1907", "345D18FB", "332518F4", "395718E9", "076718EF", "1371181B", "23281816", "2F781809", null, null, "294F100F", null, null, null, null, null, @@ -2857,7 +2857,7 @@ namespace Aaru.Tests.Filesystems "02140E0B" }; - readonly string[] oemid = + readonly string[] _oemid = { "IBM 3.3", "IBM 3.2", "IBM 3.2", "IBM 3.3", "IBM 3.3", "IBM 3.3", "DRDOS 7", "IBM 5.0", "IBM 3.3", "MSDOS4.0", "MSDOS5.0", "MSDOS5.0", "MSDOS5.0", "MSDOS5.0", "MSDOS5.0", "MSDOS5.0", "MSWIN4.1", "IBM 3.3", @@ -2871,25 +2871,25 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT12 (MBR)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT12 (MBR)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FAT(); - Assert.AreEqual(true, fs.Identify(image, partitions[0]), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, partitions[0]), _testfiles[i]); fs.GetInformation(image, partitions[0], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT12", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT12", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -2897,47 +2897,47 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat12Human { - readonly string[] testfiles = + readonly string[] _testfiles = { "diska.aif", "diskb.aif" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.SHARP_525, MediaType.SHARP_525 }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1232, 1232 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 1024, 1024 }; - readonly long[] clusters = + readonly long[] _clusters = { 1232, 1232 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null }; - readonly string[] oemid = + readonly string[] _oemid = { "Hudson soft 2.00", "Hudson soft 2.00" }; @@ -2945,16 +2945,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT12 (Human68K)", testfiles[i]); - IFilter filter = new ZZZNoFilter(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT12 (Human68K)", + _testfiles[i]); + + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new FAT(); var wholePart = new Partition @@ -2964,14 +2966,14 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT12", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT12", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/FAT16.cs b/Aaru.Tests/Filesystems/FAT16.cs index 52cbf7f00..1e9c4f296 100644 --- a/Aaru.Tests/Filesystems/FAT16.cs +++ b/Aaru.Tests/Filesystems/FAT16.cs @@ -40,7 +40,7 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat16 { - readonly string[] testfiles = + readonly string[] _testfiles = { // MS-DOS 3.30A "msdos_3.30A_mf2ed.img.lz", @@ -49,7 +49,7 @@ namespace Aaru.Tests.Filesystems "msdos_3.31_mf2ed.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { // MS-DOS 3.30A MediaType.DOS_35_ED, @@ -58,7 +58,7 @@ namespace Aaru.Tests.Filesystems MediaType.DOS_35_ED }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { // MS-DOS 3.30A 5760, @@ -67,7 +67,7 @@ namespace Aaru.Tests.Filesystems 5760 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { // MS-DOS 3.30A 512, @@ -76,7 +76,7 @@ namespace Aaru.Tests.Filesystems 512 }; - readonly long[] clusters = + readonly long[] _clusters = { // MS-DOS 3.30A 5760, @@ -85,7 +85,7 @@ namespace Aaru.Tests.Filesystems 5760 }; - readonly int[] clustersize = + readonly int[] _clustersize = { // MS-DOS 3.30A 512, @@ -94,7 +94,7 @@ namespace Aaru.Tests.Filesystems 512 }; - readonly string[] volumename = + readonly string[] _volumename = { // MS-DOS 3.30A null, @@ -103,7 +103,7 @@ namespace Aaru.Tests.Filesystems null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { // MS-DOS 3.30A null, @@ -112,7 +112,7 @@ namespace Aaru.Tests.Filesystems null }; - readonly string[] oemid = + readonly string[] _oemid = { // MS-DOS 3.30A "MSDOS3.3", @@ -124,16 +124,16 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT16", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT16", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new FAT(); var wholePart = new Partition @@ -143,14 +143,14 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT16", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT16", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -158,42 +158,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat16Apm { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 63995 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 8192 }; - readonly string[] volumename = + readonly string[] _volumename = { "VOLUMELABEL" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "063D1F09" }; - readonly string[] oemid = + readonly string[] _oemid = { "BSD 4.4" }; @@ -201,15 +201,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT16 (APM)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT16 (APM)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FAT(); int part = -1; @@ -222,15 +222,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT16", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT16", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -238,42 +238,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat16Atari { - readonly string[] testfiles = + readonly string[] _testfiles = { "tos_1.04.aif", "tos_1.04_small.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 81920, 16384 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 10239, 8191 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "BA9831", "2019E1" }; - readonly string[] oemid = + readonly string[] _oemid = { null, null }; @@ -281,15 +281,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT16 (Atari)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT16 (Atari)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FAT(); int part = -1; @@ -303,15 +303,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT16", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT16", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -319,42 +319,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat16Gpt { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 63995 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 8192 }; - readonly string[] volumename = + readonly string[] _volumename = { "VOLUMELABEL" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "2E8A1F1B" }; - readonly string[] oemid = + readonly string[] _oemid = { "BSD 4.4" }; @@ -362,15 +362,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT16 (GPT)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT16 (GPT)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FAT(); int part = -1; @@ -383,15 +383,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT16", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT16", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -399,7 +399,7 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat16Mbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "drdos_3.40.aif", "drdos_3.41.aif", "drdos_5.00.aif", "drdos_6.00.aif", "drdos_7.02.aif", "drdos_7.03.aif", "drdos_8.00.aif", "msdos331.aif", "msdos401.aif", "msdos500.aif", "msdos600.aif", "msdos620rc1.aif", @@ -415,7 +415,7 @@ namespace Aaru.Tests.Filesystems "linux_4.19_fat16_msdos_flashdrive.aif", "linux_4.19_vfat16_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, @@ -425,7 +425,7 @@ namespace Aaru.Tests.Filesystems 1024000, 1024000, 1024000, 1024000, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, @@ -433,7 +433,7 @@ namespace Aaru.Tests.Filesystems 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 63882, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, 63941, @@ -442,7 +442,7 @@ namespace Aaru.Tests.Filesystems 63941, 63882, 63941, 63872, 63872 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, @@ -450,7 +450,7 @@ namespace Aaru.Tests.Filesystems 8192, 8192, 16384, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192 }; - readonly string[] volumename = + readonly string[] _volumename = { "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", null, "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", @@ -464,7 +464,7 @@ namespace Aaru.Tests.Filesystems "DICSETTER", "DICSETTER" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null, null, "1BFB0748", null, "217B1909", "0C6D18FC", "382B18F4", "3E2018E9", "0D2418EF", "195A181B", "27761816", "356B1809", null, null, "2272100F", "07280FE1", "1F630FF9", "18340FFE", @@ -475,7 +475,7 @@ namespace Aaru.Tests.Filesystems "27761816", "27761816", "27761816", "66AAF014", "5CC78D47", "A552A493", "FCC308A7" }; - readonly string[] oemid = + readonly string[] _oemid = { "IBM 3.2", "IBM 3.2", "IBM 3.3", "IBM 3.3", "IBM 3.3", "DRDOS 7", "IBM 5.0", "IBM 3.3", "MSDOS4.0", "MSDOS5.0", "MSDOS5.0", "MSDOS5.0", "MSDOS5.0", "MSDOS5.0", "MSDOS5.0", "MSWIN4.1", "IBM 3.3", "IBM 3.3", @@ -490,25 +490,25 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT16 (MBR)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT16 (MBR)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FAT(); - Assert.AreEqual(true, fs.Identify(image, partitions[0]), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, partitions[0]), _testfiles[i]); fs.GetInformation(image, partitions[0], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT16", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT16", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -516,42 +516,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat16Rdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "amigaos_3.9.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024128 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 63689 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 8192 }; - readonly string[] volumename = + readonly string[] _volumename = { "VOLUMELABEL" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "374D40D1" }; - readonly string[] oemid = + readonly string[] _oemid = { "CDP 5.0" }; @@ -559,15 +559,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT16 (RDB)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT16 (RDB)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FAT(); int part = -1; @@ -580,15 +580,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT16", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT16", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -596,42 +596,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat16Human { - readonly string[] testfiles = + readonly string[] _testfiles = { "sasidisk.aif", "scsidisk.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 162096, 204800 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 256, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 40510, 102367 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null }; - readonly string[] oemid = + readonly string[] _oemid = { "Hudson soft 2.00", " Hero Soft V1.10" }; @@ -639,15 +639,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT16 (Human68K)", testfiles[i]); - IFilter filter = new ZZZNoFilter(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT16 (Human68K)", + _testfiles[i]); + + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FAT(); int part = -1; @@ -660,15 +662,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT16", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT16", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/FAT32.cs b/Aaru.Tests/Filesystems/FAT32.cs index 505d058a7..700b8aad4 100644 --- a/Aaru.Tests/Filesystems/FAT32.cs +++ b/Aaru.Tests/Filesystems/FAT32.cs @@ -40,42 +40,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat32Apm { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 4194304 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 524278 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { "VOLUMELABEL" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "35BD1F0A" }; - readonly string[] oemid = + readonly string[] _oemid = { "BSD 4.4" }; @@ -83,15 +83,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT32 (APM)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT32 (APM)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FAT(); int part = -1; @@ -104,15 +104,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT32", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT32", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -120,42 +120,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat32Gpt { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 4194304 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 523775 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { "VOLUMELABEL" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "7ABE1F1B" }; - readonly string[] oemid = + readonly string[] _oemid = { "BSD 4.4" }; @@ -163,15 +163,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT32 (GPT)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT32 (GPT)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FAT(); int part = -1; @@ -184,15 +184,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT32", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT32", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -200,7 +200,7 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Fat32Mbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "drdos_7.03.aif", "drdos_8.00.aif", "msdos_7.10.aif", "macosx_10.11.aif", "win10.aif", "win2000.aif", "win95osr2.1.aif", "win95osr2.5.aif", "win95osr2.aif", "win98se.aif", "win98.aif", "winme.aif", @@ -209,31 +209,31 @@ namespace Aaru.Tests.Filesystems "linux_4.19_fat32_msdos_flashdrive.aif", "linux_4.19_vfat32_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 8388608, 8388608, 8388608, 4194304, 4194304, 8388608, 4194304, 4194304, 4194304, 4194304, 4194304, 4194304, 4194304, 4194304, 262144, 4194304, 4194304, 4194304, 4194304, 8388608, 1024000, 1024000, 1024000, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1048233, 1048233, 1048233, 524287, 524016, 1048233, 524152, 524152, 524152, 524112, 524112, 524112, 523520, 1048560, 260096, 524160, 524112, 524112, 65514, 1048233, 127744, 127882, 127744, 127744 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 2048, 512, 4096, 4096, 4096, 32768, 4096, 4096, 4096, 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", @@ -241,14 +241,14 @@ namespace Aaru.Tests.Filesystems "DICSETTER", "DICSETTER", "DICSETTER" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "5955996C", "1BFB1A43", "3B331809", "42D51EF1", "48073346", "EC62E6DE", "2A310DE4", "0C140DFC", "3E310D18", "0D3D0EED", "0E131162", "3F500F02", "82EB4C04", "00000000", "B488C502", "5CAC9B4E", "41540E0E", "4E600E0F", "26E20E0F", "3E0C1BE8", "63084BBA", "5CC7908D", "D1290612", "79BCA86E" }; - readonly string[] oemid = + readonly string[] _oemid = { "DRDOS7.X", "IBM 7.1", "MSWIN4.1", "BSD 4.4", "MSDOS5.0", "MSDOS5.0", "MSWIN4.1", "MSWIN4.1", "MSWIN4.1", "MSWIN4.1", "MSWIN4.1", "MSWIN4.1", "MSDOS5.0", "BeOS ", "mkfs.fat", "MSWIN4.1", "BSD 4.4", "BSD 4.4", @@ -258,25 +258,25 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "FAT32 (MBR)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "FAT32 (MBR)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FAT(); - Assert.AreEqual(true, fs.Identify(image, partitions[0]), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, partitions[0]), _testfiles[i]); fs.GetInformation(image, partitions[0], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("FAT32", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("FAT32", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/FATX.cs b/Aaru.Tests/Filesystems/FATX.cs index 491bda29a..0fe4c6711 100644 --- a/Aaru.Tests/Filesystems/FATX.cs +++ b/Aaru.Tests/Filesystems/FATX.cs @@ -48,66 +48,66 @@ namespace Aaru.Tests.Filesystems [SetUp] public void Init() { - location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Xbox FAT16", "le", "fatx.img.lz"); - filter = new LZip(); - filter.Open(location); - image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter)); - fs = new XboxFatPlugin(); + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Xbox FAT16", "le", "fatx.img.lz"); + _filter = new LZip(); + _filter.Open(_location); + _image = new ZZZRawImage(); + Assert.AreEqual(true, _image.Open(_filter)); + _fs = new XboxFatPlugin(); - wholePart = new Partition + _wholePart = new Partition { Name = "Whole device", - Length = image.Info.Sectors, - Size = image.Info.Sectors * image.Info.SectorSize + Length = _image.Info.Sectors, + Size = _image.Info.Sectors * _image.Info.SectorSize }; - Errno error = fs.Mount(image, wholePart, null, null, null); + Errno error = _fs.Mount(_image, _wholePart, null, null, null); Assert.AreEqual(Errno.NoError, error); } [TearDown] public void Destroy() { - fs?.Unmount(); - fs = null; + _fs?.Unmount(); + _fs = null; } - string location; - IFilter filter; - IMediaImage image; - IReadOnlyFilesystem fs; - Partition wholePart; + string _location; + IFilter _filter; + IMediaImage _image; + IReadOnlyFilesystem _fs; + Partition _wholePart; [Test] public void Information() { - Assert.AreEqual(62720, image.Info.Sectors); - Assert.AreEqual(1960, fs.XmlFsType.Clusters); - Assert.AreEqual(16384, fs.XmlFsType.ClusterSize); - Assert.AreEqual("FATX filesystem", fs.XmlFsType.Type); - Assert.AreEqual("Volume láb€l", fs.XmlFsType.VolumeName); - Assert.AreEqual("4639B7D0", fs.XmlFsType.VolumeSerial); + Assert.AreEqual(62720, _image.Info.Sectors); + Assert.AreEqual(1960, _fs.XmlFsType.Clusters); + Assert.AreEqual(16384, _fs.XmlFsType.ClusterSize); + Assert.AreEqual("FATX filesystem", _fs.XmlFsType.Type); + Assert.AreEqual("Volume láb€l", _fs.XmlFsType.VolumeName); + Assert.AreEqual("4639B7D0", _fs.XmlFsType.VolumeSerial); } [Test] public void MapBlock() { - Errno error = fs.MapBlock("49470015", 0, out long block); + Errno error = _fs.MapBlock("49470015", 0, out long block); Assert.AreEqual(Errno.IsDirectory, error); - error = fs.MapBlock("49470015/TitleImage", 0, out block); + error = _fs.MapBlock("49470015/TitleImage", 0, out block); Assert.AreEqual(Errno.NoSuchFile, error); - error = fs.MapBlock("49470015/TitleImage.xbx", 0, out block); + error = _fs.MapBlock("49470015/TitleImage.xbx", 0, out block); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(80, block); - error = fs.MapBlock("49470015/7AC2FE88C908/savedata.dat", 2, out block); + error = _fs.MapBlock("49470015/7AC2FE88C908/savedata.dat", 2, out block); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(272, block); - error = fs.MapBlock("49470015/7AC2FE88C908/savedata.dat", 200, out block); + error = _fs.MapBlock("49470015/7AC2FE88C908/savedata.dat", 200, out block); Assert.AreEqual(Errno.InvalidArgument, error); } @@ -115,41 +115,41 @@ namespace Aaru.Tests.Filesystems public void Read() { byte[] buffer = new byte[0]; - Errno error = fs.Read("49470015", 0, 0, ref buffer); + Errno error = _fs.Read("49470015", 0, 0, ref buffer); Assert.AreEqual(Errno.IsDirectory, error); - error = fs.Read("49470015/TitleImage", 0, 0, ref buffer); + error = _fs.Read("49470015/TitleImage", 0, 0, ref buffer); Assert.AreEqual(Errno.NoSuchFile, error); - error = fs.Read("49470015/7AC2FE88C908/savedata.dat", 0, 0, ref buffer); + error = _fs.Read("49470015/7AC2FE88C908/savedata.dat", 0, 0, ref buffer); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(0, buffer.Length); Assert.AreEqual("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", Sha256Context.Data(buffer, out _)); - error = fs.Read("49470015/7AC2FE88C908/savedata.dat", 1, 16, ref buffer); + error = _fs.Read("49470015/7AC2FE88C908/savedata.dat", 1, 16, ref buffer); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(16, buffer.Length); Assert.AreEqual("ff82559d2d0c610ac25b78dcb53a8312e32b56192044deb1f01540581bd54e80", Sha256Context.Data(buffer, out _)); - error = fs.Read("49470015/7AC2FE88C908/savedata.dat", 248, 131072, ref buffer); + error = _fs.Read("49470015/7AC2FE88C908/savedata.dat", 248, 131072, ref buffer); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(61996, buffer.Length); Assert.AreEqual("2eb0d62a96ad28473ce0dd67052efdfae31f371992e1d8309beeeff6f2b46a59", Sha256Context.Data(buffer, out _)); - error = fs.Read("49470015/7AC2FE88C908/savedata.dat", 131072, 0, ref buffer); + error = _fs.Read("49470015/7AC2FE88C908/savedata.dat", 131072, 0, ref buffer); Assert.AreEqual(Errno.InvalidArgument, error); } [Test] public void RootDirectory() { - Errno error = fs.ReadDir("", out List directory); + Errno error = _fs.ReadDir("", out List directory); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(6, directory.Count); @@ -167,7 +167,7 @@ namespace Aaru.Tests.Filesystems [Test] public void Stat() { - Errno error = fs.Stat("49470015", out FileEntryInfo stat); + Errno error = _fs.Stat("49470015", out FileEntryInfo stat); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(new DateTime(2007, 3, 6, 15, 8, 44, DateTimeKind.Utc), stat.AccessTimeUtc); Assert.AreEqual(FileAttributes.Directory, stat.Attributes); @@ -185,10 +185,10 @@ namespace Aaru.Tests.Filesystems Assert.AreEqual(null, stat.StatusChangeTimeUtc); Assert.AreEqual(null, stat.UID); - error = fs.Stat("49470015/TitleImage", out stat); + error = _fs.Stat("49470015/TitleImage", out stat); Assert.AreEqual(Errno.NoSuchFile, error); - error = fs.Stat("49470015/TitleImage.xbx", out stat); + error = _fs.Stat("49470015/TitleImage.xbx", out stat); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(new DateTime(2013, 5, 14, 12, 50, 8, DateTimeKind.Utc), stat.AccessTimeUtc); Assert.AreEqual(FileAttributes.None, stat.Attributes); @@ -210,7 +210,7 @@ namespace Aaru.Tests.Filesystems [Test] public void Statfs() { - Errno error = fs.StatFs(out FileSystemInfo stat); + Errno error = _fs.StatFs(out FileSystemInfo stat); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(1960, stat.Blocks); Assert.AreEqual(42, stat.FilenameLength); @@ -224,7 +224,7 @@ namespace Aaru.Tests.Filesystems [Test] public void SubDirectory() { - Errno error = fs.ReadDir("49470015", out List directory); + Errno error = _fs.ReadDir("49470015", out List directory); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(4, directory.Count); @@ -238,7 +238,7 @@ namespace Aaru.Tests.Filesystems Assert.AreEqual(false, directory.Contains("7ac2fe88c908")); Assert.AreEqual(false, directory.Contains("xbx")); - error = fs.ReadDir("49470015/7AC2FE88C908", out directory); + error = _fs.ReadDir("49470015/7AC2FE88C908", out directory); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(3, directory.Count); @@ -258,61 +258,63 @@ namespace Aaru.Tests.Filesystems [SetUp] public void Init() { - location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Xbox FAT16", "be", "microsoft256mb.img.lz"); - filter = new LZip(); - filter.Open(location); - image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter)); - fs = new XboxFatPlugin(); - List partitions = Core.Partitions.GetAll(image); + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Xbox FAT16", "be", + "microsoft256mb.img.lz"); + + _filter = new LZip(); + _filter.Open(_location); + _image = new ZZZRawImage(); + Assert.AreEqual(true, _image.Open(_filter)); + _fs = new XboxFatPlugin(); + List partitions = Core.Partitions.GetAll(_image); Assert.AreEqual(2, partitions.Count); - dataPartition = partitions[1]; - Errno error = fs.Mount(image, dataPartition, null, null, null); + _dataPartition = partitions[1]; + Errno error = _fs.Mount(_image, _dataPartition, null, null, null); Assert.AreEqual(Errno.NoError, error); } [TearDown] public void Destroy() { - fs?.Unmount(); - fs = null; + _fs?.Unmount(); + _fs = null; } - string location; - IFilter filter; - IMediaImage image; - IReadOnlyFilesystem fs; - Partition dataPartition; + string _location; + IFilter _filter; + IMediaImage _image; + IReadOnlyFilesystem _fs; + Partition _dataPartition; [Test] public void Information() { - Assert.AreEqual(491520, image.Info.Sectors); - Assert.AreEqual(14848, fs.XmlFsType.Clusters); - Assert.AreEqual(16384, fs.XmlFsType.ClusterSize); - Assert.AreEqual("FATX filesystem", fs.XmlFsType.Type); - Assert.AreEqual(string.Empty, fs.XmlFsType.VolumeName); - Assert.AreEqual("66C2E9D0", fs.XmlFsType.VolumeSerial); + Assert.AreEqual(491520, _image.Info.Sectors); + Assert.AreEqual(14848, _fs.XmlFsType.Clusters); + Assert.AreEqual(16384, _fs.XmlFsType.ClusterSize); + Assert.AreEqual("FATX filesystem", _fs.XmlFsType.Type); + Assert.AreEqual(string.Empty, _fs.XmlFsType.VolumeName); + Assert.AreEqual("66C2E9D0", _fs.XmlFsType.VolumeSerial); } [Test] public void MapBlock() { - Errno error = fs.MapBlock("Content/0000000000000000/FFFE07DF/00040000", 0, out long block); + Errno error = _fs.MapBlock("Content/0000000000000000/FFFE07DF/00040000", 0, out long block); Assert.AreEqual(Errno.IsDirectory, error); - error = fs.MapBlock("Content/0000000000000000/FFFE07DF/00040000/ContentCache", 0, out block); + error = _fs.MapBlock("Content/0000000000000000/FFFE07DF/00040000/ContentCache", 0, out block); Assert.AreEqual(Errno.NoSuchFile, error); - error = fs.MapBlock("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 0, out block); + error = _fs.MapBlock("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 0, out block); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(16992, block); - error = fs.MapBlock("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 2, out block); + error = _fs.MapBlock("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 2, out block); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(17056, block); - error = fs.MapBlock("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 2000000, out block); + error = _fs.MapBlock("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 2000000, out block); Assert.AreEqual(Errno.InvalidArgument, error); } @@ -320,41 +322,41 @@ namespace Aaru.Tests.Filesystems public void Read() { byte[] buffer = new byte[0]; - Errno error = fs.Read("Content/0000000000000000/FFFE07DF/00040000", 0, 0, ref buffer); + Errno error = _fs.Read("Content/0000000000000000/FFFE07DF/00040000", 0, 0, ref buffer); Assert.AreEqual(Errno.IsDirectory, error); - error = fs.Read("Content/0000000000000000/FFFE07DF/00040000/ContentCache", 0, 0, ref buffer); + error = _fs.Read("Content/0000000000000000/FFFE07DF/00040000/ContentCache", 0, 0, ref buffer); Assert.AreEqual(Errno.NoSuchFile, error); - error = fs.Read("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 0, 0, ref buffer); + error = _fs.Read("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 0, 0, ref buffer); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(0, buffer.Length); Assert.AreEqual("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", Sha256Context.Data(buffer, out _)); - error = fs.Read("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 1, 16, ref buffer); + error = _fs.Read("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 1, 16, ref buffer); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(16, buffer.Length); Assert.AreEqual("f73a941675b8df16b0fc908f242c3c51382c5b159e709e0f9ffc1e5aac35f77d", Sha256Context.Data(buffer, out _)); - error = fs.Read("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 248, 131072, ref buffer); + error = _fs.Read("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 248, 131072, ref buffer); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(85768, buffer.Length); Assert.AreEqual("19caf1365e1b7d5446ca0c2518d15e94c3ab0faaf2f8f3b31c9e1656dff57bd9", Sha256Context.Data(buffer, out _)); - error = fs.Read("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 131072, 0, ref buffer); + error = _fs.Read("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", 131072, 0, ref buffer); Assert.AreEqual(Errno.InvalidArgument, error); } [Test] public void RootDirectory() { - Errno error = fs.ReadDir("", out List directory); + Errno error = _fs.ReadDir("", out List directory); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(2, directory.Count); @@ -368,7 +370,7 @@ namespace Aaru.Tests.Filesystems [Test] public void Stat() { - Errno error = fs.Stat("Content/0000000000000000/FFFE07DF/00040000", out FileEntryInfo stat); + Errno error = _fs.Stat("Content/0000000000000000/FFFE07DF/00040000", out FileEntryInfo stat); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(new DateTime(2013, 9, 25, 12, 49, 46, DateTimeKind.Utc), stat.AccessTimeUtc); Assert.AreEqual(FileAttributes.Directory, stat.Attributes); @@ -386,10 +388,10 @@ namespace Aaru.Tests.Filesystems Assert.AreEqual(null, stat.StatusChangeTimeUtc); Assert.AreEqual(null, stat.UID); - error = fs.Stat("Content/0000000000000000/FFFE07DF/00040000/ContentCache", out stat); + error = _fs.Stat("Content/0000000000000000/FFFE07DF/00040000/ContentCache", out stat); Assert.AreEqual(Errno.NoSuchFile, error); - error = fs.Stat("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", out stat); + error = _fs.Stat("Content/0000000000000000/FFFE07DF/00040000/ContentCache.pkg", out stat); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(new DateTime(2016, 11, 18, 20, 34, 48, DateTimeKind.Utc), stat.AccessTimeUtc); Assert.AreEqual(FileAttributes.None, stat.Attributes); @@ -411,7 +413,7 @@ namespace Aaru.Tests.Filesystems [Test] public void Statfs() { - Errno error = fs.StatFs(out FileSystemInfo stat); + Errno error = _fs.StatFs(out FileSystemInfo stat); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(14848, stat.Blocks); Assert.AreEqual(42, stat.FilenameLength); @@ -425,7 +427,7 @@ namespace Aaru.Tests.Filesystems [Test] public void SubDirectory() { - Errno error = fs.ReadDir("Content", out List directory); + Errno error = _fs.ReadDir("Content", out List directory); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(2, directory.Count); @@ -435,7 +437,7 @@ namespace Aaru.Tests.Filesystems Assert.AreEqual(false, directory.Contains("000000000000000")); Assert.AreEqual(false, directory.Contains("eba4FD1C82295965")); - error = fs.ReadDir("Content/EBA4FD1C82295965/454108CF/00000001", out directory); + error = _fs.ReadDir("Content/EBA4FD1C82295965/454108CF/00000001", out directory); Assert.AreEqual(Errno.NoError, error); Assert.AreEqual(3, directory.Count); diff --git a/Aaru.Tests/Filesystems/HAMMER.cs b/Aaru.Tests/Filesystems/HAMMER.cs index c48832b3e..f85251fd8 100644 --- a/Aaru.Tests/Filesystems/HAMMER.cs +++ b/Aaru.Tests/Filesystems/HAMMER.cs @@ -40,37 +40,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class HammerMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "dflybsd_3.6.1.vdi.lz", "dflybsd_4.0.5.vdi.lz" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 104857600, 104857600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 6310, 6310 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 8388608, 8388608 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "f8e1a8bb-626d-11e7-94b5-0900274691e4", "ff4dc664-6276-11e7-983f-090027c41b46" }; @@ -78,15 +78,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "HAMMER (MBR)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "HAMMER (MBR)", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new Vdi(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new HAMMER(); int part = -1; @@ -99,14 +99,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HAMMER", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HAMMER", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/HFS.cs b/Aaru.Tests/Filesystems/HFS.cs index 66ac621c4..10db6ef54 100644 --- a/Aaru.Tests/Filesystems/HFS.cs +++ b/Aaru.Tests/Filesystems/HFS.cs @@ -40,46 +40,46 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Hfs { - readonly string[] testfiles = + readonly string[] _testfiles = { "macos_1.1_mf2dd.img.lz", "macos_2.0_mf2dd.img.lz", "macos_6.0.7_mf2dd.img.lz", "nextstep_3.3_mf2hd.img.lz", "openstep_4.0_mf2hd.img.lz", "openstep_4.2_mf2hd.img.lz", "rhapsody_dr1_mf2hd.img.lz", "ecs20_mf2hd_fstester.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.AppleSonyDS, MediaType.AppleSonyDS, MediaType.AppleSonyDS, MediaType.DOS_35_HD, MediaType.DOS_35_HD, MediaType.DOS_35_HD, MediaType.DOS_35_HD, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1600, 1600, 1600, 2880, 2880, 2880, 2880, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1594, 1594, 1594, 2874, 2874, 2874, 2874, 2874 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "VOLUME LABEL" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null, null, null, null }; @@ -87,16 +87,16 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Apple HFS", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Apple HFS", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new AppleHFS(); var wholePart = new Partition @@ -106,13 +106,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -120,7 +120,7 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class HfsApm { - readonly string[] testfiles = + readonly string[] _testfiles = { "amigaos_3.9.aif", "darwin_1.3.1.aif", "darwin_1.4.1.aif", "darwin_6.0.2.aif", "darwin_8.0.1.aif", "macos_1.1.aif", "macos_2.0.aif", "macos_6.0.7.aif", "macos_7.5.3.aif", "macos_7.5.aif", "macos_7.6.aif", @@ -131,33 +131,33 @@ namespace Aaru.Tests.Filesystems "silverlining_2.2.1.aif", "speedtools_3.6.aif", "vcpformatter_2.1.1.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024128, 409600, 409600, 409600, 409600, 41820, 41820, 81648, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 409600, 51200, 51200, 41820, 41820, 54840, 54840, 54840, 54840, 54840, 41820, 54840, 54840, 262144, 51200, 51200, 54840 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 64003, 51189, 51189, 58502, 58502, 41788, 38950, 39991, 63954, 63990, 63954, 63954, 63954, 63922, 63922, 63922, 63922, 63884, 63883, 63883, 58506, 50926, 50094, 38950, 38950, 38950, 38950, 7673, 38950, 38950, 38950, 38950, 38950, 46071, 50382, 49135, 54643 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 8192, 4096, 4096, 3584, 3584, 512, 512, 1024, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 3584, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 1024, 512, 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", @@ -167,7 +167,7 @@ namespace Aaru.Tests.Filesystems "Volume label", "Volume label", "Untitled", "Untitled #1", "24 MB Disk", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, "AAFE1382AF5AA898", null, null, null, null, null, null, null, null, null, null, null, null, "5A7C38B0CAF279C4", "FB49083EBD150509", "632C0B1DB46FD188", null, null, null, null, null, null, @@ -177,15 +177,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Apple HFS (APM)", testfiles[i]); - IFilter filter = new ZZZNoFilter(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Apple HFS (APM)", _testfiles[i]); + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AppleHFS(); int part = -1; @@ -198,14 +198,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -213,38 +213,38 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class HfsCdrom { - readonly string[] testfiles = + readonly string[] _testfiles = { "toast_3.5.7_hfs_from_volume.aif", "toast_3.5.7_iso9660_hfs.aif", "toast_4.1.3_hfs_from_volume.aif", "toast_4.1.3_iso9660_hfs.aif", "toast_3.5.7_hfs_from_files.aif", "toast_4.1.3_hfs_from_files.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 942, 1880, 943, 1882, 1509, 1529 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 2048, 2048, 2048, 2048, 2048, 2048 }; - readonly long[] clusters = + readonly long[] _clusters = { 3724, 931, 931, 931, 249, 249 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 2048, 2048, 2048, 12288, 12288 }; - readonly string[] volumename = + readonly string[] _volumename = { "Disk utils", "Disk utils", "Disk utils", "Disk utils", "Disk utils", "Disk utils" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null, null }; @@ -252,15 +252,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Apple HFS (CD-ROM)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Apple HFS (CD-ROM)", + _testfiles[i]); + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AppleHFS(); int part = -1; @@ -273,14 +275,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -288,38 +290,38 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class HfsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif", "darwin_1.3.1.aif", "darwin_1.4.1.aif", "darwin_6.0.2.aif", "darwin_8.0.1.aif", "linux_4.19_hfs_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144, 409600, 409600, 409600, 409600, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 65018, 51145, 51145, 58452, 58502, 63870 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 2048, 4096, 4096, 3584, 3584, 8192 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "DicSetter" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, "81FE805D61458753", null }; @@ -327,15 +329,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Apple HFS (MBR)", testfiles[i]); - IFilter filter = new ZZZNoFilter(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Apple HFS (MBR)", _testfiles[i]); + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AppleHFS(); int part = -1; @@ -348,14 +350,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -363,37 +365,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class HfsRdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "amigaos_3.9.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024128 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 63752 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 8192 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; @@ -401,15 +403,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Apple HFS (RDB)", testfiles[i]); - IFilter filter = new ZZZNoFilter(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Apple HFS (RDB)", _testfiles[i]); + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AppleHFS(); int part = -1; @@ -422,14 +424,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/HFSPlus.cs b/Aaru.Tests/Filesystems/HFSPlus.cs index 3718e48e2..7e7c86993 100644 --- a/Aaru.Tests/Filesystems/HFSPlus.cs +++ b/Aaru.Tests/Filesystems/HFSPlus.cs @@ -41,7 +41,7 @@ namespace Aaru.Tests.Filesystems public class HfsPlusApm { // Missing Darwin 1.4.1 - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif", "macosx_10.11_journal.aif", "darwin_1.3.1.aif", "darwin_1.3.1_wrapped.aif", "darwin_1.4.1_wrapped.aif", "darwin_6.0.2.aif", "darwin_6.0.2_wrapped.aif", "darwin_8.0.1_journal.aif", @@ -50,43 +50,43 @@ namespace Aaru.Tests.Filesystems "macosx_10.4_journal.aif", "macosx_10.4.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 409600, 614400, 819200, 614400, 614400, 819200, 614400, 1228800, 819200, 614400, 4194304, 4194304, 4194304, 4194304, 4194304, 4194304, 2097152, 4194304, 2097152, 4194304 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 51190, 76790, 102392, 76774, 76774, 102392, 76774, 153592, 102392, 76774, 524152, 524088, 524088, 524088, 524088, 524008, 261884, 491240, 261884, 491240 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "FA94762D086A18A9", "33D4A309C8E7BD10", null, null, null, null, null, "4D5140EB8F14A385", "0D592249833E2DC4", "AA616146576BD9BC", null, null, null, null, null, "EFA132FFFAC1ADA6", "009D570FFCF8F20B", "17F6F33AB313EE32", "AD5690C093F66FCF", "A7D63854DF76DDE6" }; - readonly string[] oemid = + readonly string[] _oemid = { "10.0", "HFSJ", "10.0", "10.0", "10.0", "10.0", "10.0", "10.0", "10.0", "10.0", "8.10", "8.10", "8.10", "8.10", "8.10", "10.0", "HFSJ", "10.0", "HFSJ", "10.0" @@ -95,15 +95,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Apple HFS+ (APM)", testfiles[i]); - IFilter filter = new ZZZNoFilter(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Apple HFS+ (APM)", + _testfiles[i]); + + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AppleHFSPlus(); int part = -1; @@ -116,15 +118,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HFS+", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HFS+", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -132,42 +134,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class HfsPlusGpt { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif", "macosx_10.11_journal.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 409600, 614400 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 51190, 76790 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "D8C68470046E67BE", "FD3CB598F3C6294A" }; - readonly string[] oemid = + readonly string[] _oemid = { "10.0", "HFSJ" }; @@ -175,15 +177,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Apple HFS+ (GPT)", testfiles[i]); - IFilter filter = new ZZZNoFilter(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Apple HFS+ (GPT)", + _testfiles[i]); + + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AppleHFSPlus(); int part = -1; @@ -196,15 +200,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HFS+", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HFS+", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -213,45 +217,45 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class HfsPlusMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif", "macosx_10.11_journal.aif", "linux.aif", "linux_journal.aif", "darwin_1.3.1.aif", "darwin_1.3.1_wrapped.aif", "darwin_1.4.1.aif", "darwin_1.4.1_wrapped.aif", "darwin_6.0.2.aif", "darwin_8.0.1_journal.aif", "darwin_8.0.1.aif", "darwin_8.0.1_wrapped.aif", "linux_4.19_hfs+_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 303104, 352256, 262144, 262144, 819200, 614400, 819200, 614400, 819200, 1228800, 819200, 614400, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 37878, 44021, 32512, 32512, 102178, 76708, 102178, 76708, 102178, 153592, 102392, 76774, 127744 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null, null, null, null, null, null, null, null, null, null, null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "C84F550907D13F50", "016599F88029F73D", null, null, null, null, null, null, null, "F92964F9B3F64ABB", "A8FAC484A0A2B177", "D5D5BF1346AD2B8D", "B9BAC6856878A404" }; - readonly string[] oemid = + readonly string[] _oemid = { "10.0", "HFSJ", "10.0", "10.0", "10.0", "10.0", "10.0", "10.0", "10.0", "10.0", "10.0", "10.0", "H+Lx" }; @@ -259,15 +263,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Apple HFS+ (MBR)", testfiles[i]); - IFilter filter = new ZZZNoFilter(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Apple HFS+ (MBR)", + _testfiles[i]); + + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AppleHFSPlus(); int part = -1; @@ -280,15 +286,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HFS+", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HFS+", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/HFSX.cs b/Aaru.Tests/Filesystems/HFSX.cs index e52f7f07d..d44d22725 100644 --- a/Aaru.Tests/Filesystems/HFSX.cs +++ b/Aaru.Tests/Filesystems/HFSX.cs @@ -40,44 +40,44 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class HfsxApm { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif", "macosx_10.11_journal.aif", "darwin_8.0.1_journal.aif", "darwin_8.0.1.aif", "macosx_10.4_journal.aif", "macosx_10.4.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 819200, 1228800, 1638400, 1433600, 4194304, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 102390, 153590, 204792, 179192, 491290, 127770 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096, 4096, 4096, 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null, null, null, null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "CC2D56884950D9AE", "7AF1175D8EA7A072", "BB4ABD7E7E2FF5AF", "E2F212D815EF77B5", "5A8C646A5D77EB16", "258C51A750F6A485" }; - readonly string[] oemid = + readonly string[] _oemid = { "10.0", "HFSJ", "10.0", "10.0", "HFSJ", "10.0" }; @@ -85,15 +85,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Apple HFSX (APM)", testfiles[i]); - IFilter filter = new ZZZNoFilter(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Apple HFSX (APM)", + _testfiles[i]); + + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AppleHFSPlus(); int part = -1; @@ -106,15 +108,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HFSX", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HFSX", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -122,42 +124,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class HfsxGpt { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif", "macosx_10.11_journal.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 819200, 1228800 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 102390, 153590 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "328343989312AE9F", "FB98504073464C5C" }; - readonly string[] oemid = + readonly string[] _oemid = { "10.0", "HFSJ" }; @@ -165,15 +167,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Apple HFSX (GPT)", testfiles[i]); - IFilter filter = new ZZZNoFilter(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Apple HFSX (GPT)", + _testfiles[i]); + + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AppleHFSPlus(); int part = -1; @@ -186,15 +190,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HFSX", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HFSX", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -202,44 +206,44 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class HfsxMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif", "macosx_10.11_journal.aif", "linux.aif", "linux_journal.aif", "darwin_8.0.1_journal.aif", "darwin_8.0.1.aif", "linux_4.19_hfsx_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 393216, 409600, 262144, 262144, 1638400, 1433600, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 49140, 51187, 32512, 32512, 204792, 179192, 127744 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096, 4096, 4096, 4096, 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null, null, null, null, null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "C2BCCCE6DE5BC98D", "AC54CD78C75CC30F", null, null, "7559DD01BCFADD9A", "AEA39CFBBF14C0FF", "5E4A8781D3C9286C" }; - readonly string[] oemid = + readonly string[] _oemid = { "10.0", "HFSJ", "10.0", "10.0", "10.0", "10.0", "H+Lx" }; @@ -247,15 +251,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Apple HFSX (MBR)", testfiles[i]); - IFilter filter = new ZZZNoFilter(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Apple HFSX (MBR)", + _testfiles[i]); + + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new AppleHFSPlus(); int part = -1; @@ -268,15 +274,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HFSX", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HFSX", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/HPFS.cs b/Aaru.Tests/Filesystems/HPFS.cs index 59edf486a..66f14843d 100644 --- a/Aaru.Tests/Filesystems/HPFS.cs +++ b/Aaru.Tests/Filesystems/HPFS.cs @@ -40,46 +40,46 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Hpfs { - readonly string[] testfiles = + readonly string[] _testfiles = { "ecs.aif", "msos2_1.21.aif", "msos2_1.30.1.aif", "os2_1.20.aif", "os2_1.30.aif", "os2_6.307.aif", "os2_6.514.aif", "os2_6.617.aif", "os2_8.162.aif", "os2_9.023.aif", "winnt_3.10.aif", "winnt_3.50.aif", "ecs20_fstester.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144, 1024000, 1024000, 1024000, 1024000, 1024000, 262144, 262144, 262144, 262144, 262144, 262144, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 261072, 1023056, 1023056, 1023056, 1023056, 1023056, 262016, 262016, 262016, 262016, 262016, 262112, 1022112 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUMELABEL", "VOLUME LABE" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "2BBBD814", "AC0DDC15", "ABEB2C15", "6C4EE015", "6C406015", "6C49B015", "2BCEB414", "2C157414", "2BF55414", "2BE31414", "E851CB14", "A4EDC29C", "AC096014" }; - readonly string[] oemid = + readonly string[] _oemid = { "IBM 4.50", "OS2 10.1", "OS2 10.0", "OS2 10.0", "OS2 10.0", "OS2 20.0", "OS2 20.0", "OS2 20.1", "OS2 20.0", "OS2 20.0", "MSDOS5.0", "MSDOS5.0", "IBM 4.50" @@ -88,27 +88,27 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "High Performance File System", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "High Performance File System", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new HPFS(); - Assert.AreEqual(true, fs.Identify(image, partitions[0]), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, partitions[0]), _testfiles[i]); fs.GetInformation(image, partitions[0], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HPFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HPFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/HPOFS.cs b/Aaru.Tests/Filesystems/HPOFS.cs index 5e9d9e7d2..8b889389f 100644 --- a/Aaru.Tests/Filesystems/HPOFS.cs +++ b/Aaru.Tests/Filesystems/HPOFS.cs @@ -39,47 +39,47 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Hpofs { - readonly string[] testfiles = + readonly string[] _testfiles = { "rid1.img.lz", "rid10.img.lz", "rid66percent.img.lz", "rid266.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DOS_35_HD, MediaType.DOS_35_HD, MediaType.DOS_35_HD, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 2880, 2880, 2880, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 2880, 2880, 2880, 2880 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512, 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "VOLUME LABEL", "VOLUME LABEL", "VOLUME LABEL", "VOLUME LABEL" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "AC226814", "AC160814", "AC306C14", "ABEF2C14" }; - readonly string[] oemid = + readonly string[] _oemid = { "IBM 10.2", "IBM 10.2", "IBM 10.2", "IBM 10.2" }; @@ -87,18 +87,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", - "High Performance Optical File System", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", + "High Performance Optical File System", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new HPOFS(); var wholePart = new Partition @@ -108,14 +108,14 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("HPOFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("HPOFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/HTFS.cs b/Aaru.Tests/Filesystems/HTFS.cs index 79f1e30eb..b7a98ffb2 100644 --- a/Aaru.Tests/Filesystems/HTFS.cs +++ b/Aaru.Tests/Filesystems/HTFS.cs @@ -40,49 +40,49 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Htfs { - readonly string[] testfiles = + readonly string[] _testfiles = { "scoopenserver_5.0.7hw_dmf.img.lz", "scoopenserver_5.0.7hw_dshd.img.lz", "scoopenserver_5.0.7hw_mf2dd.img.lz", "scoopenserver_5.0.7hw_mf2ed.img.lz", "scoopenserver_5.0.7hw_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DMF, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 3360, 2400, 1440, 5760, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1680, 1200, 720, 2880, 1440 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "", "", "", "", "" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null }; - readonly string[] type = + readonly string[] _type = { "HTFS", "HTFS", "HTFS", "HTFS", "HTFS" }; @@ -90,18 +90,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "High Throughtput File System", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "High Throughtput File System", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new SysVfs(); var wholePart = new Partition @@ -111,13 +111,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -125,42 +125,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class HtfsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "scoopenserver_5.0.7hw.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 2097152 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1020096 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; - readonly string[] type = + readonly string[] _type = { "HTFS" }; @@ -168,17 +168,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", - "High Throughtput File System (MBR)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", + "High Throughtput File System (MBR)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new SysVfs(); int part = -1; @@ -191,14 +191,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/ISO9660.cs b/Aaru.Tests/Filesystems/ISO9660.cs index 34b4f6bf0..5d8c2cb90 100644 --- a/Aaru.Tests/Filesystems/ISO9660.cs +++ b/Aaru.Tests/Filesystems/ISO9660.cs @@ -39,7 +39,7 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Iso9660 { - readonly string[] testfiles = + readonly string[] _testfiles = { // Toast 3.5.7 "toast_3.5.7_iso9660_apple.aif", "toast_3.5.7_iso9660_dos_apple.aif", "toast_3.5.7_iso9660_dos.aif", @@ -89,7 +89,7 @@ namespace Aaru.Tests.Filesystems "xorriso_rockridge.aif", "xorriso_violating.aif", "xorriso_zisofs.aif", "xorriso_zisofs_rockridge.aif" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { // Toast 3.5.7 MediaType.CD, MediaType.CD, MediaType.CD, MediaType.CD, MediaType.CD, MediaType.CD, MediaType.CD, @@ -124,7 +124,7 @@ namespace Aaru.Tests.Filesystems MediaType.CD, MediaType.CD, MediaType.CD, MediaType.CD, MediaType.CD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { // Toast 3.5.7 946, 946, 300, 1880, 300, 951, 300, 946, 300, 946, 946, 300, 300, 951, 300, 300, @@ -151,7 +151,7 @@ namespace Aaru.Tests.Filesystems 3688, 3686, 3686, 3686, 3673, 3673, 3673, 3686, 3675, 3673, 3673, 3675 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { // Toast 3.5.7 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, @@ -178,7 +178,7 @@ namespace Aaru.Tests.Filesystems 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048 }; - readonly long[] clusters = + readonly long[] _clusters = { // Toast 3.5.7 946, 946, 244, 946, 244, 951, 249, 946, 244, 946, 946, 244, 244, 951, 249, 244, @@ -205,7 +205,7 @@ namespace Aaru.Tests.Filesystems 3688, 3686, 3686, 3686, 3673, 3673, 3673, 3686, 3675, 3673, 3673, 3675 }; - readonly int[] clustersize = + readonly int[] _clustersize = { // Toast 3.5.7 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, @@ -232,7 +232,7 @@ namespace Aaru.Tests.Filesystems 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048 }; - readonly string[] volumename = + readonly string[] _volumename = { // Toast 3.5.7 "DISK_UTILS", "DISK_UTILS", "DISK_UTILS", "DISK_UTILS", "DISK_UTILS", "Disk utils", "Disk utils", @@ -264,7 +264,7 @@ namespace Aaru.Tests.Filesystems "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { // Toast 3.5.7 null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, @@ -291,7 +291,7 @@ namespace Aaru.Tests.Filesystems null, null, null, null, null, null, null, null, null, null, null, null }; - readonly string[] sysid = + readonly string[] _sysid = { // Toast 3.5.7 "APPLE COMPUTER, INC., TYPE: 0002", "APPLE COMPUTER, INC., TYPE: 0002", "APPLE COMPUTER, INC., TYPE: 0002", @@ -328,7 +328,7 @@ namespace Aaru.Tests.Filesystems "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }; - readonly string[] appid = + readonly string[] _appid = { // Toast 3.5.7 "TOAST ISO 9660 BUILDER COPYRIGHT (C) 1997 ADAPTEC, INC. - HAVE A NICE DAY", @@ -419,16 +419,16 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "ISO9660", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "ISO9660", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), $"{testfiles[i]}: Open()"); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, $"{testfiles[i]}: MediaType"); - Assert.AreEqual(sectors[i], image.Info.Sectors, $"{testfiles[i]}: Sectors"); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, $"{testfiles[i]}: SectorSize"); + Assert.AreEqual(true, image.Open(filter), $"{_testfiles[i]}: Open()"); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, $"{_testfiles[i]}: MediaType"); + Assert.AreEqual(_sectors[i], image.Info.Sectors, $"{_testfiles[i]}: Sectors"); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, $"{_testfiles[i]}: SectorSize"); IFilesystem fs = new ISO9660(); var wholePart = new Partition @@ -438,15 +438,17 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), $"{testfiles[i]}: Identify()"); + Assert.AreEqual(true, fs.Identify(image, wholePart), $"{_testfiles[i]}: Identify()"); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, $"{testfiles[i]}: Clusters"); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, $"{testfiles[i]}: ClusterSize"); - Assert.AreEqual("ISO9660", fs.XmlFsType.Type, $"{testfiles[i]}: Type"); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, $"{testfiles[i]}: VolumeName"); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, $"{testfiles[i]}: VolumeSerial"); - Assert.AreEqual(sysid[i], fs.XmlFsType.SystemIdentifier, $"{testfiles[i]}: SystemIdentifier"); - Assert.AreEqual(appid[i], fs.XmlFsType.ApplicationIdentifier, $"{testfiles[i]}: ApplicationIdentifier"); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, $"{_testfiles[i]}: Clusters"); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, $"{_testfiles[i]}: ClusterSize"); + Assert.AreEqual("ISO9660", fs.XmlFsType.Type, $"{_testfiles[i]}: Type"); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, $"{_testfiles[i]}: VolumeName"); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, $"{_testfiles[i]}: VolumeSerial"); + Assert.AreEqual(_sysid[i], fs.XmlFsType.SystemIdentifier, $"{_testfiles[i]}: SystemIdentifier"); + + Assert.AreEqual(_appid[i], fs.XmlFsType.ApplicationIdentifier, + $"{_testfiles[i]}: ApplicationIdentifier"); } } } diff --git a/Aaru.Tests/Filesystems/JFS2.cs b/Aaru.Tests/Filesystems/JFS2.cs index 9a931447d..0fed7ec87 100644 --- a/Aaru.Tests/Filesystems/JFS2.cs +++ b/Aaru.Tests/Filesystems/JFS2.cs @@ -40,38 +40,38 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Jfs2 { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif", "linux_caseinsensitive.aif", "ecs20_fstester.aif", "linux_4.19_jfs_flashdrive.aif", "linux_4.19_jfs_os2_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144, 262144, 1024000, 1024000, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 257632, 257632, 1017512, 1017416, 1017416 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096, 4096, 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume labe", "Volume labe", "Volume labe", "DicSetter", "DicSetter" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "8033b783-0cd1-1645-8ecc-f8f113ad6a47", "d6cd91e9-3899-7e40-8468-baab688ee2e2", "f4077ce9-0000-0000-0000-000000007c10", "91746c77-eb51-7441-85e2-902c925969f8", @@ -81,15 +81,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "JFS2", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "JFS2", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new JFS(); int part = -1; @@ -103,14 +103,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("JFS filesystem", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("JFS filesystem", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/LFS.cs b/Aaru.Tests/Filesystems/LFS.cs index fc9bd2211..973a9b2a3 100644 --- a/Aaru.Tests/Filesystems/LFS.cs +++ b/Aaru.Tests/Filesystems/LFS.cs @@ -36,37 +36,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class LfsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "netbsd_1.6.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 409600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 409600 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512 }; - readonly string[] volumename = + readonly string[] _volumename = { null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; diff --git a/Aaru.Tests/Filesystems/LisaFS.cs b/Aaru.Tests/Filesystems/LisaFS.cs index 2a2094858..f26c30320 100644 --- a/Aaru.Tests/Filesystems/LisaFS.cs +++ b/Aaru.Tests/Filesystems/LisaFS.cs @@ -40,7 +40,7 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class LisaFs { - readonly string[] testfiles = + readonly string[] _testfiles = { "166files.dc42.lz", "222files.dc42.lz", "blank2.0.dc42.lz", "blank-disk.dc42.lz", "file-with-a-password.dc42.lz", "tfwdndrc-has-been-erased.dc42.lz", "tfwdndrc-has-been-restored.dc42.lz", @@ -51,7 +51,7 @@ namespace Aaru.Tests.Filesystems "lisafs3.dc42.lz", "lisafs3_with_desktop.dc42.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonySS, @@ -59,34 +59,34 @@ namespace Aaru.Tests.Filesystems MediaType.AppleFileWare, MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonySS }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 1702, 800, 800, 800 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 800, 800, 792, 800, 800, 800, 800, 800, 800, 800, 800, 800, 1684, 792, 800, 800 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "166Files", "222Files", "AOS 4:59 pm 10/02/87", "AOS 3.0", "AOS 3.0", "AOS 3.0", "AOS 3.0", "AOS 3.0", "AOS 3.0", "AOS 3.0", "AOS 3.0", "AOS 3.0", "AOS 4:15 pm 5/06/1983", "Office System 1 2.0", "Office System 1 3.0", "AOS 3.0" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "A23703A202010663", "A23703A201010663", "A32D261301010663", "A22CB48D01010663", "A22CC3A702010663", "A22CB48D14010663", "A22CB48D14010663", "A22CB48D01010663", "A22CB48D01010663", "A22CB48D01010663", @@ -94,7 +94,7 @@ namespace Aaru.Tests.Filesystems "A4FE1A191F011652" }; - readonly string[] oemid = + readonly string[] _oemid = { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }; @@ -102,18 +102,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Apple Lisa filesystem", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Apple Lisa filesystem", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new DiskCopy42(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new LisaFS(); var wholePart = new Partition @@ -123,14 +123,14 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("LisaFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("LisaFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } diff --git a/Aaru.Tests/Filesystems/Locus.cs b/Aaru.Tests/Filesystems/Locus.cs index dad6d0ac1..6d896cb96 100644 --- a/Aaru.Tests/Filesystems/Locus.cs +++ b/Aaru.Tests/Filesystems/Locus.cs @@ -38,47 +38,47 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Locus { - readonly string[] testfiles = + readonly string[] _testfiles = { "mf2dd.img.lz", "mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1440, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 180, 360 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { "Label", "Label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null }; - readonly string[] oemid = + readonly string[] _oemid = { null, null }; @@ -86,16 +86,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Locus filesystem", testfiles[i]); - IFilter filter = new LZip(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Locus filesystem", + _testfiles[i]); + + IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new Aaru.Filesystems.Locus(); var wholePart = new Partition @@ -105,14 +107,14 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Locus filesystem", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Locus filesystem", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/MFS.cs b/Aaru.Tests/Filesystems/MFS.cs index a18c4b025..89271648c 100644 --- a/Aaru.Tests/Filesystems/MFS.cs +++ b/Aaru.Tests/Filesystems/MFS.cs @@ -39,44 +39,44 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Mfs { - readonly string[] testfiles = + readonly string[] _testfiles = { "macos_0.1_mf1dd.img.lz", "macos_0.5_mf1dd.img.lz", "macos_1.1_mf1dd.img.lz", "macos_2.0_mf1dd.img.lz", "macos_6.0.7_mf1dd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonySS }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 800, 800, 800, 800, 800 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 391, 391, 391, 391, 391 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label", "Volume label", "Volume label", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null, null, null }; @@ -84,18 +84,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Macintosh File System", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Macintosh File System", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new AppleMFS(); var wholePart = new Partition @@ -105,13 +105,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("MFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("MFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/MINIX.cs b/Aaru.Tests/Filesystems/MINIX.cs index b12edbb25..0f10d90c8 100644 --- a/Aaru.Tests/Filesystems/MINIX.cs +++ b/Aaru.Tests/Filesystems/MINIX.cs @@ -40,38 +40,38 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class MinixV1 { - readonly string[] testfiles = + readonly string[] _testfiles = { "minix_3.1.2a_dsdd.img.lz", "minix_3.1.2a_dshd.img.lz", "minix_3.1.2a_mf2dd.img.lz", "minix_3.1.2a_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DOS_525_DS_DD_9, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 720, 2400, 1440, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 360, 1200, 720, 1440 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 1024 }; - readonly string[] types = + readonly string[] _types = { "Minix 3 v1", "Minix 3 v1", "Minix 3 v1", "Minix 3 v1" }; @@ -79,18 +79,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "MINIX v1 filesystem", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "MINIX v1 filesystem", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new MinixFS(); var wholePart = new Partition @@ -100,11 +100,11 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(types[i], fs.XmlFsType.Type, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_types[i], fs.XmlFsType.Type, _testfiles[i]); } } } @@ -112,32 +112,32 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class MinixV1Mbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif", "minix_3.1.2a.aif", "linux_4.19_minix1_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144, 102400, 131072 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 65535, 50399, 64512 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024 }; - readonly string[] types = + readonly string[] _types = { "Minix v1", "Minix 3 v1", "Minix v1" }; @@ -145,17 +145,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "MINIX v1 filesystem (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "MINIX v1 filesystem (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new MinixFS(); int part = -1; @@ -170,12 +170,12 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(types[i], fs.XmlFsType.Type, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_types[i], fs.XmlFsType.Type, _testfiles[i]); } } } @@ -183,38 +183,38 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class MinixV2 { - readonly string[] testfiles = + readonly string[] _testfiles = { "minix_3.1.2a_dsdd.img.lz", "minix_3.1.2a_dshd.img.lz", "minix_3.1.2a_mf2dd.img.lz", "minix_3.1.2a_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DOS_525_DS_DD_9, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 720, 2400, 1440, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 360, 1200, 720, 1440 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 1024 }; - readonly string[] types = + readonly string[] _types = { "Minix 3 v2", "Minix 3 v2", "Minix 3 v2", "Minix 3 v2" }; @@ -222,18 +222,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "MINIX v2 filesystem", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "MINIX v2 filesystem", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new MinixFS(); var wholePart = new Partition @@ -243,11 +243,11 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(types[i], fs.XmlFsType.Type, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_types[i], fs.XmlFsType.Type, _testfiles[i]); } } } @@ -255,32 +255,32 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class MinixV2Mbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "minix_3.1.2a.aif", "linux_4.19_minix2_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 511055, 510976 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024 }; - readonly string[] types = + readonly string[] _types = { "Minix 3 v2", "Minix v2" }; @@ -288,17 +288,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "MINIX v2 filesystem (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "MINIX v2 filesystem (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new MinixFS(); int part = -1; @@ -312,12 +312,12 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(types[i], fs.XmlFsType.Type, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_types[i], fs.XmlFsType.Type, _testfiles[i]); } } } @@ -325,38 +325,38 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class MinixV3 { - readonly string[] testfiles = + readonly string[] _testfiles = { "minix_3.1.2a_dsdd.img.lz", "minix_3.1.2a_dshd.img.lz", "minix_3.1.2a_mf2dd.img.lz", "minix_3.1.2a_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DOS_525_DS_DD_9, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 720, 2400, 1440, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 90, 300, 180, 360 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096, 4096, 4096 }; - readonly string[] types = + readonly string[] _types = { "Minix v3", "Minix v3", "Minix v3", "Minix v3" }; @@ -364,18 +364,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "MINIX v3 filesystem", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "MINIX v3 filesystem", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new MinixFS(); var wholePart = new Partition @@ -385,11 +385,11 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(types[i], fs.XmlFsType.Type, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_types[i], fs.XmlFsType.Type, _testfiles[i]); } } } @@ -397,32 +397,32 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class MinixV3Mbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "minix_3.1.2a.aif", "linux_4.19_minix3_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 4194304, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 523151, 510976 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 1024 }; - readonly string[] types = + readonly string[] _types = { "Minix v3", "Minix v3" }; @@ -430,17 +430,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "MINIX v3 filesystem (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "MINIX v3 filesystem (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new MinixFS(); int part = -1; @@ -454,12 +454,12 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(types[i], fs.XmlFsType.Type, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_types[i], fs.XmlFsType.Type, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/NILFS2.cs b/Aaru.Tests/Filesystems/NILFS2.cs index 4c23d7b86..f05bb55d5 100644 --- a/Aaru.Tests/Filesystems/NILFS2.cs +++ b/Aaru.Tests/Filesystems/NILFS2.cs @@ -40,37 +40,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Nilfs2 { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 32512 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "6b1ca79e-7048-a748-93a0-89c74b02cb5a" }; @@ -78,17 +78,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", - "New Implementation of a Log-structured File System 2", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", + "New Implementation of a Log-structured File System 2", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new NILFS2(); int part = -1; @@ -101,14 +101,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("NILFS2 filesystem", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("NILFS2 filesystem", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/NTFS.cs b/Aaru.Tests/Filesystems/NTFS.cs index 79137fa6f..aa3916d59 100644 --- a/Aaru.Tests/Filesystems/NTFS.cs +++ b/Aaru.Tests/Filesystems/NTFS.cs @@ -40,42 +40,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class NtfsGpt { - readonly string[] testfiles = + readonly string[] _testfiles = { "haiku_hrev51259.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 2097152 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 261887 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null, null, null, null, null, null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "106DA7693F7F6B3F" }; - readonly string[] oemid = + readonly string[] _oemid = { null }; @@ -83,17 +83,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "New Technology File System (GPT)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", + "New Technology File System (GPT)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new NTFS(); int part = -1; @@ -106,15 +106,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("NTFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("NTFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -122,44 +122,44 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class NtfsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "win10.aif", "win2000.aif", "winnt_3.10.aif", "winnt_3.50.aif", "winnt_3.51.aif", "winnt_4.00.aif", "winvista.aif", "linux.aif", "haiku_hrev51259.aif", "linux_4.19_ntfs3g_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 524288, 2097152, 1024000, 524288, 524288, 524288, 524288, 262144, 2097152, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 65263, 1046511, 1023057, 524256, 524256, 524096, 64767, 32511, 261887, 127743 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 1024, 512, 512, 512, 512, 4096, 4096, 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null, null, null, null, null, null, null, null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "C46C1B3C6C1B28A6", "8070C8EC70C8E9CC", "10CC6AC6CC6AA5A6", "7A14F50014F4BFE5", "24884447884419A6", "822C288D2C287E73", "E20AF54B0AF51D6B", "065BB96B7C1BCFDA", "46EC796749C6FA66", "1FC3802B52F9611C" }; - readonly string[] oemid = + readonly string[] _oemid = { null, null, null, null, null, null, null, null, null, null }; @@ -167,17 +167,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "New Technology File System (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", + "New Technology File System (MBR)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new NTFS(); int part = -1; @@ -193,15 +193,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("NTFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("NTFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/NWFS386.cs b/Aaru.Tests/Filesystems/NWFS386.cs index a186d9c9e..300375c29 100644 --- a/Aaru.Tests/Filesystems/NWFS386.cs +++ b/Aaru.Tests/Filesystems/NWFS386.cs @@ -35,37 +35,37 @@ namespace Aaru.Tests.Filesystems [TestFixture, SuppressMessage("ReSharper", "UnusedMember.Local")] public class Nwfs386 { - readonly string[] testfiles = + readonly string[] _testfiles = { "netware_3.12.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 104857600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 104856192 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "UNKNOWN" }; diff --git a/Aaru.Tests/Filesystems/OCFS2.cs b/Aaru.Tests/Filesystems/OCFS2.cs index ba1680dcc..f9ddf3d7d 100644 --- a/Aaru.Tests/Filesystems/OCFS2.cs +++ b/Aaru.Tests/Filesystems/OCFS2.cs @@ -36,37 +36,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Ocfs2 { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 104857600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 104856192 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "UNKNOWN" }; diff --git a/Aaru.Tests/Filesystems/PFS3.cs b/Aaru.Tests/Filesystems/PFS3.cs index 91bb883e8..191d45402 100644 --- a/Aaru.Tests/Filesystems/PFS3.cs +++ b/Aaru.Tests/Filesystems/PFS3.cs @@ -40,42 +40,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Pfs3Rdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "uae.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024128 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1023552 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "PFS" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; - readonly string[] oemid = + readonly string[] _oemid = { null }; @@ -83,17 +83,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Professional File System 3", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Professional File System 3", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new PFS(); int part = -1; @@ -106,15 +106,15 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("PFS v3", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("PFS v3", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/ProDOS.cs b/Aaru.Tests/Filesystems/ProDOS.cs index 3666579e0..b95f2d43c 100644 --- a/Aaru.Tests/Filesystems/ProDOS.cs +++ b/Aaru.Tests/Filesystems/ProDOS.cs @@ -40,39 +40,39 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class ProdosApm { - readonly string[] testfiles = + readonly string[] _testfiles = { "macos_7.5.3.aif", "macos_7.6.aif", "macos_8.0.aif", "macos_8.1.aif", "macos_9.0.4.aif", "macos_9.1.aif", "macos_9.2.1.aif", "macos_9.2.2.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 49152, 49152, 49152, 49152, 49152, 49152, 49152, 49152 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 48438, 48438, 48438, 48438, 46326, 46326, 46326, 46326 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "VOLUME.LABEL", "VOLUME.LABEL", "VOLUME.LABEL", "VOLUME.LABEL", "VOLUME.LABEL", "VOLUME.LABEL", "VOLUME.LABEL", "VOLUME.LABEL" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null, null, null, null }; @@ -80,17 +80,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "ProDOS filesystem (APM)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "ProDOS filesystem (APM)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new ProDOSPlugin(); int part = -1; @@ -103,14 +103,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("ProDOS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("ProDOS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/QNX4.cs b/Aaru.Tests/Filesystems/QNX4.cs index 62b6f7aec..0d6902e32 100644 --- a/Aaru.Tests/Filesystems/QNX4.cs +++ b/Aaru.Tests/Filesystems/QNX4.cs @@ -40,32 +40,32 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Qnx4 { - readonly string[] testfiles = + readonly string[] _testfiles = { "qnx_4.24_dsdd.img.lz", "qnx_4.24_dshd.img.lz", "qnx_4.24_mf2dd.img.lz", "qnx_4.24_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DOS_525_DS_DD_9, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 720, 2400, 1440, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 720, 2400, 1440, 2880 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512, 512, 512 }; @@ -73,16 +73,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "QNX 4 filesystem", testfiles[i]); - IFilter filter = new LZip(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "QNX 4 filesystem", + _testfiles[i]); + + IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new QNX4(); var wholePart = new Partition @@ -92,11 +94,11 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("QNX4 filesystem", fs.XmlFsType.Type, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("QNX4 filesystem", fs.XmlFsType.Type, _testfiles[i]); } } } @@ -104,27 +106,27 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Qnx4Mbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "qnx_4.24.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1023104 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512 }; @@ -132,17 +134,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "QNX 4 filesystem (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "QNX 4 filesystem (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new QNX4(); int part = -1; @@ -155,12 +157,12 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("QNX4 filesystem", fs.XmlFsType.Type, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("QNX4 filesystem", fs.XmlFsType.Type, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/ReFS.cs b/Aaru.Tests/Filesystems/ReFS.cs index f32ce45da..245fe8cc2 100644 --- a/Aaru.Tests/Filesystems/ReFS.cs +++ b/Aaru.Tests/Filesystems/ReFS.cs @@ -40,42 +40,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class ReFsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "win10.vdi.lz" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 67108864 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 8372224 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; - readonly string[] oemid = + readonly string[] _oemid = { null }; @@ -83,17 +83,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Resilient File System (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Resilient File System (MBR)", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new Vdi(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); int part = -1; @@ -105,16 +105,16 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); IFilesystem fs = new ReFS(); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Resilient File System", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Resilient File System", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/Reiser3.cs b/Aaru.Tests/Filesystems/Reiser3.cs index 182e0e932..b9a56be9d 100644 --- a/Aaru.Tests/Filesystems/Reiser3.cs +++ b/Aaru.Tests/Filesystems/Reiser3.cs @@ -40,33 +40,33 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Reiser3 { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux_r3.5.aif", "linux_r3.6.aif", "linux_4.19_reiser_3.5_flashdrive.aif", "linux_4.19_reiser_3.6_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144, 262144, 1024000, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 32512, 32512, 127744, 127744 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096, 4096, 4096 }; - readonly string[] reiserversion = + readonly string[] _reiserversion = { "Reiser 3.5 filesystem", "Reiser 3.6 filesystem", "Reiser 3.5 filesystem", "Reiser 3.6 filesystem" }; @@ -74,17 +74,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Reiser filesystem v3", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Reiser filesystem v3", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new Reiser(); int part = -1; @@ -97,12 +97,12 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(reiserversion[i], fs.XmlFsType.Type, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_reiserversion[i], fs.XmlFsType.Type, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/Reiser4.cs b/Aaru.Tests/Filesystems/Reiser4.cs index 14b7ffc16..78db723ce 100644 --- a/Aaru.Tests/Filesystems/Reiser4.cs +++ b/Aaru.Tests/Filesystems/Reiser4.cs @@ -39,37 +39,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Reiser4 { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 32511 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "b0c1924e-6f10-8c42-b6c5-66a457896460" }; @@ -77,17 +77,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Reiser filesystem v4", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Reiser filesystem v4", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new Aaru.Filesystems.Reiser4(); int part = -1; @@ -100,14 +100,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Reiser 4 filesystem", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Reiser 4 filesystem", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/SFS.cs b/Aaru.Tests/Filesystems/SFS.cs index 5be2e03c9..af3036599 100644 --- a/Aaru.Tests/Filesystems/SFS.cs +++ b/Aaru.Tests/Filesystems/SFS.cs @@ -40,37 +40,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class SfsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "aros.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 409600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 408240 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512 }; - readonly string[] volumename = + readonly string[] _volumename = { null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; @@ -78,17 +78,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Smart File System (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Smart File System (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new SFS(); int part = -1; @@ -101,14 +101,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("SmartFileSystem", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("SmartFileSystem", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -116,37 +116,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class SfsMbrRdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "aros.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 409600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 406224 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512 }; - readonly string[] volumename = + readonly string[] _volumename = { null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; @@ -154,17 +154,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Smart File System (MBR+RDB)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Smart File System (MBR+RDB)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new SFS(); int part = -1; @@ -177,14 +177,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("SmartFileSystem", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("SmartFileSystem", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -192,37 +192,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class SfsRdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "uae.aif", "aros.aif", "amigaos_4.0.aif", "amigaos_4.0_sfs2.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024128, 409600, 1024128, 1024128 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 127000, 407232, 511040, 511040 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 2048, 512, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null, null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null }; @@ -230,17 +230,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Smart File System (RDB)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Smart File System (RDB)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new SFS(); int part = -1; @@ -254,14 +254,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("SmartFileSystem", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("SmartFileSystem", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/SysV.cs b/Aaru.Tests/Filesystems/SysV.cs index 553d7cf7d..b54873631 100644 --- a/Aaru.Tests/Filesystems/SysV.cs +++ b/Aaru.Tests/Filesystems/SysV.cs @@ -40,7 +40,7 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class SysV { - readonly string[] testfiles = + readonly string[] _testfiles = { "amix.adf.lz", "att_unix_svr4v2.1_dsdd.img.lz", "att_unix_svr4v2.1_mf2dd.img.lz", "att_unix_svr4v2.1_mf2hd.img.lz", "scoopenserver_5.0.7hw_dmf.img.lz", "scoopenserver_5.0.7hw_dshd.img.lz", @@ -48,43 +48,43 @@ namespace Aaru.Tests.Filesystems "scoopenserver_5.0.7hw_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.CBM_AMIGA_35_DD, MediaType.DOS_525_DS_DD_9, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD, MediaType.DMF, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1760, 720, 1440, 2880, 3360, 2400, 1440, 5760, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 880, 360, 720, 1440, 1680, 1200, 720, 2880, 1440 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "", "", "", "", "", "", "", "", "" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null, null, null, null, null }; - readonly string[] type = + readonly string[] _type = { "SVR4 fs", "SVR4 fs", "SVR4 fs", "SVR4 fs", "SVR4 fs", "SVR4 fs", "SVR4 fs", "SVR4 fs", "SVR4 fs" }; @@ -92,18 +92,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "System V filesystem", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "System V filesystem", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new SysVfs(); var wholePart = new Partition @@ -113,13 +113,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -127,42 +127,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class SysVMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "att_unix_svr4v2.1.aif", "att_unix_svr4v2.1_2k.aif", "scoopenserver_5.0.7hw.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000, 1024000, 2097152 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 511056, 255528, 1020096 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 2048, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "/usr3", "/usr3", "Volume label" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null }; - readonly string[] type = + readonly string[] _type = { "SVR4 fs", "SVR4 fs", "SVR4 fs" }; @@ -170,17 +170,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "System V filesystem (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "System V filesystem (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new SysVfs(); int part = -1; @@ -194,14 +194,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -209,42 +209,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class SysVRdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "amix.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024128 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 511424 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; - readonly string[] type = + readonly string[] _type = { "SVR4 fs" }; @@ -252,17 +252,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "System V filesystem (RDB)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "System V filesystem (RDB)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new SysVfs(); int part = -1; @@ -275,14 +275,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/UDF.cs b/Aaru.Tests/Filesystems/UDF.cs index 1f970f91d..0d84395b3 100644 --- a/Aaru.Tests/Filesystems/UDF.cs +++ b/Aaru.Tests/Filesystems/UDF.cs @@ -39,7 +39,7 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Udf { - readonly string[] testfiles = + readonly string[] _testfiles = { "1.02/linux.aif", "1.02/macosx_10.11.aif", "1.50/linux.aif", "1.50/macosx_10.11.aif", "2.00/linux.aif", "2.00/macosx_10.11.aif", "2.01/linux.aif", "2.01/macosx_10.11.aif", "2.50/linux.aif", @@ -48,43 +48,43 @@ namespace Aaru.Tests.Filesystems "2.00/linux_4.19_udf_2.00_flashdrive.aif", "2.01/linux_4.19_udf_2.01_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000, 204800, 1024000, 409600, 1024000, 614400, 1024000, 819200, 1024000, 1024000, 1228800, 8388608, 8388608, 8388608, 1024000, 1024000, 1024000, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1024000, 204800, 1024000, 409600, 1024000, 614400, 1024000, 819200, 1024000, 1024000, 1228800, 8388608, 8388608, 8388608, 1024000, 1024000, 1024000, 1024000 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly string[] udfversion = + readonly string[] _udfversion = { "UDF v1.02", "UDF v1.02", "UDF v1.50", "UDF v1.50", "UDF v2.00", "UDF v2.00", "UDF v2.01", "UDF v2.01", "UDF v2.50", "UDF v2.50", "UDF v2.60", "UDF v1.50", "UDF v1.50", "UDF v2.01", "UDF v2.01", "UDF v2.01", "UDF v2.01", "UDF v2.01" }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "*NoLabel*", "*NoLabel*", "anonymous", "DicSetter", "DicSetter", "DicSetter", "DicSetter", "DicSetter", "DicSetter" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "595c5cfa38ce8b66LinuxUDF", "6D02A231 (Mac OS X newfs_udf) UDF Volume Set", "595c5d00c5b3405aLinuxUDF", "4DD0458B (Mac OS X newfs_udf) UDF Volume Set", "595c5d07f4fc8e8dLinuxUDF", @@ -95,7 +95,7 @@ namespace Aaru.Tests.Filesystems "5cc7f4183e0d5f7aLinuxUDF", "5cc8816fcb3a3b38LinuxUDF", "595EB55A", "7cc94d726669d773" }; - readonly string[] oemid = + readonly string[] _oemid = { "*Linux UDFFS", "*Apple Mac OS X UDF FS", "*Linux UDFFS", "*Apple Mac OS X UDF FS", "*Linux UDFFS", "*Apple Mac OS X UDF FS", "*Linux UDFFS", "*Apple Mac OS X UDF FS", "*Linux UDFFS", @@ -107,17 +107,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Universal Disc Format", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new UDF(); var wholePart = new Partition @@ -127,14 +127,14 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(udfversion[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSetIdentifier, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_udfversion[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSetIdentifier, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } @@ -142,47 +142,47 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class UdfOptical { - readonly string[] testfiles = + readonly string[] _testfiles = { "1.50/ecs20.aif", "2.00/ecs20.aif", "2.01/ecs20.aif", "2.01/ecs20_cdrw.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 2295104, 2295104, 2295104, 295264 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 2048, 2048, 2048, 2048 }; - readonly long[] clusters = + readonly long[] _clusters = { 2295104, 2295104, 2295104, 295264 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 2048, 2048, 2048, 2048 }; - readonly string[] udfversion = + readonly string[] _udfversion = { "UDF v2.01", "UDF v2.01", "UDF v2.01", "UDF v2.01" }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "UDF5A5DEF48", "VolLabel", "UDF5A5DFF10" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "Volume Set ID not specified", "Volume Set ID not specified", "VolumeSetId", "Volume Set ID not specified" }; - readonly string[] oemid = + readonly string[] _oemid = { "*ExpressUDF", "*ExpressUDF", "*ExpressUDF", "*ExpressUDF" }; @@ -190,17 +190,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Universal Disc Format", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new UDF(); var wholePart = new Partition @@ -210,14 +210,14 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(udfversion[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSetIdentifier, testfiles[i]); - Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_udfversion[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSetIdentifier, _testfiles[i]); + Assert.AreEqual(_oemid[i], fs.XmlFsType.SystemIdentifier, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/UFS.cs b/Aaru.Tests/Filesystems/UFS.cs index ad50eb0ae..8dc261c57 100644 --- a/Aaru.Tests/Filesystems/UFS.cs +++ b/Aaru.Tests/Filesystems/UFS.cs @@ -40,50 +40,50 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Ufs { - readonly string[] testfiles = + readonly string[] _testfiles = { "amix_mf2dd.adf.lz", "netbsd_1.6_mf2hd.img.lz", "att_unix_svr4v2.1_dsdd.img.lz", "att_unix_svr4v2.1_dshd.img.lz", "att_unix_svr4v2.1_mf2dd.img.lz", "att_unix_svr4v2.1_mf2hd.img.lz", "solaris_2.4_mf2dd.img.lz", "solaris_2.4_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.CBM_AMIGA_35_DD, MediaType.DOS_35_HD, MediaType.DOS_525_DS_DD_9, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1760, 2880, 720, 2400, 1440, 2880, 1440, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 880, 2880, 360, 1200, 720, 1440, 711, 1422 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 512, 1024, 1024, 1024, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null, null, null, null, null, null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null, null, null, null }; - readonly string[] type = + readonly string[] _type = { "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS" }; @@ -91,16 +91,16 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "UNIX filesystem", testfiles[i]); - IFilter filter = new LZip(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "UNIX filesystem", _testfiles[i]); + IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new FFSPlugin(); var wholePart = new Partition @@ -110,13 +110,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -124,44 +124,44 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class UfsApm { - readonly string[] testfiles = + readonly string[] _testfiles = { "ffs43/darwin_1.3.1.aif", "ffs43/darwin_1.4.1.aif", "ffs43/darwin_6.0.2.aif", "ffs43/darwin_8.0.1.aif", "ufs1/darwin_1.3.1.aif", "ufs1/darwin_1.4.1.aif", "ufs1/darwin_6.0.2.aif", "ufs1/darwin_8.0.1.aif", "ufs1/macosx_10.2.aif", "ufs1/macosx_10.3.aif", "ufs1/macosx_10.4.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000, 1024000, 1024000, 1024000, 204800, 204800, 204800, 204800, 2097152, 2097152, 2097152 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 511488, 511488, 511488, 511488, 102368, 102368, 102368, 102368, 1047660, 1038952, 1038952 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null, null, null, null, null, null, null, null, null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null, null, null, null, null, null, null }; - readonly string[] type = + readonly string[] _type = { "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS" }; @@ -169,17 +169,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "UNIX filesystem (APM)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "UNIX filesystem (APM)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FFSPlugin(); int part = -1; @@ -192,14 +192,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -207,7 +207,7 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class UfsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "ufs1/linux.aif", "ufs2/linux.aif", "ffs43/darwin_1.3.1.aif", "ffs43/darwin_1.4.1.aif", "ffs43/darwin_6.0.2.aif", "ffs43/darwin_8.0.1.aif", "ffs43/dflybsd_1.2.0.aif", "ffs43/dflybsd_3.6.1.aif", @@ -219,45 +219,45 @@ namespace Aaru.Tests.Filesystems "ufs2/netbsd_7.1.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144, 262144, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 1024000, 409600, 204800, 204800, 204800, 204800, 2097152, 2097152, 2097152, 2097152, 8388608, 8388608, 2097152, 1024000, 2097152, 2097152, 16777216, 16777216, 16777216, 2097152 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 65024, 65024, 511024, 511024, 511024, 511488, 511950, 255470, 255470, 511992, 204768, 102280, 102280, 102280, 102368, 1048500, 523758, 523758, 262138, 1048231, 2096462, 524284, 511968, 1038240, 1046808, 2096472, 2096472, 4192945, 524272 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 2048, 2048, 1024, 1024, 1024, 1024, 1024, 2048, 2048, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 2048, 2048, 4096, 4096, 2048, 2048, 1024, 1024, 1024, 4096, 4096, 2048, 2048 }; - readonly string[] volumename = + readonly string[] _volumename = { null, "VolumeLabel", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "VolumeLabel", "VolumeLabel", "VolumeLabel", "" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }; - readonly string[] type = + readonly string[] _type = { "UFS", "UFS2", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS2", "UFS2", "UFS2", "UFS2" @@ -266,17 +266,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "UNIX filesystem (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "UNIX filesystem (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FFSPlugin(); int part = -1; @@ -296,14 +296,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -311,42 +311,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class UfsNeXt { - readonly string[] testfiles = + readonly string[] _testfiles = { "nextstep_3.3.aif", "openstep_4.0.aif", "openstep_4.2.aif", "rhapsody_dr1.aif", "rhapsody_dr2.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 409600, 409600, 409600, 409600, 409600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 204640, 204640, 204640, 204640, 204464 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null, null, null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null }; - readonly string[] type = + readonly string[] _type = { "UFS", "UFS", "UFS", "UFS", "UFS" }; @@ -354,17 +354,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "UNIX filesystem (NeXT)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "UNIX filesystem (NeXT)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FFSPlugin(); int part = -1; @@ -378,14 +378,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -393,7 +393,7 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class UfsNeXtFloppy { - readonly string[] testfiles = + readonly string[] _testfiles = { "nextstep_3.3_mf2dd.img.lz", "nextstep_3.3_mf2hd.img.lz", "openstep_4.0_mf2dd.img.lz", "openstep_4.0_mf2hd.img.lz", "openstep_4.2_mf2dd.img.lz", "openstep_4.2_mf2hd.img.lz", @@ -401,37 +401,37 @@ namespace Aaru.Tests.Filesystems "rhapsody_dr2_mf2hd.img.lz" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1440, 2880, 1440, 2880, 1440, 2880, 1440, 2880, 1440, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 624, 1344, 624, 1344, 624, 1344, 624, 1344, 624, 1344 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null, null, null, null, null, null, null, null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null, null, null, null, null, null }; - readonly string[] type = + readonly string[] _type = { "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS", "UFS" }; @@ -439,17 +439,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "UNIX filesystem (NeXT)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "UNIX filesystem (NeXT)", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FFSPlugin(); int part = -1; @@ -463,14 +463,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -478,42 +478,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class UfsRdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "amix.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024128 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 511424 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; - readonly string[] type = + readonly string[] _type = { "UFS" }; @@ -521,17 +521,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "UNIX filesystem (RDB)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "UNIX filesystem (RDB)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FFSPlugin(); int part = -1; @@ -544,14 +544,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -559,42 +559,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class UfsSuni86 { - readonly string[] testfiles = + readonly string[] _testfiles = { "solaris_7.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 4194304 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 2063376 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null }; - readonly string[] type = + readonly string[] _type = { "UFS" }; @@ -602,17 +602,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "UNIX filesystem (SunOS x86)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "UNIX filesystem (SunOS x86)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new FFSPlugin(); int part = -1; @@ -625,14 +625,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/UNIXBFS.cs b/Aaru.Tests/Filesystems/UNIXBFS.cs index a4fa3aced..eb500caca 100644 --- a/Aaru.Tests/Filesystems/UNIXBFS.cs +++ b/Aaru.Tests/Filesystems/UNIXBFS.cs @@ -40,39 +40,39 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Unixbfs { - readonly string[] testfiles = + readonly string[] _testfiles = { "amix_mf2dd.adf.lz", "att_unix_svr4v2.1_dsdd.img.lz", "att_unix_svr4v2.1_dshd.img.lz", "att_unix_svr4v2.1_mf2dd.img.lz", "att_unix_svr4v2.1_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.CBM_AMIGA_35_DD, MediaType.DOS_525_DS_DD_9, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1760, 720, 2400, 1440, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 1760, 720, 2400, 1440, 2880 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512, 512, 512, 512, 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Label", null, null, null, null }; @@ -80,16 +80,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Boot File System", testfiles[i]); - IFilter filter = new LZip(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Boot File System", + _testfiles[i]); + + IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new BFS(); var wholePart = new Partition @@ -99,12 +101,12 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("BFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("BFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); } } } @@ -112,32 +114,32 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class UnixbfsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 260096 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 512 }; - readonly string[] volumename = + readonly string[] _volumename = { "Label" }; @@ -145,17 +147,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Boot File System (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Boot File System (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new BFS(); int part = -1; @@ -168,13 +170,13 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("BFS", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("BFS", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); } } } @@ -182,42 +184,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class UnixbfsRdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "amix.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024128 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 65024 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 2048 }; - readonly string[] volumename = + readonly string[] _volumename = { null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "UNKNOWN" }; - readonly string[] type = + readonly string[] _type = { "UFS" }; @@ -225,17 +227,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Boot File System (RDB)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Boot File System (RDB)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new BFS(); int part = -1; @@ -248,14 +250,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/XENIX.cs b/Aaru.Tests/Filesystems/XENIX.cs index a41ad025a..9fdd41355 100644 --- a/Aaru.Tests/Filesystems/XENIX.cs +++ b/Aaru.Tests/Filesystems/XENIX.cs @@ -40,49 +40,49 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Xenix { - readonly string[] testfiles = + readonly string[] _testfiles = { "scoopenserver_5.0.7hw_dmf.img.lz", "scoopenserver_5.0.7hw_dshd.img.lz", "scoopenserver_5.0.7hw_mf2dd.img.lz", "scoopenserver_5.0.7hw_mf2ed.img.lz", "scoopenserver_5.0.7hw_mf2hd.img.lz" }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DMF, MediaType.DOS_525_HD, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_ED, MediaType.DOS_35_HD }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 3360, 2400, 1440, 5760, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 0, 0, 0, 0, 0, 1680, 1200, 720, 2880, 1440 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "", "", "", "", "" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null, null, null }; - readonly string[] type = + readonly string[] _type = { "XENIX fs", "XENIX fs", "XENIX fs", "XENIX fs", "XENIX fs" }; @@ -90,16 +90,18 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "XENIX filesystem", testfiles[i]); - IFilter filter = new LZip(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "XENIX filesystem", + _testfiles[i]); + + IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new ZZZRawImage(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new SysVfs(); var wholePart = new Partition @@ -109,13 +111,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -123,42 +125,42 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class XenixMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "xenix_2.3.2d.aif", "xenix_2.3.4h.aif", "scoopenserver_5.0.7hw.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 40960, 40960, 2097152 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 0, 0, 0, 19624, 19624, 19624 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "", "", "" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null, null }; - readonly string[] type = + readonly string[] _type = { "XENIX fs", "XENIX fs", "XENIX fs" }; @@ -166,17 +168,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "XENIX filesystem (MBR)", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "XENIX filesystem (MBR)", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new SysVfs(); int part = -1; @@ -189,14 +191,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(type[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/XFS.cs b/Aaru.Tests/Filesystems/XFS.cs index 05511d403..072870a4a 100644 --- a/Aaru.Tests/Filesystems/XFS.cs +++ b/Aaru.Tests/Filesystems/XFS.cs @@ -40,37 +40,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class XfsMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif", "linux_4.19_xfs_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1048576, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 130816, 127744 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { "Volume label", "DicSetter" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "230075b7-9834-b44e-a257-982a058311d8", "ed6b4d35-aa66-ce4a-9d8f-c56dbc6d7c8c" }; @@ -78,15 +78,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "XFS", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "XFS", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new XFS(); int part = -1; @@ -99,14 +99,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("XFS filesystem", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("XFS filesystem", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/Xia.cs b/Aaru.Tests/Filesystems/Xia.cs index 63349e4e5..f8a08f7ec 100644 --- a/Aaru.Tests/Filesystems/Xia.cs +++ b/Aaru.Tests/Filesystems/Xia.cs @@ -40,37 +40,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class XiaMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif", "linux-files.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1024000, 2048000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 511528, 1023088 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { null, null }; @@ -78,15 +78,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Xia filesystem", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Xia filesystem", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new Xia(); int part = -1; @@ -99,14 +99,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("Xia filesystem", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("Xia filesystem", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/ZFS.cs b/Aaru.Tests/Filesystems/ZFS.cs index 149d762b4..0883ce18c 100644 --- a/Aaru.Tests/Filesystems/ZFS.cs +++ b/Aaru.Tests/Filesystems/ZFS.cs @@ -39,37 +39,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Zfs { - readonly string[] testfiles = + readonly string[] _testfiles = { "netbsd_7.1.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 33554432 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 0 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 0 }; - readonly string[] volumename = + readonly string[] _volumename = { "NetBSD 7.1" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "2639895335654686206" }; @@ -77,17 +77,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Zettabyte File System", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Zettabyte File System", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IFilesystem fs = new ZFS(); var wholePart = new Partition @@ -97,13 +97,13 @@ namespace Aaru.Tests.Filesystems Size = image.Info.Sectors * image.Info.SectorSize }; - Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]); + Assert.AreEqual(true, fs.Identify(image, wholePart), _testfiles[i]); fs.GetInformation(image, wholePart, out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("ZFS filesystem", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("ZFS filesystem", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/btrfs.cs b/Aaru.Tests/Filesystems/btrfs.cs index 3aaf671bc..8e59eeba1 100644 --- a/Aaru.Tests/Filesystems/btrfs.cs +++ b/Aaru.Tests/Filesystems/btrfs.cs @@ -41,37 +41,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Btrfs { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif", "linux_4.19_btrfs_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 32512, 127744 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { "VolumeLabel", "btrfs" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "a4fc5201-85cc-6840-8a68-998cab9ae897", "5af44541-0605-f541-af6d-c229576707ab" }; @@ -79,17 +79,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "btrfs", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "btrfs", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IPartition parts = new MBR(); - Assert.AreEqual(true, parts.GetInformation(image, out List partitions, 0), testfiles[i]); + Assert.AreEqual(true, parts.GetInformation(image, out List partitions, 0), _testfiles[i]); IFilesystem fs = new BTRFS(); int part = -1; @@ -101,14 +101,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("B-tree file system", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("B-tree file system", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/exFAT.cs b/Aaru.Tests/Filesystems/exFAT.cs index bbe3c5b80..f6257d92a 100644 --- a/Aaru.Tests/Filesystems/exFAT.cs +++ b/Aaru.Tests/Filesystems/exFAT.cs @@ -40,37 +40,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class ExFatApm { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 32710 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "595AC82C" }; @@ -78,15 +78,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "exFAT (APM)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "exFAT (APM)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new exFAT(); int part = -1; @@ -99,14 +99,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("exFAT", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("exFAT", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -114,37 +114,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class ExFatGpt { - readonly string[] testfiles = + readonly string[] _testfiles = { "macosx_10.11.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 32208 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096 }; - readonly string[] volumename = + readonly string[] _volumename = { null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "595ACC39" }; @@ -152,15 +152,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "exFAT (GPT)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "exFAT (GPT)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new exFAT(); int part = -1; @@ -173,14 +173,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("exFAT", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("exFAT", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } @@ -188,37 +188,37 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class ExFatMbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif", "macosx_10.11.aif", "win10.aif", "winvista.aif", "linux_4.19_exfat_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144, 262144, 262144, 262144, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 32464, 32712, 32448, 32208, 15964 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 4096, 4096, 4096, 4096, 32768 }; - readonly string[] volumename = + readonly string[] _volumename = { null, null, null, null, null }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "603565AC", "595AC21E", "20126663", "0AC5CA52", "636E083B" }; @@ -226,15 +226,15 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "exFAT (MBR)", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "exFAT (MBR)", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); List partitions = Core.Partitions.GetAll(image); IFilesystem fs = new exFAT(); int part = -1; @@ -247,14 +247,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual("exFAT", fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual("exFAT", fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filesystems/ext2.cs b/Aaru.Tests/Filesystems/ext2.cs index 7ef6841a2..584a14791 100644 --- a/Aaru.Tests/Filesystems/ext2.cs +++ b/Aaru.Tests/Filesystems/ext2.cs @@ -41,39 +41,39 @@ namespace Aaru.Tests.Filesystems [TestFixture] public class Ext2 { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux_ext2.aif", "linux_ext3.aif", "linux_ext4.aif", "netbsd_7.1.aif", "netbsd_7.1_r0.aif", "linux_4.19_ext2_flashdrive.aif", "linux_4.19_ext3_flashdrive.aif", "linux_4.19_ext4_flashdrive.aif" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 262144, 262144, 262144, 8388608, 2097152, 1024000, 1024000, 1024000 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly long[] clusters = + readonly long[] _clusters = { 130048, 130048, 130048, 1046567, 260135, 510976, 510976, 510976 }; - readonly int[] clustersize = + readonly int[] _clustersize = { 1024, 1024, 1024, 4096, 4096, 1024, 1024, 1024 }; - readonly string[] volumename = + readonly string[] _volumename = { "VolumeLabel", "VolumeLabel", "VolumeLabel", "Volume label", "Volume label", "DicSetter", "DicSetter", "DicSetter" }; - readonly string[] volumeserial = + readonly string[] _volumeserial = { "8e3992cf-7d98-e44a-b753-0591a35913eb", "1b411516-5415-4b42-95e6-1a247056a960", "b2f8f305-770f-ad47-abe4-f0484aa319e9", "e72aee05-627b-11e7-a573-0800272a08ec", @@ -81,7 +81,7 @@ namespace Aaru.Tests.Filesystems "a3914b55-260f-7245-8c72-7ccdf45436cb", "10413797-43d1-6545-8fbc-6ebc9d328be9" }; - readonly string[] extversion = + readonly string[] _extversion = { "ext2", "ext3", "ext4", "ext2", "ext2", "ext2", "ext3", "ext4" }; @@ -89,17 +89,17 @@ namespace Aaru.Tests.Filesystems [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "ext2", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "ext2", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); IPartition parts = new MBR(); - Assert.AreEqual(true, parts.GetInformation(image, out List partitions, 0), testfiles[i]); + Assert.AreEqual(true, parts.GetInformation(image, out List partitions, 0), _testfiles[i]); IFilesystem fs = new ext2FS(); int part = -1; @@ -111,14 +111,14 @@ namespace Aaru.Tests.Filesystems break; } - Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); - Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); + Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}"); + Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); - Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); - Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); - Assert.AreEqual(extversion[i], fs.XmlFsType.Type, testfiles[i]); - Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); - Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); + Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]); + Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]); + Assert.AreEqual(_extversion[i], fs.XmlFsType.Type, _testfiles[i]); + Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]); + Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]); } } } diff --git a/Aaru.Tests/Filters/AppleDoubleDave.cs b/Aaru.Tests/Filters/AppleDoubleDave.cs index b9e291f02..d37597d7d 100644 --- a/Aaru.Tests/Filters/AppleDoubleDave.cs +++ b/Aaru.Tests/Filters/AppleDoubleDave.cs @@ -41,22 +41,22 @@ namespace Aaru.Tests.Filters const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250"; const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4"; const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3"; - readonly string location; - readonly string sidecar; + readonly string _location; + readonly string _sidecar; public AppleDoubleDave() { - location = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "dave", "DOS_720.dmg"); + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "dave", "DOS_720.dmg"); - sidecar = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "dave", "resource.frk", - "DOS_720.dmg"); + _sidecar = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "dave", "resource.frk", + "DOS_720.dmg"); } [Test] public void CheckContents() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[737280]; str.Read(data, 0, 737280); @@ -70,10 +70,10 @@ namespace Aaru.Tests.Filters [Test] public void CheckCorrectFile() { - string result = Md5Context.File(location, out _); + string result = Md5Context.File(_location, out _); Assert.AreEqual(EXPECTED_FILE, result); - result = Md5Context.File(sidecar, out _); + result = Md5Context.File(_sidecar, out _); Assert.AreEqual(EXPECTED_SIDECAR, result); } @@ -81,14 +81,14 @@ namespace Aaru.Tests.Filters public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void CheckResource() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetResourceForkStream(); byte[] data = new byte[286]; str.Read(data, 0, 286); @@ -103,7 +103,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(737280, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/AppleDoubleDos.cs b/Aaru.Tests/Filters/AppleDoubleDos.cs index 68dcdb37d..1f461cf95 100644 --- a/Aaru.Tests/Filters/AppleDoubleDos.cs +++ b/Aaru.Tests/Filters/AppleDoubleDos.cs @@ -41,20 +41,20 @@ namespace Aaru.Tests.Filters const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250"; const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4"; const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3"; - readonly string location; - readonly string sidecar; + readonly string _location; + readonly string _sidecar; public AppleDoubleDos() { - location = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "dos", "DOS_720.dmg"); - sidecar = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "dos", "DOS_720.adf"); + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "dos", "DOS_720.dmg"); + _sidecar = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "dos", "DOS_720.adf"); } [Test] public void CheckContents() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[737280]; str.Read(data, 0, 737280); @@ -68,10 +68,10 @@ namespace Aaru.Tests.Filters [Test] public void CheckCorrectFile() { - string result = Md5Context.File(location, out _); + string result = Md5Context.File(_location, out _); Assert.AreEqual(EXPECTED_FILE, result); - result = Md5Context.File(sidecar, out _); + result = Md5Context.File(_sidecar, out _); Assert.AreEqual(EXPECTED_SIDECAR, result); } @@ -79,14 +79,14 @@ namespace Aaru.Tests.Filters public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void CheckResource() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetResourceForkStream(); byte[] data = new byte[286]; str.Read(data, 0, 286); @@ -101,7 +101,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(737280, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/AppleDoubleNetatalk.cs b/Aaru.Tests/Filters/AppleDoubleNetatalk.cs index 6d76bed03..cf62edc69 100644 --- a/Aaru.Tests/Filters/AppleDoubleNetatalk.cs +++ b/Aaru.Tests/Filters/AppleDoubleNetatalk.cs @@ -41,22 +41,22 @@ namespace Aaru.Tests.Filters const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250"; const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4"; const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3"; - readonly string location; - readonly string sidecar; + readonly string _location; + readonly string _sidecar; public AppleDoubleNetatalk() { - location = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "netatalk", "DOS_720.dmg"); + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "netatalk", "DOS_720.dmg"); - sidecar = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "netatalk", ".AppleDouble", - "DOS_720.dmg"); + _sidecar = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "netatalk", ".AppleDouble", + "DOS_720.dmg"); } [Test] public void CheckContents() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[737280]; str.Read(data, 0, 737280); @@ -70,10 +70,10 @@ namespace Aaru.Tests.Filters [Test] public void CheckCorrectFile() { - string result = Md5Context.File(location, out _); + string result = Md5Context.File(_location, out _); Assert.AreEqual(EXPECTED_FILE, result); - result = Md5Context.File(sidecar, out _); + result = Md5Context.File(_sidecar, out _); Assert.AreEqual(EXPECTED_SIDECAR, result); } @@ -81,14 +81,14 @@ namespace Aaru.Tests.Filters public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void CheckResource() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetResourceForkStream(); byte[] data = new byte[286]; str.Read(data, 0, 286); @@ -103,7 +103,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(737280, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/AppleDoubleOsX.cs b/Aaru.Tests/Filters/AppleDoubleOsX.cs index 0e335b28e..71071f1c4 100644 --- a/Aaru.Tests/Filters/AppleDoubleOsX.cs +++ b/Aaru.Tests/Filters/AppleDoubleOsX.cs @@ -41,20 +41,20 @@ namespace Aaru.Tests.Filters const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250"; const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4"; const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3"; - readonly string location; - readonly string sidecar; + readonly string _location; + readonly string _sidecar; public AppleDoubleOsX() { - location = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "osx", "DOS_720.dmg"); - sidecar = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "osx", "._DOS_720.dmg"); + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "osx", "DOS_720.dmg"); + _sidecar = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "osx", "._DOS_720.dmg"); } [Test] public void CheckContents() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[737280]; str.Read(data, 0, 737280); @@ -68,10 +68,10 @@ namespace Aaru.Tests.Filters [Test] public void CheckCorrectFile() { - string result = Md5Context.File(location, out _); + string result = Md5Context.File(_location, out _); Assert.AreEqual(EXPECTED_FILE, result); - result = Md5Context.File(sidecar, out _); + result = Md5Context.File(_sidecar, out _); Assert.AreEqual(EXPECTED_SIDECAR, result); } @@ -79,14 +79,14 @@ namespace Aaru.Tests.Filters public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void CheckResource() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetResourceForkStream(); byte[] data = new byte[286]; str.Read(data, 0, 286); @@ -101,7 +101,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(737280, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/AppleDoubleProDos.cs b/Aaru.Tests/Filters/AppleDoubleProDos.cs index 280a6a0bc..2f207a3d2 100644 --- a/Aaru.Tests/Filters/AppleDoubleProDos.cs +++ b/Aaru.Tests/Filters/AppleDoubleProDos.cs @@ -41,20 +41,20 @@ namespace Aaru.Tests.Filters const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250"; const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4"; const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3"; - readonly string location; - readonly string sidecar; + readonly string _location; + readonly string _sidecar; public AppleDoubleProDos() { - location = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "prodos", "DOS_720.dmg"); - sidecar = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "prodos", "R.DOS_720.dmg"); + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "prodos", "DOS_720.dmg"); + _sidecar = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "prodos", "R.DOS_720.dmg"); } [Test] public void CheckContents() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[737280]; str.Read(data, 0, 737280); @@ -68,10 +68,10 @@ namespace Aaru.Tests.Filters [Test] public void CheckCorrectFile() { - string result = Md5Context.File(location, out _); + string result = Md5Context.File(_location, out _); Assert.AreEqual(EXPECTED_FILE, result); - result = Md5Context.File(sidecar, out _); + result = Md5Context.File(_sidecar, out _); Assert.AreEqual(EXPECTED_SIDECAR, result); } @@ -79,14 +79,14 @@ namespace Aaru.Tests.Filters public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void CheckResource() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetResourceForkStream(); byte[] data = new byte[286]; str.Read(data, 0, 286); @@ -101,7 +101,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(737280, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/AppleDoubleUnAr.cs b/Aaru.Tests/Filters/AppleDoubleUnAr.cs index cb92f0db0..719f0a8b4 100644 --- a/Aaru.Tests/Filters/AppleDoubleUnAr.cs +++ b/Aaru.Tests/Filters/AppleDoubleUnAr.cs @@ -41,20 +41,20 @@ namespace Aaru.Tests.Filters const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250"; const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4"; const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3"; - readonly string location; - readonly string sidecar; + readonly string _location; + readonly string _sidecar; public AppleDoubleUnAr() { - location = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "unar", "DOS_720.dmg"); - sidecar = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "unar", "DOS_720.dmg.rsrc"); + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "unar", "DOS_720.dmg"); + _sidecar = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "unar", "DOS_720.dmg.rsrc"); } [Test] public void CheckContents() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[737280]; str.Read(data, 0, 737280); @@ -68,10 +68,10 @@ namespace Aaru.Tests.Filters [Test] public void CheckCorrectFile() { - string result = Md5Context.File(location, out _); + string result = Md5Context.File(_location, out _); Assert.AreEqual(EXPECTED_FILE, result); - result = Md5Context.File(sidecar, out _); + result = Md5Context.File(_sidecar, out _); Assert.AreEqual(EXPECTED_SIDECAR, result); } @@ -79,14 +79,14 @@ namespace Aaru.Tests.Filters public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void CheckResource() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetResourceForkStream(); byte[] data = new byte[286]; str.Read(data, 0, 286); @@ -101,7 +101,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(737280, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/AppleDoubleUnix.cs b/Aaru.Tests/Filters/AppleDoubleUnix.cs index 5c6980279..b80738f00 100644 --- a/Aaru.Tests/Filters/AppleDoubleUnix.cs +++ b/Aaru.Tests/Filters/AppleDoubleUnix.cs @@ -41,20 +41,20 @@ namespace Aaru.Tests.Filters const string EXPECTED_SIDECAR = "7b0c25bf8cb70f6fb1a15eca31585250"; const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4"; const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3"; - readonly string location; - readonly string sidecar; + readonly string _location; + readonly string _sidecar; public AppleDoubleUnix() { - location = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "unix", "DOS_720.dmg"); - sidecar = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleDouble", "unix", "%DOS_720.dmg"); + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "unix", "DOS_720.dmg"); + _sidecar = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleDouble", "unix", "%DOS_720.dmg"); } [Test] public void CheckContents() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[737280]; str.Read(data, 0, 737280); @@ -68,10 +68,10 @@ namespace Aaru.Tests.Filters [Test] public void CheckCorrectFile() { - string result = Md5Context.File(location, out _); + string result = Md5Context.File(_location, out _); Assert.AreEqual(EXPECTED_FILE, result); - result = Md5Context.File(sidecar, out _); + result = Md5Context.File(_sidecar, out _); Assert.AreEqual(EXPECTED_SIDECAR, result); } @@ -79,14 +79,14 @@ namespace Aaru.Tests.Filters public void CheckFilterId() { IFilter filter = new AppleDouble(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void CheckResource() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetResourceForkStream(); byte[] data = new byte[286]; str.Read(data, 0, 286); @@ -101,7 +101,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(737280, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/AppleSingle.cs b/Aaru.Tests/Filters/AppleSingle.cs index c56c950c3..b5cb8ce37 100644 --- a/Aaru.Tests/Filters/AppleSingle.cs +++ b/Aaru.Tests/Filters/AppleSingle.cs @@ -39,15 +39,16 @@ namespace Aaru.Tests.Filters const string EXPECTED_FILE = "7497a3b156dcd0c1046a1ab12e188ab7"; const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4"; const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3"; - readonly string location; + readonly string _location; - public AppleSingle() => location = Path.Combine(Consts.TestFilesRoot, "Filters", "AppleSingle", "DOS_720.ASF"); + public AppleSingle() => + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "AppleSingle", "DOS_720.ASF"); [Test] public void CheckContents() { IFilter filter = new Aaru.Filters.AppleSingle(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[737280]; str.Read(data, 0, 737280); @@ -61,7 +62,7 @@ namespace Aaru.Tests.Filters [Test] public void CheckCorrectFile() { - string result = Md5Context.File(location, out _); + string result = Md5Context.File(_location, out _); Assert.AreEqual(EXPECTED_FILE, result); } @@ -69,14 +70,14 @@ namespace Aaru.Tests.Filters public void CheckFilterId() { IFilter filter = new Aaru.Filters.AppleSingle(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void CheckResource() { IFilter filter = new Aaru.Filters.AppleSingle(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetResourceForkStream(); byte[] data = new byte[286]; str.Read(data, 0, 286); @@ -91,7 +92,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new Aaru.Filters.AppleSingle(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(737280, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/BZip2.cs b/Aaru.Tests/Filters/BZip2.cs index 19095ceb9..ebefba3bb 100644 --- a/Aaru.Tests/Filters/BZip2.cs +++ b/Aaru.Tests/Filters/BZip2.cs @@ -36,23 +36,23 @@ namespace Aaru.Tests.Filters [TestFixture] public class BZip2 { - static readonly byte[] ExpectedFile = + static readonly byte[] _expectedFile = { 0xf8, 0xb6, 0xbc, 0x62, 0x33, 0xcf, 0x1d, 0x28, 0x02, 0xef, 0x80, 0xf1, 0xe4, 0xfc, 0x1b, 0xdf }; - static readonly byte[] ExpectedContents = + static readonly byte[] _expectedContents = { 0x18, 0x90, 0x5a, 0xf9, 0x83, 0xd8, 0x2b, 0xdd, 0x1a, 0xcc, 0x69, 0x75, 0x4f, 0x0f, 0x81, 0x5e }; - readonly string location; + readonly string _location; - public BZip2() => location = Path.Combine(Consts.TestFilesRoot, "Filters", "bzip2.bz2"); + public BZip2() => _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "bzip2.bz2"); [Test] public void CheckContents() { IFilter filter = new Aaru.Filters.BZip2(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[1048576]; str.Read(data, 0, 1048576); @@ -60,28 +60,28 @@ namespace Aaru.Tests.Filters str.Dispose(); filter.Close(); Md5Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedContents, result); + Assert.AreEqual(_expectedContents, result); } [Test] public void CheckCorrectFile() { - byte[] result = Md5Context.File(location); - Assert.AreEqual(ExpectedFile, result); + byte[] result = Md5Context.File(_location); + Assert.AreEqual(_expectedFile, result); } [Test] public void CheckFilterId() { IFilter filter = new Aaru.Filters.BZip2(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void Test() { IFilter filter = new Aaru.Filters.BZip2(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(1048576, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/GZip.cs b/Aaru.Tests/Filters/GZip.cs index d1fc241af..c8452b7ef 100644 --- a/Aaru.Tests/Filters/GZip.cs +++ b/Aaru.Tests/Filters/GZip.cs @@ -36,23 +36,23 @@ namespace Aaru.Tests.Filters [TestFixture] public class GZip { - static readonly byte[] ExpectedFile = + static readonly byte[] _expectedFile = { 0x35, 0xe2, 0x9c, 0x9d, 0x05, 0x1b, 0x6d, 0xa6, 0x6c, 0x24, 0xeb, 0x30, 0xe8, 0xd2, 0xa6, 0x6b }; - static readonly byte[] ExpectedContents = + static readonly byte[] _expectedContents = { 0x18, 0x90, 0x5a, 0xf9, 0x83, 0xd8, 0x2b, 0xdd, 0x1a, 0xcc, 0x69, 0x75, 0x4f, 0x0f, 0x81, 0x5e }; - readonly string location; + readonly string _location; - public GZip() => location = Path.Combine(Consts.TestFilesRoot, "Filters", "gzip.gz"); + public GZip() => _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "gzip.gz"); [Test] public void CheckContents() { IFilter filter = new Aaru.Filters.GZip(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[1048576]; str.Read(data, 0, 1048576); @@ -60,28 +60,28 @@ namespace Aaru.Tests.Filters str.Dispose(); filter.Close(); Md5Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedContents, result); + Assert.AreEqual(_expectedContents, result); } [Test] public void CheckCorrectFile() { - byte[] result = Md5Context.File(location); - Assert.AreEqual(ExpectedFile, result); + byte[] result = Md5Context.File(_location); + Assert.AreEqual(_expectedFile, result); } [Test] public void CheckFilterId() { IFilter filter = new Aaru.Filters.GZip(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void Test() { IFilter filter = new Aaru.Filters.GZip(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(1048576, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/LZip.cs b/Aaru.Tests/Filters/LZip.cs index 8eca0c526..2c8956c52 100644 --- a/Aaru.Tests/Filters/LZip.cs +++ b/Aaru.Tests/Filters/LZip.cs @@ -36,23 +36,23 @@ namespace Aaru.Tests.Filters [TestFixture] public class LZip { - static readonly byte[] ExpectedFile = + static readonly byte[] _expectedFile = { 0x3f, 0x7b, 0x77, 0x3e, 0x52, 0x48, 0xd5, 0x26, 0xf4, 0xb1, 0xac, 0x15, 0xb2, 0xb3, 0x5f, 0x87 }; - static readonly byte[] ExpectedContents = + static readonly byte[] _expectedContents = { 0x18, 0x90, 0x5a, 0xf9, 0x83, 0xd8, 0x2b, 0xdd, 0x1a, 0xcc, 0x69, 0x75, 0x4f, 0x0f, 0x81, 0x5e }; - readonly string location; + readonly string _location; - public LZip() => location = Path.Combine(Consts.TestFilesRoot, "Filters", "lzip.lz"); + public LZip() => _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "lzip.lz"); [Test] public void CheckContents() { IFilter filter = new Aaru.Filters.LZip(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[1048576]; str.Read(data, 0, 1048576); @@ -60,28 +60,28 @@ namespace Aaru.Tests.Filters str.Dispose(); filter.Close(); Md5Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedContents, result); + Assert.AreEqual(_expectedContents, result); } [Test] public void CheckCorrectFile() { - byte[] result = Md5Context.File(location); - Assert.AreEqual(ExpectedFile, result); + byte[] result = Md5Context.File(_location); + Assert.AreEqual(_expectedFile, result); } [Test] public void CheckFilterId() { IFilter filter = new Aaru.Filters.LZip(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void Test() { IFilter filter = new Aaru.Filters.LZip(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(1048576, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/MacBinary1.cs b/Aaru.Tests/Filters/MacBinary1.cs index 7bc5c41fc..9b74b60ff 100644 --- a/Aaru.Tests/Filters/MacBinary1.cs +++ b/Aaru.Tests/Filters/MacBinary1.cs @@ -39,15 +39,16 @@ namespace Aaru.Tests.Filters const string EXPECTED_FILE = "596c38555bc7ba284648d1ce57700884"; const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4"; const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3"; - readonly string location; + readonly string _location; - public MacBinary1() => location = Path.Combine(Consts.TestFilesRoot, "Filters", "MacBinary", "macbinary1.bin"); + public MacBinary1() => + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "MacBinary", "macbinary1.bin"); [Test] public void CheckContents() { IFilter filter = new Aaru.Filters.AppleSingle(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[737280]; str.Read(data, 0, 737280); @@ -61,7 +62,7 @@ namespace Aaru.Tests.Filters [Test] public void CheckCorrectFile() { - string result = Md5Context.File(location, out _); + string result = Md5Context.File(_location, out _); Assert.AreEqual(EXPECTED_FILE, result); } @@ -69,14 +70,14 @@ namespace Aaru.Tests.Filters public void CheckFilterId() { IFilter filter = new Aaru.Filters.AppleSingle(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void CheckResource() { IFilter filter = new Aaru.Filters.AppleSingle(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetResourceForkStream(); byte[] data = new byte[286]; str.Read(data, 0, 286); @@ -91,7 +92,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new Aaru.Filters.AppleSingle(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(737280, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/MacBinary2.cs b/Aaru.Tests/Filters/MacBinary2.cs index bd1173a8f..4322956c6 100644 --- a/Aaru.Tests/Filters/MacBinary2.cs +++ b/Aaru.Tests/Filters/MacBinary2.cs @@ -40,15 +40,16 @@ namespace Aaru.Tests.Filters const string EXPECTED_FILE = "a8daa55a65432353e95dc4c61d42660f"; const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4"; const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3"; - readonly string location; + readonly string _location; - public MacBinary2() => location = Path.Combine(Consts.TestFilesRoot, "Filters", "MacBinary", "macbinary2.bin"); + public MacBinary2() => + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "MacBinary", "macbinary2.bin"); [Test] public void CheckContents() { IFilter filter = new MacBinary(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[737280]; str.Read(data, 0, 737280); @@ -62,7 +63,7 @@ namespace Aaru.Tests.Filters [Test] public void CheckCorrectFile() { - string result = Md5Context.File(location, out _); + string result = Md5Context.File(_location, out _); Assert.AreEqual(EXPECTED_FILE, result); } @@ -70,14 +71,14 @@ namespace Aaru.Tests.Filters public void CheckFilterId() { IFilter filter = new MacBinary(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void CheckResource() { IFilter filter = new MacBinary(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetResourceForkStream(); byte[] data = new byte[286]; str.Read(data, 0, 286); @@ -92,7 +93,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new MacBinary(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(737280, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/MacBinary3.cs b/Aaru.Tests/Filters/MacBinary3.cs index 83135aa25..527de5d32 100644 --- a/Aaru.Tests/Filters/MacBinary3.cs +++ b/Aaru.Tests/Filters/MacBinary3.cs @@ -40,15 +40,16 @@ namespace Aaru.Tests.Filters const string EXPECTED_FILE = "3a7363a6109fb52a264b0b45dfa16694"; const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4"; const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3"; - readonly string location; + readonly string _location; - public MacBinary3() => location = Path.Combine(Consts.TestFilesRoot, "Filters", "MacBinary", "macbinary3.bin"); + public MacBinary3() => + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "MacBinary", "macbinary3.bin"); [Test] public void CheckContents() { IFilter filter = new MacBinary(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[737280]; str.Read(data, 0, 737280); @@ -62,7 +63,7 @@ namespace Aaru.Tests.Filters [Test] public void CheckCorrectFile() { - string result = Md5Context.File(location, out _); + string result = Md5Context.File(_location, out _); Assert.AreEqual(EXPECTED_FILE, result); } @@ -70,14 +71,14 @@ namespace Aaru.Tests.Filters public void CheckFilterId() { IFilter filter = new MacBinary(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void CheckResource() { IFilter filter = new MacBinary(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetResourceForkStream(); byte[] data = new byte[286]; str.Read(data, 0, 286); @@ -92,7 +93,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new MacBinary(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(737280, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/PCExchange.cs b/Aaru.Tests/Filters/PCExchange.cs index 491590c98..a0255bfe4 100644 --- a/Aaru.Tests/Filters/PCExchange.cs +++ b/Aaru.Tests/Filters/PCExchange.cs @@ -29,7 +29,6 @@ using System.IO; using Aaru.Checksums; using Aaru.CommonTypes.Interfaces; -using Aaru.Filters; using NUnit.Framework; namespace Aaru.Tests.Filters @@ -40,16 +39,16 @@ namespace Aaru.Tests.Filters const string EXPECTED_FILE = "348825a08fa84766d20b91ed917012b9"; const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4"; const string EXPECTED_RESOURCE = "5cb168d60ce8b2b1b3133c2faaf47165"; - readonly string location; + readonly string _location; public PcExchange() => - location = Path.Combine(Consts.TestFilesRoot, "Filters", "PC Exchange", "DC6_RW_DOS_720.img"); + _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "PC Exchange", "DC6_RW_DOS_720.img"); [Test] public void CheckContents() { - IFilter filter = new PCExchange(); - filter.Open(location); + IFilter filter = new Aaru.Filters.PcExchange(); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[737280]; str.Read(data, 0, 737280); @@ -63,8 +62,8 @@ namespace Aaru.Tests.Filters [Test] public void CheckCorrectFile() { - string result = Md5Context.File(Path.Combine(Consts.TestFilesRoot, "Filters", "PC Exchange", "FINDER.DAT"), - out _); + string result = + Md5Context.File(Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "PC Exchange", "FINDER.DAT"), out _); Assert.AreEqual(EXPECTED_FILE, result); } @@ -72,15 +71,15 @@ namespace Aaru.Tests.Filters [Test] public void CheckFilterId() { - IFilter filter = new PCExchange(); - Assert.AreEqual(true, filter.Identify(location)); + IFilter filter = new Aaru.Filters.PcExchange(); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void CheckResource() { - IFilter filter = new PCExchange(); - filter.Open(location); + IFilter filter = new Aaru.Filters.PcExchange(); + filter.Open(_location); Stream str = filter.GetResourceForkStream(); byte[] data = new byte[546]; str.Read(data, 0, 546); @@ -94,8 +93,8 @@ namespace Aaru.Tests.Filters [Test] public void Test() { - IFilter filter = new PCExchange(); - filter.Open(location); + IFilter filter = new Aaru.Filters.PcExchange(); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(737280, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Filters/XZ.cs b/Aaru.Tests/Filters/XZ.cs index 026fdaa52..ce98e532e 100644 --- a/Aaru.Tests/Filters/XZ.cs +++ b/Aaru.Tests/Filters/XZ.cs @@ -37,23 +37,23 @@ namespace Aaru.Tests.Filters [TestFixture] public class Xz { - static readonly byte[] ExpectedFile = + static readonly byte[] _expectedFile = { 0x6c, 0x88, 0xa5, 0x9a, 0x1b, 0x7a, 0xec, 0x59, 0x2b, 0xef, 0x8a, 0x28, 0xdb, 0x11, 0x01, 0xc8 }; - static readonly byte[] ExpectedContents = + static readonly byte[] _expectedContents = { 0x18, 0x90, 0x5a, 0xf9, 0x83, 0xd8, 0x2b, 0xdd, 0x1a, 0xcc, 0x69, 0x75, 0x4f, 0x0f, 0x81, 0x5e }; - readonly string location; + readonly string _location; - public Xz() => location = Path.Combine(Consts.TestFilesRoot, "Filters", "xz.xz"); + public Xz() => _location = Path.Combine(Consts.TEST_FILES_ROOT, "Filters", "xz.xz"); [Test] public void CheckContents() { IFilter filter = new XZ(); - filter.Open(location); + filter.Open(_location); Stream str = filter.GetDataForkStream(); byte[] data = new byte[1048576]; str.Read(data, 0, 1048576); @@ -61,28 +61,28 @@ namespace Aaru.Tests.Filters str.Dispose(); filter.Close(); Md5Context.Data(data, out byte[] result); - Assert.AreEqual(ExpectedContents, result); + Assert.AreEqual(_expectedContents, result); } [Test] public void CheckCorrectFile() { - byte[] result = Md5Context.File(location); - Assert.AreEqual(ExpectedFile, result); + byte[] result = Md5Context.File(_location); + Assert.AreEqual(_expectedFile, result); } [Test] public void CheckFilterId() { IFilter filter = new XZ(); - Assert.AreEqual(true, filter.Identify(location)); + Assert.AreEqual(true, filter.Identify(_location)); } [Test] public void Test() { IFilter filter = new XZ(); - filter.Open(location); + filter.Open(_location); Assert.AreEqual(true, filter.IsOpened()); Assert.AreEqual(1048576, filter.GetDataForkLength()); Assert.AreNotEqual(null, filter.GetDataForkStream()); diff --git a/Aaru.Tests/Images/2MG.cs b/Aaru.Tests/Images/2MG.cs index a66499b09..448b04b4f 100644 --- a/Aaru.Tests/Images/2MG.cs +++ b/Aaru.Tests/Images/2MG.cs @@ -38,29 +38,29 @@ namespace Aaru.Tests.Images [TestFixture] public class Apple2Mg { - readonly string[] testfiles = + readonly string[] _testfiles = { "blank140.2mg.lz", "dos32.2mg.lz", "dos33-do.2mg.lz", "dos33-nib.2mg.lz", "dos33-po.2mg.lz", "prodos1440.2mg.lz" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 560, 455, 560, 560, 560, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 256, 256, 256, 256, 256, 512 }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.Apple33SS, MediaType.Apple32SS, MediaType.Apple33SS, MediaType.Apple33SS, MediaType.Apple33SS, MediaType.DOS_35_HD }; - readonly string[] md5S = + readonly string[] _md5S = { "7db5d585270ab858043d50e60068d45f", "906c1bdbf76bf089ea47aae98151df5d", "91d020725d081500caa1fd8aad959397", "91d020725d081500caa1fd8aad959397", "91d020725d081500caa1fd8aad959397", "eb9b60c78b30d2b6541ed0781944b6da" @@ -69,20 +69,20 @@ namespace Aaru.Tests.Images [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Media image formats", "2mg", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Media image formats", "2mg", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new DiscImages.Apple2Mg(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); // How many sectors to read at once - const uint SECTORS_TO_READ = 256; - ulong doneSectors = 0; + const uint sectorsToRead = 256; + ulong doneSectors = 0; var ctx = new Md5Context(); @@ -90,10 +90,10 @@ namespace Aaru.Tests.Images { byte[] sector; - if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ) + if(image.Info.Sectors - doneSectors >= sectorsToRead) { - sector = image.ReadSectors(doneSectors, SECTORS_TO_READ); - doneSectors += SECTORS_TO_READ; + sector = image.ReadSectors(doneSectors, sectorsToRead); + doneSectors += sectorsToRead; } else { @@ -104,7 +104,7 @@ namespace Aaru.Tests.Images ctx.Update(sector); } - Assert.AreEqual(md5S[i], ctx.End(), testfiles[i]); + Assert.AreEqual(_md5S[i], ctx.End(), _testfiles[i]); } } } diff --git a/Aaru.Tests/Images/Anex86.cs b/Aaru.Tests/Images/Anex86.cs index 7926e16dd..1759963e1 100644 --- a/Aaru.Tests/Images/Anex86.cs +++ b/Aaru.Tests/Images/Anex86.cs @@ -38,31 +38,31 @@ namespace Aaru.Tests.Images [TestFixture] public class Anex86 { - readonly string[] testfiles = + readonly string[] _testfiles = { "anex86_10mb.hdi.lz", "anex86_15mb.hdi.lz", "anex86_20mb.hdi.lz", "anex86_30mb.hdi.lz", "anex86_40mb.hdi.lz", "anex86_5mb.hdi.lz", "blank_md2hd.fdi.lz", "msdos33d_md2hd.fdi.lz", "msdos50_epson_md2hd.fdi.lz", "msdos50_md2hd.fdi.lz", "msdos62_md2hd.fdi.lz" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 40920, 61380, 81840, 121770, 162360, 20196, 1232, 1232, 1232, 1232, 1232 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 256, 256, 256, 256, 256, 256, 1024, 1024, 1024, 1024, 1024 }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.GENERIC_HDD, MediaType.GENERIC_HDD, MediaType.GENERIC_HDD, MediaType.GENERIC_HDD, MediaType.GENERIC_HDD, MediaType.GENERIC_HDD, MediaType.NEC_525_HD, MediaType.NEC_525_HD, MediaType.NEC_525_HD, MediaType.NEC_525_HD, MediaType.NEC_525_HD }; - readonly string[] md5S = + readonly string[] _md5S = { "1c5387e38e58165c517c059e5d48905d", "a84366658c1c3bd09af4d0d42fbf716e", "919c9eecf1b65b10870f617cb976668a", "02d35af02581afb2e56792dcaba2c1af", "b8c3f858f1a9d300d3e74f36eea04354", "c348bbbaf99fcb8c8e66de157aef62f4", @@ -73,20 +73,20 @@ namespace Aaru.Tests.Images [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Media image formats", "Anex86", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Media image formats", "Anex86", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new DiscImages.Anex86(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); // How many sectors to read at once - const uint SECTORS_TO_READ = 256; - ulong doneSectors = 0; + const uint sectorsToRead = 256; + ulong doneSectors = 0; var ctx = new Md5Context(); @@ -94,10 +94,10 @@ namespace Aaru.Tests.Images { byte[] sector; - if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ) + if(image.Info.Sectors - doneSectors >= sectorsToRead) { - sector = image.ReadSectors(doneSectors, SECTORS_TO_READ); - doneSectors += SECTORS_TO_READ; + sector = image.ReadSectors(doneSectors, sectorsToRead); + doneSectors += sectorsToRead; } else { @@ -108,7 +108,7 @@ namespace Aaru.Tests.Images ctx.Update(sector); } - Assert.AreEqual(md5S[i], ctx.End(), testfiles[i]); + Assert.AreEqual(_md5S[i], ctx.End(), _testfiles[i]); } } } diff --git a/Aaru.Tests/Images/CisCopy.cs b/Aaru.Tests/Images/CisCopy.cs index 066568cf0..2c569c812 100644 --- a/Aaru.Tests/Images/CisCopy.cs +++ b/Aaru.Tests/Images/CisCopy.cs @@ -39,7 +39,7 @@ namespace Aaru.Tests.Images public class CisCopy { // TODO: Support compression - readonly string[] testfiles = + readonly string[] _testfiles = { "md1dd8_all.dcf.lz", "md1dd8_belelung.dcf.lz", "md1dd8_fat.dcf.lz", "md1dd_all.dcf.lz", "md1dd_belelung.dcf.lz", "md1dd_fat.dcf.lz", "md2dd8_all.dcf.lz", "md2dd8_belelung.dcf.lz", @@ -48,18 +48,18 @@ namespace Aaru.Tests.Images "mf2dd_fat.dcf.lz", "mf2hd_all.dcf.lz", "mf2hd_belelung.dcf.lz", "mf2hd_fat.dcf.lz" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 320, 320, 320, 360, 360, 360, 640, 640, 640, 720, 720, 720, 2400, 2400, 2400, 1440, 1440, 1440, 2880, 2880, 2880 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DOS_525_SS_DD_8, MediaType.DOS_525_SS_DD_8, MediaType.DOS_525_SS_DD_8, MediaType.DOS_525_SS_DD_9, MediaType.DOS_525_SS_DD_9, MediaType.DOS_525_SS_DD_9, MediaType.DOS_525_DS_DD_8, MediaType.DOS_525_DS_DD_8, @@ -69,7 +69,7 @@ namespace Aaru.Tests.Images MediaType.DOS_35_HD }; - readonly string[] md5S = + readonly string[] _md5S = { "95c0b76419c1c74db6dbe1d790f97dde", "95c0b76419c1c74db6dbe1d790f97dde", "6f6507e416b7320d583dc347b8e57844", "48b93e8619c4c13f4a3724b550e4b371", "48b93e8619c4c13f4a3724b550e4b371", "1d060d2e2543e1c2e8569f5451660060", @@ -83,20 +83,20 @@ namespace Aaru.Tests.Images [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Media image formats", "CisCopy", testfiles[i]); - IFilter filter = new LZip(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Media image formats", "CisCopy", _testfiles[i]); + IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new DiscImages.CisCopy(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); // How many sectors to read at once - const uint SECTORS_TO_READ = 256; - ulong doneSectors = 0; + const uint sectorsToRead = 256; + ulong doneSectors = 0; var ctx = new Md5Context(); @@ -104,10 +104,10 @@ namespace Aaru.Tests.Images { byte[] sector; - if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ) + if(image.Info.Sectors - doneSectors >= sectorsToRead) { - sector = image.ReadSectors(doneSectors, SECTORS_TO_READ); - doneSectors += SECTORS_TO_READ; + sector = image.ReadSectors(doneSectors, sectorsToRead); + doneSectors += sectorsToRead; } else { @@ -118,7 +118,7 @@ namespace Aaru.Tests.Images ctx.Update(sector); } - Assert.AreEqual(md5S[i], ctx.End(), testfiles[i]); + Assert.AreEqual(_md5S[i], ctx.End(), _testfiles[i]); } } } diff --git a/Aaru.Tests/Images/CopyQM.cs b/Aaru.Tests/Images/CopyQM.cs index ff18ece98..9c5fe06dd 100644 --- a/Aaru.Tests/Images/CopyQM.cs +++ b/Aaru.Tests/Images/CopyQM.cs @@ -38,30 +38,30 @@ namespace Aaru.Tests.Images [TestFixture] public class CopyQm { - readonly string[] testfiles = + readonly string[] _testfiles = { "mf2dd.cqm.lz", "mf2dd_fdformat_800.cqm.lz", "mf2dd_freedos.cqm.lz", "mf2hd_blind.cqm.lz", "mf2hd.cqm.lz", "mf2hd_fdformat_168.cqm.lz", "mf2hd_freedos.cqm.lz" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1440, 1600, 1600, 2880, 2880, 3360, 3360 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512 }; // TODO: Add "unknown" media types - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.DOS_35_DS_DD_9, MediaType.CBM_35_DD, MediaType.CBM_35_DD, MediaType.DOS_35_HD, MediaType.DOS_35_HD, MediaType.DMF, MediaType.DMF }; - readonly string[] md5S = + readonly string[] _md5S = { "de3f85896f771b7e5bc4c9e3926d64e4", "c533488a21098a62c85f1649abda2803", "1ff7649b679ba22ff20d39ff717dbec8", "b4a602f67903c46eef62addb0780aa56", "b4a602f67903c46eef62addb0780aa56", "03c2af6a8ebf4bd6f530335de34ae5dd", @@ -71,20 +71,20 @@ namespace Aaru.Tests.Images [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Media image formats", "CopyQM", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Media image formats", "CopyQM", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new DiscImages.CopyQm(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); // How many sectors to read at once - const uint SECTORS_TO_READ = 256; - ulong doneSectors = 0; + const uint sectorsToRead = 256; + ulong doneSectors = 0; var ctx = new Md5Context(); @@ -92,10 +92,10 @@ namespace Aaru.Tests.Images { byte[] sector; - if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ) + if(image.Info.Sectors - doneSectors >= sectorsToRead) { - sector = image.ReadSectors(doneSectors, SECTORS_TO_READ); - doneSectors += SECTORS_TO_READ; + sector = image.ReadSectors(doneSectors, sectorsToRead); + doneSectors += sectorsToRead; } else { @@ -106,7 +106,7 @@ namespace Aaru.Tests.Images ctx.Update(sector); } - Assert.AreEqual(md5S[i], ctx.End(), testfiles[i]); + Assert.AreEqual(_md5S[i], ctx.End(), _testfiles[i]); } } } diff --git a/Aaru.Tests/Images/D88.cs b/Aaru.Tests/Images/D88.cs index 52f9a2471..88ef2e87d 100644 --- a/Aaru.Tests/Images/D88.cs +++ b/Aaru.Tests/Images/D88.cs @@ -38,7 +38,7 @@ namespace Aaru.Tests.Images [TestFixture] public class D88 { - readonly string[] testfiles = + readonly string[] _testfiles = { "1942 (1987)(ASCII)(JP).d77.lz", "'Ashe (1988)(Quasar)(Disk 4 of 4)(User Disk).d88.lz", "Crimsin (1988)(Xtalsoft)(Disk 3 of 3).d88.lz", "Dragon Slayer (1986)(Falcom - Login)(JP).d88.lz", @@ -51,19 +51,19 @@ namespace Aaru.Tests.Images "Visual Instrument Player (198x)(Kamiya)(JP)(Disk 1 of 2).d88.lz" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 1280, 1280, 1280, 411, 1440, 1280, 1280, 4033, 1440, 1232, 1440, 1232, 1440, 1232, 1440, 1232, 1284, 1232, 1280 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 256, 256, 256, 256, 256, 256, 256, 128, 512, 1024, 512, 1024, 512, 1024, 512, 1024, 1024, 1024, 256 }; // TODO: Add "unknown" media types - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.NEC_525_SS, MediaType.NEC_525_SS, MediaType.NEC_525_SS, MediaType.Unknown, MediaType.Unknown, MediaType.NEC_525_SS, MediaType.NEC_525_SS, MediaType.Unknown, MediaType.Unknown, MediaType.NEC_525_HD, @@ -71,7 +71,7 @@ namespace Aaru.Tests.Images MediaType.NEC_525_HD, MediaType.Unknown, MediaType.NEC_525_HD, MediaType.NEC_525_SS }; - readonly string[] md5S = + readonly string[] _md5S = { "a4103c39cd7fd9fc3de8418dfcf22364", "b948048c03e0b3d34d77f5c9dced0b41", "f91152fab791d4dc0677a289d90478a5", "39b01df04a6312b09f1b83c9f3a46b22", "ef775ec1f41b8b725ea83ec8c5ca04e2", "5c2b22f824524cd6c539aaeb2ecb84cd", @@ -85,20 +85,20 @@ namespace Aaru.Tests.Images [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Media image formats", "D88", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Media image formats", "D88", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new DiscImages.D88(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); // How many sectors to read at once - const uint SECTORS_TO_READ = 256; - ulong doneSectors = 0; + const uint sectorsToRead = 256; + ulong doneSectors = 0; var ctx = new Md5Context(); @@ -106,10 +106,10 @@ namespace Aaru.Tests.Images { byte[] sector; - if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ) + if(image.Info.Sectors - doneSectors >= sectorsToRead) { - sector = image.ReadSectors(doneSectors, SECTORS_TO_READ); - doneSectors += SECTORS_TO_READ; + sector = image.ReadSectors(doneSectors, sectorsToRead); + doneSectors += sectorsToRead; } else { @@ -120,7 +120,7 @@ namespace Aaru.Tests.Images ctx.Update(sector); } - Assert.AreEqual(md5S[i], ctx.End(), testfiles[i]); + Assert.AreEqual(_md5S[i], ctx.End(), _testfiles[i]); } } } diff --git a/Aaru.Tests/Images/DART.cs b/Aaru.Tests/Images/DART.cs index b64fd0280..07743c0a8 100644 --- a/Aaru.Tests/Images/DART.cs +++ b/Aaru.Tests/Images/DART.cs @@ -38,29 +38,29 @@ namespace Aaru.Tests.Images [TestFixture] public class Dart { - readonly string[] testfiles = + readonly string[] _testfiles = { "mf1dd_hfs_best.dart.lz", "mf1dd_hfs_fast.dart.lz", "mf1dd_mfs_best.dart.lz", "mf1dd_mfs_fast.dart.lz", "mf2dd_hfs_best.dart.lz", "mf2dd_hfs_fast.dart.lz", "mf2dd_mfs_best.dart.lz", "mf2dd_mfs_fast.dart.lz" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 800, 800, 800, 800, 1600, 1600, 1600, 1600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonyDS, MediaType.AppleSonyDS, MediaType.AppleSonyDS, MediaType.AppleSonyDS }; - readonly string[] md5S = + readonly string[] _md5S = { "eae3a95671d077deb702b3549a769f56", "eae3a95671d077deb702b3549a769f56", "c5d92544c3e78b7f0a9b4baaa9a64eec", "c5d92544c3e78b7f0a9b4baaa9a64eec", "a99744348a70b62b57bce2dec9132ced", "a99744348a70b62b57bce2dec9132ced", @@ -70,20 +70,20 @@ namespace Aaru.Tests.Images [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Media image formats", "DART", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Media image formats", "DART", _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new DiscImages.Dart(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); // How many sectors to read at once - const uint SECTORS_TO_READ = 256; - ulong doneSectors = 0; + const uint sectorsToRead = 256; + ulong doneSectors = 0; var ctx = new Md5Context(); @@ -91,10 +91,10 @@ namespace Aaru.Tests.Images { byte[] sector; - if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ) + if(image.Info.Sectors - doneSectors >= sectorsToRead) { - sector = image.ReadSectors(doneSectors, SECTORS_TO_READ); - doneSectors += SECTORS_TO_READ; + sector = image.ReadSectors(doneSectors, sectorsToRead); + doneSectors += sectorsToRead; } else { @@ -105,7 +105,7 @@ namespace Aaru.Tests.Images ctx.Update(sector); } - Assert.AreEqual(md5S[i], ctx.End(), testfiles[i]); + Assert.AreEqual(_md5S[i], ctx.End(), _testfiles[i]); } } } diff --git a/Aaru.Tests/Images/DiskCopy42.cs b/Aaru.Tests/Images/DiskCopy42.cs index 544a35f9d..1fc93470a 100644 --- a/Aaru.Tests/Images/DiskCopy42.cs +++ b/Aaru.Tests/Images/DiskCopy42.cs @@ -38,7 +38,7 @@ namespace Aaru.Tests.Images [TestFixture] public class DiskCopy42 { - readonly string[] testfiles = + readonly string[] _testfiles = { // Made with DiskCopy 4.2 "Made by DiskCopy 4.2/mf1dd_hfs.img.lz", "Made by DiskCopy 4.2/mf1dd_mfs.img.lz", @@ -56,18 +56,18 @@ namespace Aaru.Tests.Images "Made by Mac OS X/UFS_800.img.lz" }; - readonly ulong[] sectors = + readonly ulong[] _sectors = { 800, 800, 1600, 1600, 2880, 1600, 2880, 1440, 2880, 1600, 2880, 1440, 2880, 1600, 2880, 1600, 2880, 1440, 1600 }; - readonly uint[] sectorsize = + readonly uint[] _sectorsize = { 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 }; - readonly MediaType[] mediatypes = + readonly MediaType[] _mediatypes = { MediaType.AppleSonySS, MediaType.AppleSonySS, MediaType.AppleSonyDS, MediaType.AppleSonyDS, MediaType.DOS_35_HD, MediaType.AppleSonyDS, MediaType.DOS_35_HD, MediaType.DOS_35_DS_DD_9, @@ -76,7 +76,7 @@ namespace Aaru.Tests.Images MediaType.DOS_35_DS_DD_9, MediaType.AppleSonyDS }; - readonly string[] md5S = + readonly string[] _md5S = { "eae3a95671d077deb702b3549a769f56", "c5d92544c3e78b7f0a9b4baaa9a64eec", "a99744348a70b62b57bce2dec9132ced", "93e71b9ecdb39d3ec9245b4f451856d4", "3160038ca028ccf52ad7863790072145", "5e255c4bc0f6a26ecd27845b37e65aaa", @@ -90,22 +90,22 @@ namespace Aaru.Tests.Images [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 4.2", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Media image formats", "DiskCopy 4.2", + _testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new DiscImages.DiskCopy42(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); - Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); - Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); - Assert.AreEqual(mediatypes[i], image.Info.MediaType, testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); + Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]); + Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]); + Assert.AreEqual(_mediatypes[i], image.Info.MediaType, _testfiles[i]); // How many sectors to read at once - const uint SECTORS_TO_READ = 256; - ulong doneSectors = 0; + const uint sectorsToRead = 256; + ulong doneSectors = 0; var ctx = new Md5Context(); @@ -113,10 +113,10 @@ namespace Aaru.Tests.Images { byte[] sector; - if(image.Info.Sectors - doneSectors >= SECTORS_TO_READ) + if(image.Info.Sectors - doneSectors >= sectorsToRead) { - sector = image.ReadSectors(doneSectors, SECTORS_TO_READ); - doneSectors += SECTORS_TO_READ; + sector = image.ReadSectors(doneSectors, sectorsToRead); + doneSectors += sectorsToRead; } else { @@ -127,7 +127,7 @@ namespace Aaru.Tests.Images ctx.Update(sector); } - Assert.AreEqual(md5S[i], ctx.End(), testfiles[i]); + Assert.AreEqual(_md5S[i], ctx.End(), _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/Acorn.cs b/Aaru.Tests/Partitions/Acorn.cs index a0e6d2072..b3d51290b 100644 --- a/Aaru.Tests/Partitions/Acorn.cs +++ b/Aaru.Tests/Partitions/Acorn.cs @@ -39,12 +39,12 @@ namespace Aaru.Tests.Partitions [TestFixture] public class Acorn { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux_ics.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { // Linux (ICS) // TODO: Values are incorrect @@ -100,27 +100,27 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "Acorn", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "Acorn", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]); - Assert.AreEqual(wanted[i][j].Size, partitions[j].Size, testfiles[i]); - Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]); - Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]); - Assert.AreEqual(wanted[i][j].Offset, partitions[j].Offset, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Size, partitions[j].Size, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Name, partitions[j].Name, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Offset, partitions[j].Offset, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/AppleMap.cs b/Aaru.Tests/Partitions/AppleMap.cs index 5bab123db..1325c50d0 100644 --- a/Aaru.Tests/Partitions/AppleMap.cs +++ b/Aaru.Tests/Partitions/AppleMap.cs @@ -39,7 +39,7 @@ namespace Aaru.Tests.Partitions [TestFixture] public class AppleMap { - readonly string[] testfiles = + readonly string[] _testfiles = { "d2_driver.aif", "hdt_1.8_encrypted1.aif", "hdt_1.8_encrypted2.aif", "hdt_1.8_password.aif", "hdt_1.8.aif", "linux.aif", "macos_1.1.aif", "macos_2.0.aif", "macos_4.2.aif", "macos_4.3.aif", "macos_6.0.2.aif", @@ -48,7 +48,7 @@ namespace Aaru.Tests.Partitions "silverlining_2.2.1.aif", "speedtools_3.6.aif", "vcpformatter_2.1.1.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { // D2 new[] @@ -2024,29 +2024,29 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "Apple Partition Map", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "Apple Partition Map", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]); - Assert.AreEqual(wanted[i][j].Size, partitions[j].Size, testfiles[i]); - Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]); - Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]); - Assert.AreEqual(wanted[i][j].Offset, partitions[j].Offset, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Size, partitions[j].Size, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Name, partitions[j].Name, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Offset, partitions[j].Offset, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/Atari.cs b/Aaru.Tests/Partitions/Atari.cs index adb2bb73e..40f62a649 100644 --- a/Aaru.Tests/Partitions/Atari.cs +++ b/Aaru.Tests/Partitions/Atari.cs @@ -39,12 +39,12 @@ namespace Aaru.Tests.Partitions [TestFixture] public class Atari { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux_ahdi.aif", "linux_icd.aif", "tos_1.04.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { // Linux (AHDI) new[] @@ -318,27 +318,29 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "Atari ST", testfiles[i]); - IFilter filter = new ZZZNoFilter(); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "Atari ST", + _testfiles[i]); + + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]); - Assert.AreEqual(wanted[i][j].Size, partitions[j].Size, testfiles[i]); - Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]); - Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]); - Assert.AreEqual(wanted[i][j].Offset, partitions[j].Offset, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Size, partitions[j].Size, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Name, partitions[j].Name, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Offset, partitions[j].Offset, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/BSD.cs b/Aaru.Tests/Partitions/BSD.cs index a67d6e9d8..e6d0d9ab2 100644 --- a/Aaru.Tests/Partitions/BSD.cs +++ b/Aaru.Tests/Partitions/BSD.cs @@ -39,12 +39,12 @@ namespace Aaru.Tests.Partitions [TestFixture] public class Bsd { - readonly string[] testfiles = + readonly string[] _testfiles = { "parted.aif", "netbsd_1.6.aif", "netbsd_6.1.5.aif", "netbsd_7.1.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { // Parted new[] @@ -397,29 +397,29 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "BSD slices", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "BSD slices", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]); - Assert.AreEqual(wanted[i][j].Size, partitions[j].Size, testfiles[i]); - Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]); - Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]); - Assert.AreEqual(wanted[i][j].Offset, partitions[j].Offset, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Size, partitions[j].Size, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Name, partitions[j].Name, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Offset, partitions[j].Offset, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/GPT.cs b/Aaru.Tests/Partitions/GPT.cs index e00e16ce7..cfe3baf50 100644 --- a/Aaru.Tests/Partitions/GPT.cs +++ b/Aaru.Tests/Partitions/GPT.cs @@ -39,12 +39,12 @@ namespace Aaru.Tests.Partitions [TestFixture] public class Gpt { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif", "parted.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { // Linux new[] @@ -159,29 +159,29 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "GUID Partition Table", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "GUID Partition Table", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]); - Assert.AreEqual(wanted[i][j].Size, partitions[j].Size, testfiles[i]); - Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]); - Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]); - Assert.AreEqual(wanted[i][j].Offset, partitions[j].Offset, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Size, partitions[j].Size, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Name, partitions[j].Name, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Offset, partitions[j].Offset, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/MBR.cs b/Aaru.Tests/Partitions/MBR.cs index da9d95361..11aded387 100644 --- a/Aaru.Tests/Partitions/MBR.cs +++ b/Aaru.Tests/Partitions/MBR.cs @@ -39,7 +39,7 @@ namespace Aaru.Tests.Partitions [TestFixture] public class Mbr { - readonly string[] testfiles = + readonly string[] _testfiles = { "concurrentdos_6.0.aif", "darwin_1.4.1.aif", "darwin_6.0.2.aif", "darwin_8.0.1.aif", "drdos_3.40.aif", "drdos_3.41.aif", "drdos_5.00.aif", "drdos_6.00.aif", "drdos_7.02.aif", "drdos_7.03.aif", "drdos_8.0.aif", @@ -50,7 +50,7 @@ namespace Aaru.Tests.Partitions "win96osr25.aif", "winnt_3.10.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { // Concurrent DOS 6.0 new[] @@ -1991,30 +1991,30 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "Master Boot Record", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "Master Boot Record", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length * 512, partitions[j].Size, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length * 512, partitions[j].Size, _testfiles[i]); // Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]); - Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start * 512, partitions[j].Offset, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start * 512, partitions[j].Offset, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/MINIX.cs b/Aaru.Tests/Partitions/MINIX.cs index d5cfd1915..d97a0d2b6 100644 --- a/Aaru.Tests/Partitions/MINIX.cs +++ b/Aaru.Tests/Partitions/MINIX.cs @@ -39,12 +39,12 @@ namespace Aaru.Tests.Partitions [TestFixture] public class Minix { - readonly string[] testfiles = + readonly string[] _testfiles = { "minix_3.1.2a.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { // Parted new[] @@ -99,28 +99,28 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "MINIX", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "MINIX", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]); - Assert.AreEqual(wanted[i][j].Size, partitions[j].Size, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Size, partitions[j].Size, _testfiles[i]); // Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]); - Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]); - Assert.AreEqual(wanted[i][j].Offset, partitions[j].Offset, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Offset, partitions[j].Offset, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/PC98.cs b/Aaru.Tests/Partitions/PC98.cs index c4b2a5b74..6fc9c95a1 100644 --- a/Aaru.Tests/Partitions/PC98.cs +++ b/Aaru.Tests/Partitions/PC98.cs @@ -39,12 +39,12 @@ namespace Aaru.Tests.Partitions [TestFixture] public class Pc98 { - readonly string[] testfiles = + readonly string[] _testfiles = { "msdos330.aif", "msdos330_alt.aif", "msdos500_epson.aif", "msdos500.aif", "msdos620.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { // NEC MS-DOS 3.30 (256Mb HDD) new[] @@ -381,25 +381,25 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "PC-98", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "PC-98", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]); - Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Name, partitions[j].Name, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/RDB.cs b/Aaru.Tests/Partitions/RDB.cs index e7057dd68..ad7035fd3 100644 --- a/Aaru.Tests/Partitions/RDB.cs +++ b/Aaru.Tests/Partitions/RDB.cs @@ -39,12 +39,12 @@ namespace Aaru.Tests.Partitions [TestFixture] public class Rdb { - readonly string[] testfiles = + readonly string[] _testfiles = { "amigaos_3.9.aif", "amigaos_4.0.aif", "parted.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { // AmigaOS 3.9 new[] @@ -230,29 +230,29 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "Rigid Disk Block", - testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "Rigid Disk Block", + _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]); - Assert.AreEqual(wanted[i][j].Size, partitions[j].Size, testfiles[i]); - Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]); - Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]); - Assert.AreEqual(wanted[i][j].Offset, partitions[j].Offset, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Size, partitions[j].Size, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Name, partitions[j].Name, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Offset, partitions[j].Offset, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/SGI.cs b/Aaru.Tests/Partitions/SGI.cs index 351143245..9e93ba506 100644 --- a/Aaru.Tests/Partitions/SGI.cs +++ b/Aaru.Tests/Partitions/SGI.cs @@ -39,12 +39,12 @@ namespace Aaru.Tests.Partitions [TestFixture] public class Sgi { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif", "parted.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { // Linux's fdisk new[] @@ -222,28 +222,28 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "SGI", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "SGI", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length * 512, partitions[j].Size, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length * 512, partitions[j].Size, _testfiles[i]); // Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]); - Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start * 512, partitions[j].Offset, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start * 512, partitions[j].Offset, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/Sun.cs b/Aaru.Tests/Partitions/Sun.cs index 8e38fc91c..da405c66b 100644 --- a/Aaru.Tests/Partitions/Sun.cs +++ b/Aaru.Tests/Partitions/Sun.cs @@ -40,12 +40,12 @@ namespace Aaru.Tests.Partitions [TestFixture] public class Sun { - readonly string[] testfiles = + readonly string[] _testfiles = { "linux.aif", "parted.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { // Linux's fdisk new[] @@ -151,28 +151,28 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "Sun", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "Sun", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length * 512, partitions[j].Size, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length * 512, partitions[j].Size, _testfiles[i]); // Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]); - Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start * 512, partitions[j].Offset, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start * 512, partitions[j].Offset, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/VTOC.cs b/Aaru.Tests/Partitions/VTOC.cs index 87765ec95..725050ecc 100644 --- a/Aaru.Tests/Partitions/VTOC.cs +++ b/Aaru.Tests/Partitions/VTOC.cs @@ -39,12 +39,12 @@ namespace Aaru.Tests.Partitions [TestFixture] public class Vtoc { - readonly string[] testfiles = + readonly string[] _testfiles = { "att_unix_vtoc.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { // AT&T UNIX System V Release 4 Version 2.1 for 386 new[] @@ -199,28 +199,30 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "UNIX VTOC", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "UNIX VTOC", + _testfiles[i]); + IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty //Assert.AreEqual(wanted[i][j].PartitionDescription, partitions[j].PartitionDescription, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length * 512, partitions[j].Size, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length * 512, partitions[j].Size, _testfiles[i]); // Assert.AreEqual(wanted[i][j].Name, partitions[j].Name, testfiles[i]); - Assert.AreEqual(wanted[i][j].Type, partitions[j].Type, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start * 512, partitions[j].Offset, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Type, partitions[j].Type, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start * 512, partitions[j].Offset, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.Tests/Partitions/Xbox.cs b/Aaru.Tests/Partitions/Xbox.cs index bd3c76d1b..00e8e88c0 100644 --- a/Aaru.Tests/Partitions/Xbox.cs +++ b/Aaru.Tests/Partitions/Xbox.cs @@ -39,12 +39,12 @@ namespace Aaru.Tests.Partitions [TestFixture] public class Xbox { - readonly string[] testfiles = + readonly string[] _testfiles = { "microsoft256mb.aif" }; - readonly Partition[][] wanted = + readonly Partition[][] _wanted = { new[] { @@ -72,25 +72,25 @@ namespace Aaru.Tests.Partitions [Test] public void Test() { - for(int i = 0; i < testfiles.Length; i++) + for(int i = 0; i < _testfiles.Length; i++) { - string location = Path.Combine(Consts.TestFilesRoot, "Partitioning schemes", "Xbox", testfiles[i]); + string location = Path.Combine(Consts.TEST_FILES_ROOT, "Partitioning schemes", "Xbox", _testfiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); - Assert.AreEqual(true, image.Open(filter), testfiles[i]); + Assert.AreEqual(true, image.Open(filter), _testfiles[i]); List partitions = Core.Partitions.GetAll(image); - Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]); + Assert.AreEqual(_wanted[i].Length, partitions.Count, _testfiles[i]); for(int j = 0; j < partitions.Count; j++) { // Too chatty - Assert.AreEqual(wanted[i][j].Description, partitions[j].Description, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length * 512, partitions[j].Size, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start * 512, partitions[j].Offset, testfiles[i]); - Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]); - Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]); - Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]); + Assert.AreEqual(_wanted[i][j].Description, partitions[j].Description, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length * 512, partitions[j].Size, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start * 512, partitions[j].Offset, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Length, partitions[j].Length, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Sequence, partitions[j].Sequence, _testfiles[i]); + Assert.AreEqual(_wanted[i][j].Start, partitions[j].Start, _testfiles[i]); } } } diff --git a/Aaru.sln.DotSettings b/Aaru.sln.DotSettings index 3c6cfa19f..77d128266 100644 --- a/Aaru.sln.DotSettings +++ b/Aaru.sln.DotSettings @@ -177,6 +177,50 @@ </Entry> </TypePattern> </Patterns> + AAIP + AP + APFS + BAM + BFS + BT + BTRFS + CBM + CHS + CID + CSD + EFI + EFS + FS + HAMMER + HPFS + ISO + JFS + LBA + LFCR + LFN + LIF + LSN + LZMA + MDD + MDDF + NILFS + NTFS + OCR + ODS + PC + PCFX + PDP + PFS + QNX + RBF + RT + SCR + SFS + UDF + UID + UNICOS + VTX + XFS /opt/dotnet/sdk/3.0.100/MSBuild.dll 1048576 True @@ -267,6 +311,7 @@ True True True + True True True True