fstat
Obtains information about an open file
#include <sys\stat.h>
int fstat (
int handle,
struct stat *statblk);
fstat returns a value of 0 when the information is obtained successfully. Otherwise, a value of -1 is returned.
If an error occurs, errno is set to:
If fstat does not complete successfully, NetWareErrno is set.
The fstat function obtains information about an open file whose file handle is handle. This information is placed in the structure located at the address indicated by the statblk parameter.
The SYS\STAT.H header file contains definitions for stat and describes the contents of the fields within that structure.
#include <stdio.h>
#include <nwtypes.h>
#include <fcntl.h>
#include <sys\types.h>
#include <sys\stat.h>
main()
{
int handle;
struct stat buf;
handle = open ("test.dat",O_RDONLY | O_BINARY,0);
if(handle == -1)
{
printf ("could not open file");
exit (0);
}
if(fstat (handle,&buf) == -1)
printf ("fstat error\r\n");
close(handle);
printf ("st_dev = %x\r\n",buf.st_dev);
printf ("st_ino = %x\r\n",buf.st_ino);
printf ("st_mode = %x\r\n",buf.st_mode);
printf ("st_nlink = %x\r\n",buf.st_nlink);
printf ("st_uid = %x\r\n",buf.st_uid);
printf ("st_gid = %x\r\n",buf.st_gid);
printf ("st_rdev = %x\r\n",buf.st_rdev);
printf ("st_size = %x\r\n",buf.st_size);
printf ("st_atime = %x\r\n",buf.st_atime);
printf ("st_mtime = %x\r\n",buf.st_mtime);
printf ("st_ctime = %x\r\n",buf.st_ctime);
printf ("st_btime = %x\r\n",buf.st_btime);
printf ("st_attr = %x\r\n",buf.st_attr);
printf ("st_archivedID = %x\r\n",buf.st_archivedID);
printf ("st_updatedID = %x\r\n",buf.st_updatedID);
printf ("st_inheritedRightsMask =
%x\r\n",buf.st_inheritedRightsMask);
printf ("st_originatingNameSpace =
%c\r\n",buf.st_originatingNameSpace);
printf ("st_name = %s\r\n",buf.st_name);
/*—————- new fields starting in v. 4.11 —————-*/
printf ("st_name2 = %s\r\n",buf.st_name2);
printf ("st_blksize = %x\r\n",buf.st_blksize);
printf ("st_blocks = %x\r\n",buf.st_blocks);
printf ("st_flags = %x\r\n",buf.st_flags);
}