From 84233ea2543c7b409c324d180913b75b8907643d Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Fri, 13 Jan 2023 22:54:35 +0000 Subject: [PATCH] Add check for free disk space --- Bloxstrap/Bootstrapper.cs | 8 ++++++++ Bloxstrap/Helpers/Utilities.cs | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index fddaf84..02c7937 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -461,6 +461,14 @@ namespace Bloxstrap else Dialog.Message = "Upgrading Roblox..."; + // check if we have at least 300 megabytes of free disk space + if (Utilities.GetFreeDiskSpace(Directories.Base) < 1024*1024*300) + { + Program.ShowMessageBox($"{Program.ProjectName} requires at least 300 MB of disk space to install Roblox. Please free up some disk space and try again.", MessageBoxIcon.Error); + Program.Exit(ERROR_INSTALL_FAILURE); + return; + } + Directory.CreateDirectory(Directories.Base); Dialog.CancelEnabled = true; diff --git a/Bloxstrap/Helpers/Utilities.cs b/Bloxstrap/Helpers/Utilities.cs index 11530c4..75b4488 100644 --- a/Bloxstrap/Helpers/Utilities.cs +++ b/Bloxstrap/Helpers/Utilities.cs @@ -7,6 +7,17 @@ namespace Bloxstrap.Helpers { public class Utilities { + public static long GetFreeDiskSpace(string path) + { + foreach (DriveInfo drive in DriveInfo.GetDrives()) + { + if (path.StartsWith(drive.Name)) + return drive.AvailableFreeSpace; + } + + return -1; + } + public static void OpenWebsite(string website) { Process.Start(new ProcessStartInfo { FileName = website, UseShellExecute = true });