From 618c41628548dbf8991718972f5688aa57aa27d3 Mon Sep 17 00:00:00 2001 From: Miepee Date: Sun, 11 Sep 2022 15:34:43 +0200 Subject: [PATCH] Add a bit of documentation --- AM2RPortHelperLib/HelperMethods.cs | 22 ++++++++++++++++++++++ AM2RPortHelperLib/PortHelper.cs | 14 ++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/AM2RPortHelperLib/HelperMethods.cs b/AM2RPortHelperLib/HelperMethods.cs index c82f422..c5b971f 100644 --- a/AM2RPortHelperLib/HelperMethods.cs +++ b/AM2RPortHelperLib/HelperMethods.cs @@ -6,6 +6,10 @@ namespace AM2RPortHelperLib; public static partial class PortHelper { + /// + /// Recursively lowercases all files and folders from a specified directory. + /// + /// The path to the directory whose contents should be lowercased. private static void LowercaseFolder(string directory) { DirectoryInfo dir = new DirectoryInfo(directory); @@ -19,6 +23,7 @@ public static partial class PortHelper foreach(var subDir in dir.GetDirectories()) { if (subDir.Name == subDir.Name.ToLower()) continue; + // ReSharper disable once PossibleNullReferenceException - since this is a subdirectory, it always has a parent subDir.MoveTo(subDir.Parent.FullName + "/" + subDir.Name.ToLower()); LowercaseFolder(subDir.FullName); } @@ -56,6 +61,18 @@ public static partial class PortHelper } } + /// + /// Resizes an , resizes it via Nearest Neighbor to a specified dimension, and then saves it to a specified path. + /// + /// The image to resize and save. + /// The dimensions should be resized to. + /// The filepath where the resized image should be saved to. + /// + /// + /// Image icon = Image.Load("icon.png"); + /// SaveAndroidIcon(icon, 128, "128.png"); + /// + /// private static void SaveAndroidIcon(Image icon, int dimensions, string filePath) { Image picture = icon; @@ -63,6 +80,11 @@ public static partial class PortHelper picture.SaveAsPng(filePath); } + /// + /// Calculates the SHA256 hash of a specified file. + /// + /// The full filepath to a file whose SHA256 hash should be calculated. + /// The SHA256 hash of . private static string CalculateSHA256(string filename) { // Check if file exists first diff --git a/AM2RPortHelperLib/PortHelper.cs b/AM2RPortHelperLib/PortHelper.cs index fcaad1b..187b20e 100644 --- a/AM2RPortHelperLib/PortHelper.cs +++ b/AM2RPortHelperLib/PortHelper.cs @@ -7,6 +7,9 @@ namespace AM2RPortHelperLib; public static partial class PortHelper { + /// + /// The current version of . + /// public const string Version = "1.3"; public delegate void OutputHandlerDelegate(string output); @@ -20,8 +23,19 @@ public static partial class PortHelper Console.WriteLine(output); } + /// + /// A temporary directory + /// private static readonly string tmp = Path.GetTempPath(); + + /// + /// The current directory of the AM2RPortHelper program. + /// private static readonly string currentDir = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); + + /// + /// The "utils" folder that's shipped with the AM2RPortHelper. + /// private static readonly string utilDir = currentDir + "/utils"; public static void PortLauncherMod(string inputLauncherZipPath, string targetOS, bool includeAndroid, string outputLauncherZipPath, OutputHandlerDelegate outputDelegate = null)