%include "Moose:Mouse.Inc"

%systemroutinespec phex(%integer i)

%include "FSys.Inc"
%externalroutinespec fsys initialise

%constinteger free size = 256 - 8
%recordformat header fm((%short checksum, 
                         %short root, used, flags, free count,
                         %shortarray free(1 : free size),
                         %short should have, seed) %c
                        %or %bytearray b(0 : 511))

%begin
   %record(header fm) h
   %integer token, status = 0, size = 0, flags = 0
      fsys initialise
      status = fsys open file(nil, 16_01010002, read access, -1,
                              token, size, flags)
      printstring("Open status ");  write(status, 0)
      printstring(", size ");  write(size, 0)
      printstring(", flags ");  phex(flags);  newline
      %stop %if status < 0
      status = fsys read file block(nil, token, 0, size, h)
      printstring("Read block 0 status ");  write(status, 0);  newline
      %if status < 0 %start
         status = fsys close file(nil, token, 0)
         %stop
      %finish
      status = fsys close file(nil, token, 0)
      printstring("Close status ");  write(status, 0);  newline
      printstring("Tree root at ");  write(h_root, 0);  newline
%end %of %program
