home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
554
/
JUILLET
/
FCUT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-10-07
|
4KB
|
119 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 295 of 335
From : Ian Lin 1:249/120.0 03 Jul 93 07:03
To : Jack Moffitt
Subj : Overlays
────────────────────────────────────────────────────────────────────────────────
JM> Yes.. but make sure it's a COPY /B <filename.exe>+<filename.ovr>
Yup, I'll remember. In fact, I made a neat little program that I found
some use for that in the end you may need to use COPY /B for. It's a simple
little file cutter. I figured I may use ARJ so I can back files up to
multiple volumes, but not all other archivers have that feature so I made
a binary file cutter. Once done though, you'll want to use COPY /B and not
just COPY to put the files back together. And just in case somebody wants
to know what my program looks like, I guess I'll post it now to save the
request message(s), if any would have been. Any suggestions for improvement
would also be appreciated. I also have another one that's for text files
(LCUT). I figured I'd never need one of those, then I downloaded a 600K
text file that listed all files on one of my local boards and I then needed
it! (MS-DOS 6 EDIT can't handle all that!)
___-- FCUT.PAS ---------}
{$I-,G+}
uses dos,crt;
var
inf,outf:file;
k,fnum,v,nrd,nw:word;
bnum,lim,size:longint;
b:array [1..20480] of byte;
p:record
y:boolean;
p:word;
end;
begin
writeln ('FCUT v2.0');
if paramcount<3 then begin
writeln ('Help screen.');
writeln
(fexpand(paramstr(0)),' <bytes> <infile> <outfile names 1, 2, 3, etc.>');
writeln ('Use the /p parameter to pause between files.');
writeln ('Error codes.'); writeln ('0: not enough parameters');
writeln ('1: Invalid byte number to cut at');
writeln ('2: Input file not found'); writeln ('4: Input file is empty');
writeln ('5: input file also specified for output');
writeln ('6: Critical write error.');
halt(0)
end;
val (paramstr(1),lim,v);
if (v<> 0) or (lim<0) then begin
writeln ('Invalid byte value "',paramstr(1),'"'); halt(1)
end;
assign (inf,fexpand(paramstr(2)));
reset (inf,1);
if ioresult<>0 then begin
writeln ('Input file ',fexpand(paramstr(2)),' not found.'); halt(2);
end;
if filesize(inf)=0 then begin
writeln ('Input file '+paramstr(2)+' is empty.'); halt(4);
end;
p.y:=false; p.p:=0;
for fnum:=3 to paramcount do begin
if (fexpand(paramstr(fnum))=(fexpand(paramstr(2)))) then begin
writeln ('Error: Input file also specified for output');
halt(5); end;
if (paramstr(fnum)='/p') or (paramstr(fnum)='/P') then begin
p.y:=true; p.p:=fnum; end;
end;
fnum:=3;
repeat
if p.y then begin
writeln ('Press a key to continue, any other to detonate...');
repeat until keypressed;
v:=word(readkey);
end;
if fnum<>p.p then begin
assign (outf,fexpand(paramstr(fnum)));
rewrite (outf,1);
bnum:=0;
k:=lim div sizeof(b); size:=lim mod sizeof(b);
if k>0 then
repeat
blockread (inf,b,sizeof(b),nrd);
blockwrite (outf,b,nrd,nw);
inc(bnum,nw);
dec(k);
if nrd<>nw then begin
writeln ('Critical write error (',fexpand(paramstr(fnum)),')');
halt(6);
end;
until (k=0) or (nrd=0);
if size>0 then begin
blockread(inf,b,size,nrd);
blockwrite(outf,b,nrd,nw);
inc(bnum,nw);
if nrd<>nw then begin
writeln ('Critical write error (',fexpand(paramstr(fnum)),')');
halt(6);
end;
end;
if (paramcount=fnum) and (not(eof(inf))) then
repeat
blockread(inf,b,sizeof(b),nrd);
blockwrite(outf,b,nrd,nw);
inc(bnum,nw);
if nrd<>nw then begin
writeln ('Critical write error (',fexpand(paramstr(fnum)),')');
halt(6); end;
until nrd=0;
writeln ('Wrote ',bnum,' bytes to ',fexpand(paramstr(fnum)));
if bnum>lim then
writeln (bnum-lim,' bytes over cut limit in ',fexpand(paramstr(fnum)));
close (outf);
inc (fnum);
end;
until (fnum>paramcount) or (eof(inf));
close (inf);
writeln ('Lum''s Place BBS 613 531 1911 Door games & Files & Soon IMS mail');
writeln
('This file cutter util written by NetRunner, co-sysop of Lum''s Place');
end.