home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !gcc / include / libscl / sys / h / stat < prev    next >
Encoding:
Text File  |  2006-09-17  |  5.6 KB  |  153 lines

  1. /* sys/stat.h extension header for the RISC OS SharedCLibrary.
  2.    Copyright (c) 1997-2005 Nick Burrett
  3.    All rights reserved.
  4.  
  5.    Redistribution and use in source and binary forms, with or without
  6.    modification, are permitted provided that the following conditions
  7.    are met:
  8.    1. Redistributions of source code must retain the above copyright
  9.       notice, this list of conditions and the following disclaimer.
  10.    2. Redistributions in binary form must reproduce the above copyright
  11.       notice, this list of conditions and the following disclaimer in the
  12.       documentation and/or other materials provided with the distribution.
  13.    3. The name of the author may not be used to endorse or promote products
  14.       derived from this software without specific prior written permission.
  15.  
  16.    THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  17.    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18.    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19.    IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  20.    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21.    NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22.    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23.    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24.    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25.    THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
  26.  
  27. #ifndef __SYS_STAT_H
  28. #define __SYS_STAT_H
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. struct stat
  35.   {
  36.   __dev_t     st_dev; /* Device containing the file.  */
  37.   __ino_t     st_ino; /* File serial number.  */
  38.   __mode_t     st_mode; /* File mode.  */
  39.   __nlink_t    st_nlink; /* Link count.  */
  40.   __uid_t    st_uid; /* User ID of the file's owner.  */
  41.   __gid_t    st_gid; /* Group ID of the file's group. */
  42.   __dev_t     st_rdev; /* Device number, if device.  */
  43.   __off_t     st_size; /* Size of file, in bytes.  */
  44.   __time_t    st_atime; /* Time of last access.  */
  45.   unsigned long int st_atime_usec;
  46.   __time_t    st_mtime; /* Time of last modification.  */
  47.   unsigned long int st_mtime_usec;
  48.   __time_t    st_ctime; /* Time of last status change.  */
  49.   unsigned long int st_ctime_usec;
  50.   unsigned long int st_blksize; /* Optimal block size for I/O.  */
  51. #define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
  52.   unsigned long int st_blocks; /* Number of 512-byte blocks allocated.  */
  53.   };
  54.  
  55. /* Bit masks.  */
  56.  
  57. /* Extract the file type code portion of a mode value.  */
  58. #define S_IFMT        0770000
  59.  
  60. /* File type code for a FIFO or pipe.  */
  61. #define S_IFIFO     0010000
  62. #define S_IFPORT    S_IFIFO
  63. /* File type code for a terminal type device file.  */
  64. #define S_IFCHR     0020000
  65. /* File type code for a directory. */
  66. #define S_IFDIR     0040000
  67. /* File type code for a block-oriented device file (disk file).  */
  68. #define S_IFBLK     0100000
  69. /* File type code for a regular file.  */
  70. #define S_IFREG     0200000
  71. /* File type code for a symbolic link.  */
  72. #define S_IFLNK     0400000
  73. /* This is the set-user-ID on execute bit.  */
  74. #define S_ISUID     0004000
  75. /* This is the set-group-ID on execute bit.  */
  76. #define S_ISGID     0002000
  77. /* Socket.  */
  78. #define S_IFSOCK        0140000
  79.  
  80. /* Protection bits.  */
  81.  
  82. /* Save swapped text after use. */
  83. #define S_ISVTX     01000
  84. /* Read by owner.  */
  85. #define S_IREAD         0400
  86. /* Write by owner.  */
  87. #define S_IWRITE    0200
  88. /* Execute by owner.  */
  89. #define S_IEXEC        0100
  90.  
  91. /* Execute (for ordinary files) or search (for directories)
  92.    permission bit for the owner of the file.  */
  93. #define S_IXUSR        S_IEXEC
  94. /* Write permission bit for the owner of the file.  */
  95. #define S_IWUSR            S_IWRITE
  96. /* Read permission bit for the owner of the file.  */
  97. #define S_IRUSR        S_IREAD
  98.  
  99. /* Read, write and execute by owner.  */
  100. #define S_IRWXU (S_IREAD | S_IWRITE | S_IEXEC)
  101.  
  102. #define S_IRGRP    (S_IRUSR >> 3)    /* Read by group.  */
  103. #define S_IWGRP    (S_IWUSR >> 3)    /* Write by group.  */
  104. #define S_IXGRP    (S_IXUSR >> 3)    /* Execute by group.  */
  105. /* Read, write, and execute by group.  */
  106. #define S_IRWXG    (S_IRWXU >> 3)
  107.  
  108. #define S_IROTH    (S_IRGRP >> 3)    /* Read by others.  */
  109. #define S_IWOTH    (S_IWGRP >> 3)    /* Write by others.  */
  110. #define S_IXOTH    (S_IXGRP >> 3)    /* Execute by others.  */
  111. /* Read, write, and execute by others.  */
  112. #define S_IRWXO    (S_IRWXG >> 3)
  113.  
  114.  
  115.  
  116. /* Return nonzero if the file is a directory.  */
  117. #define S_ISDIR(x) (((x) & S_IFSOCK) == S_IFDIR)
  118. /* Return nonzero if the file is a terminal type device.  */
  119. #define S_ISCHR(x) ((x) & S_IFCHR)
  120. /* Return nonzero if the file is a block special file (like a disk). */
  121. #define S_ISBLK(x) (((x) & S_IFSOCK) == S_IFBLK)
  122. /* Return nonzero if the file is a regular file.  */
  123. #define S_ISREG(x) ((x) & S_IFREG)
  124. /* Return nonzero if the file is a FIFO file for pipe.  */
  125. #define S_ISFIFO(x) ((x) & S_IFIFO)
  126. /* Return nonzero if the file is a symbolic link.  */
  127. #define S_ISLNK(x) ((x) & S_IFLNK)
  128. /* Return nonzero if the file is a socket.  */
  129. #define S_ISSOCK(x) (((x) & S_IFSOCK) == S_IFSOCK)
  130.  
  131. extern int stat (const char *__filename, struct stat *__buf);
  132. extern int lstat (const char *__filename, struct stat *__buf);
  133. extern int fstat (int __fd, struct stat *__buf);
  134.  
  135. /* Set file access permissions for file to mode.  */
  136. extern int chmod (const char *file, __mode_t mode);
  137.  
  138. /* Set file access permissions of the file fd is open on to mode.  */
  139. extern int fchmod (int fd, __mode_t mode);
  140.  
  141. /* Set the file creation mask of the current process to mask,
  142.    return the old creation mask.  */
  143. extern __mode_t umask (__mode_t mask);
  144.  
  145. /* Create a new directory named path, with permission bits mode.  */
  146. extern int mkdir (const char *path, __mode_t mode);
  147.  
  148. #ifdef __cplusplus
  149.     }
  150. #endif
  151.  
  152. #endif
  153.