Cleaned up warnings in code

This commit is contained in:
Henry Asbridge 2022-06-23 15:50:26 +01:00
parent 1c39468343
commit b4d28966c7
2 changed files with 14 additions and 11 deletions

View file

@ -5,13 +5,15 @@ using System.IO;
using System.Linq;
using System.Net;
namespace LBPUnion.UnionPatcher.Communication;
#pragma warning disable SYSLIB0014 // the FtpWebRequest is needed in this case
namespace LBPUnion.UnionPatcher.Communication;
public static class FTP
{
public static bool FileExists(string url, string user, string pass)
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url);
request.Credentials = new NetworkCredential(user, pass);
request.Method = WebRequestMethods.Ftp.GetDateTimestamp;
@ -36,6 +38,7 @@ public static class FTP
public static string[] ListDirectory(string url, string user, string pass)
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url);
request.Credentials = new NetworkCredential(user, pass);
request.Method = WebRequestMethods.Ftp.ListDirectory;
@ -53,7 +56,7 @@ public static class FTP
.Where(dir => !string.IsNullOrWhiteSpace(dir) && dir != "." && dir != "..")
.ToList();
foreach(string dir in dirs.ToArray())
foreach (string dir in dirs.ToArray())
{
Console.WriteLine($"/{dir}");
}
@ -128,7 +131,7 @@ public static class FTP
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
using StreamReader reader = new(responseStream);
return reader.ReadToEnd();

View file

@ -12,7 +12,7 @@ using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
namespace LBPUnion.UnionPatcher.Communication;
namespace LBPUnion.UnionPatcher.Communication;
public class PS3MAPI
{
@ -102,7 +102,7 @@ public class PS3MAPI
Double = 2,
Triple = 3,
}
/// <summary>Ring PS3 Buzzer.</summary>
/// <param name="mode">Simple, Double, Continuous</param>
public void RingBuzzer(BuzzerMode mode)
@ -234,7 +234,7 @@ public class PS3MAPI
}
}
main_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
main_ipEndPoint = new IPEndPoint(Dns.GetHostByName(sServerIP).AddressList[0], Port);
main_ipEndPoint = new IPEndPoint(Dns.GetHostAddresses(sServerIP)[0], Port);
try
{
main_sock.Connect(main_ipEndPoint);
@ -781,12 +781,12 @@ public class PS3MAPI
SetBinaryMode(false);
}
}
catch (Exception e)
catch
{
CloseDataSocket();
ReadResponse();
SetBinaryMode(false);
throw e;
throw;
}
}
}
@ -847,12 +847,12 @@ public class PS3MAPI
SetBinaryMode(false);
}
}
catch (Exception e)
catch
{
CloseDataSocket();
ReadResponse();
SetBinaryMode(false);
throw e;
throw;
}
}
}
@ -1094,7 +1094,7 @@ public class PS3MAPI
{
CloseDataSocket();
data_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
data_ipEndPoint = new IPEndPoint(Dns.GetHostByName(sServerIP).AddressList[0], iPort);
data_ipEndPoint = new IPEndPoint(Dns.GetHostAddresses(sServerIP)[0], iPort);
data_sock.Connect(data_ipEndPoint);
}
catch (Exception e)