newlib/winsup/mingw/include/sys/stat.h

199 lines
5.4 KiB
C
Raw Normal View History

2000-02-17 20:38:33 +01:00
/*
* stat.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
2000-02-17 20:38:33 +01:00
*
* Symbolic constants for opening and creating files, also stat, fstat and
* chmod functions.
*
*/
#ifndef _STAT_H_
#define _STAT_H_
/* All the headers include this file. */
#include <_mingw.h>
#define __need_size_t
#define __need_wchar_t
#ifndef RC_INVOKED
#include <stddef.h>
#endif /* Not RC_INVOKED */
#include <sys/types.h>
/*
* Constants for the stat st_mode member.
*/
#define _S_IFLNK 0xF000 /* Pretend */
2000-02-17 20:38:33 +01:00
#define _S_IFIFO 0x1000 /* FIFO */
#define _S_IFCHR 0x2000 /* Character */
#define _S_IFBLK 0x3000 /* Block: Is this ever set under w32? */
2000-02-17 20:38:33 +01:00
#define _S_IFDIR 0x4000 /* Directory */
#define _S_IFREG 0x8000 /* Regular */
#define _S_IFMT 0xF000 /* File type mask */
#define _S_IEXEC 0x0040
#define _S_IWRITE 0x0080
#define _S_IREAD 0x0100
#define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
#define _S_IXUSR _S_IEXEC
#define _S_IWUSR _S_IWRITE
#define _S_IRUSR _S_IREAD
#define _S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#define _S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
#define _S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR)
#define _S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK)
#define _S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
#define _S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) /* Should always be zero.*/
2000-02-17 20:38:33 +01:00
#ifndef _NO_OLDNAMES
#define S_IFLNK _S_IFLNK
2000-02-17 20:38:33 +01:00
#define S_IFIFO _S_IFIFO
#define S_IFCHR _S_IFCHR
#define S_IFBLK _S_IFBLK
#define S_IFDIR _S_IFDIR
#define S_IFREG _S_IFREG
#define S_IFMT _S_IFMT
#define S_IEXEC _S_IEXEC
#define S_IWRITE _S_IWRITE
#define S_IREAD _S_IREAD
#define S_IRWXU _S_IRWXU
#define S_IXUSR _S_IXUSR
#define S_IWUSR _S_IWUSR
#define S_IRUSR _S_IRUSR
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* Should always be zero.*/
2000-02-17 20:38:33 +01:00
#endif /* Not _NO_OLDNAMES */
#ifndef RC_INVOKED
#ifndef _STAT_DEFINED
/*
* The structure manipulated and returned by stat and fstat.
*
* NOTE: If called on a directory the values in the time fields are not only
* invalid, they will cause localtime et. al. to return NULL. And calling
* asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
*/
struct _stat
{
_dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
_ino_t st_ino; /* Always zero ? */
_mode_t st_mode; /* See above constants */
short st_nlink; /* Number of links. */
short st_uid; /* User: Maybe significant on NT ? */
short st_gid; /* Group: Ditto */
_dev_t st_rdev; /* Seems useless (not even filled in) */
_off_t st_size; /* File size in bytes */
time_t st_atime; /* Accessed date (always 00:00 hrs local
* on FAT) */
time_t st_mtime; /* Modified time */
time_t st_ctime; /* Creation time */
};
struct stat
{
_dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
_ino_t st_ino; /* Always zero ? */
_mode_t st_mode; /* See above constants */
short st_nlink; /* Number of links. */
short st_uid; /* User: Maybe significant on NT ? */
short st_gid; /* Group: Ditto */
_dev_t st_rdev; /* Seems useless (not even filled in) */
_off_t st_size; /* File size in bytes */
time_t st_atime; /* Accessed date (always 00:00 hrs local
* on FAT) */
time_t st_mtime; /* Modified time */
time_t st_ctime; /* Creation time */
};
Add prototypes for new msvcrt.dll versions * include/_mingw.h (__MSVCRT_VERSION__): Define default as 0x0600. * include/time.h (__time64_t): Add typedef. (_mktime64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_ctime64): Likewise. (_wctime64): Likewise. (_gmtime64): Likewise. (_localtime64): Likewise. (wcsftime): Move into _WTIME_DEFINED block. Regroup non-ANSI prototypes. * include/io.h: Include <stdint.h>. (__finddata64_t): Add struct definition. (__wfinddata64_t): Likewise. (_findfirst64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_findnext64): Likewise. (_wfindfirst64): Likewise. (_wfindnext64): Likewise. * include/sys/timeb.h (__timeb64): Add struct definition. (_ftime64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. * include/sys/utime.h (__utimbuf64): Add struct definition. (_utime64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_futime64): Likewise. (_wutime64): Likewise. * include/sys/stat.h (__stat64): Add struct definition. (_fstat64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_stat64): Likewise. (_wstat64): Likwise. * include/sys/types.h (__time64_t): Add typedef. * include/wchar.h (__wfinddata64_t): Add structure definition. (__stat64): Likewise. (_wctime64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_wfindfirst64): Likewise. (_wfindnext64): Likewise. (_wutime64): Likewise. (_wstat64): Likwise. * include/malloc.h (_aligned_free): Add prototype for __MSVCRT_VERSION__ >= 0x0700. (_aligned_malloc): Likewise. (_aligned_offset_malloc): Likewise. (_aligned_offset_realloc): Likewise. (_aligned_realloc): Likewise. * include/string.h (_wcserror): Add prototype for __MSVCRT_VERSION__ >= 0x0700. (__wcserror): Likewise. * include/math.h (_set_SSE2_enable): Add prototype for __MSVCRT_VERSION__ >= 0x0701.
2004-03-26 12:30:24 +01:00
#if defined (__MSVCRT__)
struct _stati64 {
_dev_t st_dev;
_ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
__int64 st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
Add prototypes for new msvcrt.dll versions * include/_mingw.h (__MSVCRT_VERSION__): Define default as 0x0600. * include/time.h (__time64_t): Add typedef. (_mktime64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_ctime64): Likewise. (_wctime64): Likewise. (_gmtime64): Likewise. (_localtime64): Likewise. (wcsftime): Move into _WTIME_DEFINED block. Regroup non-ANSI prototypes. * include/io.h: Include <stdint.h>. (__finddata64_t): Add struct definition. (__wfinddata64_t): Likewise. (_findfirst64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_findnext64): Likewise. (_wfindfirst64): Likewise. (_wfindnext64): Likewise. * include/sys/timeb.h (__timeb64): Add struct definition. (_ftime64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. * include/sys/utime.h (__utimbuf64): Add struct definition. (_utime64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_futime64): Likewise. (_wutime64): Likewise. * include/sys/stat.h (__stat64): Add struct definition. (_fstat64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_stat64): Likewise. (_wstat64): Likwise. * include/sys/types.h (__time64_t): Add typedef. * include/wchar.h (__wfinddata64_t): Add structure definition. (__stat64): Likewise. (_wctime64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_wfindfirst64): Likewise. (_wfindnext64): Likewise. (_wutime64): Likewise. (_wstat64): Likwise. * include/malloc.h (_aligned_free): Add prototype for __MSVCRT_VERSION__ >= 0x0700. (_aligned_malloc): Likewise. (_aligned_offset_malloc): Likewise. (_aligned_offset_realloc): Likewise. (_aligned_realloc): Likewise. * include/string.h (_wcserror): Add prototype for __MSVCRT_VERSION__ >= 0x0700. (__wcserror): Likewise. * include/math.h (_set_SSE2_enable): Add prototype for __MSVCRT_VERSION__ >= 0x0701.
2004-03-26 12:30:24 +01:00
struct __stat64
{
_dev_t st_dev;
_ino_t st_ino;
_mode_t st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
_off_t st_size;
__time64_t st_atime;
__time64_t st_mtime;
__time64_t st_ctime;
};
#endif /* __MSVCRT__ */
2000-02-17 20:38:33 +01:00
#define _STAT_DEFINED
#endif /* _STAT_DEFINED */
#ifdef __cplusplus
extern "C" {
#endif
_CRTIMP int __cdecl _fstat (int, struct _stat*);
_CRTIMP int __cdecl _chmod (const char*, int);
_CRTIMP int __cdecl _stat (const char*, struct _stat*);
#define _lstat _stat
2000-02-17 20:38:33 +01:00
#ifndef _NO_OLDNAMES
/* These functions live in liboldnames.a. */
_CRTIMP int __cdecl fstat (int, struct stat*);
_CRTIMP int __cdecl chmod (const char*, int);
_CRTIMP int __cdecl stat (const char*, struct stat*);
#define lstat stat
2000-02-17 20:38:33 +01:00
#endif /* Not _NO_OLDNAMES */
Add prototypes for new msvcrt.dll versions * include/_mingw.h (__MSVCRT_VERSION__): Define default as 0x0600. * include/time.h (__time64_t): Add typedef. (_mktime64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_ctime64): Likewise. (_wctime64): Likewise. (_gmtime64): Likewise. (_localtime64): Likewise. (wcsftime): Move into _WTIME_DEFINED block. Regroup non-ANSI prototypes. * include/io.h: Include <stdint.h>. (__finddata64_t): Add struct definition. (__wfinddata64_t): Likewise. (_findfirst64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_findnext64): Likewise. (_wfindfirst64): Likewise. (_wfindnext64): Likewise. * include/sys/timeb.h (__timeb64): Add struct definition. (_ftime64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. * include/sys/utime.h (__utimbuf64): Add struct definition. (_utime64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_futime64): Likewise. (_wutime64): Likewise. * include/sys/stat.h (__stat64): Add struct definition. (_fstat64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_stat64): Likewise. (_wstat64): Likwise. * include/sys/types.h (__time64_t): Add typedef. * include/wchar.h (__wfinddata64_t): Add structure definition. (__stat64): Likewise. (_wctime64): Add prototype for __MSVCRT_VERSION__ >= 0x0601. (_wfindfirst64): Likewise. (_wfindnext64): Likewise. (_wutime64): Likewise. (_wstat64): Likwise. * include/malloc.h (_aligned_free): Add prototype for __MSVCRT_VERSION__ >= 0x0700. (_aligned_malloc): Likewise. (_aligned_offset_malloc): Likewise. (_aligned_offset_realloc): Likewise. (_aligned_realloc): Likewise. * include/string.h (_wcserror): Add prototype for __MSVCRT_VERSION__ >= 0x0700. (__wcserror): Likewise. * include/math.h (_set_SSE2_enable): Add prototype for __MSVCRT_VERSION__ >= 0x0701.
2004-03-26 12:30:24 +01:00
#if defined (__MSVCRT__)
_CRTIMP int __cdecl _fstati64(int, struct _stati64 *);
_CRTIMP int __cdecl _stati64(const char *, struct _stati64 *);
/* These require newer versions of msvcrt.dll (6.10 or higher). */
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP int __cdecl _fstat64 (int, struct __stat64*);
_CRTIMP int __cdecl _stat64 (const char*, struct __stat64*);
#endif /* __MSVCRT_VERSION__ >= 0x0601 */
#if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
_CRTIMP int __cdecl _wstat(const wchar_t*, struct _stat*);
_CRTIMP int __cdecl _wstati64 (const wchar_t*, struct _stati64*);
#if __MSVCRT_VERSION__ >= 0x0601
_CRTIMP int __cdecl _wstat64 (const wchar_t*, struct __stat64*);
#endif /* __MSVCRT_VERSION__ >= 0x0601 */
#define _WSTAT_DEFINED
#endif /* _WSTAT_DEFIND */
#endif /* __MSVCRT__ */
2000-02-17 20:38:33 +01:00
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _STAT_H_ */