Made a static member of the Configuration class rather

This commit is contained in:
Tristan B. Velloza Kildaire 2021-12-25 12:29:16 +02:00
parent 58265272be
commit 203762c454
1 changed files with 37 additions and 37 deletions

View File

@ -33,7 +33,43 @@ public final class Configuration
return config;
}
/**
* Reads in the JSON from the given path to the configuration
* file
*
* On error throws TODO
*/
private static JSONValue readConfig(string path)
{
File file;
file.open(path); /* TODO:Check this for errors */
/* TODO: Only open with read rights */
/* Allocate a buffer for the file */
byte[] contents;
contents.length = file.size(); /* TODO: Check size here */
/* TODO: Check this */
/* TODO: Technically the below is fine */
file.rawRead(contents);
JSONValue config;
try
{
config = parseJSON(cast(string)contents);
}
catch(JSONException e)
{
/* TODO: Get specific error here to show where config syntax is wrong */
throw new ConfigurationError(e);
}
return config;
}
/**
* Load the configuration from a JSON source, returning the
@ -185,40 +221,4 @@ struct NetworkInformation
}
/**
* Reads in the JSON from the given path to the configuration
* file
*
* On error throws TODO
*/
private JSONValue readConfig(string path)
{
File file;
file.open(path); /* TODO:Check this for errors */
/* TODO: Only open with read rights */
/* Allocate a buffer for the file */
byte[] contents;
contents.length = file.size(); /* TODO: Check size here */
/* TODO: Check this */
/* TODO: Technically the below is fine */
file.rawRead(contents);
JSONValue config;
try
{
config = parseJSON(cast(string)contents);
}
catch(JSONException e)
{
/* TODO: Get specific error here to show where config syntax is wrong */
throw new ConfigurationError(e);
}
return config;
}