aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/ao_read_config_files.d
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2016-06-16 01:49:06 -0400
committerRalph Amissah <ralph@amissah.com>2019-04-04 14:48:18 -0400
commit8ab7e935913c102fb039110e20b71f698a68c6ee (patch)
tree3472debd16ce656a57150399ce666e248565f011 /src/sdp/ao_read_config_files.d
parentstep4.1 as step4 but extract header meta & make on first reading in document (diff)
step5 sdlang used for config files and doc headers
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;
+ }
+ }
+}