Skip to content

Commit 9dc0cda

Browse files
committed
add static
1 parent 296da73 commit 9dc0cda

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/ImageSharp/Common/Helpers/RiffHelper.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
namespace SixLabors.ImageSharp.Common.Helpers;
88

9-
internal class RiffHelper
9+
internal static class RiffHelper
1010
{
1111
/// <summary>
1212
/// The header bytes identifying RIFF file.
1313
/// </summary>
14-
public static readonly uint RiffFourCc = 0x52_49_46_46;
14+
private const uint RiffFourCc = 0x52_49_46_46;
1515

1616
public static void WriteRiffFile(Stream stream, string formType, Action<Stream> func) =>
1717
WriteChunk(stream, RiffFourCc, s =>
@@ -64,7 +64,7 @@ public static void WriteChunk(Stream stream, uint fourCc, ReadOnlySpan<byte> dat
6464
stream.Write(data);
6565

6666
// padding
67-
if (size % 2 == 1)
67+
if (size % 2 is 1)
6868
{
6969
stream.WriteByte(0);
7070
}
@@ -103,7 +103,7 @@ public static void EndWriteChunk(Stream stream, long sizePosition)
103103
uint dataSize = (uint)(position - sizePosition - 4);
104104

105105
// padding
106-
if (dataSize % 2 == 1)
106+
if (dataSize % 2 is 1)
107107
{
108108
stream.WriteByte(0);
109109
position++;
@@ -114,4 +114,13 @@ public static void EndWriteChunk(Stream stream, long sizePosition)
114114

115115
stream.Position = position;
116116
}
117+
118+
public static long BeginWriteRiffFile(Stream stream, string formType)
119+
{
120+
long sizePosition = BeginWriteChunk(stream, RiffFourCc);
121+
stream.Write(Encoding.ASCII.GetBytes(formType));
122+
return sizePosition;
123+
}
124+
125+
public static void EndWriteRiffFile(Stream stream, long sizePosition) => EndWriteChunk(stream, sizePosition);
117126
}

0 commit comments

Comments
 (0)