next up previous contents index
Next: fdClose Up: Functions and procedures Previous: FD_IsSet

fdOpen

   

Declaration:

Function fdOpen (pathname:string;flags:longint[; Mode: longint]) : longint;

Description:

fdOpen opens a file in pathname with flags flags a ORed combination of Open_Accmode, Open_RdOnly, Open_WrOnly, Open_RdWr, Open_Creat, Open_Excl, Open_NoCtty, Open_Trunc, Open_Append, Open_NonBlock, Open_NDelay, Open_Sync

The optional mode argument specifies the permissions to set when opening the file. This is modified by the umask setting. The real permissions are Mode and not umask.

The return value of the function is the filedescriptor, or a negative value if there was an error.

Errors:

Errors are returned in LinuxError

See also:

fdClose, fdRead, fdWrite,fdTruncate

Example
Program Example19;

{ Program to demonstrate the fdOpen, fdwrite and fdCLose functions. }

Uses linux;

Const Line : String[80] = 'This is easy writing !';

Var FD : Longint;

begin
  FD:=fdOpen ('Test.dat',Open_WrOnly or Open_Creat);
  if FD>0 then
    begin
    if length(Line)<>fdwrite (FD,Line[1],Length(Line)) then
      Writeln ('Error when writing to file !');
    fdClose(FD);
    end;
end.



Michael Van Canneyt
Tue Mar 31 16:46:10 CEST 1998