mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: Possible 'System.NullReferenceException'.
This commit is contained in:
@@ -183,10 +183,13 @@ namespace DiscImageChef.Commands
|
||||
else
|
||||
{
|
||||
plugins.PluginsList.TryGetValue(idPlugins[0], out plugin);
|
||||
DicConsole.WriteLine(string.Format("Identified by {0}.", plugin.Name));
|
||||
plugin.GetInformation(imageFormat, partitions[i], out information);
|
||||
DicConsole.Write(information);
|
||||
Core.Statistics.AddFilesystem(plugin.XmlFSType.Type);
|
||||
if(plugin != null)
|
||||
{
|
||||
DicConsole.WriteLine(string.Format("Identified by {0}.", plugin.Name));
|
||||
plugin.GetInformation(imageFormat, partitions[i], out information);
|
||||
DicConsole.Write(information);
|
||||
Core.Statistics.AddFilesystem(plugin.XmlFSType.Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,10 +222,13 @@ namespace DiscImageChef.Commands
|
||||
else
|
||||
{
|
||||
plugins.PluginsList.TryGetValue(idPlugins[0], out plugin);
|
||||
DicConsole.WriteLine(string.Format("Identified by {0}.", plugin.Name));
|
||||
plugin.GetInformation(imageFormat, wholePart, out information);
|
||||
DicConsole.Write(information);
|
||||
Core.Statistics.AddFilesystem(plugin.XmlFSType.Type);
|
||||
if(plugin != null)
|
||||
{
|
||||
DicConsole.WriteLine(string.Format("Identified by {0}.", plugin.Name));
|
||||
plugin.GetInformation(imageFormat, wholePart, out information);
|
||||
DicConsole.Write(information);
|
||||
Core.Statistics.AddFilesystem(plugin.XmlFSType.Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace DiscImageChef.Commands
|
||||
|
||||
byte[] hiddenSector = inputFormat.ReadSector(i);
|
||||
|
||||
mediaChecksum.Update(hiddenSector);
|
||||
mediaChecksum?.Update(hiddenSector);
|
||||
}
|
||||
|
||||
DicConsole.DebugWriteLine("Checksum command",
|
||||
@@ -155,17 +155,19 @@ namespace DiscImageChef.Commands
|
||||
doneSectors += sectors - doneSectors;
|
||||
}
|
||||
|
||||
if(options.WholeDisc) mediaChecksum.Update(sector);
|
||||
if(options.WholeDisc)
|
||||
mediaChecksum?.Update(sector);
|
||||
|
||||
if(options.SeparatedTracks) trackChecksum.Update(sector);
|
||||
if(options.SeparatedTracks) trackChecksum?.Update(sector);
|
||||
}
|
||||
|
||||
DicConsole.WriteLine();
|
||||
|
||||
if(options.SeparatedTracks)
|
||||
foreach(ChecksumType chk in trackChecksum.End())
|
||||
DicConsole.WriteLine("Track {0}'s {1}: {2}", currentTrack.TrackSequence, chk.type,
|
||||
chk.Value);
|
||||
if(trackChecksum != null)
|
||||
foreach(ChecksumType chk in trackChecksum.End())
|
||||
DicConsole.WriteLine("Track {0}'s {1}: {2}", currentTrack.TrackSequence, chk.type,
|
||||
chk.Value);
|
||||
|
||||
previousTrackEnd = currentTrack.TrackEndSector;
|
||||
}
|
||||
@@ -176,12 +178,13 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.Write("\rHashing track-less sector {0}", i);
|
||||
|
||||
byte[] hiddenSector = inputFormat.ReadSector(i);
|
||||
mediaChecksum.Update(hiddenSector);
|
||||
mediaChecksum?.Update(hiddenSector);
|
||||
}
|
||||
|
||||
if(options.WholeDisc)
|
||||
foreach(ChecksumType chk in mediaChecksum.End())
|
||||
DicConsole.WriteLine("Disk's {0}: {1}", chk.type, chk.Value);
|
||||
if(mediaChecksum != null)
|
||||
foreach(ChecksumType chk in mediaChecksum.End())
|
||||
DicConsole.WriteLine("Disk's {0}: {1}", chk.type, chk.Value);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
@@ -152,14 +152,18 @@ namespace DiscImageChef.Commands
|
||||
.GetType().GetConstructor(new[]
|
||||
{
|
||||
typeof(ImagePlugin), typeof(Partition), typeof(Encoding)
|
||||
}).Invoke(new object[] {imageFormat, partitions[i], null});
|
||||
})
|
||||
?.Invoke(new object[] {imageFormat, partitions[i], null});
|
||||
|
||||
if(fs == null) continue;
|
||||
|
||||
error = fs.Mount(options.Debug);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
error = fs.ReadDir("/", ref rootDir);
|
||||
if(error == Errno.NoError) foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry);
|
||||
if(error == Errno.NoError)
|
||||
foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry);
|
||||
else
|
||||
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}",
|
||||
error.ToString());
|
||||
@@ -179,15 +183,20 @@ namespace DiscImageChef.Commands
|
||||
.GetType().GetConstructor(new[]
|
||||
{
|
||||
typeof(ImagePlugin), typeof(Partition), typeof(Encoding)
|
||||
}).Invoke(new object[] {imageFormat, partitions[i], null});
|
||||
})
|
||||
?.Invoke(new object[] {imageFormat, partitions[i], null});
|
||||
if(fs == null) continue;
|
||||
|
||||
error = fs.Mount(options.Debug);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
error = fs.ReadDir("/", ref rootDir);
|
||||
if(error == Errno.NoError) foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry);
|
||||
if(error == Errno.NoError)
|
||||
foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry);
|
||||
else
|
||||
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString());
|
||||
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}",
|
||||
error.ToString());
|
||||
|
||||
Core.Statistics.AddFilesystem(fs.XmlFSType.Type);
|
||||
}
|
||||
@@ -217,15 +226,20 @@ namespace DiscImageChef.Commands
|
||||
.GetType().GetConstructor(new[]
|
||||
{
|
||||
typeof(ImagePlugin), typeof(Partition), typeof(Encoding)
|
||||
}).Invoke(new object[] {imageFormat, wholePart, null});
|
||||
})
|
||||
?.Invoke(new object[] {imageFormat, wholePart, null});
|
||||
if(fs == null) continue;
|
||||
|
||||
error = fs.Mount(options.Debug);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
error = fs.ReadDir("/", ref rootDir);
|
||||
if(error == Errno.NoError) foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry);
|
||||
if(error == Errno.NoError)
|
||||
foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry);
|
||||
else
|
||||
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString());
|
||||
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}",
|
||||
error.ToString());
|
||||
|
||||
Core.Statistics.AddFilesystem(fs.XmlFSType.Type);
|
||||
}
|
||||
@@ -235,48 +249,50 @@ namespace DiscImageChef.Commands
|
||||
else
|
||||
{
|
||||
plugins.PluginsList.TryGetValue(idPlugins[0], out plugin);
|
||||
DicConsole.WriteLine(string.Format("Identified by {0}.", plugin.Name));
|
||||
Filesystem fs = (Filesystem)plugin
|
||||
.GetType().GetConstructor(new[]
|
||||
{
|
||||
typeof(ImagePlugin), typeof(Partition), typeof(Encoding)
|
||||
}).Invoke(new object[] {imageFormat, wholePart, null});
|
||||
error = fs.Mount(options.Debug);
|
||||
if(error == Errno.NoError)
|
||||
if(plugin != null)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
error = fs.ReadDir("/", ref rootDir);
|
||||
DicConsole.WriteLine(string.Format("Identified by {0}.", plugin.Name));
|
||||
Filesystem fs = (Filesystem)plugin
|
||||
.GetType().GetConstructor(new[] {typeof(ImagePlugin), typeof(Partition), typeof(Encoding)})
|
||||
?.Invoke(new object[] {imageFormat, wholePart, null});
|
||||
error = fs.Mount(options.Debug);
|
||||
if(error == Errno.NoError)
|
||||
foreach(string entry in rootDir)
|
||||
if(options.Long)
|
||||
{
|
||||
FileEntryInfo stat = new FileEntryInfo();
|
||||
List<string> xattrs = new List<string>();
|
||||
|
||||
error = fs.Stat(entry, ref stat);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
error = fs.ReadDir("/", ref rootDir);
|
||||
if(error == Errno.NoError)
|
||||
foreach(string entry in rootDir)
|
||||
if(options.Long)
|
||||
{
|
||||
DicConsole.WriteLine("{0}\t{1}\t{2} bytes\t{3}", stat.CreationTimeUtc,
|
||||
stat.Inode, stat.Length, entry);
|
||||
FileEntryInfo stat = new FileEntryInfo();
|
||||
List<string> xattrs = new List<string>();
|
||||
|
||||
error = fs.ListXAttr(entry, ref xattrs);
|
||||
if(error != Errno.NoError) continue;
|
||||
|
||||
foreach(string xattr in xattrs)
|
||||
error = fs.Stat(entry, ref stat);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
byte[] xattrBuf = new byte[0];
|
||||
error = fs.GetXattr(entry, xattr, ref xattrBuf);
|
||||
if(error == Errno.NoError) DicConsole.WriteLine("\t\t{0}\t{1} bytes", xattr, xattrBuf.Length);
|
||||
DicConsole.WriteLine("{0}\t{1}\t{2} bytes\t{3}", stat.CreationTimeUtc,
|
||||
stat.Inode, stat.Length, entry);
|
||||
|
||||
error = fs.ListXAttr(entry, ref xattrs);
|
||||
if(error != Errno.NoError) continue;
|
||||
|
||||
foreach(string xattr in xattrs)
|
||||
{
|
||||
byte[] xattrBuf = new byte[0];
|
||||
error = fs.GetXattr(entry, xattr, ref xattrBuf);
|
||||
if(error == Errno.NoError)
|
||||
DicConsole.WriteLine("\t\t{0}\t{1} bytes", xattr, xattrBuf.Length);
|
||||
}
|
||||
}
|
||||
else DicConsole.WriteLine("{0}", entry);
|
||||
}
|
||||
else DicConsole.WriteLine("{0}", entry);
|
||||
}
|
||||
else DicConsole.WriteLine("{0}", entry);
|
||||
else DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString());
|
||||
else DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString());
|
||||
|
||||
Core.Statistics.AddFilesystem(fs.XmlFSType.Type);
|
||||
Core.Statistics.AddFilesystem(fs.XmlFSType.Type);
|
||||
}
|
||||
else DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
|
||||
}
|
||||
else DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user