diff options
| author | Ralph Amissah <ralph@amissah.com> | 2017-09-29 19:29:11 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 | 
| commit | 0f37cbf6a34eb57aa1b5ca09d1cbe3f607997b88 (patch) | |
| tree | 569baa56ccd6278b460b026a8ccb4a4f7bba5886 | |
| parent | 0.19.0 conf make meta, composite struct, instead of associative array (diff) | |
sisupod.zip related fixes
| -rw-r--r-- | org/default_paths.org | 14 | ||||
| -rw-r--r-- | org/output_sisupod.org | 24 | ||||
| -rw-r--r-- | src/sdp/output/paths_output.d | 14 | ||||
| -rw-r--r-- | src/sdp/output/source_sisupod.d | 24 | 
4 files changed, 52 insertions, 24 deletions
| diff --git a/org/default_paths.org b/org/default_paths.org index 7dfef88..a6d9023 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -133,18 +133,21 @@ doc  template SiSUpathsSisupod() {    mixin SiSUrgxInit;    static auto rgx = Rgx(); -  string base_dir = "sisupod"; -  string suffix = ".zip"; +  string _base_dir = "sisupod"; +  string _suffix = ".zip";    auto SiSUpathsSisupod()() {      struct _PathsStruct {        string base_filename(string fn_src) {          return fn_src.baseName.stripExtension;        } +      string sisupod_dir() { +        return _base_dir; +      }        string sisupod_filename(string fn_src) { -        return base_dir.chainPath(base_filename(fn_src) ~ suffix).array; +        return _base_dir.chainPath(base_filename(fn_src) ~ _suffix).array;        }        string base(string fn_src) { -        return base_dir.chainPath(base_filename(fn_src)).array; +        return _base_dir.chainPath(base_filename(fn_src)).array;        }      }      return _PathsStruct(); @@ -165,6 +168,9 @@ template SiSUpathsSisupodZipped() {    ) {      struct _PathsStruct {        auto spod_pths = SiSUpathsSisupod!()(); +      string sisupod_dir() { +        return spod_pths.sisupod_dir; +      }        string base_filename(string fn_src) {          return spod_pths.base_filename(fn_src);        } diff --git a/org/output_sisupod.org b/org/output_sisupod.org index a2085dd..a852b1c 100644 --- a/org/output_sisupod.org +++ b/org/output_sisupod.org @@ -76,6 +76,10 @@ assert (doc_matters.source_filename.match(rgx.src_fn));  #+name: source_sisupod_mkdirs  #+BEGIN_SRC d  /+ create directory structure +/ +if (!exists(pth_sisupod.sisupod_dir)) { +  // used both by sisupod zipped (& sisupod filesystem (unzipped) which makes its own recursive dirs) +  pth_sisupod.sisupod_dir.mkdirRecurse; +}  if (doc_matters.opt_action["source"]) {    if (!exists(pth_sisupod_filesystem.text_root(doc_matters.source_filename))) {      pth_sisupod_filesystem.text_root(doc_matters.source_filename).mkdirRecurse; @@ -105,9 +109,8 @@ if (doc_matters.opt_action["source"]) {  debug(sisupod) {    writeln(__LINE__, ": ",      doc_matters.source_filename, " -> ", -    pth_sisupod_filesystem.fn_doc( -    doc_matters.source_filename, -  )); +    pth_sisupod_filesystem.fn_doc(doc_matters.source_filename) +  );  }  auto zip = new ZipArchive();  auto fn_sisupod = pth_sisupod.sisupod_filename(doc_matters.source_filename); @@ -133,7 +136,6 @@ auto fn_sisupod = pth_sisupod.sisupod_filename(doc_matters.source_filename);          zip_data.write(cast(char[]) ((fn_src).read));          zip_arc_member_file.expandedData = zip_data.toBytes();          zip.addMember(zip_arc_member_file); -        createZipFile!()(pth_sisupod.sisupod_filename(fn_src), zip.build());        }      }    } @@ -153,7 +155,6 @@ auto fn_sisupod = pth_sisupod.sisupod_filename(doc_matters.source_filename);        zip_data.write((fn_src).readText);        zip_arc_member_file.expandedData = zip_data.toBytes();        zip.addMember(zip_arc_member_file); -      createZipFile!()(pth_sisupod.sisupod_filename(fn_src), zip.build());      }    }  } @@ -172,7 +173,6 @@ auto fn_sisupod = pth_sisupod.sisupod_filename(doc_matters.source_filename);        zip_data.write((fn_src).readText);        zip_arc_member_file.expandedData = zip_data.toBytes();        zip.addMember(zip_arc_member_file); -      createZipFile!()(pth_sisupod.sisupod_filename(fn_src), zip.build());      }    }  } @@ -202,17 +202,25 @@ auto fn_sisupod = pth_sisupod.sisupod_filename(doc_matters.source_filename);          }          if (doc_matters.opt_action["sisupod"]) {            auto zip_arc_member_file = new ArchiveMember(); -          zip_arc_member_file.name = insert_file; +          zip_arc_member_file.name = fn_out;            auto zip_data = new OutBuffer();            zip_data.write((fn_src).readText);            zip_arc_member_file.expandedData = zip_data.toBytes();            zip.addMember(zip_arc_member_file); -          createZipFile!()(pth_sisupod.sisupod_filename(fn_src), zip.build()); +          createZipFile!()(fn_sisupod, zip.build());          }        }      }    }  } +{ +  auto fn_src = doc_matters.source_filename; +  if (exists(fn_src)) { +    if (doc_matters.opt_action["sisupod"]) { +      createZipFile!()(fn_sisupod, zip.build()); +    } +  } +}  #+END_SRC  ** sha256 of sisupod.zip, zip debug, read zip archive diff --git a/src/sdp/output/paths_output.d b/src/sdp/output/paths_output.d index 5902b6b..ae4d4ac 100644 --- a/src/sdp/output/paths_output.d +++ b/src/sdp/output/paths_output.d @@ -10,18 +10,21 @@ import sdp.meta.rgx;  template SiSUpathsSisupod() {    mixin SiSUrgxInit;    static auto rgx = Rgx(); -  string base_dir = "sisupod"; -  string suffix = ".zip"; +  string _base_dir = "sisupod"; +  string _suffix = ".zip";    auto SiSUpathsSisupod()() {      struct _PathsStruct {        string base_filename(string fn_src) {          return fn_src.baseName.stripExtension;        } +      string sisupod_dir() { +        return _base_dir; +      }        string sisupod_filename(string fn_src) { -        return base_dir.chainPath(base_filename(fn_src) ~ suffix).array; +        return _base_dir.chainPath(base_filename(fn_src) ~ _suffix).array;        }        string base(string fn_src) { -        return base_dir.chainPath(base_filename(fn_src)).array; +        return _base_dir.chainPath(base_filename(fn_src)).array;        }      }      return _PathsStruct(); @@ -36,6 +39,9 @@ template SiSUpathsSisupodZipped() {    ) {      struct _PathsStruct {        auto spod_pths = SiSUpathsSisupod!()(); +      string sisupod_dir() { +        return spod_pths.sisupod_dir; +      }        string base_filename(string fn_src) {          return spod_pths.base_filename(fn_src);        } diff --git a/src/sdp/output/source_sisupod.d b/src/sdp/output/source_sisupod.d index db19f68..9c83905 100644 --- a/src/sdp/output/source_sisupod.d +++ b/src/sdp/output/source_sisupod.d @@ -27,6 +27,10 @@ template SiSUpod() {      assert (doc_matters.source_filename.match(rgx.src_fn));      try {        /+ create directory structure +/ +      if (!exists(pth_sisupod.sisupod_dir)) { +        // used both by sisupod zipped (& sisupod filesystem (unzipped) which makes its own recursive dirs) +        pth_sisupod.sisupod_dir.mkdirRecurse; +      }        if (doc_matters.opt_action["source"]) {          if (!exists(pth_sisupod_filesystem.text_root(doc_matters.source_filename))) {            pth_sisupod_filesystem.text_root(doc_matters.source_filename).mkdirRecurse; @@ -50,9 +54,8 @@ template SiSUpod() {        debug(sisupod) {          writeln(__LINE__, ": ",            doc_matters.source_filename, " -> ", -          pth_sisupod_filesystem.fn_doc( -          doc_matters.source_filename, -        )); +          pth_sisupod_filesystem.fn_doc(doc_matters.source_filename) +        );        }        auto zip = new ZipArchive();        auto fn_sisupod = pth_sisupod.sisupod_filename(doc_matters.source_filename); @@ -78,7 +81,6 @@ template SiSUpod() {                zip_data.write(cast(char[]) ((fn_src).read));                zip_arc_member_file.expandedData = zip_data.toBytes();                zip.addMember(zip_arc_member_file); -              createZipFile!()(pth_sisupod.sisupod_filename(fn_src), zip.build());              }            }          } @@ -98,7 +100,6 @@ template SiSUpod() {              zip_data.write((fn_src).readText);              zip_arc_member_file.expandedData = zip_data.toBytes();              zip.addMember(zip_arc_member_file); -            createZipFile!()(pth_sisupod.sisupod_filename(fn_src), zip.build());            }          }        } @@ -117,7 +118,6 @@ template SiSUpod() {              zip_data.write((fn_src).readText);              zip_arc_member_file.expandedData = zip_data.toBytes();              zip.addMember(zip_arc_member_file); -            createZipFile!()(pth_sisupod.sisupod_filename(fn_src), zip.build());            }          }        } @@ -147,17 +147,25 @@ template SiSUpod() {                }                if (doc_matters.opt_action["sisupod"]) {                  auto zip_arc_member_file = new ArchiveMember(); -                zip_arc_member_file.name = insert_file; +                zip_arc_member_file.name = fn_out;                  auto zip_data = new OutBuffer();                  zip_data.write((fn_src).readText);                  zip_arc_member_file.expandedData = zip_data.toBytes();                  zip.addMember(zip_arc_member_file); -                createZipFile!()(pth_sisupod.sisupod_filename(fn_src), zip.build()); +                createZipFile!()(fn_sisupod, zip.build());                }              }            }          }        } +      { +        auto fn_src = doc_matters.source_filename; +        if (exists(fn_src)) { +          if (doc_matters.opt_action["sisupod"]) { +            createZipFile!()(fn_sisupod, zip.build()); +          } +        } +      }        if (exists(fn_sisupod)) {          try {            auto data = (cast(byte[]) (fn_sisupod).read); | 
