Gets information about a file.
#include <sys/types.h> #include <sys/stat.h> /* 32 bit file size and 32 time */
int stat (const char *filename, struct stat *buffer); /* 64 bit file size and 32 bit time */
int _stat64 (const char *filename, struct stat64 *buffer); /* 64 bit file size and 64 bit time */
int _stat64x64 (const char *filename, struct stat64x64 *buffer);
filename
buffer
struct stat {
dev_t st_dev; /* ID of device containing this file */
ino_t st_ino; /* File serial number */
mode_t st_mode; /* File mode */
nlink_t st_nlink; /* Number of links */
uid_t st_uid; /* User ID of the file's owner */
gid_t st_gid; /* Group ID of the file's group */
dev_t st_rdev; /* Same as st_dev */
off_t st_size; /* File size in bytes (regular files only) */
time_t st_atime; /* Time of last access */
time_t st_mtime; /* Time of last data modification */
time_t st_ctime; /* Time of last file status change */
};
struct stat64 {
dev_t st_dev; /* ID of device containing this file */
ino_t st_ino_lo; /* File serial number */
ino_t st_ino_hi; /* File serial number */
mode_t st_mode; /* File mode */
nlink_t st_nlink; /* Number of links */
uid_t st_uid; /* User ID of the file's owner */
gid_t st_gid; /* Group ID of the file's group */
dev_t st_rdev; /* Same as st_dev */
unsigned long64 st_size; /* File size in bytes (regular files only) */
time_t st_atime; /* Time of last access */
time_t st_mtime; /* Time of last data modification */
time_t st_ctime; /* Time of last file status change */
};
/*
* file types for st_mode field
*/
#define S_IFMT 0xF000 /* mask */
#define S_IFIFO 0x1000 /* fifo file */
#define S_IFCHR 0x2000 /* character device */
#define S_IFDIR 0x4000 /* directory */
#define S_IFBLK 0x6000 /* block device */
#define S_IFREG 0x8000 /* regular file */
/*
* file types test masks
*/
#define S_ISDIR(m) (((m) & S_IFMT ) == S_IFDIR)
#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_ISFIFO(m) (((m) & S_IFMT ) == S_IFIFO)
/*
* file access permission levels (in octal)
*/
#define S_ISGID 0002000 /* set group ID on execution */
#define S_ISUID 0001000 /* set user ID on execution */
#define S_IREAD 0000400 /* pre-POSIX definition */
#define S_IWRITE 0000200 /* pre-POSIX definition */
#define S_IEXEC 0000100 /* pre-POSIX definition */
#define S_IARCHIVE 0100000 /* DOS specific mode */
#define S_ISUBDIR 0040000 /* DOS specific mode */
#define S_IVOLUME 0020000 /* DOS specific mode */
#define S_ISYSTEM 0010000 /* DOS specific mode */
#define S_IHIDDEN 0004000 /* DOS specific mode */
/*
* file owner class (in octal)
*/
#define S_IRWXU 0000700 /* mask for file owner class */
#define S_IRUSR 0000400 /* read permission for file owner class */
#define S_IWUSR 0000200 /* write permission for file owner class */
#define S_IXUSR 0000100 /* execute/search permission for file owner class */
/*
* file group class (in octal)
*/
#define S_IRWXG 0000070 /* mask for file group class */
#define S_IRGRP 0000040 /* read permission for file group class */
#define S_IWGRP 0000020 /* write permission for file group class */
#define S_IXGRP 0000010 /* execute or search permission for file group class */
/*
* file other class (in octal)
*/
#define S_IRWXO 0000007 /* mask for file other class */
#define S_IROTH 0000004 /* read permission for file other class */
#define S_IWOTH 0000002 /* write permission for file other class */
#define S_IXOTH 0000001 /* execute or search permission for file other class */
This function translates real-time OS file ownership rights and real-time OS access rights to POSIX as described in SYS/STAT.H.
stat() is always 32 bit.
If you need to force the compiler to interpret time_t as the new 64-bit time_t, you can define _USE_64BIT_TIME_T. If _USE_64BIT_TIME_T is defined: _stat(64) behaves like _stat64x64. This is recommended to ensure that your application does not fail after January 18, 2038, but is not backwards-compatible with previous versions of INtime.
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 (stat) INtime 4.0 (_stat64) |
intime/rt/include/stat.h | sys/types.h sys/stat.h |
clib.lib |