Sage-ST ä

Bufio

Documentation

Global Declarations (Constants, Types, Variables)
BFClose BFOpen BFReadBlock
BFReadChar BFReadLine BFReadPos BFSetPos
BFStats BFWriteBlock BFWriteChar BFWriteLine
BFWriteLn BFWritePos BFWriteString GetHandleState





  TYPE
    FileBF;




  PROCEDURE BFOpen
             (VAR   FTable   : FileBF;
              CONST FileName : ARRAY OF CHAR;
              CONST Modify   : BOOLEAN;
              CONST Append   : BOOLEAN;
              CONST maxBuf   : CARDINAL;
              VAR   state    : Files.FileState);

  (**
      BFOpen - Open a file for large buffered reads and writes.


      This procedure opens a sequential file for buffered
      reads.  Buffered reading can be considerably faster than
      normal IO since large buffers are used and therefore head
      seek and position times are reduced.

      CALLING SEQUENCE -

        BFOpen (fTable, fileName, modify, append, maxBuf, state)

      ENTRY -

        fTable : FileBF
          File table

        fileName : ARRAY OF CHAR
          Name of file to open

        modify : BOOLEAN
          Open file with write permission (TRUE) or read
          only permission (FALSE).

        append : BOOLEAN
          If using 'modify' permission, start writing at
          the end of an existing file (TRUE), or create
          a new file (FALSE);

        maxBuf : CARDINAL
          The maximum size of file IO buffer in bytes.

      EXIT -

        state : FileState
          The file status.
  *)




  PROCEDURE BFClose
             (VAR   FTable : FileBF;
              VAR   state  : Files.FileState);

  (**
      BFClose - Close a file used for large buffered reads and writes.


      Close a file opened with the BFOpen procedure.

      CALLING SEQUENCE -

        BFClose (fTable, state)

      ENTRY -

        fTable : FileBF
          File table

      EXIT -

        state : FileState
          The file status.
  *)




  PROCEDURE BFSetPos
             (VAR   FTable  : FileBF;
              CONST filePos : Files.FilePosition;
              VAR   state   : Files.FileState);

  (**
      BFSetPos - Set the position on the file for the next read or write.


      This procedure allows the position of the next buffered
      read or write to be set to a relative file position.
      This is not necessary, and in fact inefficient, during
      normal sequential processing of a file.  When this
      procedure is used, sequential buffered processing begins
      again at the point specified in the same mode (either
      READ or MODIFY) in which the file was opened.  The
      position for the end of the file may be determined using
      the BFStats procedure and then this procedure used to set
      position there.

      CALLING SEQUENCE -

        BFSetPos (fTable, filePos, state);

      ENTRY -

        fTable : FileBF
          File table

      EXIT -

        filePos : Files.FilePosition
          The position (0 .. n) on the file where 0 is the beginning
          of the file.

        state : FileState
          The file status.
  *)




  PROCEDURE BFReadLine
             (VAR   FTable    : FileBF;
              VAR   line      : ARRAY OF CHAR;
              VAR   lineSize  : CARDINAL;
              VAR   endOfFile : BOOLEAN;
              VAR   state     : Files.FileState);

  (**
      BFReadLine - Read a line from a file.


      This procedure reads a line from a file opened with the
      BFOpen procedure.  The end of line characters are
      recognized and not returned in the line.

      CALLING SEQUENCE -

        BFReadLine (fTable, line, lineSize, endOfFile)

      ENTRY -

        fTable : FileBF
          File table

      EXIT -

        line : ARRAY OF CHAR
          The line read from the file.

        lineSize : CARDINAL
          The number of characters read into 'line'.

        endOfFile : BOOLEAN
          End of file reached.

        state : FileState
          The file status.
  *)




  PROCEDURE BFReadBlock
             (VAR   FTable    : FileBF;
              CONST buf       : SYSTEM.ADDRESS;
              CONST nBytes    : CARDINAL;
              VAR   bytesRead : CARDINAL;
              VAR   endOfFile : BOOLEAN;
              VAR   state     : Files.FileState);

  (**
      BFReadBlock - Read a block of bytes from a file.


      Read a block of data from the buffered file.  This file
      should have been opened with the BFOpen procedure.  Any
      end of line characters are not detected as with the
      BFReadLine procedure.

      CALLING SEQUENCE -

        BFReadBlock (fTable, buf, nBytes, bytesRead, endOfFile, state)

      ENTRY -

        fTable : FileBF
          File table

        nBytes : CARDINAL
          The number of bytes (characters) requested to be read.

      EXIT -

        buf : ADDRESS
          The data read from the file.

        bytesRead : CARDINAL
          The number of characters read into 'buf'.

        endOfFile : BOOLEAN
          End of file reached, no bytes available to be read.

        state : FileState
          The file status.
  *)




  PROCEDURE BFReadChar
             (VAR   FTable    : FileBF;
              VAR   TheChar   : CHAR;
              VAR   endOfFile : BOOLEAN;
              VAR   state     : Files.FileState);

  (**
      BFReadChar - Read a block of bytes from a file.


      Read a character from the buffered file.  This file
      should have been opened with the BFOpen procedure.

      CALLING SEQUENCE -

        BFReadChar (fTable, c, endOfFile, state)

      ENTRY -

        fTable : FileBF
          File table

      EXIT -

        c : CHARACTER
          The character read from the file.

        endOfFile : BOOLEAN
          End of file reached, no characters available.

        state : FileState
          The file status.
  *)




  PROCEDURE BFReadPos
             (VAR   FTable    : FileBF;
              CONST buf       : SYSTEM.ADDRESS;
              CONST filePos   : Files.FilePosition;
              CONST nBytes    : CARDINAL;
              VAR   bytesRead : CARDINAL;
              VAR   endOfFile : BOOLEAN;
              VAR   state     : Files.FileState);

  (**
      BFReadPos - Read a block of bytes from a file without buffering.


      Read a block of data from a specified position on a file
      without using buffering.  The read/write position of the
      file and its buffer are not disturbed by this operation
      so that continual sequential buffered I/O may occur after
      reading using BFReadPos.  This procedure may be called if
      the file has been opened with either READ or MODIFY
      permission.

      CALLING SEQUENCE -

        BFReadPos (fTable, buf, filePos, nBytes, bytesRead, endOfFile, state)

      ENTRY -

        fTable : FileBF
          File table

        filePos : Files.FilePosition
          The position within the file from which to read (0 .. n).

        nBytes : CARDINAL
          The number of bytes (characters) requested to be read.

      EXIT -

        buf : ADDRESS
          The data from the file.

        bytesRead : CARDINAL
          The number of characters read into 'buf'.

        endOfFile : BOOLEAN
          End of file reached, no bytes available to be read.

        state : FileState
          The file status.
  *)




  PROCEDURE BFWriteLn
             (VAR   FTable : FileBF;
              VAR   state  : Files.FileState);

  (**
      BFWriteLn - Terminate a line to a buffered file.


      Terminate a line on the buffered file.  This file should
      have been opened with the BFOpen procedure with modify
      permission.

      CALLING SEQUENCE -

        BFWriteLn (fTable, line, state)

      ENTRY -

        fTable : FileBF
          File table

      EXIT -

        state : FileState
          The file status.
  *)




  PROCEDURE BFWriteString
             (VAR   FTable : FileBF;
              CONST line   : ARRAY OF CHAR;
              VAR   state  : Files.FileState);

  (**
      BFWriteString - Write out a line to a buffered file.


      Write out a line to the buffered file.  This does not
      output a line terminator.  This file should have been
      opened with the BFOpen procedure with modify permission.

      CALLING SEQUENCE -

        BFWriteString (fTable, line, state)

      ENTRY -

        fTable : FileBF
          File table

        line : ARRAY OF CHAR
          Line to be written out.

      EXIT -

        state : FileState
          The file status.
  *)




  PROCEDURE BFWriteLine
             (VAR   FTable : FileBF;
              CONST line   : ARRAY OF CHAR;
              VAR   state  : Files.FileState);

  (**
      BFWriteLine - Write out a complete line to a buffered file.


      Write out a line to the buffered file.  This includes the
      the standard line terminators.  This file should have
      been opened with the BFOpen procedure with modify
      permission.

      CALLING SEQUENCE -

        BFWriteLine (fTable, line, state)

      ENTRY -

        fTable : FileBF
          File table

        line : ARRAY OF CHAR
          Line to be written out.

      EXIT -

        state : FileState
          The file status.
  *)




  PROCEDURE BFWriteChar
             (VAR   FTable : FileBF;
              CONST cc     : CHAR;
              VAR   state  : Files.FileState);

  (**
      BFWriteChar - Write out a character to a buffered file.


      Write out a character to the buffered file.  This file
      should have been opened with the BFOpen procedure with
      modify permission.

      CALLING SEQUENCE -

        BFWriteChar (fTable, cc, state)

      ENTRY -

        fTable : FileBF
          File table

        cc : CHAR
          Character to be written out.

      EXIT -

        state : FileState
          The file status.
  *)




  PROCEDURE BFWriteBlock
             (VAR   FTable : FileBF;
              CONST buf    : SYSTEM.ADDRESS;
              CONST nBytes : CARDINAL;
              VAR   state  : Files.FileState);

  (**
      BFWriteBlock - Write out a block of data to a buffered file.


      Write out a block of data to the buffered file.  This
      file should have been opened with the BFOpen procedure
      with modify permission.  This procedure writes out
      characters within the block without attempting to
      determine end of line characters, etc.

      CALLING SEQUENCE -

        BFWriteBlock (fTable, buf, nBytes, state)

      ENTRY -

        fTable : FileBF
          File table.

        buf : ADDRESS
          Address of the block of data to written out.

        nBytes : CARDINAL
          Number of bytes to write out.

      EXIT -

        state : FileState
          The file status.
  *)




  PROCEDURE BFWritePos
             (VAR   FTable  : FileBF;
              CONST buf     : SYSTEM.ADDRESS;
              CONST filePos : Files.FilePosition;
              CONST nBytes  : CARDINAL;
              VAR   state   : Files.FileState);

  (**
      BFWritePos - Write out a block of data to a file.


      Write a block of data to a specified position on a file
      without using buffering.  The read/write position of the
      file and its buffer are not disturbed by this operation
      so that continual sequential buffered I/O may occur after
      reading using BFReadPos.  This procedure may be called if
      the file has been opened with either READ or MODIFY
      permission.

      CALLING SEQUENCE -

        BFWritePos (fTable, buf, filePos, nBytes, state)

      ENTRY -

        fTable : FileBF
          File table.

        buf : ADDRESS
          Address of the block of data to written out.

        filePos : Files.FilePosition
          The position within the file to write to (0 .. n).

        nBytes : CARDINAL
          Number of bytes to write out.

      EXIT -

        state : FileState
          The file status.
  *)




  PROCEDURE BFStats
             (VAR   FTable     : FileBF;
              VAR   FileSize   : Files.FilePosition;
              VAR   currentPos : Files.FilePosition;
              VAR   state      : Files.FileState);

  (**
      BFStats - Return statistics on the file being processed.


      This procedure returns the current statistics for file
      identifed.

      CALLING SEQUENCE -

        BFStats (fTable, fileSize, currentPos, state)

      ENTRY -

        fTable : FileBF
          File table.

      EXIT -

        fileSize : Files.FilePosition
          Byte size of the file.

        currentPos : Files.FilePosition
          Next byte position that will be returned if a read
          is performed, or next byte position that will be
          written to if a write is performed.

        state : FileState
          The file status.
  *)




  PROCEDURE GetHandleState
             (CONST FTable : FileBF) : ModSys.HandleState;

  (**
      GetHandleState - Gets the current state of the handle (HandleOpened or HandleClosed).


      This procedure gets the state of the handle.  It returns one of two values depending
      on whether the handle is currently open or closed.

      CALLING SEQUENCE -

        GetHandleState (FTable);

      ENTRY -

        FTable : FileBF
          The file handle to be tested.

      EXIT -

        HandleState
          ModSys.HandleClosed - The handle is currently closed.
          ModSys.HandleOpen -  The handle is open for use.
  *)




Send mail to   warren.merrill@inl.gov with questions or comments about this web site.
Copyright © 1989-2006 Battelle Energy Alliance