assertreadonly the whole directory

This commit is contained in:
bluepilledgreat 2025-03-11 10:22:28 +00:00
parent 779ee43207
commit 597682f4bd
2 changed files with 12 additions and 0 deletions

View File

@ -693,6 +693,8 @@ namespace Bloxstrap
if (dirName != App.State.Prop.Player.VersionGuid && dirName != App.State.Prop.Studio.VersionGuid)
{
Filesystem.AssertReadOnlyDirectory(dir);
// check if it's still being used first
// we dont want to accidentally delete the files of a running roblox instance
if (!TryDeleteRobloxInDirectory(dir))

View File

@ -31,5 +31,15 @@ namespace Bloxstrap.Utility
fileInfo.IsReadOnly = false;
App.Logger.WriteLine("Filesystem::AssertReadOnly", $"The following file was set as read-only: {filePath}");
}
internal static void AssertReadOnlyDirectory(string directoryPath)
{
var directory = new DirectoryInfo(directoryPath) { Attributes = FileAttributes.Normal };
foreach (var info in directory.GetFileSystemInfos("*", SearchOption.AllDirectories))
info.Attributes = FileAttributes.Normal;
App.Logger.WriteLine("Filesystem::AssertReadOnlyDirectory", $"The following directory was set as read-only: {directoryPath}");
}
}
}