#include <sys/types.h> #include <sys/stat.h> int fstat(int filedes, struct stat *info);
fstat
gets status information for an HFS file and returns it in a
stat
structure, defined in <sys/stat.h>
. The filedes
file descriptor is
the file descriptor for which status information is needed.
filedes
must be an open file descriptor associated with an
OpenEdition HFS file. info
is the area of memory in which the status
information is stored.
The following macros (defined in <stat.h>
) are available:
S_ISBLK(mode)
S_ISCHR(mode)
S_ISDIR(mode)
S_ISFIFO(mode)
S_ISLNK(mode)
S_ISREG(mode)
S_ISSOCK(mode)
fstat
returns a 0 if it is successful and a
- 1 if it is not successful.
#include <sys/types.h> #include <sys/stat.h> #include <stdio.h> int samefile(int fd1, int fd2) { struct stat stat1, stat2; int rc; rc = fstat(fd1, &stat1); if (rc == -1) { perror("fstat error"); return -1; } rc = fstat(fd2, &stat2); if (rc == -1) { perror("fstat error"); return -1; } if (stat1.st_dev == stat2.st_dev && stat1.st_ino == stat2.st_ino) return 1; else return 0; }
fattr
, lstat
, stat
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.