mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-04 22:07:40 +00:00
Allow to lock steam controller locking files
- This locks `controller_neptune` configs when adding steam detection - This overwrites default desktop/chord template - This enables a desktop template
This commit is contained in:
parent
cc085bfc2a
commit
19e7ed7012
14 changed files with 279 additions and 23 deletions
|
|
@ -262,6 +262,83 @@ namespace SteamController.Helpers
|
|||
}
|
||||
}
|
||||
|
||||
public static bool? IsConfigFileOverwritten(String path, byte[] content)
|
||||
{
|
||||
try
|
||||
{
|
||||
var configPath = GetConfigPath(path);
|
||||
if (configPath is null)
|
||||
return null;
|
||||
|
||||
byte[] diskContent = File.ReadAllBytes(configPath);
|
||||
return content.SequenceEqual(diskContent);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool? ResetConfigFile(String path)
|
||||
{
|
||||
try
|
||||
{
|
||||
var configPath = GetConfigPath(path);
|
||||
if (configPath is null)
|
||||
return null;
|
||||
|
||||
File.Copy(configPath + ".orig", configPath, true);
|
||||
return true;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (System.Security.SecurityException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool? OverwriteConfigFile(String path, byte[] content, bool backup)
|
||||
{
|
||||
try
|
||||
{
|
||||
var configPath = GetConfigPath(path);
|
||||
if (configPath is null)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
byte[] diskContent = File.ReadAllBytes(configPath);
|
||||
if (content.Equals(diskContent))
|
||||
return false;
|
||||
}
|
||||
catch (IOException) { }
|
||||
|
||||
if (backup)
|
||||
File.Copy(configPath, configPath + ".orig", true);
|
||||
File.WriteAllBytes(configPath, content);
|
||||
return true;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (System.Security.SecurityException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static T? GetValue<T>(string key, string value) where T : struct
|
||||
{
|
||||
try
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue