-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from daredloco/feature-subfolders
Feature subfolders
- Loading branch information
Showing
11 changed files
with
211 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace GitInstaller | ||
{ | ||
public class Uninstaller | ||
{ | ||
public string location; | ||
public List<string> files = new List<string>(); | ||
public List<string> directories = new List<string>(); | ||
|
||
public Uninstaller(string loca) | ||
{ | ||
location = loca; | ||
} | ||
|
||
public Uninstaller(string loca, string[] fs, string[] dirs) | ||
{ | ||
location = loca; | ||
files.AddRange(fs); | ||
directories.AddRange(dirs); | ||
} | ||
|
||
public void GenerateFile() | ||
{ | ||
string fname = Path.Combine(location, "gituninstaller.cfg"); | ||
List<string> flines = new List<string>() { $"###{Settings.Project} Uninstaller###" }; | ||
|
||
flines.Add("This is a file generated by GitInstaller, "); | ||
flines.Add("to use it either install a newer version of the software installed with it"); | ||
flines.Add("or open the GitInstaller for this application, select this folder and press \"Uninstall\""); | ||
|
||
flines.Add("###FILES###"); | ||
foreach (string f in files) | ||
{ | ||
flines.Add(f); | ||
} | ||
|
||
flines.Add("###DIRECTORIES###"); | ||
foreach (string d in directories) | ||
{ | ||
flines.Add(d); | ||
} | ||
|
||
File.WriteAllLines(fname, flines.ToArray()); | ||
} | ||
|
||
public static bool DoUninstall(string flocation) | ||
{ | ||
MainWindow.Instance.prog_loading.IsIndeterminate = true; | ||
flocation = Path.Combine(flocation, "gituninstaller.cfg"); | ||
if (!File.Exists(flocation)) | ||
{ | ||
MainWindow.Instance.WriteLog("Couldn't find gituninstaller.cfg, did you choose the right path?"); | ||
return false; | ||
} | ||
|
||
bool infiles = false; | ||
bool indirs = false; | ||
bool wassuccess = true; | ||
foreach(string fline in File.ReadAllLines(flocation)) | ||
{ | ||
if(fline != "") | ||
{ | ||
if (infiles && fline != "###FILES###" && fline != "###DIRECTORIES###") | ||
{ | ||
try | ||
{ | ||
if (!File.Exists(fline)) | ||
throw new Exception("File \"" + fline + "\" does not exist"); | ||
File.Delete(fline); | ||
MainWindow.Instance.WriteLog("File \"" + fline + "\" deleted!"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
MainWindow.Instance.WriteLog("Couldn't delete file \"" + fline + "\" => " + ex.Message); | ||
wassuccess = false; | ||
} | ||
} | ||
else if (indirs && fline != "###FILES###" && fline != "###DIRECTORIES###") | ||
{ | ||
try | ||
{ | ||
if (!Directory.Exists(fline)) | ||
throw new Exception("Directory \"" + fline + "\" does not exist"); | ||
Directory.Delete(fline, true); | ||
MainWindow.Instance.WriteLog("Directory \"" + fline + "\" deleted!"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
MainWindow.Instance.WriteLog("Couldn't delete directory \"" + fline + "\" => " + ex.Message); | ||
wassuccess = false; | ||
} | ||
} | ||
else if (fline == "###FILES###") | ||
{ | ||
infiles = true; | ||
indirs = false; | ||
} | ||
else if (fline == "###DIRECTORIES###") | ||
{ | ||
infiles = false; | ||
indirs = true; | ||
} | ||
} | ||
} | ||
File.Delete(flocation); | ||
MainWindow.Instance.prog_loading.IsIndeterminate = false; | ||
return wassuccess; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.