1 /* Copyright (C) 1991, 2000 Aladdin Enterprises. All rights reserved. 2 3 This software is provided AS-IS with no warranty, either express or 4 implied. 5 6 This software is distributed under license and may not be copied, 7 modified or distributed except as expressly authorized under the terms 8 of the license contained in the file LICENSE in this distribution. 9 10 For more information about licensing, please refer to 11 http://www.ghostscript.com/licensing/. For information on 12 commercial licensing, go to http://www.artifex.com/licensing/ or 13 contact Artifex Software, Inc., 101 Lucas Valley Road #110, 14 San Rafael, CA 94903, U.S.A., +1(415)492-9861. 15 */ 16 17 /* $Id: stat_.h,v 1.10 2003/04/10 18:45:12 alexcher Exp $ */ 18 /* Generic substitute for Unix sys/stat.h */ 19 20 #ifndef stat__INCLUDED 21 # define stat__INCLUDED 22 23 /* We must include std.h before any file that includes sys/types.h. */ 24 #include "std.h" 25 26 /* Metrowerks Standard Library doesn't use subdirs */ 27 #ifdef __MWERKS__ 28 #include <stat.h> 29 #else 30 #include <sys/stat.h> 31 #endif 32 33 /* 34 * Many environments, including the MS-DOS compilers, don't define 35 * the st_blocks member of a stat structure. 36 */ 37 #if defined(__SVR3) || defined(__EMX__) || defined(__DVX__) || defined(OSK) || defined(__MSDOS__) || defined(__QNX__) || defined(VMS) || defined(__WIN32__) || defined(__IBMC__) || defined(__BEOS__) || defined(Plan9) || defined(__WATCOMC__) 38 # define stat_blocks(psbuf) (((psbuf)->st_size + 1023) >> 10) 39 #else 40 # define stat_blocks(psbuf) ((psbuf)->st_blocks) 41 #endif 42 43 /* 44 * Microsoft C uses _stat instead of stat, 45 * for both the function name and the structure name. 46 */ 47 #ifdef _MSC_VER 48 # define stat _stat 49 #endif 50 51 /* 52 * Some (System V?) systems test for directories in a slightly different way. 53 */ 54 #if defined(OSK) || !defined(S_ISDIR) 55 # ifdef S_IFDIR 56 # define stat_is_dir(stbuf) ((stbuf).st_mode & S_IFDIR) 57 # else 58 # ifdef _S_IFDIR 59 # define stat_is_dir(stbuf) ((stbuf).st_mode & _S_IFDIR) 60 # endif 61 # endif 62 #else 63 # define stat_is_dir(stbuf) S_ISDIR((stbuf).st_mode) 64 #endif 65 66 /* 67 * Some systems have S_IFMT and S_IFCHR but not S_ISCHR. 68 */ 69 #if !defined(S_ISCHR) || !defined(S_ISREG) 70 # ifndef S_IFMT 71 # ifdef _S_IFMT 72 # define S_IFMT _S_IFMT 73 # define S_IFCHR _S_IFCHR 74 # define S_IFREG _S_IFREG 75 # else 76 # ifdef __S_IFMT 77 # define S_IFMT __S_IFMT 78 # define S_IFCHR __S_IFCHR 79 # define S_IFREG __S_IFREG 80 # endif 81 # endif 82 # endif 83 # define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) 84 # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) 85 #endif 86 87 /* 88 * Microsoft C doesn't define S_IRUSR or S_IWUSR. 89 */ 90 #ifndef S_IRUSR 91 # ifndef S_IREAD 92 # define S_IRUSR _S_IREAD 93 # else 94 # define S_IRUSR S_IREAD 95 # endif 96 #endif 97 #ifndef S_IWUSR 98 # ifndef S_IWRITE 99 # define S_IWUSR _S_IWRITE 100 # else 101 # define S_IWUSR S_IWRITE 102 # endif 103 #endif 104 105 #endif /* stat__INCLUDED */ 106