#define INCLUDED_sysfile_h_
#include <errno.h>
-#include <limits.h>
-#ifndef WINDOWSNT
+#ifndef WIN32_NATIVE
#include <sys/errno.h> /* <errno.h> does not always imply this */
#endif
#ifndef makedev
#include <sys/types.h> /* some typedefs are used in sys/file.h */
#endif
+
+#ifndef WIN32_NATIVE
#include <sys/file.h>
+#endif
+
#include <sys/stat.h>
+
+#ifndef WIN32_NATIVE
+/* Some configuration files' definitions for the LOAD_AVE_CVT macro
+ (like sparc.h's) use macros like FSCALE, defined here. */
+#ifdef HAVE_GTK
+/* I hate GTK */
+#undef MIN
+#undef MAX
+#endif /* HAVE_GTK */
#include <sys/param.h>
+#endif
-#if defined (NeXT) || defined(__CYGWIN32__)
+#if defined (NeXT) || defined(CYGWIN)
/* what is needed from here? Do others need it too?
O_BINARY is in here under cygwin. */
# include <sys/fcntl.h>
#endif /* NeXT */
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
#include <io.h>
#include <direct.h>
#endif
#endif
#ifndef CREAT_MODE
-#ifdef WINDOWSNT
+#ifdef WIN32_NATIVE
#define CREAT_MODE (S_IREAD | S_IWRITE)
#else
#define CREAT_MODE (0666)
#endif
#endif
+#ifndef READ_PLUS_TEXT
+#ifdef O_TEXT
+#define READ_PLUS_TEXT "r+t"
+#else
+#define READ_PLUS_TEXT "r+"
+#endif
+#endif
+
+#ifndef READ_PLUS_BINARY
+#ifdef O_BINARY
+#define READ_PLUS_BINARY "r+b"
+#else
+#define READ_PLUS_BINARY "r+"
+#endif
+#endif
+
+#ifndef WRITE_TEXT
+#ifdef O_TEXT
+#define WRITE_TEXT "wt"
+#else
+#define WRITE_TEXT "w"
+#endif
+#endif
+
#ifndef WRITE_BINARY
#ifdef O_BINARY
#define WRITE_BINARY "wb"
In that case, use ordinary stat instead. */
#ifndef S_IFLNK
-#define lstat stat
+#define lstat xemacs_stat
#endif
-#if !S_IRUSR
+#ifndef S_IRUSR
# if S_IREAD
# define S_IRUSR S_IREAD
# else
# endif
#endif
-#if !S_IWUSR
+#ifndef S_IWUSR
# if S_IWRITE
# define S_IWUSR S_IWRITE
# else
# endif
#endif
-#if !S_IXUSR
+#ifndef S_IXUSR
# if S_IEXEC
# define S_IXUSR S_IEXEC
# else
# define MAXPATHLEN 1024
#endif
+/* The following definitions are needed under Windows, at least */
+#ifndef R_OK
+# define R_OK 4
+#endif
+
+/* Under native Windows, there is no concept of execute permission,
+ so redefine execute permissions to be the same as read permission */
#ifndef X_OK
-# define X_OK 01
+# ifdef WIN32_NATIVE
+# define X_OK R_OK
+# else
+# define X_OK 1
+# endif
+#endif
+
+#ifndef W_OK
+# define W_OK 2
+#endif
+
+#ifndef F_OK
+# define F_OK 0
#endif
#ifndef FD_CLOEXEC
#endif
#if defined (ENCAPSULATE_FSTAT) && !defined (DONT_ENCAPSULATE)
# undef fstat
-/* Need to use arguments to avoid messing with struct stat */
-# define fstat(fd, buf) sys_fstat (fd, buf)
+# define fstat sys_fstat
#endif
#if !defined (ENCAPSULATE_FSTAT) && defined (DONT_ENCAPSULATE)
# define sys_fstat fstat
#endif
-#ifdef ENCAPSULATE_STAT
-int sys_stat (const char *path, struct stat *buf);
-#endif
-#if defined (ENCAPSULATE_STAT) && !defined (DONT_ENCAPSULATE)
-# undef stat
-/* Need to use arguments to avoid messing with struct stat */
-# define stat(path, buf) sys_stat (path, buf)
-#endif
-#if !defined (ENCAPSULATE_STAT) && defined (DONT_ENCAPSULATE)
-# define sys_stat stat
-#endif
+int xemacs_stat (const char *path, struct stat *buf);
/* encapsulations: file-manipulation calls */