Skip to content

Commit 324f8eb

Browse files
committed
Refactor: Replace custom WriteAllBytes with File API
Removed the custom WriteAllBytes method from the Program class, which handled writing a ReadOnlySpan<byte> to a file. Updated the code to use the built-in File.WriteAllBytes method instead. This change simplifies the codebase by leveraging .NET's standard library functionality and eliminates redundant code.
1 parent b39200e commit 324f8eb

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

AssetRipper.TextureDecoder.ConsoleApp/Program.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static void Main(string[] args)
6161
switch (outputType)
6262
{
6363
case "bgra":
64-
WriteAllBytes(path + ".bgra", bitmap.Bits);
64+
File.WriteAllBytes(path + ".bgra", bitmap.Bits);
6565
break;
6666
case "bmp":
6767
bitmap.FlipY();
@@ -243,11 +243,4 @@ private static void DecodePvrtc(ReadOnlySpan<byte> input, int width, int height,
243243
bool do2bit = bool.Parse(do2bitModeString);
244244
PvrtcDecoder.DecompressPVRTC<ColorBGRA32, byte>(input, width, height, do2bit, output);
245245
}
246-
247-
public static void WriteAllBytes(string path, ReadOnlySpan<byte> bytes)
248-
{
249-
ArgumentException.ThrowIfNullOrEmpty(path, nameof(path));
250-
using Microsoft.Win32.SafeHandles.SafeFileHandle sfh = File.OpenHandle(path, FileMode.Create, FileAccess.Write, FileShare.Read);
251-
RandomAccess.Write(sfh, bytes, 0);
252-
}
253246
}

0 commit comments

Comments
 (0)