Skip to content

Commit

Permalink
Merge pull request #4 from daredloco/documentation-update
Browse files Browse the repository at this point in the history
Documentation update
  • Loading branch information
daredloco authored Dec 4, 2020
2 parents 6ce39ef + 3486d3e commit 7812cb1
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 4 deletions.
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
4 changes: 2 additions & 2 deletions GitInstaller/GitInstaller/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.1.0")]
[assembly: AssemblyFileVersion("1.7.1.0")]
[assembly: AssemblyVersion("1.7.2.0")]
[assembly: AssemblyFileVersion("1.7.2.0")]
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>
/// Checks if value has wildcard in it
/// </summary>
/// <param name="value">The value to check if the wildcard is inside</param>
/// <param name="wildcard">The wildcard search value</param>
/// <param name="wildcardchar">The character representing the wildcard</param>
/// <returns>True if wildcard is inside value or false otherwise</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
17 changes: 16 additions & 1 deletion GitInstaller/GitInstaller/ZipSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ public class ZipSettings

public ZipSettings() { }

public string GetSubfolder(string fname, string sub = "")
/// <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;
string ffolder = fname.Replace(fname.Split('/')[fname.Split('/').Length - 1], "").Replace(fname.Split('\\')[fname.Split('\\').Length - 1],"");
Expand All @@ -25,6 +30,11 @@ public string GetSubfolder(string fname, string sub = "")
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 7812cb1

Please sign in to comment.