mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: Invert 'if' statement to reduce nesting.
This commit is contained in:
@@ -104,25 +104,24 @@ namespace DiscImageChef.Core
|
||||
public static void WriteTo(string who, string filename, byte[] data, string whatWriting = null,
|
||||
bool overwrite = false)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(filename))
|
||||
{
|
||||
if(File.Exists(filename))
|
||||
if(overwrite) File.Delete(filename);
|
||||
else
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Not overwriting file {0}", filename);
|
||||
return;
|
||||
}
|
||||
if(string.IsNullOrEmpty(filename)) return;
|
||||
|
||||
try
|
||||
if(File.Exists(filename))
|
||||
if(overwrite) File.Delete(filename);
|
||||
else
|
||||
{
|
||||
DicConsole.DebugWriteLine(who, "Writing " + whatWriting + " to {0}", filename);
|
||||
FileStream outputFs = new FileStream(filename, FileMode.CreateNew);
|
||||
outputFs.Write(data, 0, data.Length);
|
||||
outputFs.Close();
|
||||
DicConsole.ErrorWriteLine("Not overwriting file {0}", filename);
|
||||
return;
|
||||
}
|
||||
catch { DicConsole.ErrorWriteLine("Unable to write file {0}", filename); }
|
||||
|
||||
try
|
||||
{
|
||||
DicConsole.DebugWriteLine(who, "Writing " + whatWriting + " to {0}", filename);
|
||||
FileStream outputFs = new FileStream(filename, FileMode.CreateNew);
|
||||
outputFs.Write(data, 0, data.Length);
|
||||
outputFs.Close();
|
||||
}
|
||||
catch { DicConsole.ErrorWriteLine("Unable to write file {0}", filename); }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user