2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
* Copyright 2001-2002 NaN Holding BV. All rights reserved. */
|
2018-06-17 16:32:54 +02:00
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2009-09-24 19:50:15 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup bli
|
|
|
|
* \brief Compatibility-like things for windows.
|
2011-02-18 13:58:08 +00:00
|
|
|
*/
|
|
|
|
|
2012-04-15 07:54:07 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
# error "This include is for Windows only!"
|
|
|
|
#endif
|
2010-01-26 11:25:39 +00:00
|
|
|
|
2020-08-26 15:50:48 +02:00
|
|
|
#include "BLI_sys_types.h"
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2005-03-19 20:04:25 +00:00
|
|
|
|
2020-03-18 10:38:37 -06:00
|
|
|
#include <windows.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#undef rad
|
|
|
|
#undef rad1
|
|
|
|
#undef rad2
|
|
|
|
#undef rad3
|
|
|
|
#undef vec
|
|
|
|
#undef rect
|
|
|
|
#undef rct1
|
|
|
|
#undef rct2
|
|
|
|
|
|
|
|
#undef small
|
|
|
|
|
2021-08-04 13:26:47 +10:00
|
|
|
/* These definitions are also in BLI_math for simplicity. */
|
2005-03-19 20:04:25 +00:00
|
|
|
|
2008-08-22 15:00:30 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-03-18 11:23:56 -06:00
|
|
|
#if !defined(_USE_MATH_DEFINES)
|
|
|
|
# define _USE_MATH_DEFINES
|
|
|
|
#endif
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#define MAXPATHLEN MAX_PATH
|
|
|
|
|
2002-12-01 22:41:22 +00:00
|
|
|
#ifndef S_ISREG
|
2012-05-12 20:39:39 +00:00
|
|
|
# define S_ISREG(x) (((x)&_S_IFREG) == _S_IFREG)
|
2002-12-01 22:41:22 +00:00
|
|
|
#endif
|
|
|
|
#ifndef S_ISDIR
|
2012-05-12 20:39:39 +00:00
|
|
|
# define S_ISDIR(x) (((x)&_S_IFDIR) == _S_IFDIR)
|
2002-12-01 22:41:22 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2017-05-27 15:34:55 -04:00
|
|
|
#if defined(_MSC_VER)
|
2013-03-05 07:39:52 +00:00
|
|
|
# define R_OK 4
|
|
|
|
# define W_OK 2
|
2021-08-04 13:26:47 +10:00
|
|
|
/* Not accepted by `access()` on windows. */
|
2013-03-13 19:48:07 +00:00
|
|
|
//# define X_OK 1
|
2013-03-05 07:39:52 +00:00
|
|
|
# define F_OK 0
|
|
|
|
#endif
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
typedef unsigned int mode_t;
|
|
|
|
|
2009-09-24 10:04:43 +00:00
|
|
|
#ifndef _SSIZE_T_
|
2012-04-15 07:54:07 +00:00
|
|
|
# define _SSIZE_T_
|
2009-09-24 10:41:28 +00:00
|
|
|
/* python uses HAVE_SSIZE_T */
|
2012-04-15 07:54:07 +00:00
|
|
|
# ifndef HAVE_SSIZE_T
|
|
|
|
# define HAVE_SSIZE_T 1
|
2020-09-20 19:32:46 +02:00
|
|
|
typedef SSIZE_T ssize_t;
|
2012-04-15 07:54:07 +00:00
|
|
|
# endif
|
2009-09-24 10:04:43 +00:00
|
|
|
#endif
|
2009-09-24 09:29:59 +00:00
|
|
|
|
2021-12-20 19:01:14 +11:00
|
|
|
/** Directory reading compatibility with UNIX. */
|
2002-10-12 11:37:38 +00:00
|
|
|
struct dirent {
|
|
|
|
int d_ino;
|
|
|
|
int d_off;
|
|
|
|
unsigned short d_reclen;
|
|
|
|
char *d_name;
|
|
|
|
};
|
|
|
|
|
2021-12-20 19:01:14 +11:00
|
|
|
/** Intentionally opaque to users. */
|
2015-06-16 09:40:17 +10:00
|
|
|
typedef struct __dirstream DIR;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
DIR *opendir(const char *path);
|
2002-10-12 11:37:38 +00:00
|
|
|
struct dirent *readdir(DIR *dp);
|
2012-05-12 20:39:39 +00:00
|
|
|
int closedir(DIR *dp);
|
2012-04-12 02:50:21 +00:00
|
|
|
const char *dirname(char *path);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2020-08-26 15:50:48 +02:00
|
|
|
/* Windows utility functions. */
|
2021-12-20 19:01:14 +11:00
|
|
|
|
2022-01-07 11:38:08 +11:00
|
|
|
bool BLI_windows_register_blend_extension(bool background);
|
2021-11-01 13:09:02 +11:00
|
|
|
void BLI_windows_get_default_root_dir(char root_dir[4]);
|
2020-08-26 15:50:48 +02:00
|
|
|
int BLI_windows_get_executable_dir(char *str);
|
2008-12-20 10:02:00 +00:00
|
|
|
|
2008-08-22 15:00:30 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|