Skip to content

Commit

Permalink
Use top-level statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrainger committed Jul 9, 2024
1 parent 69e72b1 commit 15b487a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 50 deletions.
41 changes: 16 additions & 25 deletions src/BsDiffTool/Program.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
using BsDiff;

namespace BsDiffTool
// check for correct usage
if (args.Length != 3)
{
public sealed class Program
{
public static void Main(string[] args)
{
// check for correct usage
if (args.Length != 3)
{
Console.Error.WriteLine("bsdiff oldfile newfile patchfile");
return;
}
Console.Error.WriteLine("bsdiff oldfile newfile patchfile");
return;
}

var oldFile = args[0];
var newFile = args[1];
var patchFile = args[2];
var oldFile = args[0];
var newFile = args[1];
var patchFile = args[2];

try
{
using (var output = new FileStream(patchFile, FileMode.Create))
BinaryPatch.Create(File.ReadAllBytes(oldFile), File.ReadAllBytes(newFile), output);
}
catch (FileNotFoundException ex)
{
Console.Error.WriteLine("Could not open '{0}'.", ex.FileName);
}
}
}
try
{
using (var output = new FileStream(patchFile, FileMode.Create))
BinaryPatch.Create(File.ReadAllBytes(oldFile), File.ReadAllBytes(newFile), output);
}
catch (FileNotFoundException ex)
{
Console.Error.WriteLine("Could not open '{0}'.", ex.FileName);
}
42 changes: 17 additions & 25 deletions src/BsPatchTool/Program.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
using BsDiff;

namespace BsPatchTool;

public sealed class Program
// check for correct usage
if (args.Length != 3)
{
public static void Main(string[] args)
{
// check for correct usage
if (args.Length != 3)
{
Console.Error.WriteLine("bsdiff oldfile newfile patchfile");
return;
}
Console.Error.WriteLine("bsdiff oldfile newfile patchfile");
return;
}

var oldFile = args[0];
var newFile = args[1];
var patchFile = args[2];
var oldFile = args[0];
var newFile = args[1];
var patchFile = args[2];

try
{
using (var input = new FileStream(oldFile, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var output = new FileStream(newFile, FileMode.Create))
BinaryPatch.Apply(input, () => new FileStream(patchFile, FileMode.Open, FileAccess.Read, FileShare.Read), output);
}
catch (FileNotFoundException ex)
{
Console.Error.WriteLine("Could not open '{0}'.", ex.FileName);
}
}
try
{
using (var input = new FileStream(oldFile, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var output = new FileStream(newFile, FileMode.Create))
BinaryPatch.Apply(input, () => new FileStream(patchFile, FileMode.Open, FileAccess.Read, FileShare.Read), output);
}
catch (FileNotFoundException ex)
{
Console.Error.WriteLine("Could not open '{0}'.", ex.FileName);
}

0 comments on commit 15b487a

Please sign in to comment.