Skip to content

Commit

Permalink
Missing or moved files shouldn't cause an issue (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnadareski authored Oct 26, 2019
1 parent 482644a commit 99f4909
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 29 deletions.
2 changes: 1 addition & 1 deletion BurnOutSharp/BurnOutSharp.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>BurnOutSharp</id>
<version>1.03.8.1</version>
<version>1.03.8.2</version>
<title>BurnOutSharp</title>
<authors>Matt Nadareski, Gernot Knippen</authors>
<owners>Matt Nadareski, Gernot Knippen</owners>
Expand Down
10 changes: 5 additions & 5 deletions BurnOutSharp/EVORE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private struct Section

private static Process StartSafe(string file)
{
if (file == null)
if (file == null || !File.Exists(file))
return null;

Process startingprocess = new Process();
Expand All @@ -59,7 +59,7 @@ private static Process StartSafe(string file)

private static string MakeTempFile(string file, string sExtension = ".exe")
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

FileInfo filei = new FileInfo(file);
Expand All @@ -75,7 +75,7 @@ private static string MakeTempFile(string file, string sExtension = ".exe")

private static bool IsEXE(string file)
{
if (file == null)
if (file == null || !File.Exists(file))
return false;

BinaryReader breader = new BinaryReader(File.OpenRead(file));
Expand Down Expand Up @@ -199,7 +199,7 @@ private static uint RVA2Offset(uint RVA, Section[] sections)

public static string SearchProtectDiscVersion(string file)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

Process exe = new Process();
Expand Down Expand Up @@ -357,7 +357,7 @@ public static string SearchProtectDiscVersion(string file)

public static string SearchSafeDiscVersion(string file)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

Process exe = new Process();
Expand Down
2 changes: 1 addition & 1 deletion BurnOutSharp/ProtectionType/CDCops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static string CheckPath(string path, IEnumerable<string> files, bool isDi

private static string GetVersion(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down
2 changes: 1 addition & 1 deletion BurnOutSharp/ProtectionType/DVDCops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static string CheckContents(string file, string fileContent)

private static string GetVersion(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down
2 changes: 1 addition & 1 deletion BurnOutSharp/ProtectionType/InnoSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static string CheckContents(string file, string fileContent)

private static string GetVersion(string file)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down
2 changes: 1 addition & 1 deletion BurnOutSharp/ProtectionType/JoWooDXProt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static string CheckContents(string file, string fileContent)

private static string GetVersion(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down
4 changes: 2 additions & 2 deletions BurnOutSharp/ProtectionType/ProtectDisc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static string CheckContents(string file, string fileContent)

private static string GetVersionBuild6till8(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down Expand Up @@ -93,7 +93,7 @@ private static string GetVersionBuild6till8(string file, int position)
private static string GetVersionBuild76till10(string file, int position, out int irefBuild)
{
irefBuild = 0;
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down
21 changes: 14 additions & 7 deletions BurnOutSharp/ProtectionType/SafeDisc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,22 @@ public static string CheckPath(string path, IEnumerable<string> files, bool isDi
// TODO: These are all cop-outs that don't check the existence of the other files
if (files.Count(f => Path.GetFileName(f).Equals("DPLAYERX.DLL", StringComparison.OrdinalIgnoreCase)) > 0)
{
return GetDPlayerXVersion(path);
string file = files.First(f => Path.GetFileName(f).Equals("DPLAYERX.DLL", StringComparison.OrdinalIgnoreCase));
return GetDPlayerXVersion(file);
}
else if (files.Count(f => Path.GetFileName(f).Equals("drvmgt.dll", StringComparison.OrdinalIgnoreCase)) > 0)
{
return GetDrvmgtVersion(path);
string file = files.First(f => Path.GetFileName(f).Equals("drvmgt.dll", StringComparison.OrdinalIgnoreCase));
return GetDrvmgtVersion(file);
}
else if (files.Count(f => Path.GetFileName(f).Equals("secdrv.sys", StringComparison.OrdinalIgnoreCase)) > 0)
{
return GetSecdrvVersion(path);
string file = files.First(f => Path.GetFileName(f).Equals("secdrv.sys", StringComparison.OrdinalIgnoreCase));
return GetSecdrvVersion(file);
}
else if (path.EndsWith(".SafeDiscDVD.bundle", StringComparison.OrdinalIgnoreCase))
{
return "SafeDisc for Macintosh";
}
}
else
Expand Down Expand Up @@ -97,7 +104,7 @@ public static string CheckPath(string path, IEnumerable<string> files, bool isDi

private static string GetDPlayerXVersion(string file)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

FileInfo fi = new FileInfo(file);
Expand Down Expand Up @@ -125,7 +132,7 @@ private static string GetDPlayerXVersion(string file)

private static string GetDrvmgtVersion(string file)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

FileInfo fi = new FileInfo(file);
Expand Down Expand Up @@ -153,7 +160,7 @@ private static string GetDrvmgtVersion(string file)

private static string GetSecdrvVersion(string file)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

FileInfo fi = new FileInfo(file);
Expand Down Expand Up @@ -187,7 +194,7 @@ private static string GetSecdrvVersion(string file)

private static string GetVersion(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down
6 changes: 3 additions & 3 deletions BurnOutSharp/ProtectionType/SecuROM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static string CheckPath(string path, IEnumerable<string> files, bool isDi

private static string GetV4Version(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand All @@ -106,7 +106,7 @@ private static string GetV4Version(string file, int position)

private static string GetV5Version(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down Expand Up @@ -135,7 +135,7 @@ private static string GetV5Version(string file, int position)

private static string GetV7Version(string file)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down
2 changes: 1 addition & 1 deletion BurnOutSharp/ProtectionType/SolidShield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public static string CheckPath(string path, IEnumerable<string> files, bool isDi

private static string GetVersion(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down
2 changes: 1 addition & 1 deletion BurnOutSharp/ProtectionType/Sysiphus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static string CheckContents(string file, string fileContent)

private static string GetVersion(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down
2 changes: 1 addition & 1 deletion BurnOutSharp/ProtectionType/Tages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static string CheckPath(string path, IEnumerable<string> files, bool isDi

private static string GetVersion(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down
6 changes: 3 additions & 3 deletions BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static string CheckPath(string path, IEnumerable<string> files, bool isDi

private static string GetBuild(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand All @@ -76,7 +76,7 @@ private static string GetBuild(string file, int position)

private static string GetOldVersion(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand All @@ -98,7 +98,7 @@ private static string GetOldVersion(string file, int position)

private static string GetVersion(string file, int position)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
Expand Down
2 changes: 1 addition & 1 deletion BurnOutSharp/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class Utilities
/// </summary>
public static string GetFileVersion(string file)
{
if (file == null)
if (file == null || !File.Exists(file))
return string.Empty;

FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(file);
Expand Down

0 comments on commit 99f4909

Please sign in to comment.