Skip to content

Commit

Permalink
Fix settings folder permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Jun 29, 2024
1 parent 6f5e009 commit 19df9bf
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion platforms/windows/lib/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Text.Json;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Text.Json;

namespace lib;

Expand Down Expand Up @@ -39,6 +41,16 @@ public void CheckIfSettingsExists() {
Directory.CreateDirectory(Path.Join(prorgamData, "Cores"));
}

// set folder permissions
var folderInfo = new DirectoryInfo(Path.Join(prorgamData, "Cores"));
var folderSecurity = folderInfo.GetAccessControl();
folderSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null),
FileSystemRights.FullControl,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow));
folderInfo.SetAccessControl(folderSecurity);

// check if settings.json exists
if (!File.Exists(Path.Join(prorgamData, "Cores", "settings.json"))) {
// create settings.json
Expand Down

0 comments on commit 19df9bf

Please sign in to comment.