Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
Documentation for:
- ZipSettings
- ZipArchiveExtensions
- Utils (One function is missing)
- Uninstaller
  • Loading branch information
daredloco committed Dec 4, 2020
1 parent 39df816 commit 99f2454
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
5 changes: 5 additions & 0 deletions GitInstaller/GitInstaller/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ await Task.Run(() => {
_window.bt_install.IsEnabled = true;
}

/// <summary>
/// Checks if there already exists an installation inside the directory or if its a fresh installation
/// </summary>
/// <param name="directory">The installation directory</param>
/// <returns>True if a gituninstaller.cfg was found, else returns false</returns>
internal bool IsUpdate(string directory)
{
string fpath = Path.Combine(directory, "gituninstaller.cfg");
Expand Down
8 changes: 8 additions & 0 deletions GitInstaller/GitInstaller/Uninstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public Uninstaller(string loca, string[] fs, string[] dirs)
directories.AddRange(dirs);
}

/// <summary>
/// Generates a gituninstaller.cfg file inside the installation directory
/// </summary>
public void GenerateFile()
{
string fname = Path.Combine(location, "gituninstaller.cfg");
Expand All @@ -46,6 +49,11 @@ public void GenerateFile()
File.WriteAllLines(fname, flines.ToArray());
}

/// <summary>
/// Uninstall the installation at the location. Won't work if it can't find a gituninstaller.cfg file!
/// </summary>
/// <param name="flocation">The location of the installation</param>
/// <returns>True if uninstall was a success, else returns false</returns>
public static bool DoUninstall(string flocation)
{
MainWindow.Instance.prog_loading.IsIndeterminate = true;
Expand Down
12 changes: 12 additions & 0 deletions GitInstaller/GitInstaller/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public enum ZipType
None
}

/// <summary>
/// Checks if the ZipType of the path is ZipType.File or ZipType.Directory
/// </summary>
/// <param name="path">The path of the file/directory</param>
/// <returns>A ZipType object (either ZipType.Directory or ZipType.File)</returns>
public static ZipType FileOrDir(string path)
{
if (path.EndsWith("/"))
Expand All @@ -24,6 +29,13 @@ public static ZipType FileOrDir(string path)
return ZipType.File;
}

/// <summary>
/// ???
/// </summary>
/// <param name="value"></param>
/// <param name="wildcard"></param>
/// <param name="wildcardchar"></param>
/// <returns></returns>
public static bool HasWildcard(string value, string wildcard, string wildcardchar = "*")
{

Expand Down
14 changes: 13 additions & 1 deletion GitInstaller/GitInstaller/ZipArchiveExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@

namespace GitInstaller
{
// From https://stackoverflow.com/questions/14795197/forcefully-replacing-existing-files-during-extracting-file-using-system-io-compr/30425148
public static class ZipArchiveExtensions
{
// From https://stackoverflow.com/questions/14795197/forcefully-replacing-existing-files-during-extracting-file-using-system-io-compr/30425148
/// <summary>
/// Extracts a ZipArchive to a destination (with overwrite functionality)
/// </summary>
/// <param name="archive">The archive to unpack</param>
/// <param name="destinationDirectoryName">The destination directory</param>
/// <param name="overwrite">If true, it will overwrite the content inside the destination directory</param>
public static void ExtractToDirectory(this ZipArchive archive, string destinationDirectoryName, bool overwrite)
{
Uninstaller uninstaller = new Uninstaller(destinationDirectoryName);
Expand Down Expand Up @@ -38,6 +44,12 @@ public static void ExtractToDirectory(this ZipArchive archive, string destinatio
}

//Added by daRedLoCo
/// <summary>
/// Extracts a ZipArchive to a destination (with overwrite functionality and ZipSettings inside the archive)
/// </summary>
/// <param name="archive">The archive to unpack</param>
/// <param name="destinationDirectoryName">The destination directory</param>
/// <param name="overwrite">If true, it will overwrite the content inside the destination directory</param>
public static void ExtractWithSettings(this ZipArchive archive, string destinationDirectoryName, bool overwrite)
{
ZipSettings settings = null;
Expand Down
15 changes: 15 additions & 0 deletions GitInstaller/GitInstaller/ZipSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public class ZipSettings

public ZipSettings() { }

/// <summary>
/// Gets the subfolder of a file
/// </summary>
/// <param name="fname">The file to fetch the subfolder for</param>
/// <returns>The subfolder for the file</returns>
public string GetSubfolder(string fname)
{
SubFolder sf = null;
Expand All @@ -25,6 +30,11 @@ public string GetSubfolder(string fname)
return sf.Name;
}

/// <summary>
/// Returns the ZipSettings from a File
/// </summary>
/// <param name="fname">The file containing the ZipSettings</param>
/// <returns>A ZipSettings object</returns>
public static ZipSettings FromFile(string fname)
{
if (File.Exists(fname))
Expand All @@ -35,6 +45,11 @@ public static ZipSettings FromFile(string fname)
return null;
}

/// <summary>
/// Returns the ZipSettings from a Stream
/// </summary>
/// <param name="stream">The stream with the ZipSettings</param>
/// <returns>A ZipSettings object</returns>
public static ZipSettings FromStream(Stream stream)
{
using (StreamReader reader = new StreamReader(stream))
Expand Down

0 comments on commit 99f2454

Please sign in to comment.