From 8ea04c3ed529216d25dd6f4552faca506458d71c Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 19 Mar 2020 10:28:34 -0500 Subject: [PATCH] cleanup StringLog.cs, removes a warning --- BizHawk.Client.Common/movie/bk2/StringLogs.cs | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/BizHawk.Client.Common/movie/bk2/StringLogs.cs b/BizHawk.Client.Common/movie/bk2/StringLogs.cs index f4762a0437..01301e1884 100644 --- a/BizHawk.Client.Common/movie/bk2/StringLogs.cs +++ b/BizHawk.Client.Common/movie/bk2/StringLogs.cs @@ -1,7 +1,8 @@ using System; +using System.Collections; using System.Collections.Generic; using System.IO; - +using System.Security.AccessControl; using BizHawk.Common; namespace BizHawk.Client.Common @@ -67,29 +68,27 @@ namespace BizHawk.Client.Common /// internal class StreamStringLog : IStringLog { - private readonly Stream stream; + private readonly Stream _stream; private readonly List _offsets = new List(); private readonly BinaryWriter _bw; private readonly BinaryReader _br; private readonly bool _mDisk; - private long _cursor; - public StreamStringLog(bool disk) { _mDisk = disk; if (disk) { var path = TempFileManager.GetTempFilename("movieOnDisk"); - stream = new FileStream(path, FileMode.Create, System.Security.AccessControl.FileSystemRights.FullControl, FileShare.None, 4 * 1024, FileOptions.DeleteOnClose); + _stream = new FileStream(path, FileMode.Create, FileSystemRights.FullControl, FileShare.None, 4 * 1024, FileOptions.DeleteOnClose); } else { - stream = new AWEMemoryStream(); + _stream = new AWEMemoryStream(); } - _bw = new BinaryWriter(stream); - _br = new BinaryReader(stream); + _bw = new BinaryWriter(_stream); + _br = new BinaryReader(_stream); } public IStringLog Clone() @@ -105,22 +104,21 @@ namespace BizHawk.Client.Common public void Dispose() { - stream.Dispose(); + _stream.Dispose(); } public int Count => _offsets.Count; public void Clear() { - stream.SetLength(0); + _stream.SetLength(0); _offsets.Clear(); - _cursor = 0; } public void Add(string str) { - stream.Position = stream.Length; - _offsets.Add(stream.Position); + _stream.Position = _stream.Length; + _offsets.Add(_stream.Position); _bw.Write(str); _bw.Flush(); } @@ -135,14 +133,14 @@ namespace BizHawk.Client.Common { get { - stream.Position = _offsets[index]; + _stream.Position = _offsets[index]; return _br.ReadString(); } set { - stream.Position = stream.Length; - _offsets[index] = stream.Position; + _stream.Position = _stream.Length; + _offsets[index] = _stream.Position; _bw.Write(value); _bw.Flush(); } @@ -150,8 +148,8 @@ namespace BizHawk.Client.Common public void Insert(int index, string val) { - stream.Position = stream.Length; - _offsets.Insert(index, stream.Position); + _stream.Position = _stream.Length; + _offsets.Insert(index, _stream.Position); _bw.Write(val); _bw.Flush(); } @@ -178,9 +176,9 @@ namespace BizHawk.Client.Common private int _index = -1; public string Current => Log[_index]; - object System.Collections.IEnumerator.Current => Log[_index]; + object IEnumerator.Current => Log[_index]; - bool System.Collections.IEnumerator.MoveNext() + bool IEnumerator.MoveNext() { _index++; if (_index >= Log.Count) @@ -192,7 +190,7 @@ namespace BizHawk.Client.Common return true; } - void System.Collections.IEnumerator.Reset() { _index = -1; } + void IEnumerator.Reset() { _index = -1; } public void Dispose() { } } @@ -202,7 +200,7 @@ namespace BizHawk.Client.Common return new Enumerator { Log = this }; } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + IEnumerator IEnumerable.GetEnumerator() { return new Enumerator { Log = this }; }