Merge pull request #21 from Zaprit/code-cleanup

Cleaned up warnings in code
This commit is contained in:
Logan Lowe 2022-06-23 11:33:30 -06:00 committed by GitHub
commit 2872f8b2f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View file

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

View file

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