1/* 2** Copyright (C) 2002-2017 Erik de Castro Lopo <erikd@mega-nerd.com> 3** 4** This program is free software; you can redistribute it and/or modify 5** it under the terms of the GNU Lesser General Public License as published by 6** the Free Software Foundation; either version 2.1 of the License, or 7** (at your option) any later version. 8** 9** This program is distributed in the hope that it will be useful, 10** but WITHOUT ANY WARRANTY; without even the implied warranty of 11** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12** GNU Lesser General Public License for more details. 13** 14** You should have received a copy of the GNU Lesser General Public License 15** along with this program; if not, write to the Free Software 16** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17*/ 18 19/* Microsoft declares some 'unistd.h' functions in 'io.h'. */ 20 21#include <sys/stat.h> 22#ifdef HAVE_IO_H 23#include <io.h> 24#endif 25 26/* Some defines that microsoft 'forgot' to implement. */ 27 28#ifndef R_OK 29#define R_OK 4 /* Test for read permission. */ 30#endif 31 32#ifndef W_OK 33#define W_OK 2 /* Test for write permission. */ 34#endif 35 36#ifndef X_OK 37#ifdef _WIN32 38#define X_OK 0 39#else 40#define X_OK 1 /* execute permission - unsupported in windows*/ 41#endif 42#endif 43 44#ifndef F_OK 45#define F_OK 0 /* Test for existence. */ 46#endif 47 48#ifndef S_IRWXU 49#define S_IRWXU 0000700 /* rwx, owner */ 50#endif 51 52#ifndef S_IRUSR 53#define S_IRUSR 0000400 /* read permission, owner */ 54#endif 55 56#ifndef S_IWUSR 57#define S_IWUSR 0000200 /* write permission, owner */ 58#endif 59 60#ifndef S_IXUSR 61#define S_IXUSR 0000100 /* execute/search permission, owner */ 62#endif 63 64/* Windows (except MinGW) doesn't have group permissions so set all these to zero. */ 65#ifndef S_IRWXG 66#define S_IRWXG 0 /* rwx, group */ 67#endif 68 69#ifndef S_IRGRP 70#define S_IRGRP 0 /* read permission, group */ 71#endif 72 73#ifndef S_IWGRP 74#define S_IWGRP 0 /* write permission, grougroup */ 75#endif 76 77#ifndef S_IXGRP 78#define S_IXGRP 0 /* execute/search permission, group */ 79#endif 80 81/* Windows (except MinGW) doesn't have others permissions so set all these to zero. */ 82#ifndef S_IRWXO 83#define S_IRWXO 0 /* rwx, other */ 84#endif 85 86#ifndef S_IROTH 87#define S_IROTH 0 /* read permission, other */ 88#endif 89 90#ifndef S_IWOTH 91#define S_IWOTH 0 /* write permission, other */ 92#endif 93 94#ifndef S_IXOTH 95#define S_IXOTH 0 /* execute/search permission, other */ 96#endif 97 98#ifndef S_ISFIFO 99#define S_ISFIFO(mode) (((mode) & _S_IFMT) == _S_IFIFO) 100#endif 101 102#ifndef S_ISREG 103#define S_ISREG(mode) (((mode) & _S_IFREG) == _S_IFREG) 104#endif 105 106/* 107** Don't know if these are still needed. 108** 109** #define _IFMT _S_IFMT 110** #define _IFREG _S_IFREG 111*/ 112 113