home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / m / msh_ut11.zip / ARCHIVER.MSH next >
Text File  |  1992-05-10  |  8KB  |  198 lines

  1. |┌────────────────────────────┬───────────────────────────────────┐
  2. |│  This is file arjzip.msh   │ Support for archive-file-panels   │
  3. |├────────────────────────────┼───────────────────────────────────┤
  4. |│Supported archive-types:    │ ARJ LZH ZIP  (in msh 2.0 there is │
  5. |│                            │ only support for ZIP, in version  │
  6. |│                            │ 2.1 [beta] there is support for   │
  7. |│                            │ ZIP and ARJ-archives and LZH is   │
  8. |│                            │ in planning)                      │
  9. |├────────────────────────────┼───────────────────────────────────┤
  10. |│Supported archivers:        │ pkzip/pkunzip (1.10)              │
  11. |│                            │ arj (2.30)                        │
  12. |│                            │ lharc (2.13)                      │
  13. |├────────────────────────────┴───────────────────────────────────┤
  14. |│Original Code: Jean Michel, Additions: Jens Pirnay              │
  15. |└────────────────────────────────────────────────────────────────┘
  16. (panel.pattern dirpart current.name&"\\*.*"&panel.pattern!)extension_arj!
  17. (extension_arj)extension_zip!
  18. (extension_arj)extension_lzh!
  19. | Name of arc-file in next panel
  20. (panel.pattern panel.type cutfirst drop panel.type&)arcname!
  21. | Name of directory INSIDE an archive
  22. (panel.pattern panel.type cutfirst swap drop dirpart dup
  23.  length dup 1>(2 swap substring)(drop drop "")ifelse
  24. )arcdirname!
  25. | Name of arc-file in next panel
  26. (next_dir (panel.type)in_next_panel cutlast drop)next_dir_arc!
  27. | Name of directory INSIDE archive in next panel
  28. ((arcdirname)in_next_panel)next_dir_name!
  29. | Name of temporary directory (it's root)
  30. (tmp_dir "#Z#" &)   base_tmp!
  31. | Name of temporary directory (root + archive-directory)
  32. (base_tmp next_dir_name dup ("\\" swap & &)(drop)ifelse)tmp_dirname!
  33. | Name of temporary (response-) file
  34. (tmp_dir"tmp.$$$"&) tmp_filename!
  35. | Name of work-directory for archivers
  36. (tmp_dir unit_and_name drop " " &)tmpdir_arc!  | working-dirs
  37. | Make a response file, that is write all filenames
  38. | to "tmp.$$$", prepend [top] for any filename.
  39. | NB: Unix-style paths!! (C:\MSH = c:/msh)
  40. (the_cmd! (the_cmd swap & nl &
  41. ("\\" cutfirst dup (dup)if)("/" swap & &)while  || replace "\" by "/"
  42. tmp_filename write)foreachselected)resp_file!
  43. | Create all necessary temporary directories...
  44. ("mymkdir " tmp_dirname &(execute)with_nomagic)mktmpdir!
  45. | ...and remove them again
  46. ("rm -rf " base_tmp &(execute)with_nomagic)rmtmpdir!
  47. | Standard-Exit-procedure
  48. (rmtmpdir tmp_filename unlink reread reread_next)exit_tmp_dir!
  49. ||
  50. || Here are the list of external commands, modify to your own needs
  51. ||
  52. ("pkzip -m -r -p " swap & " " & base_tmp & "\\*.*" & execute)    mvzip!
  53. ("arj m -r -e1 "   swap & " " & base_tmp & execute)              mvarj!
  54. (cwd the_cmd! base_tmp cwd! "lharc m -r -x " swap &" *.*"&execute
  55.  the_cmd cwd!)                                                   mvlzh!
  56. ("pkzip -u -r -p " swap & " " & base_tmp & "\\*.*" & execute)    upmvzip!
  57. ("arj u -r -e1 "   swap & " " & base_tmp & execute)              upmvarj!
  58. (cwd the_cmd! base_tmp cwd! "lharc u -r -x " swap &" *.*"&execute
  59.  the_cmd cwd!)                                                   upmvlzh!
  60. ("pkunzip -e "arcname&" "&tmp_dirname&" @"&tmp_filename&execute) tmp_unzip!
  61. ("arj e -ju "arcname&" "&tmp_dirname&" !"&tmp_filename&execute)  tmp_unarj!
  62. ("lharc e "arcname&" "&tmp_dirname&" @"&tmp_filename&execute)    tmp_unlzh!
  63. ("pkunzip -e "arcname&" "&next_dir&" @"&tmp_filename&execute)    unzip!
  64. ("arj e -ju "arcname&" "&next_dir&" !"&tmp_filename&execute)     unarj!
  65. ("lharc e "arcname&" "&next_dir&" !"&tmp_filename&execute)       unlzh!
  66. ("pkzip -d -b"tmpdir_arc&arcname&" "&" @"&tmp_filename&execute)  delzip!
  67. ("arj d -ju -w"tmpdir_arc&arcname&" "&" !"&tmp_filename&execute) delarj!
  68. ("lharc d -w"tmpdir_arc&arcname&" "&" @"&tmp_filename&execute)   dellzh!
  69. (next_dir_arc mvzip)                                             cptmpzip!
  70. (next_dir_arc mvarj)                                             cptmparj!
  71. (next_dir_arc mvlzh)                                             cptmplzh!
  72. |
  73. ( current.isdir
  74.   ( panel.pattern dirpart
  75.     current.name ".." =
  76.     (dup length 1- 1 swap substring dirpart)
  77.     (current.name&)
  78.     ifelse
  79.     panel.pattern filepart makename
  80.     panel.pattern!
  81.   )
  82.   if
  83. )cur_action.arj!
  84. (cur_action.arj)cur_action.zip!
  85. (cur_action.arj)cur_action.lzh!
  86. |
  87. ( panel.pattern dirpart
  88.       dup length 1- 1 swap substring dirpart
  89.       panel.pattern filepart makename
  90.       panel.pattern!
  91. )go_up.arj!
  92. (go_up.arj)go_up.zip!
  93. (go_up.arj)go_up.lzh!
  94. |
  95. (exec tmp_filename unlink reread)exec_unlink!
  96. |
  97. | Actions to delete files from archive
  98. |
  99. ( "del" swap & arcdirname resp_file # tmp_filename unlink reread ) del_arc!
  100. ( "arj" del_arc ) delete.arj!
  101. ( "zip" del_arc ) delete.zip!
  102. ( "lzh" del_arc ) delete.lzh!
  103. |
  104. | Actions to view a file (archiver must have ability extract to stdout!)
  105. |
  106. ( arcname&" "&arcdirname
  107.   current.name&&">"tmp_filename&&(exec)with_nomagic
  108. |  tmp_filename pager tmp_filename unlink
  109.   browser tmp_filename & execute tmp_filename unlink
  110. )browse_arc!
  111. ( "arj p " browse_arc)        browse.arj!
  112. ( "pkunzip -c -d " browse_arc)browse.zip!
  113. ( "lharc p " browse_arc)      browse.lzh!
  114. |
  115. | Copy (=extract) from archive to directory
  116. |
  117. ( arcdirname resp_file "un" swap & #
  118.   tmp_filename unlink reread_next
  119. )copy_arc!
  120. ( "arj" copy_arc ) copy.arjto!
  121. ( "zip" copy_arc ) copy.zipto!
  122. ( "lzh" copy_arc ) copy.lzhto!
  123. |
  124. | Move (extract & delete) from archive to directory
  125. |
  126. ( arcdirname resp_file
  127.   dup "un" swap & # "del" swap & #
  128.   tmp_filename unlink reread reread_next
  129. )move_arc!
  130. ( "arj" move_arc ) move.arjto!
  131. ( "zip" move_arc ) move.zipto!
  132. ( "lzh" move_arc ) move.lzhto!
  133.  
  134. || Now actions to bring files into arj-file.
  135. || We have to make some tricksing to bring the files
  136. || exactly to the place where want them to have.
  137. ( mktmpdir selected_list& " " & tmp_dirname & execute
  138.   "cptmp" swap & # exit_tmp_dir
  139. )
  140. copyto_arc!
  141. ( "arj" "cp -f " copyto_arc ) copyto.arj!
  142. ( "zip" "cp -f " copyto_arc ) copyto.zip!
  143. ( "lzh" "cp -f " copyto_arc ) copyto.lzh!
  144. ( "arj" "mv -f " copyto_arc ) moveto.arj!
  145. ( "zip" "mv -f " copyto_arc ) moveto.zip!
  146. ( "lzh" "mv -f " copyto_arc ) moveto.lzh!
  147.  
  148. || Now inter-archive-operations alas for 2 archivers we have a lot
  149. || of variants so you may remove some if you don't need them
  150. ( | [top+1] source archive-type
  151.   | [top]   destination archive-type
  152.   darc! sarc!
  153.   arcdirname resp_file          || create a (Unix-style) response-file
  154.   mktmpdir "tmp_un" sarc & # "cptmp" darc & #
  155.   exit_tmp_dir
  156. )
  157. copy.them!
  158. ( | [top+1] source archive-type
  159.   | [top]   destination archive-type
  160.   darc! sarc!
  161.   arcdirname resp_file          || create a (Unix-style) response-file
  162.   mktmpdir "tmp_un" sarc & # "del" sarc & # "cptmp" darc & #
  163.   exit_tmp_dir
  164. )
  165. move.them!
  166.  
  167. ( "arj" "arj" copy.them ) copy.arjto.arj!
  168. ( "arj" "zip" copy.them ) copy.arjto.zip!
  169. ( "arj" "lzh" copy.them ) copy.arjto.lzh!
  170. ( "zip" "zip" copy.them ) copy.zipto.zip!
  171. ( "zip" "arj" copy.them ) copy.zipto.arj!
  172. ( "zip" "lzh" copy.them ) copy.zipto.lzh!
  173. ( "lzh" "arj" copy.them ) copy.lzhto.arj!
  174. ( "lzh" "zip" copy.them ) copy.lzhto.zip!
  175. ( "lzh" "lzh" copy.them ) copy.lzhto.lzh!
  176. ( "arj" "arj" move.them ) move.arjto.arj!
  177. ( "arj" "zip" move.them ) move.arjto.zip!
  178. ( "arj" "lzh" move.them ) move.arjto.lzh!
  179. ( "zip" "zip" move.them ) move.zipto.zip!
  180. ( "zip" "arj" move.them ) move.zipto.arj!
  181. ( "zip" "lzh" move.them ) move.zipto.lzh!
  182. |
  183. | Now edit a file inside an archive
  184. |
  185. ( "mymkdir " base_tmp & (execute)with_nomagic
  186.   arcname & " " & base_tmp & "\\ " &
  187.   arcdirname & current.name & execute
  188.   editor base_tmp & "\\" & arcdirname & current.name & execute
  189.   "upmv" swap & arcname swap # exit_tmp_dir
  190. )edit_arc!
  191. ("arj" "arj x -y "   edit_arc) edit.arj!
  192. ("zip" "pkunzip -d " edit_arc) edit.zip!
  193. ("lzh" "lharc x "    edit_arc) edit.lzh!
  194. |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  195. tmp_filename unlink rmtmpdir  | make sure all is clean !
  196. ||                            | tmp_dir should be defined, so move it's
  197. ||                            | definition in "config.msh" to the top
  198.