FOR each:
LIST
OF Rope.
ROPE ← names, each.rest
WHILE each #
NIL
DO
inStream, outStream: IO.STREAM ← NIL;
name: ROPE = each.first;
bytes: NAT ← 0;
timeBytes:
PACKED ARRAY [0..3]
OF
CARDINAL =
LOOPHOLE[BasicTime.ToPupTime[BasicTime.Now[]]];
IF Rope.Equal[name, "-n", FALSE] THEN {useNebula ← TRUE; LOOP};
IO.PutF[cmd.out, "Open %g", [rope[name]]];
inStream ←
FS.StreamOpen[name
! FS.Error => {IO.PutF[cmd.out, "\n Error - %g\n", [rope[error.explanation]]]; LOOP};
];
outStream ←
FS.StreamOpen[
IF useNebula THEN Rope.Concat["/Nebula//", name] ELSE name, create
! FS.Error => {IO.PutF[cmd.out, "\n Error - %g\n", [rope[error.explanation]]]; LOOP};
];
IO.PutRope[cmd.out, " ."];
bytes ← IO.GetBlock[inStream, buffer, 0, 512];
We must scramble a certain 4 bytes in the file to be a funny-format date.
buffer[6+0] ← timeBytes[2];
buffer[6+1] ← timeBytes[3];
buffer[6+2] ← timeBytes[0];
buffer[6+3] ← timeBytes[1];
DO
IO.PutRope[cmd.out, "."];
IO.PutBlock[outStream, buffer, 0, bytes];
bytes ← IO.GetBlock[inStream, buffer, 0, 512 ! IO.EndOfStream => EXIT];
ENDLOOP;
IO.Close[outStream];
IO.Close[inStream];
IO.PutRope[cmd.out, "\n"];
ENDLOOP;