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

Utime

Set access and modification times of a file (touch).

Declaration

Source position: oldlinux.pp line 1399

function Utime(

  const path: PathStr;

  utim: UTimeBuf

):Boolean;

Description

Utime sets the access and modification times of a file. the utimbuf record contains 2 fields, actime, and modtime, both of type Longint. They should be filled with an epoch-like time, specifying, respectively, the last access time, and the last modification time. For some filesystem (most notably, FAT), these times are the same.

Errors

Errors are returned in LinuxError.

sys_eaccess
One of the directories in Path has no search (=execute) permission.
sys_enoent
A directory entry in Path does not exist or is a symbolic link pointing to a non-existent directory.

Other errors may occur, but aren't documented.

See also

GetEpochTime

  

Return the current unix time

Chown

  

Change owner of file

Access

  

Check file access

Example

Program Example25;

{ Program to demonstrate the UTime function. }

Uses oldlinux;

Var utim : utimbuf;
    year,month,day,hour,minute,second : Word;

begin
  { Set access and modification time of executable source }
  GetTime (hour,minute,second);
  GetDate (year,month,day);
  utim.actime:=LocalToEpoch(year,month,day,hour,minute,second);
  utim.modtime:=utim.actime;
  if not Utime('ex25.pp',utim) then
    writeln ('Call to UTime failed !')
  else
    begin
    Write ('Set access and modification times to : ');
    Write (Hour:2,':',minute:2,':',second,', ');
    Writeln (Day:2,'/',month:2,'/',year:4);
    end;
end.
The latest version of this document can be found at lazarus-ccr.sourceforge.net.