Fix copying bug

This commit is contained in:
Pdawg11239
2025-03-29 20:53:04 -04:00
parent ac42c67478
commit e27b272aa6
4 changed files with 19 additions and 12 deletions

View File

@@ -10,4 +10,3 @@ GUID
DISK_GEOMETRY
PARTITION_INFORMATION
PARTITION_INFORMATION_EX
SET_PARTITION_INFORMATION

View File

@@ -47,11 +47,11 @@ namespace BadBuilder
itemsToDownload.Sort((a, b) => b.name.Length.CompareTo(a.name.Length));
if (!Directory.Exists($"{DOWNLOAD_DIR}"))
Directory.CreateDirectory($"{DOWNLOAD_DIR}");
if (itemsToDownload.Any())
{
if (!Directory.Exists($"{DOWNLOAD_DIR}"))
Directory.CreateDirectory($"{DOWNLOAD_DIR}");
HttpClient downloadClient = new();
await AnsiConsole.Progress()
@@ -90,7 +90,7 @@ namespace BadBuilder
if (File.Exists(destinationPath)) continue;
string existingPath = AnsiConsole.Prompt(
new TextPrompt<string>($"Enter the path for the [bold]{selectedItem}[/] archive:")
new TextPrompt<string>($"Enter the path to the [bold]{selectedItem}[/] archive:")
.PromptStyle(LightOrangeStyle)
.Validate(path =>
{
@@ -100,10 +100,18 @@ namespace BadBuilder
})
).Trim().Trim('"');
File.Copy(existingPath, destinationPath, overwrite: true);
AnsiConsole.MarkupLine($"[italic #76B900]Successfully copied [bold]{selectedItem}[/] to the working directory.[/]\n");
}
Console.WriteLine(existingPath);
try
{
File.Copy(existingPath, destinationPath, overwrite: true);
AnsiConsole.MarkupLine($"[italic #76B900]Successfully copied [bold]{selectedItem}[/] to the working directory.[/]\n");
}
catch (Exception ex)
{
AnsiConsole.MarkupLine($"[italic red]Failed to copy [bold]{selectedItem}[/] to the working directory. Exception: {ex.Message}[/]\n");
}
}
return items.Select(item => new ArchiveItem(item.name, Path.Combine(DOWNLOAD_DIR, item.url.Split('/').Last()))).ToList();
}

View File

@@ -173,7 +173,7 @@ namespace BadBuilder
[#CCE388] [/]
[#CCE388] [/]
[#76B900]v0.10a[/]
[#76B900]v0.20a[/]
Xbox 360 [#FF7200]BadUpdate[/] USB Builder
[#848589]Created by Pdawg[/]
[#76B900][/]

View File

@@ -3,8 +3,8 @@
internal static class Constants
{
internal const string WORKING_DIR = "Work";
internal const string DOWNLOAD_DIR = $@"{WORKING_DIR}\\Download";
internal const string EXTRACTED_DIR = $@"{WORKING_DIR}\\Extract";
internal const string DOWNLOAD_DIR = $@"{WORKING_DIR}\Download";
internal const string EXTRACTED_DIR = $@"{WORKING_DIR}\Extract";
internal const string ContentFolder = "Content\\0000000000000000\\";
}