REFACTOR: Minor refactors.

This commit is contained in:
2017-12-21 17:14:49 +00:00
parent 13a6473236
commit b9ec685b4e
3 changed files with 37 additions and 31 deletions

View File

@@ -77,7 +77,7 @@ namespace DiscImageChef.Devices.Windows
catch(Exception ex) catch(Exception ex)
{ {
#if DEBUG #if DEBUG
throw ex; throw;
#else #else
return null; return null;
#endif #endif

View File

@@ -1340,7 +1340,7 @@ namespace DiscImageChef.Filesystems
if(entry.ctime > 0 && entry.cdate > 0) if(entry.ctime > 0 && entry.cdate > 0)
{ {
xmlFSType.CreationDate = DateHandlers.DOSToDateTime(entry.cdate, entry.ctime); xmlFSType.CreationDate = DateHandlers.DOSToDateTime(entry.cdate, entry.ctime);
if(entry.ctime_ms > 0) xmlFSType.CreationDate.AddMilliseconds(entry.ctime_ms * 10); if(entry.ctime_ms > 0) xmlFSType.CreationDate = xmlFSType.CreationDate.AddMilliseconds(entry.ctime_ms * 10);
xmlFSType.CreationDateSpecified = true; xmlFSType.CreationDateSpecified = true;
sb.AppendFormat("Volume created on {0}", xmlFSType.CreationDate).AppendLine(); sb.AppendFormat("Volume created on {0}", xmlFSType.CreationDate).AppendLine();
} }

View File

@@ -178,13 +178,14 @@ namespace DiscImageChef.Commands
else else
{ {
plugins.PluginsList.TryGetValue(idPlugins[0], out plugin); plugins.PluginsList.TryGetValue(idPlugins[0], out plugin);
if(plugin == null) continue;
DicConsole.WriteLine(string.Format("Identified by {0}.", plugin.Name)); DicConsole.WriteLine(string.Format("Identified by {0}.", plugin.Name));
Filesystem fs = (Filesystem)plugin Filesystem fs = (Filesystem)plugin
.GetType().GetConstructor(new[] .GetType().GetConstructor(new[]
{ {
typeof(ImagePlugin), typeof(Partition), typeof(Encoding) typeof(ImagePlugin), typeof(Partition), typeof(Encoding)
}) })?.Invoke(new object[] {imageFormat, partitions[i], null});
?.Invoke(new object[] {imageFormat, partitions[i], null});
if(fs == null) continue; if(fs == null) continue;
error = fs.Mount(options.Debug); error = fs.Mount(options.Debug);
@@ -255,43 +256,48 @@ namespace DiscImageChef.Commands
Filesystem fs = (Filesystem)plugin Filesystem fs = (Filesystem)plugin
.GetType().GetConstructor(new[] {typeof(ImagePlugin), typeof(Partition), typeof(Encoding)}) .GetType().GetConstructor(new[] {typeof(ImagePlugin), typeof(Partition), typeof(Encoding)})
?.Invoke(new object[] {imageFormat, wholePart, null}); ?.Invoke(new object[] {imageFormat, wholePart, null});
error = fs.Mount(options.Debug); if(fs != null)
if(error == Errno.NoError)
{ {
List<string> rootDir = new List<string>(); error = fs.Mount(options.Debug);
error = fs.ReadDir("/", ref rootDir);
if(error == Errno.NoError) if(error == Errno.NoError)
foreach(string entry in rootDir) {
if(options.Long) List<string> rootDir = new List<string>();
{ error = fs.ReadDir("/", ref rootDir);
FileEntryInfo stat = new FileEntryInfo(); if(error == Errno.NoError)
List<string> xattrs = new List<string>(); foreach(string entry in rootDir)
if(options.Long)
error = fs.Stat(entry, ref stat);
if(error == Errno.NoError)
{ {
DicConsole.WriteLine("{0}\t{1}\t{2} bytes\t{3}", stat.CreationTimeUtc, FileEntryInfo stat = new FileEntryInfo();
stat.Inode, stat.Length, entry); List<string> xattrs = new List<string>();
error = fs.ListXAttr(entry, ref xattrs); error = fs.Stat(entry, ref stat);
if(error != Errno.NoError) continue; if(error == Errno.NoError)
foreach(string xattr in xattrs)
{ {
byte[] xattrBuf = new byte[0]; DicConsole.WriteLine("{0}\t{1}\t{2} bytes\t{3}", stat.CreationTimeUtc,
error = fs.GetXattr(entry, xattr, ref xattrBuf); stat.Inode, stat.Length, entry);
if(error == Errno.NoError)
DicConsole.WriteLine("\t\t{0}\t{1} bytes", xattr, xattrBuf.Length); 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
else DicConsole.WriteLine("{0}", entry); 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());
} }
} }
} }