Remove temporary extension

This commit is contained in:
Matt Nadareski
2026-06-17 22:48:55 -04:00
parent 656016830c
commit 94d271d167
6 changed files with 8 additions and 73 deletions

View File

@@ -1,35 +0,0 @@
using Xunit;
namespace BinaryObjectScanner.Test
{
public class ExtensionsTests
{
#region FileSize
[Fact]
public void FileSize_Null_Invalid()
{
string? filename = null;
long actual = filename.FileSize();
Assert.Equal(-1, actual);
}
[Fact]
public void FileSize_Empty_Invalid()
{
string? filename = string.Empty;
long actual = filename.FileSize();
Assert.Equal(-1, actual);
}
[Fact]
public void FileSize_Invalid_Invalid()
{
string? filename = "INVALID";
long actual = filename.FileSize();
Assert.Equal(-1, actual);
}
#endregion
}
}

View File

@@ -1,33 +0,0 @@
using System.IO;
namespace BinaryObjectScanner
{
// TODO: Remove when IO is updated
internal static class Extensions
{
/// <summary>
/// Helper to get the filesize from a path
/// </summary>
/// <returns>Size of the file path, -1 on error</returns>
public static long FileSize(this string? filename)
{
// Invalid filenames are ignored
if (string.IsNullOrEmpty(filename))
return -1;
// Non-file paths are ignored
if (!File.Exists(filename))
return -1;
try
{
return new FileInfo(filename).Length;
}
catch
{
// Ignore errors
return -1;
}
}
}
}

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using BinaryObjectScanner.Interfaces;
using SabreTools.IO.Extensions;
namespace BinaryObjectScanner.Protection
{
@@ -28,7 +29,7 @@ namespace BinaryObjectScanner.Protection
#else
string ifofile = Path.Combine(bupfile.DirectoryName, bupfile.Name.Substring(0, bupfile.Name.Length - bupfile.Extension.Length) + ".ifo");
#endif
if (bupfile.Length != ifofile.FileSize())
if (bupfile.Length != ifofile.GetFileSize())
{
protections.Add("DVD-Movie-PROTECT (Unconfirmed - Please report to us on Github)");
break;

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using SabreTools.Hashing;
using SabreTools.IO.Extensions;
using SabreTools.Matching;
using SabreTools.Text.Extensions;
using SabreTools.Wrappers;
@@ -799,7 +800,7 @@ namespace BinaryObjectScanner.Protection
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
return string.Empty;
return firstMatchedString.FileSize() switch
return firstMatchedString.GetFileSize() switch
{
// File size of "dplayerx.dll" and others is a commonly used indicator of SafeDisc version, though it has been found to not be completely consistent.
// Checks for versions 1.2X have been commented out, due to these versions already being detected via more accurate checks.

View File

@@ -363,7 +363,7 @@ namespace BinaryObjectScanner.Protection
// This file is present in most, if not all, SafeDisc protected discs. It seems to have very consistent file sizes, only being found to use three different file sizes in it's entire run.
// A rough estimate of the product and version can be gotten by checking the file size.
// One filesize is known to overlap with both SafeDisc and CDS-300, and so is detected separately here.
return firstMatchedString.FileSize() switch
return firstMatchedString.GetFileSize() switch
{
// Found in Redump entries 37832 and 66005.
20 => "SafeDisc 1.00.025-1.41.001",
@@ -384,7 +384,7 @@ namespace BinaryObjectScanner.Protection
if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString))
return string.Empty;
return firstMatchedString.FileSize() switch
return firstMatchedString.GetFileSize() switch
{
// Found in Redump entry 63488.
0 => "(Empty File)",

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using BinaryObjectScanner.Interfaces;
using SabreTools.IO.Extensions;
namespace BinaryObjectScanner.Protection
{
@@ -19,7 +20,7 @@ namespace BinaryObjectScanner.Protection
var ifofiles = files.FindAll(s => s.EndsWith(".ifo"));
for (int i = 0; i < ifofiles.Count; i++)
{
if (ifofiles[i].FileSize() == 0)
if (ifofiles[i].GetFileSize() == 0)
{
protections.Add("Protect DVD-Video (Unconfirmed - Please report to us on Github)");
break;