1
0
Fork 0

Final tweaks

This commit is contained in:
JoshuaMKW 2020-08-26 17:58:41 -05:00
parent f9fbba629d
commit a01931b5f8
2 changed files with 29 additions and 24 deletions

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Xml.Serialization; using System.Xml.Serialization;
@ -25,27 +26,22 @@ public class Installer
overwrite = true; overwrite = true;
} }
void CopyAll (DirectoryInfo source, DirectoryInfo destination, string wildcard, string[] exclude, int maxdepth = 16) void CopyAll (DirectoryInfo source, DirectoryInfo destination, string wildcard, string[] exclude, int maxdepth = 4)
{ {
Console.WriteLine("{0}, {1}", source.FullName, destination.FullName);
if (maxdepth <= 0) return; if (maxdepth <= 0) return;
DirectoryInfo[] subdirs = source.GetDirectories(); DirectoryInfo[] subdirs = source.GetDirectories();
foreach (DirectoryInfo dirPath in source.EnumerateDirectories()) foreach (DirectoryInfo dirPath in source.EnumerateDirectories())
{
Directory.CreateDirectory(dirPath.FullName.Replace(source.FullName, destination.FullName)); Directory.CreateDirectory(dirPath.FullName.Replace(source.FullName, destination.FullName));
}
foreach (FileInfo filePath in source.EnumerateFiles(wildcard)) foreach (FileInfo filePath in source.EnumerateFiles(wildcard))
{ {
bool include = true; File.Copy(filePath.FullName, filePath.FullName.Replace(source.FullName, destination.FullName), true);
foreach (string exc in exclude)
{
if (exc.ToLower().Contains(filePath.Name.ToLower()))
{
include = false;
break;
}
}
if (include) File.Copy(filePath.FullName, filePath.FullName.Replace(source.FullName, destination.FullName), true);
} }
foreach (DirectoryInfo dir in subdirs) foreach (DirectoryInfo dir in subdirs)
@ -90,31 +86,38 @@ public class Installer
private void SetProgramFolder(string folderName) private void SetProgramFolder(string folderName)
{ {
this.programfolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "GeckoLoader", "data"); this.programfolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "GeckoLoader");
} }
private void SetProgramFolderToPath() private void SetFolderToPath(string dir, string subdir)
{ {
var scope = EnvironmentVariableTarget.User; var scope = EnvironmentVariableTarget.User;
var curPATH = Environment.GetEnvironmentVariable("PATH", scope); var curPATH = Environment.GetEnvironmentVariable("PATH", scope);
if (!curPATH.Contains(this.programfolder)) if (!curPATH.Contains(Path.Combine(dir, subdir)))
{ {
var newValue = curPATH + ";" + this.programfolder; var newValue = curPATH + ";" + Path.Combine(dir, subdir);
Environment.SetEnvironmentVariable("PATH", newValue, scope); Environment.SetEnvironmentVariable("PATH", newValue.Replace(";;", ";"), scope);
} }
} }
private void RemoveProgramFolderFromPath() private void RemoveFolderGroupFromPath(string dir)
{ {
var scope = EnvironmentVariableTarget.User; var scope = EnvironmentVariableTarget.User;
var curPATH = Environment.GetEnvironmentVariable("PATH", scope); var curPATH = Environment.GetEnvironmentVariable("PATH", scope);
if (curPATH.Contains(this.programfolder)) string[] oldPATHList = curPATH.Split(';');
List<string> newPATHList = new List<string>();
foreach(string path in oldPATHList)
{ {
var newValue = curPATH.Replace(";" + this.programfolder, ""); if (!path.ToLower().Contains(dir.ToLower()))
Environment.SetEnvironmentVariable("PATH", newValue, scope); {
newPATHList.Add(path);
}
} }
Environment.SetEnvironmentVariable("PATH", String.Join(";", newPATHList.ToArray()), scope);
} }
private bool MoveFilesToprogramfolder(string wildcard, bool copy = true, bool overwrite = false) private bool MoveFilesToprogramfolder(string wildcard, bool copy = true, bool overwrite = false)
@ -172,10 +175,11 @@ public class Installer
status = HandleConsoleQuestion("What do you want to do?", actionoptions); status = HandleConsoleQuestion("What do you want to do?", actionoptions);
if (status.ToLower() == (string)actionoptions.GetValue(0)) if (status.ToLower() == (string)actionoptions.GetValue(0))
{ {
this.SetProgramFolderToPath(); this.RemoveFolderGroupFromPath(this.programfolder);
this.SetFolderToPath(this.programfolder, "");
if (this.MoveFilesToprogramfolder("*", this.copyfiles, this.overwrite) == false) if (this.MoveFilesToprogramfolder("*", this.copyfiles, this.overwrite) == false)
{ {
Console.WriteLine("Failed to install :( Is Geckoloader and its dependancies in the same directory?"); Console.WriteLine("Failed to install :(");
} }
else else
{ {
@ -184,7 +188,7 @@ public class Installer
} }
else else
{ {
this.RemoveProgramFolderFromPath(); this.RemoveFolderGroupFromPath(this.programfolder);
this.DeleteProgramFolder(); this.DeleteProgramFolder();
Console.WriteLine("Uninstalled successfully!"); Console.WriteLine("Uninstalled successfully!");
} }

View file

@ -3,6 +3,7 @@ from cx_Freeze import setup, Executable
options = { options = {
'build_exe': { 'build_exe': {
'optimize': 2,
'excludes': ['tkinter'] 'excludes': ['tkinter']
} }
} }
@ -12,7 +13,7 @@ executables = [
] ]
setup(name='GeckoLoader', setup(name='GeckoLoader',
version='v6.0.0', version='v6.0.1',
description='DOL Patcher for extending the codespace of Wii/GC games', description='DOL Patcher for extending the codespace of Wii/GC games',
executables=executables, executables=executables,
options=options options=options