From 15452ded52fc5fb5bc1f9bd5a71e4db0e4c71797 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 2 Apr 2024 16:12:08 -0400 Subject: [PATCH] Use new IO extension --- .../Streams/CueSheet.Deserializer.cs | 39 ++----------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/SabreTools.Serialization/Streams/CueSheet.Deserializer.cs b/SabreTools.Serialization/Streams/CueSheet.Deserializer.cs index fb258be4..6bd52cb8 100644 --- a/SabreTools.Serialization/Streams/CueSheet.Deserializer.cs +++ b/SabreTools.Serialization/Streams/CueSheet.Deserializer.cs @@ -33,7 +33,7 @@ namespace SabreTools.Serialization.Streams string? lastLine = null; while (true) { - string? line = lastLine ?? ReadLine(data); + string? line = lastLine ?? data.ReadQuotedString(); lastLine = null; // If we have a null line, break from the loop @@ -141,7 +141,7 @@ namespace SabreTools.Serialization.Streams while (true) { - string? line = lastLine ?? ReadLine(data); + string? line = lastLine ?? data.ReadQuotedString(); lastLine = null; // If we have a null line, break from the loop @@ -226,7 +226,7 @@ namespace SabreTools.Serialization.Streams while (true) { - string? line = lastLine ?? ReadLine(data); + string? line = lastLine ?? data.ReadQuotedString(); lastLine = null; // If we have a null line, break from the loop @@ -506,39 +506,6 @@ namespace SabreTools.Serialization.Streams #region Helpers - /// - /// Read a line from the input file, where a line is either terminated by a newline character - /// or by an end quote - /// - private static string? ReadLine(Stream data) - { - // If we are at the end of data - if (data.Position >= data.Length) - return null; - - var bytes = new List(); - bool openQuote = false; - while (data.Position < data.Length) - { - // Read the byte value - byte b = data.ReadByteValue(); - - // If we have a quote, flip the flag - if (b == (byte)'"') - openQuote = !openQuote; - - // If we have a newline not in a quoted string, exit the loop - else if (b == (byte)'\n' && !openQuote) - break; - - // Add the byte to the set - bytes.Add(b); - } - - var line = new string(bytes.Select(b => (char)b).ToArray()); - return line.TrimEnd(); - } - /// /// Get the file type from a given string ///