Unit 'amigados' Package
[Overview][Constants][Types][Procedures and functions][Index] [#os4units]

Examine

Examine a directory or file associated with a lock

Declaration

Source position: amigados.pas line 2441

function Examine(

  Lock: LongInt;

  FileInfoBlock: PFileInfoBlock

):LongBool;

Arguments

Lock

  

Pointer to a Lock

FileInfoBlock

  

allocated File info Block

Description

Examine() fills in information in the TFileInfoBlock concerning the file or directory associated with the lock. This information includes the name, size, creation date and whether it is a file or directory. FileInfoBlock must be longword aligned. Examine() gives a return code of False if it fails.

You may make a local copy of the TFileInfoBlock, as long as it is never passed to ExNext().

So, follow these steps to examine a directory:

  1. Pass a Lock and a FileInfoBlock to Examine(). The lock must be on the directory you wish to examine.
  2. Pass ExNext() the same lock and TFileInfoBlock.
  3. Do something with the information returned in the TFileInfoBlock. Note that the fib_DirEntryType field is positive for directories, negative for files.
  4. Keep calling ExNext() until it returns False. Check IoErr() to ensure that the reason for failure was ERROR_NO_MORE_ENTRIES.

See also

Lock

  

Lock a directory or file

UnLock

  

Unlock a directory or file

ExNext

  

Examine the next entry in a directory

ExamineFH

  

Gets information on an open file

ExAll

  

Examine an entire directory

Example

program ExamineTest;
uses
  AmigaDos;
procedure CheckDir(ALock: BPTR);
var
  FIB: PFileInfoBlock;
begin
  FIB := AllocDosObject(DOS_FIB, nil);
  if Assigned(FIB) then
  begin
    if Examine(ALock, FIB) <> 0 then
    begin
      repeat
        writeln(FIB^.fib_FileName);
      until ExNext(ALock, FIB) = 0;
    end;
    if IOErr() = ERROR_NO_MORE_ENTRIES then
      writeln('nothing more found')
    else
      writeln('Something went wrong ', IOErr);
    FreeDosObject(DOS_FIB, FIB);
  end;
end;
var
  RAMLock: BPTR;
begin
  RAMLock := Lock('RAM:', SHARED_LOCK);
  CheckDir(RAMLock);
  unlock(RAMLock);
end.

Documentation generated on: 2021-07-30