From de02319cfa7b4bbff8c111bda02be1a7c6591555 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 5 Jan 2020 20:17:17 -0500 Subject: dlang safe default imminent, look ahead - @safe @trusted & @system, reconsider @trusted --- org/default_paths.org | 132 +++++++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) (limited to 'org/default_paths.org') diff --git a/org/default_paths.org b/org/default_paths.org index 82ea93d..2d03aa6 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -48,7 +48,7 @@ import template PodManifest() { mixin spineRgxInit; static auto rgx = Rgx(); - auto PodManifest(O)( + @safe auto PodManifest(O)( O _opt_actions, string _pth="" ) { @@ -56,7 +56,7 @@ template PodManifest() { string pod_manifest_filename() { return "pod.manifest"; } - string pod_manifest_path() { + @safe string pod_manifest_path() { string _manifest_path; if ((isValidPath(_pth) && exists(_pth) != 0 && _pth.isDir) && (exists(_pth.chainPath(pod_manifest_filename).array) != 0 @@ -78,10 +78,10 @@ template PodManifest() { } return _manifest_path; } - string pods_collection_root_path() { + @safe string pods_collection_root_path() { return (pod_manifest_path.length > 0) ? ((chainPath(pod_manifest_path, "..")).asNormalizedPath).array.to!string : ""; } - string pod_manifest_file_with_path() { + @safe string pod_manifest_file_with_path() { string _k; if (exists(pod_manifest_path.chainPath(pod_manifest_filename).array)!=0) { _k = pod_manifest_path.chainPath(pod_manifest_filename).array; @@ -125,14 +125,14 @@ template PathMatters() { mixin InternalMarkup; static auto rgx = Rgx(); static auto mkup = InlineMarkup(); - auto PathMatters(O,E)( + @safe auto PathMatters(O,E)( O _opt_actions, E _env, string _pth, string _fns = "", char[][] _manifest_fn_list = [[]], ) { - auto _manifested = PodManifest!()(_opt_actions, _pth); + @safe auto _manifested = PodManifest!()(_opt_actions, _pth); struct ManifestMatters_ { auto env() { auto _env = _env; @@ -146,7 +146,7 @@ template PathMatters() { } return Env_(); } - auto opt() { + @safe auto opt() { struct Opt_ { auto action() { return _opt_actions; @@ -154,45 +154,45 @@ template PathMatters() { } return Opt_(); } - bool src_is_pod() { + @safe bool src_is_pod() { return (_manifested.pod_manifest_path.length > 0) ? true : false; } - auto pod() { + @safe auto pod() { struct Pod_ { - bool src_is_pod() { + @safe bool src_is_pod() { return (_manifested.pod_manifest_path.length > 0) ? true : false; } - string collection_root() { + @safe string collection_root() { return _manifested.pods_collection_root_path; } - string manifest_filename() { + @safe string manifest_filename() { return _manifested.pod_manifest_filename; } - string manifest_path() { + @safe string manifest_path() { return _manifested.pod_manifest_path; } - string pod_name_with_path() { + @safe string pod_name_with_path() { return _manifested.pod_manifest_path.baseName; } - string manifest_file_with_path() { + @safe string manifest_file_with_path() { return _manifested.pod_manifest_file_with_path; } - string[] config_dr_document_make_dirs() { + @safe string[] config_dr_document_make_dirs() { string[] _config_dirs; return _config_dirs; } - string[] config_local_site_dirs() { + @safe string[] config_local_site_dirs() { string[] _config_dirs; return _config_dirs; } - string[] image_dirs() { + @safe string[] image_dirs() { string[] _image_dirs; return _image_dirs; } - auto manifest_list_of_filenames() { + @safe auto manifest_list_of_filenames() { return _manifest_fn_list; } - string[] manifest_list_of_languages() { + @safe string[] manifest_list_of_languages() { string[] _lngs; foreach (filename_; manifest_list_of_filenames) { string _k = "en"; @@ -206,43 +206,43 @@ template PathMatters() { } return Pod_(); } - auto src() { + @safe auto src() { string _fns = _fns; // required here by dmd & not by ldc (for D:2078) auto _opt_actions = _opt_actions; auto _env = _env; struct SRC_ { - bool is_pod() { + @safe bool is_pod() { return (_manifested.pod_manifest_path.length > 0) ? true : false; } - string path_and_fn() { + @safe string path_and_fn() { return _fns; } - string pod_name_with_path() { + @safe string pod_name_with_path() { return (is_pod) ? _manifested.pod_manifest_path : ""; } - string pods_collection_root_path() { + @safe string pods_collection_root_path() { return (is_pod) ? _manifested.pods_collection_root_path : ""; } - string pod_name() { + @safe string pod_name() { return pod_name_with_path.baseName; } - string filename() { + @safe string filename() { return path_and_fn.baseName; } - string filename_base() { + @safe string filename_base() { return filename.stripExtension; } - string filename_extension() { + @safe string filename_extension() { return filename.match(rgx.src_pth_sst_or_ssm).captures["extension"]; } - string lng() { + @safe string lng() { string _k; if (auto m = path_and_fn.match(rgx.language_code_and_filename)) { _k = m.captures[1]; } else {_k = "en"; } return _k; } - string doc_uid() { + @safe string doc_uid() { string _uid; if (is_pod && !(pod_name_with_path.empty)) { if (pod_name_with_path.baseName == filename_base) { @@ -255,7 +255,7 @@ template PathMatters() { } return _uid; } - string doc_uid_out() { + @safe string doc_uid_out() { string _uid; if (is_pod && !(pod_name_with_path.empty)) { if (pod_name_with_path.baseName == filename_base) { @@ -268,7 +268,7 @@ template PathMatters() { } return _uid; } - string docname_composite_unique_per_src_doc() { + @safe string docname_composite_unique_per_src_doc() { string _fn; if (pod_name_with_path.baseName == filename_base) { _fn = filename_base ~ mkup.sep ~ filename_extension ~ mkup.sep ~ lng; @@ -279,7 +279,7 @@ template PathMatters() { } return _fn; } - string docname_composite_unique_per_src_pod() { + @safe string docname_composite_unique_per_src_pod() { /+ z pod name if any + src filename (without lng code) filename ~ mkup.sep ~ lng @@ -298,19 +298,19 @@ template PathMatters() { } return _fn; } - string language() { + @safe string language() { return lng(); } - string file_with_absolute_path() { + @safe string file_with_absolute_path() { return _env["pwd"].chainPath(path_and_fn).array; } - string absolute_path_to_src() { + @safe string absolute_path_to_src() { return (_env["pwd"].chainPath(path_and_fn)).dirName.array; } - string path_to_doc_root_path_to_lang_and_filename() { + @safe string path_to_doc_root_path_to_lang_and_filename() { return _env["pwd"].chainPath(path_and_fn).array; } - string base_dir() { + @safe string base_dir() { string _dir; if ( auto m = (absolute_path_to_src) @@ -328,7 +328,7 @@ template PathMatters() { } return _dir; } - string base_parent_dir_path() { + @safe string base_parent_dir_path() { string _dir; if ( auto m = (absolute_path_to_src) @@ -340,7 +340,7 @@ template PathMatters() { } return _dir; } - string base_dir_path() { + @safe string base_dir_path() { string _dir; if ( auto m = (absolute_path_to_src) @@ -360,11 +360,11 @@ template PathMatters() { } return _dir; } - string media_dir_path() { + @safe string media_dir_path() { string _dir = ((base_dir_path.chainPath("media")).asNormalizedPath).array; return _dir; } - string image_dir_path() { + @safe string image_dir_path() { string _paths; string[] _possible_img_pths = [ "./image", "../image", "../../image" ]; string _img_pth_found = ""; @@ -388,10 +388,10 @@ template PathMatters() { } return _img_pth_found; } - auto conf_dir_path() { + @safe auto conf_dir_path() { return ((base_dir_path.chainPath("conf")).asNormalizedPath).array; } - auto base_parent_dir() { + @safe auto base_parent_dir() { string _dir; if ( auto m = (absolute_path_to_src) @@ -406,13 +406,13 @@ template PathMatters() { } return _dir; } - string[] config_dirs() { + @safe string[] config_dirs() { string[] _config_dirs; if (is_pod) { } else {} return _config_dirs; } - string[] image_dirs() { + @safe string[] image_dirs() { string[] _image_dirs; if (is_pod) { } else {} @@ -421,7 +421,7 @@ template PathMatters() { } return SRC_(); } - auto output() { + @safe auto output() { /+ - command line if output path set - config file if found and set set @@ -435,7 +435,7 @@ template PathMatters() { +/ auto _env = _env; struct Out_ { - auto path() { + @safe auto path() { auto _output_path = _env["pwd"]; if ((_opt_actions.output_dir_set.length > 0) && isValidPath(_opt_actions.output_dir_set) @@ -471,21 +471,21 @@ template PathMatters() { template ConfigFilePaths() { mixin spineRgxInit; static auto rgx = Rgx(); - auto ConfigFilePaths(M,E)( + @safe auto ConfigFilePaths(M,E)( M _manifested, E _env, string _cli_config_path_set = "" ) { struct ConfFilePaths { - string config_filename_document() { + @safe string config_filename_document() { return "dr_document_make"; } - string config_filename_site() { + @safe string config_filename_site() { return "config_local_site"; } - auto possible_config_path_locations() { + @safe auto possible_config_path_locations() { struct _ConfFilePaths { - string[] dr_document_make() { + @safe string[] dr_document_make() { /+ FIX clean up conf paths ↓ +/ /+ config local site (file system only, not in pod) +/ /+ return paths +/ @@ -534,7 +534,7 @@ template ConfigFilePaths() { +/ return _possible_config_path_locations; } - string[] config_local_site() { + @safe string[] config_local_site() { /+ FIX clean up conf paths ↓ +/ /+ config local site (file system only, not in pod) +/ string[] _possible_config_path_locations; @@ -645,15 +645,15 @@ filelist for processing [things to ponder] template spinePathsSRC() { mixin spineRgxInit; static auto rgx = Rgx(); - auto spinePathsSRC(D,Fn)( + @safe auto spinePathsSRC(D,Fn)( D _pwd, Fn _fn_src_and_path, ) { struct drSrcPaths { - auto pwd() { + @safe auto pwd() { return _pwd; } - string language() { + @safe string language() { // use command line info as well? string _k; if (auto m = _fn_src_and_path.match(rgx.language_code_and_filename)) { @@ -663,28 +663,28 @@ template spinePathsSRC() { } return _k; } - string doc_root() { + @safe string doc_root() { return "dr_doc"; } - auto media_root() { + @safe auto media_root() { return ((doc_root.chainPath("media")).asNormalizedPath).array; } - auto conf_root() { + @safe auto conf_root() { return ((doc_root.chainPath("conf")).asNormalizedPath).array; } - auto text_root() { + @safe auto text_root() { return ((media_root.chainPath("text")).asNormalizedPath).array; } - auto image_root() { + @safe auto image_root() { return ((media_root.chainPath("image")).asNormalizedPath).array; } - auto doc_src_fn_with_path_for_text_root_and_lng() { + @safe auto doc_src_fn_with_path_for_text_root_and_lng() { return ((text_root.chainPath(language)).asNormalizedPath).array; } - auto doc_src_fn() { + @safe auto doc_src_fn() { return ((_fn_src_and_path.baseName).asNormalizedPath).array; } - auto doc_src_with_path() { + @safe auto doc_src_with_path() { return ((pwd.chainPath(_fn_src_and_path)).asNormalizedPath).array; } } -- cgit v1.2.3