mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: Possible 'null' assignment to entity marked with 'NotNull' attribute.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
@@ -71,7 +72,7 @@ namespace DiscImageChef.Core
|
||||
if(((HttpWebResponse)response).StatusCode != HttpStatusCode.OK) return;
|
||||
|
||||
Stream data = response.GetResponseStream();
|
||||
StreamReader reader = new StreamReader(data);
|
||||
StreamReader reader = new StreamReader(data ?? throw new InvalidOperationException());
|
||||
|
||||
string responseFromServer = reader.ReadToEnd();
|
||||
data.Close();
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace DiscImageChef.Core
|
||||
if(((HttpWebResponse)response).StatusCode != HttpStatusCode.OK) return;
|
||||
|
||||
Stream data = response.GetResponseStream();
|
||||
StreamReader reader = new StreamReader(data);
|
||||
StreamReader reader = new StreamReader(data ?? throw new InvalidOperationException());
|
||||
|
||||
string responseFromServer = reader.ReadToEnd();
|
||||
data.Close();
|
||||
|
||||
@@ -274,7 +274,7 @@ namespace DiscImageChef.DiscImages
|
||||
{
|
||||
line = tocStream.ReadLine();
|
||||
|
||||
dm = dr.Match(line);
|
||||
dm = dr.Match(line ?? throw new InvalidOperationException());
|
||||
cm = cr.Match(line);
|
||||
|
||||
// Skip comments at start of file
|
||||
@@ -390,7 +390,7 @@ namespace DiscImageChef.DiscImages
|
||||
line++;
|
||||
_line = tocStream.ReadLine();
|
||||
|
||||
matchDiskType = regexDiskType.Match(_line);
|
||||
matchDiskType = regexDiskType.Match(_line ?? throw new InvalidOperationException());
|
||||
matchComment = regexComment.Match(_line);
|
||||
|
||||
// Skip comments at start of file
|
||||
@@ -416,7 +416,7 @@ namespace DiscImageChef.DiscImages
|
||||
line++;
|
||||
_line = tocStream.ReadLine();
|
||||
|
||||
matchComment = regexComment.Match(_line);
|
||||
matchComment = regexComment.Match(_line ?? throw new ());
|
||||
matchDiskType = regexDiskType.Match(_line);
|
||||
matchMcn = regexMcn.Match(_line);
|
||||
matchTrack = regexTrack.Match(_line);
|
||||
|
||||
@@ -351,7 +351,7 @@ namespace DiscImageChef.DiscImages
|
||||
Match tm;
|
||||
|
||||
// First line must be SESSION, REM, CATALOG, FILE or CDTEXTFILE.
|
||||
sm = sr.Match(_line);
|
||||
sm = sr.Match(_line ?? throw new InvalidOperationException());
|
||||
rm = rr.Match(_line);
|
||||
cm = cr.Match(_line);
|
||||
fm = fr.Match(_line);
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
Match hdm;
|
||||
|
||||
hdm = hdr.Match(_line);
|
||||
hdm = hdr.Match(_line ?? throw new InvalidOperationException());
|
||||
|
||||
return hdm.Success;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace DiscImageChef.DiscImages
|
||||
{
|
||||
Regex regexTrack = new Regex(TRACK_REGEX);
|
||||
|
||||
Match trackMatch = regexTrack.Match(_line);
|
||||
Match trackMatch = regexTrack.Match(_line ?? throw new InvalidOperationException());
|
||||
|
||||
if(!trackMatch.Success) return false;
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace DiscImageChef.DiscImages
|
||||
}
|
||||
else
|
||||
{
|
||||
trackMatch = regexTrack.Match(_line);
|
||||
trackMatch = regexTrack.Match(_line ?? throw new InvalidOperationException());
|
||||
|
||||
if(!trackMatch.Success)
|
||||
throw new ImageNotSupportedException(string.Format("Unknown line \"{0}\" at line {1}",
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
{
|
||||
XmlReader defsReader =
|
||||
XmlReader.Create(Assembly.GetExecutingAssembly()
|
||||
.GetManifestResourceStream("DiscImageChef.Filesystems.CPM.cpmdefs.xml"));
|
||||
.GetManifestResourceStream("DiscImageChef.Filesystems.CPM.cpmdefs.xml") ?? throw new InvalidOperationException());
|
||||
XmlSerializer defsSerializer = new XmlSerializer(typeof(CpmDefinitions));
|
||||
definitions = (CpmDefinitions)defsSerializer.Deserialize(defsReader);
|
||||
|
||||
|
||||
@@ -256,11 +256,11 @@ namespace DiscImageChef.Filters
|
||||
string filenameNoExt = Path.GetFileNameWithoutExtension(path);
|
||||
string parentFolder = Path.GetDirectoryName(path);
|
||||
|
||||
ProDosAppleDouble = Path.Combine(parentFolder, "R." + filename);
|
||||
ProDosAppleDouble = Path.Combine(parentFolder ?? throw new InvalidOperationException(), "R." + filename);
|
||||
UNIXAppleDouble = Path.Combine(parentFolder, "%" + filename);
|
||||
DOSAppleDouble = Path.Combine(parentFolder, filenameNoExt + ".ADF");
|
||||
DOSAppleDoubleLower = Path.Combine(parentFolder, filenameNoExt + ".adf");
|
||||
NetatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", filename);
|
||||
NetatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", filename ?? throw new InvalidOperationException());
|
||||
DAVEAppleDouble = Path.Combine(parentFolder, "resource.frk", filename);
|
||||
OSXAppleDouble = Path.Combine(parentFolder, "._" + filename);
|
||||
UnArAppleDouble = Path.Combine(parentFolder, filename + ".rsrc");
|
||||
@@ -426,11 +426,11 @@ namespace DiscImageChef.Filters
|
||||
string filenameNoExt = Path.GetFileNameWithoutExtension(path);
|
||||
string parentFolder = Path.GetDirectoryName(path);
|
||||
|
||||
ProDosAppleDouble = Path.Combine(parentFolder, "R." + filename);
|
||||
ProDosAppleDouble = Path.Combine(parentFolder ?? throw new InvalidOperationException(), "R." + filename);
|
||||
UNIXAppleDouble = Path.Combine(parentFolder, "%" + filename);
|
||||
DOSAppleDouble = Path.Combine(parentFolder, filenameNoExt + ".ADF");
|
||||
DOSAppleDoubleLower = Path.Combine(parentFolder, filenameNoExt + ".adf");
|
||||
NetatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", filename);
|
||||
NetatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", filename ?? throw new InvalidOperationException());
|
||||
DAVEAppleDouble = Path.Combine(parentFolder, "resource.frk", filename);
|
||||
OSXAppleDouble = Path.Combine(parentFolder, "._" + filename);
|
||||
UnArAppleDouble = Path.Combine(parentFolder, filename + ".rsrc");
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace DiscImageChef.Filters
|
||||
{
|
||||
string parentFolder = Path.GetDirectoryName(path);
|
||||
|
||||
if(!File.Exists(Path.Combine(parentFolder, FinderInfo))) return false;
|
||||
if(!File.Exists(Path.Combine(parentFolder ?? throw new InvalidOperationException(), FinderInfo))) return false;
|
||||
|
||||
if(!Directory.Exists(Path.Combine(parentFolder, Resources))) return false;
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
if(baseFilename != macName && baseFilename != dosName && baseFilename != dosNameLow) continue;
|
||||
|
||||
dataFound |= File.Exists(Path.Combine(parentFolder, macName)) ||
|
||||
dataFound |= File.Exists(Path.Combine(parentFolder, macName ?? throw new InvalidOperationException())) ||
|
||||
File.Exists(Path.Combine(parentFolder, dosName)) ||
|
||||
File.Exists(Path.Combine(parentFolder, dosNameLow));
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace DiscImageChef.Filters
|
||||
string baseFilename = Path.GetFileName(path);
|
||||
|
||||
FileStream finderDatStream =
|
||||
new FileStream(Path.Combine(parentFolder, FinderInfo), FileMode.Open, FileAccess.Read);
|
||||
new FileStream(Path.Combine(parentFolder ?? throw new InvalidOperationException(), FinderInfo), FileMode.Open, FileAccess.Read);
|
||||
|
||||
while(finderDatStream.Position + 0x5C <= finderDatStream.Length)
|
||||
{
|
||||
@@ -285,7 +285,7 @@ namespace DiscImageChef.Filters
|
||||
|
||||
if(baseFilename != macName && baseFilename != dosName && baseFilename != dosNameLow) continue;
|
||||
|
||||
if(File.Exists(Path.Combine(parentFolder, macName))) dataPath = Path.Combine(parentFolder, macName);
|
||||
if(File.Exists(Path.Combine(parentFolder, macName ?? throw new InvalidOperationException()))) dataPath = Path.Combine(parentFolder, macName);
|
||||
else if(File.Exists(Path.Combine(parentFolder, dosName)))
|
||||
dataPath = Path.Combine(parentFolder, dosName);
|
||||
else if(File.Exists(Path.Combine(parentFolder, dosNameLow)))
|
||||
@@ -304,8 +304,8 @@ namespace DiscImageChef.Filters
|
||||
break;
|
||||
}
|
||||
|
||||
dataLen = new FileInfo(dataPath).Length;
|
||||
rsrcLen = new FileInfo(rsrcPath).Length;
|
||||
dataLen = new FileInfo(dataPath ?? throw new InvalidOperationException()).Length;
|
||||
rsrcLen = new FileInfo(rsrcPath ?? throw new InvalidOperationException()).Length;
|
||||
|
||||
basePath = path;
|
||||
opened = true;
|
||||
|
||||
@@ -74,10 +74,10 @@ namespace DiscImageChef.Server.Controllers
|
||||
|
||||
Random rng = new Random();
|
||||
string filename = string.Format("NewReport_{0:yyyyMMddHHmmssfff}_{1}.xml", DateTime.UtcNow, rng.Next());
|
||||
while(File.Exists(Path.Combine(HostingEnvironment.MapPath("~"), "Upload", filename))) filename = string.Format("NewReport_{0:yyyyMMddHHmmssfff}_{1}.xml", DateTime.UtcNow, rng.Next());
|
||||
while(File.Exists(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Upload", filename))) filename = string.Format("NewReport_{0:yyyyMMddHHmmssfff}_{1}.xml", DateTime.UtcNow, rng.Next());
|
||||
|
||||
FileStream newFile =
|
||||
new FileStream(Path.Combine(HostingEnvironment.MapPath("~"), "Upload", filename),
|
||||
new FileStream(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Upload", filename),
|
||||
FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None);
|
||||
xs.Serialize(newFile, newReport);
|
||||
newFile.Close();
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace DiscImageChef.Server.Controllers
|
||||
}
|
||||
|
||||
FileStream fs =
|
||||
WaitForFile(Path.Combine(HostingEnvironment.MapPath("~"), "Statistics", "Statistics.xml"),
|
||||
WaitForFile(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"),
|
||||
FileMode.Open, FileAccess.ReadWrite, FileShare.None);
|
||||
|
||||
if(fs == null)
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace DiscImageChef.Server
|
||||
{
|
||||
MarkdownContent mkdown = new MarkdownContent();
|
||||
StreamReader sr =
|
||||
new StreamReader(Path.Combine(HostingEnvironment.MapPath("~"), "docs", "README.md"));
|
||||
new StreamReader(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "docs", "README.md"));
|
||||
string mdcontent = sr.ReadToEnd();
|
||||
sr.Close();
|
||||
|
||||
|
||||
@@ -77,12 +77,12 @@ namespace DiscImageChef.Server
|
||||
|
||||
try
|
||||
{
|
||||
if(!File.Exists(Path.Combine(HostingEnvironment.MapPath("~"), "Statistics",
|
||||
if(!File.Exists(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Statistics",
|
||||
"Statistics.xml")))
|
||||
{
|
||||
#if DEBUG
|
||||
content.InnerHtml = string.Format("<b>Sorry, cannot load data file \"{0}\"</b>",
|
||||
Path.Combine(HostingEnvironment.MapPath("~"),
|
||||
Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(),
|
||||
"Statistics", "Statistics.xml"));
|
||||
#else
|
||||
content.InnerHtml = "<b>Sorry, cannot load data file</b>";
|
||||
@@ -94,7 +94,7 @@ namespace DiscImageChef.Server
|
||||
|
||||
XmlSerializer xs = new XmlSerializer(statistics.GetType());
|
||||
FileStream fs =
|
||||
WaitForFile(Path.Combine(HostingEnvironment.MapPath("~"), "Statistics", "Statistics.xml"),
|
||||
WaitForFile(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"),
|
||||
FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
statistics = (Stats)xs.Deserialize(fs);
|
||||
fs.Close();
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace DiscImageChef.Server
|
||||
else if(!string.IsNullOrWhiteSpace(model)) xmlFile = model + ".xml";
|
||||
|
||||
if(xmlFile == null ||
|
||||
!File.Exists(Path.Combine(HostingEnvironment.MapPath("~"), "Reports", xmlFile)))
|
||||
!File.Exists(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Reports", xmlFile)))
|
||||
{
|
||||
content.InnerHtml = "<b>Could not find the specified report</b>";
|
||||
return;
|
||||
@@ -95,7 +95,7 @@ namespace DiscImageChef.Server
|
||||
DeviceReport report = new DeviceReport();
|
||||
XmlSerializer xs = new XmlSerializer(report.GetType());
|
||||
StreamReader sr =
|
||||
new StreamReader(Path.Combine(HostingEnvironment.MapPath("~"), "Reports",
|
||||
new StreamReader(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Reports",
|
||||
xmlFile));
|
||||
report = (DeviceReport)xs.Deserialize(sr);
|
||||
sr.Close();
|
||||
@@ -567,10 +567,10 @@ namespace DiscImageChef.Server
|
||||
vendorDescription = null;
|
||||
productDescription = null;
|
||||
|
||||
if(!File.Exists(Path.Combine(HostingEnvironment.MapPath("~"), "usb.ids"))) return;
|
||||
if(!File.Exists(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "usb.ids"))) return;
|
||||
|
||||
StreamReader tocStream =
|
||||
new StreamReader(Path.Combine(HostingEnvironment.MapPath("~"), "usb.ids"));
|
||||
new StreamReader(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "usb.ids"));
|
||||
string _line;
|
||||
bool inManufacturer = false;
|
||||
ushort number;
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace DiscImageChef.Commands
|
||||
|
||||
FileStream xmlFs =
|
||||
new
|
||||
FileStream(Path.Combine(Path.GetDirectoryName(options.InputFile), Path.GetFileNameWithoutExtension(options.InputFile) + ".cicm.xml"),
|
||||
FileStream(Path.Combine(Path.GetDirectoryName(options.InputFile) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(options.InputFile) + ".cicm.xml"),
|
||||
FileMode.CreateNew);
|
||||
|
||||
XmlSerializer xmlSer =
|
||||
@@ -169,7 +169,7 @@ namespace DiscImageChef.Commands
|
||||
|
||||
FileStream xmlFs =
|
||||
new
|
||||
FileStream(Path.Combine(Path.GetDirectoryName(options.InputFile), Path.GetFileNameWithoutExtension(options.InputFile) + ".cicm.xml"),
|
||||
FileStream(Path.Combine(Path.GetDirectoryName(options.InputFile) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(options.InputFile) + ".cicm.xml"),
|
||||
FileMode.CreateNew);
|
||||
|
||||
XmlSerializer xmlSer =
|
||||
|
||||
Reference in New Issue
Block a user