home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / varie / gdtrash1.1rev.2 / arexx / trashdelete.dopus5 < prev   
Text File  |  2000-01-19  |  5KB  |  251 lines

  1. /* Full Dopus Delete command with Trashcan feature */
  2. /* By Nils-Erik Reklev Skilnand*/
  3.  
  4. parse arg portname handle
  5. if portname='' then portname='DOPUS.1'
  6. address value portname
  7.  
  8. options results
  9.  
  10. if handle="" then do
  11.  
  12. lister query source
  13. handle=result
  14. if rc~=0 then exit
  15. end
  16. lf='0a'x
  17.  
  18. if (show('p','ArcDir'space(handle,0))) then do
  19.     lister request handle '"Warning:"'lf'"DelTrash does not work with ArcDir"'lf'"Please configure the Delete button with the normal"'lf'" Delete command for another mouse button"'lf'"Example: Left mouse button DelTrash"'lf'"Right mouse button Delete (dopus command Delete)" Ok'
  20.     exit
  21. end
  22.  
  23. if open(1,'Env:trash.prefs','R') then do
  24.     do i=1 to 6
  25.         prefs.i = readln(1)
  26.     end
  27.         
  28.     if prefs.4 ~="" then trashpath=prefs.4
  29.     Call close(1)
  30. end     
  31.  
  32. lister query Handle selfiles stem files.
  33. lister query Handle seldirs stem dirs.
  34. IF (files.count=0&dirs.count=0) then exit
  35.  
  36. i=1;argm='';fuckthem=0;un=0
  37.  
  38. lister query Handle path
  39. pfad=result
  40.  
  41. entries=0
  42. lister query handle selentries
  43. allents=result
  44. do while allents~=''
  45.     entries=entries+1
  46.     parse var allents '"' name.entries '"' allents
  47.     lister query handle entry '"'name.entries'"' stem fileinfo.
  48.     type.entries=fileinfo.type
  49.     name1.entries=name.entries
  50.     name.entries ='"'pfad || name.entries'"'
  51.     prot.entries = fileinfo.protstring
  52. end
  53.  
  54. lister set handle newprogress name info bar
  55. lister set handle newprogress title "Removing Files ..."
  56. lister set handle newprogress info "Number of files: "entries
  57.  
  58. lister request handle '"Warning: You cannot get back"'lf'"What you delete! OK to delete"'lf'""'lf'"'files.count' file(s) and"'lf'"'dirs.count' drawer(s)(and their contents)?" Proceed|DeleteAll|Trash All|Cancel'
  59.  
  60. if rc=1 then do
  61.     call subdel
  62. end
  63. if rc=2 then do
  64.     do i=i to entries
  65.         if (lastpos('d',prot.i)=0&argm~='force'&fuckthem=0) then call pro
  66.         if lastpos('d',prot.i)=0 then do
  67.             select
  68.                 when (ch=1|ch=2) then call del
  69.                 when ch=3 then call pro    
  70.                 when ch=4 then nop
  71.                 otherwise nop
  72.             end
  73.         end
  74.         else call del
  75.         
  76.     end
  77. end
  78.  
  79. if rc=3 then do
  80.     do i=i to entries
  81.         if (lastpos('d',prot.i)=0&argm~='force'&fuckthem=0) then call pro
  82.         if lastpos('d',prot.i)=0 then do
  83.             select
  84.                 when (ch=1|ch=2) then call trash
  85.                 when ch=3 then call pro    
  86.                 when ch=4 then nop
  87.                 otherwise nop
  88.             end
  89.         end
  90.         else call trash        
  91.     end
  92. end
  93.  
  94. lister clear handle progress
  95. Lister refresh handle full
  96. exit
  97.  
  98. SubDel:
  99. if i>entries then return
  100. lister request handle '"Delete 'name1.i' ?" Delete|Delete All|Trash|Trash All|Skip|Abort'
  101. select
  102.     when rc=1 then do
  103.         if (lastpos('d',prot.i)=0&argm~='force'&fuckthem=0) then call pro
  104.         if lastpos('d',prot.i)=0 then do
  105.             select
  106.                 when ch=2 then do
  107.                     call del
  108.                     i=i+1
  109.                 end
  110.                 when ch=3 then call subdel    
  111.                 when ch=4 then do
  112.                     i=i+1
  113.                 end
  114.                 otherwise nop
  115.             end
  116.         end
  117.         else do
  118.             call del
  119.             i=i+1
  120.         end
  121.         call subdel
  122.         
  123.     end
  124.  
  125.     when rc=2 then do
  126.         do i=i to entries
  127.             if (lastpos('d',prot.i)=0&argm~='force'&fuckthem=0) then call pro
  128.             if lastpos('d',prot.i)=0 then do
  129.                 select
  130.                     when (ch=1|ch=2) then call del
  131.                     when ch=3 then do
  132.                         i=i-1
  133.                         call pro
  134.                     end    
  135.                     when ch=4 then nop
  136.                     otherwise nop
  137.                 end
  138.             end
  139.             else call del
  140.         
  141.         end
  142.     end
  143.  
  144.     when rc=3 then do
  145.         if (lastpos('d',prot.i)=0&argm~='force'&fuckthem=0) then call pro
  146.         if lastpos('d',prot.i)=0 then do
  147.             select
  148.                 when ch=2 then do
  149.                     call trash
  150.                     i=i+1
  151.                 end
  152.                 when ch=3 then call subdel    
  153.                 when ch=4 then do
  154.                     i=i+1
  155.                 end
  156.                 otherwise nop
  157.             end
  158.         end
  159.         else do
  160.             call trash
  161.             i=i+1
  162.         end        
  163.         call subdel
  164.     end
  165.  
  166.     when rc=4 then do
  167.         do i=i to entries
  168.             if (lastpos('d',prot.i)=0&argm~='force'&fuckthem=0) then call pro
  169.             if lastpos('d',prot.i)=0 then do
  170.                 select
  171.                     when (ch=1|ch=2) then call trash
  172.                     when ch=3 then do
  173.                         i=i-1
  174.                         call pro
  175.                     end    
  176.                     when ch=4 then nop
  177.                     otherwise nop
  178.                 end
  179.             end
  180.             else call trash
  181.         
  182.         end
  183.     end
  184.  
  185.     when rc=5 then do
  186.         lister set handle newprogress info entries "/" entries-i Name1.i
  187.             lister set handle newprogress bar entries i
  188.         i=i+1
  189.         call subdel
  190.     end
  191. otherwise nop
  192. end
  193. return
  194.  
  195. pro:
  196. lister request handle '""'name1.i'" is protected against deletion."'lf'"Unprotect and try again?" Unprotect|Unprotect All|Skip|Skip All|Abort'
  197. select
  198.     when rc=1 then do
  199.         address command 'protect 'name.i' +d'
  200.         prot.i='d'
  201.         ch=1
  202.     end
  203.  
  204.     when rc=2 then do
  205.         argm='force'
  206.         prot.i='d'
  207.         ch=2
  208.     end
  209.  
  210.     when rc=3 then do
  211.         i=i+1
  212.         ch=3
  213.     end
  214.  
  215.     when rc=4 then do
  216.         fuckthem=1
  217.         ch=4
  218.     end
  219.     
  220.     when rc=0 then do
  221.         lister clear handle progress
  222.         Lister refresh handle full
  223.         exit
  224.     end
  225. otherwise nop
  226. end
  227. return
  228.  
  229. Del:
  230. address command 'Delete all 'argm' 'name.i''
  231. lister set handle newprogress info entries "/" entries-i Name1.i
  232. lister set handle newprogress bar entries i
  233. return
  234.  
  235. Trash:
  236. if argm='force' then address command 'protect all 'name.i' +d'
  237. if type.i < 0 then do
  238.     address command 'Move 'name.i' to 'trashpath''
  239.     address command 'Echo >'trashpath||strip(name1.i,B,'"')||.path' 'pfad''
  240.     Address Command 'SetDate 'trashpath||strip(name1.i,B,'"')''
  241. end
  242.  
  243. lister set handle newprogress info entries "/" entries-i Name1.i
  244. lister set handle newprogress bar entries i
  245.  
  246. if type.i > 0 then do
  247.     address command 'Move 'name.i' to 'trashpath||strip(name1.i,B,'"')''    
  248.     address command 'Echo >'trashpath||strip(name1.i,B,'"')||.path' 'pfad''
  249.     Address Command 'SetDate 'trashpath||strip(name1.i,B,'"')''
  250. end
  251. return