1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 17 * All rights reserved. 18 */ 19 20 #pragma once 21 22 /** \file 23 * \ingroup bli 24 * \brief Compatibility-like things for windows. 25 */ 26 27 #ifndef _WIN32 28 # error "This include is for Windows only!" 29 #endif 30 31 #include "BLI_sys_types.h" 32 33 #define WIN32_LEAN_AND_MEAN 34 35 #include <windows.h> 36 37 #undef rad 38 #undef rad1 39 #undef rad2 40 #undef rad3 41 #undef vec 42 #undef rect 43 #undef rct1 44 #undef rct2 45 46 #undef small 47 48 // These definitions are also in BLI_math for simplicity 49 50 #ifdef __cplusplus 51 extern "C" { 52 #endif 53 54 #if !defined(_USE_MATH_DEFINES) 55 # define _USE_MATH_DEFINES 56 #endif 57 58 #define MAXPATHLEN MAX_PATH 59 60 #ifndef S_ISREG 61 # define S_ISREG(x) (((x)&_S_IFREG) == _S_IFREG) 62 #endif 63 #ifndef S_ISDIR 64 # define S_ISDIR(x) (((x)&_S_IFDIR) == _S_IFDIR) 65 #endif 66 67 /* defines for using ISO C++ conformant names */ 68 #if !defined(_MSC_VER) || _MSC_VER < 1900 69 # define snprintf _snprintf 70 #endif 71 72 #if defined(_MSC_VER) 73 # define R_OK 4 74 # define W_OK 2 75 // not accepted by access() on windows 76 //# define X_OK 1 77 # define F_OK 0 78 #endif 79 80 typedef unsigned int mode_t; 81 82 #ifndef _SSIZE_T_ 83 # define _SSIZE_T_ 84 /* python uses HAVE_SSIZE_T */ 85 # ifndef HAVE_SSIZE_T 86 # define HAVE_SSIZE_T 1 87 typedef SSIZE_T ssize_t; 88 # endif 89 #endif 90 91 /* Directory reading compatibility with UNIX. */ 92 struct dirent { 93 int d_ino; 94 int d_off; 95 unsigned short d_reclen; 96 char *d_name; 97 }; 98 99 /* intentionally opaque to users */ 100 typedef struct __dirstream DIR; 101 102 DIR *opendir(const char *path); 103 struct dirent *readdir(DIR *dp); 104 int closedir(DIR *dp); 105 const char *dirname(char *path); 106 107 /* Windows utility functions. */ 108 void BLI_windows_register_blend_extension(const bool background); 109 void BLI_windows_get_default_root_dir(char *root_dir); 110 int BLI_windows_get_executable_dir(char *str); 111 112 #ifdef __cplusplus 113 } 114 #endif 115