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