1Tcl_Access(3)               Tcl Library Procedures               Tcl_Access(3)
2
3
4
5______________________________________________________________________________
6

NAME

8       Tcl_Access, Tcl_Stat - check file permissions and other attributes
9

SYNOPSIS

11       #include <tcl.h>
12
13       int
14       Tcl_Access(path, mode)
15
16       int
17       Tcl_Stat(path, statPtr)
18

ARGUMENTS

20       const char *path (in)              Native name of the file to check the
21                                          attributes of.
22
23       int mode (in)                      Mask consisting of one  or  more  of
24                                          R_OK,  W_OK,  X_OK  and  F_OK. R_OK,
25                                          W_OK  and  X_OK   request   checking
26                                          whether  the  file  exists  and  has
27                                          read, write and execute permissions,
28                                          respectively.   F_OK just requests a
29                                          check for the existence of the file.
30
31       struct stat *statPtr (out)         The structure that contains the  re‐
32                                          sult.
33______________________________________________________________________________
34

DESCRIPTION

36       As of Tcl 8.4, the object-based APIs Tcl_FSAccess and Tcl_FSStat should
37       be used in preference to Tcl_Access and  Tcl_Stat,  wherever  possible.
38       Those  functions  also  support  Tcl's  virtual filesystem layer, which
39       these do not.
40
41   OBSOLETE FUNCTIONS
42       There are two reasons for calling Tcl_Access and Tcl_Stat  rather  than
43       calling  system  level  functions access and stat directly.  First, the
44       Windows implementation of both functions fixes some bugs in the  system
45       level calls. Second, both Tcl_Access and Tcl_Stat (as well as Tcl_Open‐
46       FileChannelProc) hook into a linked list of functions. This allows  the
47       possibility to reroute file access to alternative media or access meth‐
48       ods.
49
50       Tcl_Access checks whether the process would be allowed to  read,  write
51       or  test  for existence of the file (or other file system object) whose
52       name is path. If path is a symbolic link on Unix, then  permissions  of
53       the file referred by this symbolic link are tested.
54
55       On  success  (all  requested permissions granted), zero is returned. On
56       error (at least one bit in mode asked for a permission that is  denied,
57       or some other error occurred), -1 is returned.
58
59       Tcl_Stat  fills  the  stat structure statPtr with information about the
60       specified file. You do not need any access rights to the  file  to  get
61       this information but you need search rights to all directories named in
62       the path leading to the file. The stat structure includes info  regard‐
63       ing  device, inode (always 0 on Windows), privilege mode, nlink (always
64       1 on Windows), user id (always 0 on Windows), group  id  (always  0  on
65       Windows),  rdev  (same  as  device on Windows), size, last access time,
66       last modification time, and creation time.
67
68       If path exists, Tcl_Stat returns 0 and the  stat  structure  is  filled
69       with data. Otherwise, -1 is returned, and no stat info is given.
70

KEYWORDS

72       stat, access
73

SEE ALSO

75       Tcl_FSAccess(3), Tcl_FSStat(3)
76
77
78
79Tcl                                   8.1                        Tcl_Access(3)
Impressum