Optimizer settings gardening

This commit is contained in:
2021-01-06 19:30:33 +01:00
parent 05117f6836
commit 1fcb640029
5 changed files with 25 additions and 15 deletions
+7 -11
View File
@@ -8,36 +8,32 @@ class optimizer_settings
public function __construct(string $path)
{
$this->path = $path;
if (file_exists($path))
{
$this->load();
}
}
public function load()
public function load() : void
{
$raw = file_get_contents($this->path);
$json = json_decode($raw, true);
$json = utils::load_json($this->path);
$this->osu_path = $json["osu_path"] ?? "";
}
public function save()
public function save() : void
{
$json = array();
$json["osu_path"] = $this->osu_path;
$json = [ "osu_path" => $this->osu_path ];
$raw = json_encode($json);
file_put_contents($this->path, $raw);
file_put_contents($this->path, json_encode($json));
}
public function set_osu_path($path) : void
{
$sanitized = str_replace("\\", "/", $path);
$sanitized = rtrim($sanitized, "/");
if (file_exists($path))
{
$this->osu_path = $sanitized;
$this->osu_path = utils::to_unix_slashes_without_trail($path);
}
}