home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / NWTP04 / XSERV / GETOFIL.PAS < prev    next >
Pascal/Delphi Source File  |  1993-12-29  |  3KB  |  103 lines

  1. { Skeleton of the program; still to be worked out when File and Directory
  2.   Services are finished. }
  3.  
  4.  
  5.        LastRecordSeen is an i/o parameter;
  6.        -An initial value of 0 has to be supplied;
  7.        -The function can be called until LastRecordSeen becomes 0,
  8.         indicating the end of the FIR-list.
  9.  
  10.  
  11.        Type TfileInfoRecord is declared in unit nwServ:
  12.  
  13.        Type TfileInfoRecord=record
  14.                 taskNbr   :Byte;
  15.                 lockFlag  :Byte;
  16.                 AccessFlag:Byte;
  17.                 LockType  :Byte;
  18.                 volumeNbr :Byte; { 0..31 }
  19.                 DirEntry  :Word;
  20.                 FileName  :string[13];
  21.                 end;
  22.  
  23.        LockType =  00 no lock;
  24.                FE file lock;
  25.                FF locked by Begin Share File Set
  26.  
  27.        Bitfields for lock flags:
  28.         bit 0       file is locked
  29.         bit 1       file opened Shareable
  30.         bit 2       logged
  31.         bit 3       file opened Normal
  32.         bit 6       TTS holding lock
  33.         bit 7       Transaction Flag set on file
  34.  
  35.        Bitfields for access flags:
  36.         bit 0       file open for reading by calling station
  37.         bit 1       file open for writing by calling station
  38.         bit 2       deny reads by other stations
  39.         bit 3       deny writes by other stations
  40.         bit 4       file detached
  41.         bit 5       TTS Holding Detach
  42.         bit 6       TTS Holding Open
  43.  
  44.        The calling workstation must have console operator privileges.
  45.  
  46. SeeAlso  : GetPathFromDirectoryEntry,CheckConsolePrivileges.
  47.  
  48. Example  :
  49.  
  50.   Var lastRec: word;
  51.  
  52.       FIR:TfileInfoRecord;
  53.  
  54.  
  55.   GetConnectionID(serverName,connID); { Get the connection ID of the
  56.                     current server with the function
  57.                     getConnectionID ( or determine
  58.                     the connectionID of other servers
  59.                     thru other calls ) }
  60.   GetPreferredServer(oldConnID);
  61.   SetPreferredServer(connID);  { Save old Preferred Server Number and
  62.                  make server 'ConnID' the preferred
  63.                  server. FROM NOW ON, ALL REQUESTS/
  64.                  functions WILL BE SERVICED BY -THIS-
  65.                  SERVER. }
  66.  
  67.   IF NOT CheckConsolePrivileges  { You can use the function
  68.                    CheckConsolePrivileges to avoid
  69.                    console privilege errors in the
  70.                    getConnectionsOpenFiles Function. }
  71.    then begin
  72.     writeln('!error..etc..');
  73.     halt(1)
  74.     end;
  75.  
  76.   GetConnectionNumber(connNmbr);{ Use the getConnectionNumber to get
  77.                   your connectionNumber (or other
  78.                   calls to get other Object connection
  79.                   numbers) }
  80.  
  81.   SetPreferredServer(oldConnID); { From now on, all requests/functions
  82.                    will again be serviced by the original
  83.                    server. Note that the
  84.                    GetConnectionsOpenFiles function has
  85.                    its own connectionID parameter, it
  86.                    takes care of its own server routing. }
  87.  
  88.   LastRec:=0; (initial value must be 0 )
  89.  
  90.   While GetConnectionsOpenFiles(connID,connNmbr,lastRec,FIR)
  91.     AND (lastRec<>0)
  92.   do begin
  93.      {..work with -or- analyze FIR..}
  94.      {..filename= FIR.Filename (max 14 chars), to get full filename}
  95.      {..call the GetPathFromDirectoryEntryFunction:}
  96.  
  97.      GetPathFromDirectoryEntry(connID,FIR.volumeNbr,FIR.DirEntry,Path);
  98.      writeln(Path);
  99.  
  100.      end;
  101.  
  102.  
  103.