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



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

Chmod

Change file permission bits

Declaration

Source position: oldlinux.pp line 1398

function Chmod(

  path: PathStr;

  Newmode: LongInt

):Boolean;

Description

Chmod Sets the Mode bits of the file in Path to NewMode. Newmode can be specified by 'or'-ing the following:

S_ISUID
Set user ID on execution.
S_ISGID
Set Group ID on execution.
S_ISVTX
Set sticky bit.
S_IRUSR
Read by owner.
S_IWUSR
Write by owner.
S_IXUSR
Execute by owner.
S_IRGRP
Read by group.
S_IWGRP
Write by group.
S_IXGRP
Execute by group.
S_IROTH
Read by others.
S_IWOTH
Write by others.
S_IXOTH
Execute by others.
S_IRWXO
Read, write, execute by others.
S_IRWXG
Read, write, execute by groups.
S_IRWXU
Read, write, execute by user.

Errors

Errors are returned in LinuxError.

sys_eperm
The effective UID doesn't match the ownership of the file, and is not zero. Owner or group were not specified correctly.
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.
sys_enomem
Insufficient kernel memory.
sys_erofs
The file is on a read-only filesystem.
sys_eloop
Path has a reference to a circular symbolic link, i.e. a symbolic link, whose expansion points to itself.

See also

Chown

  

Change owner of file

Access

  

Check file access

Octal

  

Convert octal to decimal value

Example

Program Example23;

{ Program to demonstrate the Chmod function. }

Uses oldlinux;

Var F : Text;

begin
  { Create a file }
  Assign (f,'testex21');
  Rewrite (F);
  Writeln (f,'#!/bin/sh');
  Writeln (f,'echo Some text for this file');
  Close (F);
  { Octal() makes the correct number from a
    number that LOOKS octal }
  Chmod ('testex21',octal (777));
  { File is now executable  }
  execl ('./testex21');
end.

Notes

 No notes exist for this page yet. 





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