home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / modu1096.zip / ISOsym / seqfile.def < prev    next >
Text File  |  1996-08-29  |  4KB  |  86 lines

  1. DEFINITION MODULE SeqFile;
  2.  
  3.     (* Rewindable sequential files *)
  4.  
  5. IMPORT IOChan, ChanConsts;
  6. FROM ChanConsts IMPORT ChanFlags;
  7.  
  8. TYPE
  9.   ChanId      = IOChan.ChanId;
  10.   FlagSet     = ChanConsts.FlagSet;
  11.   OpenResults = ChanConsts.OpenResults;
  12.  
  13.  
  14. (* Accept singleton values of FlagSet *)
  15. CONST
  16.   read  = FlagSet{readFlag}; (* input operations are requested/available *)
  17.   write = FlagSet{writeFlag};(* output operations are requested/available *)
  18.   old   = FlagSet{oldFlag};  (* file may/must/did exist before channel was opened *)
  19.   text  = FlagSet{textFlag}; (* text operations are requested/available *)
  20.   raw   = FlagSet{rawFlag};  (* raw operations are requested/available *)
  21.  
  22.  
  23. PROCEDURE OpenWrite (VAR cid   : ChanId;
  24.                          name  : ARRAY OF CHAR;
  25.                          flags : FlagSet;
  26.                      VAR res   : OpenResults);
  27. (* Attempts to obtain and open a channel connected to a stored rewindable file
  28.    The write flag is implied; without the raw flag, text is implied.
  29.    If successful, assigns to the parameter cid the identity of a channel
  30.    open to a stored file of the given name and assigns the value
  31.    opened to the parameter res.
  32.    The file is truncated to zero length.  Output mode is selected.
  33.    If a channel cannot be opened as required, the value of the parameter
  34.    res indicates the reason and cid identifies the bad channel. *)
  35.  
  36. PROCEDURE OpenAppend (VAR cid   : ChanId;
  37.                           name  : ARRAY OF CHAR;
  38.                           flags : FlagSet;
  39.                       VAR res   : OpenResults);
  40. (* Attempts to obtain and open a channel connected to a stored rewindable file
  41.    The write and old flags are implied; without the raw flag, text is implied.
  42.    If successful, assigns to the parameter cid the identity of a channel
  43.    open to a stored file of the given name and assigns the value
  44.    opened to the parameter res.
  45.    Output mode is selected and the write position corresponds to the
  46.    length of the file.
  47.    If a channel cannot be opened as required, the value of the parameter
  48.    res indicates the reason and cid identifies the bad channel. *)
  49.  
  50. PROCEDURE OpenRead (VAR cid   : ChanId;
  51.                         name  : ARRAY OF CHAR;
  52.                         flags : FlagSet;
  53.                     VAR res   : OpenResults);
  54. (* Attempts to obtain and open a channel connected to a stored rewindable file
  55.    The read and old flags are implied; without the raw flag, text is implied.
  56.    If successful, assigns to the parameter cid the identity of a channel
  57.    open to a stored file of the given name and assigns the value
  58.    opened to the parameter res.
  59.    Input mode is selected. The read position is at start of file.
  60.    If a channel cannot be opened as required, the value of the parameter
  61.    res indicates the reason and cid identifies the bad channel. *)
  62.  
  63. PROCEDURE IsSeqFile (cid : ChanId) : BOOLEAN;
  64. (* Tests if the channel is open to a rewindable sequential file *)
  65.  
  66. PROCEDURE Reread (cid : ChanId);
  67. (* If the channel is not open to a rewindable file, the exception
  68.    wrongDevice is raised. Otherwise, if successful, sets the read
  69.    position to the start of the file and selects input mode.
  70.    If the operation cannot be performed, perhaps because of
  71.    insufficient permissions, neither input nor output mode is selected. *)
  72.  
  73. PROCEDURE Rewrite (cid : ChanId);
  74. (* If the channel is not open to a rewindable file, the exception
  75.    wrongDevice is raised. Otherwise, if successful, truncates the
  76.    file to zero length and selects output mode.
  77.    If the operation cannot be performed, perhaps because of
  78.    insufficient permissions, neither input nor output mode is selected. *)
  79.  
  80. PROCEDURE Close (VAR cid : ChanId);
  81. (* If the channel is not open to a rewindable file, the exception
  82.    wrongDevice is raised. Otherwise, the channel is closed and the value
  83.    identifying the bad channel is assigned to the parameter cid. *)
  84.  
  85. END SeqFile.
  86.