msvc-compat.h 1.05 KB
Newer Older
Vicent Marti committed
1
/*
schu committed
2
 * Copyright (C) 2009-2012 the libgit2 contributors
Vicent Marti committed
3 4 5 6
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */
7 8 9 10 11
#ifndef INCLUDE_msvc_compat__
#define INCLUDE_msvc_compat__

#if defined(_MSC_VER)

Vicent Marti committed
12
/* access() mode parameter #defines	*/
13 14 15
#	define F_OK 0 /* existence check */
#	define W_OK 2 /* write mode check */
#	define R_OK 4 /* read mode check */
16

17 18 19
#	define lseek _lseeki64
#	define stat _stat64
#	define fstat _fstat64
20 21

/* stat: file mode type testing macros */
22 23
#	define _S_IFLNK 0120000
#	define S_IFLNK _S_IFLNK
24
#	define S_IXUSR 00100
25

26 27 28 29
#	define S_ISDIR(m)	(((m) & _S_IFMT) == _S_IFDIR)
#	define S_ISREG(m)	(((m) & _S_IFMT) == _S_IFREG)
#	define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
#	define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
30

31
#	define mode_t unsigned short
32

33
/* case-insensitive string comparison */
34 35
#	define strcasecmp	_stricmp
#	define strncasecmp _strnicmp
36

37 38 39
/* MSVC doesn't define ssize_t at all */
typedef SSIZE_T ssize_t;

40 41 42
#endif

#endif /* INCLUDE_msvc_compat__ */