next up previous contents index
Next: fdRead Up: Functions and procedures Previous: fdFlush

fdOpen

   

Declaration:

Function fdOpen (Var PathName;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 PathName can be of type PChar or String

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, fdFlush, fdSeek

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
Thu Sep 10 13:59:33 CEST 1998