aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/ao_read_config_files.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdp/ao_read_config_files.d')
-rw-r--r--src/sdp/ao_read_config_files.d71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/sdp/ao_read_config_files.d b/src/sdp/ao_read_config_files.d
new file mode 100644
index 0000000..47980da
--- /dev/null
+++ b/src/sdp/ao_read_config_files.d
@@ -0,0 +1,71 @@
+/+
+ ao_config_files.d
+ - read config files
++/
+template SiSUconfiguration() {
+ private import
+ std.exception,
+ // std.regex,
+ std.stdio,
+ std.utf,
+ std.conv : to;
+ // private import
+ // ao_rgx; // ao_defaults.d
+ // mixin RgxInit;
+ // auto rgx = Rgx();
+ private
+ struct Config {
+ private import std.file;
+ final private string readInConfigFile() {
+ // enforce(
+ // exists(fn_src)!=0,
+ // "file not found"
+ // );
+ string[] possible_config_path_locations = [
+ environment["PWD"] ~ "/.sisu",
+ environment["PWD"] ~ "/_sisu",
+ environment["HOME"] ~ "/.sisu",
+ "/etc/sisu"
+ ];
+ string conf_sdl = "conf.sdl";
+ string config_file_str;
+ foreach(pth; possible_config_path_locations) {
+ auto conf_file = format(
+ "%s/%s",
+ pth,
+ conf_sdl,
+ );
+ // writeln(conf_file);
+ try {
+ if (exists(conf_file)) {
+ writeln(conf_file);
+ config_file_str = readText(conf_file);
+ break;
+ }
+ }
+ catch (ErrnoException ex) {
+ //// Handle errors
+ // switch(ex.errno) {
+ // case EPERM:
+ // case EACCES:
+ // // Permission denied
+ // break;
+ // case ENOENT:
+ // // File does not exist
+ // break;
+ // default:
+ // // Handle other errors
+ // break;
+ // }
+ }
+ // catch (UTFException ex) {
+ // // Handle validation errors
+ // }
+ catch (FileException ex) {
+ // Handle errors
+ }
+ }
+ return config_file_str;
+ }
+ }
+}