Skip to content

Commit

Permalink
Minor Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Sep 28, 2023
1 parent 025307b commit 1c3fb2a
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 2 deletions.
50 changes: 49 additions & 1 deletion src/Bundle/Sucrose.Bundle/Main.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public partial class Main : Window

private static string Launcher => Path.Combine(InstallPath, Department, Executable);

private static string TemporaryFile => "Sucrose.Backgroundog.sys";

private static string TemporaryFolder => "Sucrose.Backgroundog";

private static string QuietUninstall => $"\"{Uninstall}\" -s";

private static string Executable => "Sucrose.Launcher.exe";
Expand Down Expand Up @@ -114,6 +118,50 @@ private static async Task ControlDirectory(string Path)
Directory.CreateDirectory(Path);
}

private static async Task ControlDirectoryStable(string Path)
{
if (Directory.Exists(Path))
{
string[] Files = Directory.GetFiles(Path, "*", SearchOption.AllDirectories);

foreach (string Record in Files)
{
if (Record == TemporaryFile)
{
try
{
File.Delete(Record);
}
catch { }
}
else
{
File.Delete(Record);
}
}

string[] Folders = Directory.GetDirectories(Path);

foreach (string Record in Folders)
{
if (Record == TemporaryFolder)
{
try
{
Directory.Delete(Record);
}
catch { }
}
else
{
Directory.Delete(Record, true);
}
}
}

await Task.CompletedTask;
}

private static async Task ExtractResources(string SourcePath, string ExtractPath)
{
Assembly Entry = SHA.Assemble(SEAT.Entry);
Expand Down Expand Up @@ -201,7 +249,7 @@ private async void Window_ContentRendered(object sender, EventArgs e)
await Task.Delay(MaxDelay);

await ControlDirectory(PackagePath);
await ControlDirectory(InstallPath);
await ControlDirectoryStable(InstallPath);

await Task.Delay(MaxDelay);

Expand Down
46 changes: 45 additions & 1 deletion src/Project/Sucrose.Undo/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public partial class App : Application

private static string RegistryName => @"Software\Microsoft\Windows\CurrentVersion\Uninstall";

private static string TemporaryFile => "Sucrose.Backgroundog.sys";

private static string TemporaryFolder => "Sucrose.Backgroundog";

private static string Text => "Sucrose Wallpaper Engine";

private static string Shortcut => $"{Text}.lnk";
Expand All @@ -37,7 +41,47 @@ private static void DeleteDirectory(string Path)
{
if (Directory.Exists(Path))
{
Directory.Delete(Path, recursive: true);
string[] Files = Directory.GetFiles(Path, "*", SearchOption.AllDirectories);

foreach (string Record in Files)
{
if (Record == TemporaryFile)
{
try
{
File.Delete(Record);
}
catch { }
}
else
{
File.Delete(Record);
}
}

string[] Folders = Directory.GetDirectories(Path);

foreach (string Record in Folders)
{
if (Record == TemporaryFolder)
{
try
{
Directory.Delete(Record);
}
catch { }
}
else
{
Directory.Delete(Record, true);
}
}

try
{
Directory.Delete(Path, true);
}
catch { }
}
}

Expand Down

0 comments on commit 1c3fb2a

Please sign in to comment.