home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 4
/
AACD04.ISO
/
AACD
/
Online
/
AWebScripts
/
DL.awebrx
< prev
next >
Wrap
Text File
|
1999-11-25
|
3KB
|
147 lines
/* $VER: Download.awebrx 1.4 (23.11.99) by Jorma Oksanen <tenu@sci.fi>
Downloads files without requester
Setup:
GUI/Menus/ARexx
Set Download options
RUN AWeb3:Plugins/DL.awebrx set
GUI/Popup/Link
Download
RUN AWeb3:Plugins/DL.awebrx u=%u;d="DL:AWeb";m=5
Possible arguments are:
set Set new dowload directory and/or default action.
If you give other arguments, they are set as
defaults, otherwise you will be asked for the
download directory and the default mode.
URL given is ignored.
u="<url>" Download URL to download directory
d="<dir>" Download URL to specified directory. This
doesn't change the default directory.
m=n Set default action for already existing file.
This doesn't change the default mode.
0 = Requester 3 = New name
1 = Overwrite 4 = Auto Rename
2 = Append 5 = Skip
*/
options results
parse arg args
cname='AWebDL-opt'
u=''; d=''; m=0
interpret getclip(cname)
set=abbrev(upper(args)' ','SET '); if set then args=substr(args,5)
interpret args
/* Ask download directory if not already set or if asked to do so */
if (d='')|(set) then do
if d='' then do
'getcfg savepath var d'
if verify(right(d,1),":/") then d=d'/'
end
if (~set)|((set)&(args='')) then do
'requestfile "Set DL directory" file "'d'" savemode dirsonly'
if rc=5 then exit
d=result
end
if (set)&(args='') then do
'request "DL" "Select default action for already existing files" "_Requester|_Overwrite|_Append|_New name|Auto _Rename|_Skip"'
if rc=5 then m=5
else m=result-1
end
call setclip(cname,'m='m';d="'d'"')
if set then exit
end
if right(u,1)='/' then file='index.html'
else do
file=translate(u,' ','/')
file=word(translate(word(file,words(file)),' ','#'),1)
end
file=d||purify(file)
app=''
/* rename until unique name */
if exists(file) then file=req(m,file)
'load "'u'" saveas "'file'"' app
exit
/* Quote wildcard chars */
Purify: procedure
return translate(arg(1),'','`~"=#?/:;\*%()[]<>'||"'")
/* Return filename for saving */
req: procedure expose app
parse arg m,file
if m=5 then exit /* cancel */
ok=0
do until ok
if m=0 then do
'request "DL" "'file'*nalready exists!" "_Overwrite|_Append|_New name|Auto _Rename|_Cancel"'
if rc=5 then exit
end
else do
result=m
m=0
end
select
when result=1 then ok=1 /* overwrite */
when result=2 then do /* append */
app='append'; ok=1
end
when result=3 then do /* new name */
'requestfile "DL - select new file name" file' file 'savemode'
if rc=5 then exit
file=result; ok=~exists(file)
end
when result=4 then do /* rename */
file=auto(file); ok=1
end
otherwise nop
end
end
return file
auto: procedure
do i=2 while exists(arg(1)'.'i); end
return arg(1)'.'i