From 8ab7e935913c102fb039110e20b71f698a68c6ee Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 16 Jun 2016 01:49:06 -0400 Subject: step5 sdlang used for config files and doc headers --- src/sdp/ao_read_config_files.d | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/sdp/ao_read_config_files.d (limited to 'src/sdp/ao_read_config_files.d') 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; + } + } +} -- cgit v1.2.3