Use debug flag for exception printing

This commit is contained in:
Matt Nadareski
2022-05-15 20:58:27 -07:00
parent 295b86fbd0
commit dfee4a8d76
20 changed files with 206 additions and 56 deletions

View File

@@ -63,7 +63,7 @@ namespace BurnOutSharp.FileType
br.BaseStream.Seek(offset, SeekOrigin.Begin);
uint compressedSize = br.ReadUInt32();
// Some files can lack the length prefix
if (compressedSize > br.BaseStream.Length)
{
@@ -102,8 +102,11 @@ namespace BurnOutSharp.FileType
}
}
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
br.BaseStream.Seek(current, SeekOrigin.Begin);
}
}
@@ -116,14 +119,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -51,7 +51,10 @@ namespace BurnOutSharp.FileType
bz2File.CopyTo(fs);
}
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
// Collect and format all found protections
@@ -62,14 +65,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -75,8 +75,10 @@ namespace BurnOutSharp.FileType
fileContent = br.ReadBytes((int)stream.Length);
}
}
catch
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
Utilities.AppendToDictionary(protections, file, "[Out of memory attempting to open]");
return protections;
}

View File

@@ -54,7 +54,10 @@ namespace BurnOutSharp.FileType
string tempFile = Path.Combine(tempPath, entry.Key);
entry.WriteToFile(tempFile);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
}
@@ -66,14 +69,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -75,7 +75,10 @@ namespace BurnOutSharp.FileType
fs.Write(fileContents, 0, fileContents.Length);
}
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
// Collect and format all found protections
@@ -86,14 +89,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
return null;

View File

@@ -64,7 +64,10 @@ namespace BurnOutSharp.FileType
string tempFile = Path.Combine(tempPath, cabfile.FileName(i));
cabfile.FileSave(i, tempFile);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
// Collect and format all found protections
@@ -75,14 +78,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
return null;

View File

@@ -69,7 +69,10 @@ namespace BurnOutSharp.FileType
Directory.CreateDirectory(Path.GetDirectoryName(tempFile));
mpqArchive.ExtractFile(sub, tempFile);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
}
@@ -81,14 +84,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -53,14 +53,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -51,7 +51,10 @@ namespace BurnOutSharp.FileType
string tempFile = Path.Combine(tempPath, sub.Name.TrimEnd('.'));
sub.CopyTo(tempFile);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
// Collect and format all found protections
@@ -62,14 +65,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -63,7 +63,10 @@ namespace BurnOutSharp.FileType
string tempFile = Path.Combine(tempPath, entry.Key);
entry.WriteToFile(tempFile);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
}
@@ -75,14 +78,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -59,7 +59,10 @@ namespace BurnOutSharp.FileType
string tempFile = Path.Combine(tempPath, entry.Key);
entry.WriteToFile(tempFile);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
}
@@ -71,14 +74,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -54,7 +54,10 @@ namespace BurnOutSharp.FileType
string tempFile = Path.Combine(tempPath, entry.Key);
entry.WriteToFile(tempFile);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
// Collect and format all found protections
@@ -65,7 +68,10 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
@@ -73,7 +79,10 @@ namespace BurnOutSharp.FileType
return protections;
}
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -57,7 +57,10 @@ namespace BurnOutSharp.FileType
string tempFile = Path.Combine(tempPath, entry.Key);
entry.WriteToFile(tempFile);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
}
@@ -69,14 +72,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -97,9 +97,9 @@ namespace BurnOutSharp.FileType
if (fileContent.Contains("http://cp.sonybmg.com/xcp/"))
Utilities.AppendToDictionary(protections, file, "XCP");
}
catch
catch (Exception ex)
{
// We don't care what the error was
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return protections;

View File

@@ -68,14 +68,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -50,7 +50,10 @@ namespace BurnOutSharp.FileType
xzFile.CopyTo(fs);
}
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
// Collect and format all found protections
@@ -61,14 +64,20 @@ namespace BurnOutSharp.FileType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -81,7 +81,10 @@ namespace BurnOutSharp.PackerType
string tempFile = Path.Combine(tempPath, entry.Key);
entry.WriteToFile(tempFile);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
}
@@ -93,14 +96,20 @@ namespace BurnOutSharp.PackerType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -158,7 +158,10 @@ namespace BurnOutSharp.PackerType
string tempFile = Path.Combine(tempPath, entry.Key);
entry.WriteToFile(tempFile);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
}
}
@@ -170,14 +173,20 @@ namespace BurnOutSharp.PackerType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -111,14 +111,20 @@ namespace BurnOutSharp.PackerType
{
Directory.Delete(tempPath, true);
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
// Remove temporary path references
Utilities.StripFromKeys(protections, tempPath);
return protections;
}
catch { }
catch (Exception ex)
{
if (scanner.IncludeDebug) Console.WriteLine(ex);
}
return null;
}

View File

@@ -261,6 +261,8 @@ namespace BurnOutSharp
}
catch (Exception ex)
{
if (IncludeDebug) Console.WriteLine(ex);
var protections = new ConcurrentDictionary<string, ConcurrentQueue<string>>();
Utilities.AppendToDictionary(protections, file, "[Exception opening file, please try again]");
Utilities.ClearEmptyKeys(protections);
@@ -296,9 +298,10 @@ namespace BurnOutSharp
stream.Read(magic, 0, 16);
stream.Seek(0, SeekOrigin.Begin);
}
catch
catch (Exception ex)
{
// We don't care what the issue was, we can't read or seek the file
if (IncludeDebug) Console.WriteLine(ex);
return null;
}
@@ -442,7 +445,8 @@ namespace BurnOutSharp
}
catch (Exception ex)
{
//Utilities.AppendToDictionary(protections, fileName, ex.ToString());
if (IncludeDebug) Console.WriteLine(ex);
Utilities.AppendToDictionary(protections, fileName, "[Exception opening file, please try again]");
}