home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Extra 1997 #5
/
AmigaPlus_Extra-CD_5-97.iso
/
online-tools
/
mail
/
mailserver
/
sys
/
autoencode
next >
Wrap
Text File
|
1995-04-08
|
1KB
|
63 lines
/* $VER: 1.0 */
/* Check for binary files, then automatically uuencode them to OUTFILE
If not binary, simply copy the file to OUTFILE */
parse arg files
if words(files) < 2 then
do
say 'USAGE: autoencode INFILE OUTFILE'
exit
end
infile = word(files,1)
outfile = word(files,2)
outfile2 = outfile'.2'
uucmd = 'c:uuxt a 'outfile2' 'infile' >nil:'
if ~exists(infile) then
do
say 'File "'infile'" does not exist.'
exit
end
open(tmpfile,infile,'r')
/* Find file length */
lof = seek(tmpfile,0,'E')
len = min(lof,100)
seek(tmpfile,0,'B')
string = readch(tmpfile,100)
close(tmpfile)
bin = 'no'
do chrnum = 1 to 100
chr = substr(string,chrnum,1)
if c2d(chr) >127 then bin = 'yes'
end
if bin = 'no' then
address command 'copy 'infile' 'outfile2
else
address command uucmd
/* Add the filename to the file */
address command 'echo File: 'infile' > 'outfile
address command 'echo "" >> 'outfile
address command 'echo ---------- 8< ----- Cut Here ---------------------------------------- >> 'outfile
address command 'echo "" >> 'outfile
address command 'type 'outfile2' >> 'outfile
address command 'delete >nil: 'outfile2
exit