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 / MYDEFS.ZIP / ARCHIVER.MSH next >
Text File  |  1992-05-09  |  8KB  |  194 lines

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