Unit 'AmigaDOS' Package
[Overview][Constants][Types][Procedures and functions][Variables][Index] [#morphunits]

ExNext64

Examine the next entry in a directory.

Declaration

Source position: amigados.pas line 2306

function ExNext64(

  Lock: LongInt;

  Fib: PFileInfoBlock;

  Tags: Pointer

):LongInt;

Arguments

Lock

  

lock on the direcory the contents of which to examine

Fib

  

A FileInfoBlock previously initialized by Examine64() (or used before with ExNext64()), fib_Size64 contains the size of the file. fib_NumBlocks64 contains the number of blocks for the file.

Tags

  

tags, no tags defined for now, supply nil

Function result

= 0 for fail, <> 0 for success whether the operation was successful or not. A failure occurs also if there is no "next" entry in the directory. Then IoErr() equals ERROR_NO_MORE_ENTRIES.

Description

If scanning a filesystem tree recursively, you'll need to allocated a new PFileInfoBlock for each directory level.

To examine a directory, do the following:

  1. Pass a lock on the directory and a PFileInfoBlock (allocated by AllocDosObject()) to Examine64().
  2. Pass the same parameters to ExNext64()).
  3. Do something with the PFileInfoBlock returned.
  4. Call ExNext64() repeatedly until it returns FALSE and use the information you are provided. When ExNext64 returns False, check IoErr() to make sure that there was no real failure (ERROR_NO_MORE_ENTRIES).

See also

Examine64

  

Fill in a FileInfoBlock structure concerning a file or directory associated with a particular lock.

AllocDosObject

  

Creates a dos object

ExAll

  

Examine an entire directory

IOErr

  

Return extra information from the system

Example

program Examine64Test;
uses
  AmigaDos;
procedure CheckDir(ALock: BPTR);
var
  FIB: PFileInfoBlock;
begin
  FIB := AllocDosObject(DOS_FIB, nil);
  if Assigned(FIB) then
  begin
    if Examine64(ALock, FIB, nil) <> 0 then
    begin
      repeat
        writeln(FIB^.fib_FileName);
      until ExNext64(ALock, FIB, nil) = 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