help files
Z505 | PasWiki | FUQ | Search | Main Docs | API Guide



[Overview][Constants][Types][Procedures and functions][Variables] Reference for unit 'oldlinux' (#rtl)

OpenDir

Open directory for reading

Declaration

Source position: line 0

function OpenDir(

  f: pchar

):PDir;

function OpenDir(

  f: String

):PDir;

Description

OpenDir opens the directory f, and returns a pdir pointer to a Dir record, which can be used to read the directory structure. If the directory cannot be opened, nil is returned.

Errors

Errors are returned in LinuxError.

See also

CloseDir

  

Close directory file descriptor

ReadDir

  

Read entry from directory

SeekDir

  

Seek to position in directory

TellDir

  

Return current location in a directory

Example

Program Example35;

{ Program to demonstrate the
  OpenDir,ReadDir, SeekDir and TellDir functions. }

Uses oldlinux;

Var TheDir : PDir;
    ADirent : PDirent;
    Entry : Longint;

begin
  TheDir:=OpenDir('./.');
  Repeat
    Entry:=TellDir(TheDir);
    ADirent:=ReadDir (TheDir);
    If ADirent<>Nil then
      With ADirent^ do
        begin
        Writeln ('Entry No : ',Entry);
        Writeln ('Inode    : ',ino);
        Writeln ('Offset   : ',off);
        Writeln ('Reclen   : ',reclen);
        Writeln ('Name     : ',pchar(@name[0]));
        end;
  Until ADirent=Nil;
  Repeat
    Write ('Entry No. you would like to see again (-1 to stop): ');
    ReadLn (Entry);
    If Entry<>-1 then
      begin
      SeekDir (TheDir,Entry);
      ADirent:=ReadDir (TheDir);
      If ADirent<>Nil then
        With ADirent^ do
          begin
          Writeln ('Entry No : ',Entry);
          Writeln ('Inode    : ',ino);
          Writeln ('Offset   : ',off);
          Writeln ('Reclen   : ',reclen);
          Writeln ('Name     : ',pchar(@name[0]));
          end;
    end;
  Until Entry=-1;
  CloseDir (TheDir);
end.

Notes

 No notes exist for this page yet. 





lufdoc, Powtils, fpc, freepascal, delphi, kylix, c/c++, mysql, cgi web framework docs, Z505