From 45de58d2f184fd7037fd77ddd0fc7b70f75b260b Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 8 Aug 2024 14:01:42 -0400 Subject: [PATCH] Simplify using statements --- NDecrypt.N3DS/CIATool.cs | 22 +++++++++++----------- NDecrypt.N3DS/ThreeDSTool.cs | 22 +++++++++++----------- NDecrypt.Nitro/DSTool.cs | 22 +++++++++++----------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/NDecrypt.N3DS/CIATool.cs b/NDecrypt.N3DS/CIATool.cs index 9de8d33..011d190 100644 --- a/NDecrypt.N3DS/CIATool.cs +++ b/NDecrypt.N3DS/CIATool.cs @@ -69,20 +69,20 @@ public bool ProcessFile() try { // Open the read and write on the same file for inplace processing - using (BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) - using (BinaryWriter writer = new BinaryWriter(File.Open(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))) + using BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); + using BinaryWriter writer = new BinaryWriter(File.Open(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)); + + // Deserialize the CIA information + var cia = Serializer.ReadCIA(reader); + if (cia == null) { - var cia = Serializer.ReadCIA(reader); - if (cia == null) - { - Console.WriteLine("Error: Not a 3DS CIA!"); - return false; - } - - // Process all NCCH partitions - ProcessAllPartitions(cia, reader, writer); + Console.WriteLine("Error: Not a 3DS CIA!"); + return false; } + // Process all NCCH partitions + ProcessAllPartitions(cia, reader, writer); + return false; } catch diff --git a/NDecrypt.N3DS/ThreeDSTool.cs b/NDecrypt.N3DS/ThreeDSTool.cs index 5e530a2..a0a3bc8 100644 --- a/NDecrypt.N3DS/ThreeDSTool.cs +++ b/NDecrypt.N3DS/ThreeDSTool.cs @@ -68,20 +68,20 @@ public bool ProcessFile() try { // Open the read and write on the same file for inplace processing - using (var reader = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) - using (var writer = new BinaryWriter(File.Open(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))) + using var reader = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); + using var writer = new BinaryWriter(File.Open(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)); + + // Deserialize the cart information + (var cart, var backupHeader) = Serializer.ReadCart(reader, decryptArgs.Development); + if (cart?.Header == null) { - (var cart, var backupHeader) = Serializer.ReadCart(reader, decryptArgs.Development); - if (cart?.Header == null) - { - Console.WriteLine("Error: Not a 3DS cart image!"); - return false; - } - - // Process all 8 NCCH partitions - ProcessAllPartitions(cart.Header, backupHeader, reader, writer); + Console.WriteLine("Error: Not a 3DS cart image!"); + return false; } + // Process all 8 NCCH partitions + ProcessAllPartitions(cart.Header, backupHeader, reader, writer); + return true; } catch diff --git a/NDecrypt.Nitro/DSTool.cs b/NDecrypt.Nitro/DSTool.cs index 49e6e94..9a8b50c 100644 --- a/NDecrypt.Nitro/DSTool.cs +++ b/NDecrypt.Nitro/DSTool.cs @@ -39,20 +39,20 @@ public bool ProcessFile() try { // Open the read and write on the same file for inplace processing - using (BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) - using (BinaryWriter writer = new BinaryWriter(File.Open(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))) + using BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); + using BinaryWriter writer = new BinaryWriter(File.Open(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)); + + // Deserialize the cart information + Cart? cart = Serializer.ReadCart(reader); + if (cart == null) { - Cart? cart = Serializer.ReadCart(reader); - if (cart == null) - { - Console.WriteLine("Error: Not a DS or DSi Rom!"); - return false; - } - - // Process the secure area - ProcessSecureArea(cart, reader, writer); + Console.WriteLine("Error: Not a DS or DSi Rom!"); + return false; } + // Process the secure area + ProcessSecureArea(cart, reader, writer); + return true; } catch