home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !gcc / include / libscl / sys / h / stat < prev    next >
Encoding:
Text File  |  2004-09-05  |  4.1 KB  |  128 lines

  1.  
  2. #ifndef __SYS_STAT_H
  3. #define __SYS_STAT_H
  4.  
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8.  
  9. struct stat
  10.   {
  11.   __dev_t     st_dev; /* Device containing the file.  */
  12.   __ino_t     st_ino; /* File serial number.  */
  13.   __mode_t     st_mode; /* File mode.  */
  14.   __nlink_t    st_nlink; /* Link count.  */
  15.   __uid_t    st_uid; /* User ID of the file's owner.  */
  16.   __gid_t    st_gid; /* Group ID of the file's group. */
  17.   __dev_t     st_rdev; /* Device number, if device.  */
  18.   __off_t     st_size; /* Size of file, in bytes.  */
  19.   __time_t    st_atime; /* Time of last access.  */
  20.   unsigned long int st_atime_usec;
  21.   __time_t    st_mtime; /* Time of last modification.  */
  22.   unsigned long int st_mtime_usec;
  23.   __time_t    st_ctime; /* Time of last status change.  */
  24.   unsigned long int st_ctime_usec;
  25.   unsigned long int st_blksize; /* Optimal block size for I/O.  */
  26. #define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
  27.   unsigned long int st_blocks; /* Number of 512-byte blocks allocated.  */
  28.   };
  29.  
  30. /* Bit masks.  */
  31.  
  32. /* Extract the file type code portion of a mode value.  */
  33. #define S_IFMT        0770000
  34.  
  35. /* File type code for a FIFO or pipe.  */
  36. #define S_IFIFO     0010000
  37. #define S_IFPORT    S_IFIFO
  38. /* File type code for a terminal type device file.  */
  39. #define S_IFCHR     0020000
  40. /* File type code for a directory. */
  41. #define S_IFDIR     0040000
  42. /* File type code for a block-oriented device file (disk file).  */
  43. #define S_IFBLK     0100000
  44. /* File type code for a regular file.  */
  45. #define S_IFREG     0200000
  46. /* File type code for a symbolic link.  */
  47. #define S_IFLNK     0400000
  48. /* This is the set-user-ID on execute bit.  */
  49. #define S_ISUID     0004000
  50. /* This is the set-group-ID on execute bit.  */
  51. #define S_ISGID     0002000
  52. /* Socket.  */
  53. #define S_IFSOCK        0140000
  54.  
  55. /* Protection bits.  */
  56.  
  57. /* Save swapped text after use. */
  58. #define S_ISVTX     01000
  59. /* Read by owner.  */
  60. #define S_IREAD         0400
  61. /* Write by owner.  */
  62. #define S_IWRITE    0200
  63. /* Execute by owner.  */
  64. #define S_IEXEC        0100
  65.  
  66. /* Execute (for ordinary files) or search (for directories)
  67.    permission bit for the owner of the file.  */
  68. #define S_IXUSR        S_IEXEC
  69. /* Write permission bit for the owner of the file.  */
  70. #define S_IWUSR            S_IWRITE
  71. /* Read permission bit for the owner of the file.  */
  72. #define S_IRUSR        S_IREAD
  73.  
  74. /* Read, write and execute by owner.  */
  75. #define S_IRWXU (S_IREAD | S_IWRITE | S_IEXEC)
  76.  
  77. #define S_IRGRP    (S_IRUSR >> 3)    /* Read by group.  */
  78. #define S_IWGRP    (S_IWUSR >> 3)    /* Write by group.  */
  79. #define S_IXGRP    (S_IXUSR >> 3)    /* Execute by group.  */
  80. /* Read, write, and execute by group.  */
  81. #define S_IRWXG    (S_IRWXU >> 3)
  82.  
  83. #define S_IROTH    (S_IRGRP >> 3)    /* Read by others.  */
  84. #define S_IWOTH    (S_IWGRP >> 3)    /* Write by others.  */
  85. #define S_IXOTH    (S_IXGRP >> 3)    /* Execute by others.  */
  86. /* Read, write, and execute by others.  */
  87. #define S_IRWXO    (S_IRWXG >> 3)
  88.  
  89.  
  90.  
  91. /* Return nonzero if the file is a directory.  */
  92. #define S_ISDIR(x) (((x) & S_IFSOCK) == S_IFDIR)
  93. /* Return nonzero if the file is a terminal type device.  */
  94. #define S_ISCHR(x) ((x) & S_IFCHR)
  95. /* Return nonzero if the file is a block special file (like a disk). */
  96. #define S_ISBLK(x) (((x) & S_IFSOCK) == S_IFBLK)
  97. /* Return nonzero if the file is a regular file.  */
  98. #define S_ISREG(x) ((x) & S_IFREG)
  99. /* Return nonzero if the file is a FIFO file for pipe.  */
  100. #define S_ISFIFO(x) ((x) & S_IFIFO)
  101. /* Return nonzero if the file is a symbolic link.  */
  102. #define S_ISLNK(x) ((x) & S_IFLNK)
  103. /* Return nonzero if the file is a socket.  */
  104. #define S_ISSOCK(x) (((x) & S_IFSOCK) == S_IFSOCK)
  105.  
  106. extern int stat (const char *__filename, struct stat *__buf);
  107. extern int lstat (const char *__filename, struct stat *__buf);
  108. extern int fstat (int __fd, struct stat *__buf);
  109.  
  110. /* Set file access permissions for file to mode.  */
  111. extern int chmod (const char *file, __mode_t mode);
  112.  
  113. /* Set file access permissions of the file fd is open on to mode.  */
  114. extern int fchmod (int fd, __mode_t mode);
  115.  
  116. /* Set the file creation mask of the current process to mask,
  117.    return the old creation mask.  */
  118. extern __mode_t umask (__mode_t mask);
  119.  
  120. /* Create a new directory named path, with permission bits mode.  */
  121. extern int mkdir (const char *path, __mode_t mode);
  122.  
  123. #ifdef __cplusplus
  124.     }
  125. #endif
  126.  
  127. #endif
  128.