[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


stat

Gets information about a file.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <stat.h>
int stat(const char *path, struct stat *buf);
Parameters:

Parameters for this facility are:

path  
const char *  
The path name  
buf  
struct stat *  
A pointer to the stat struct  

Remarks:

This function gets information on the file specified in path and puts the information in the structure that buf points to. The structure contains the fields listed in "Stat Structure and Definitions."

Return:

If it is successful, stat() returns zero.

See Also:

"fstat"

"uname"

Example of stat() usage.:
#include <stdio.h>
#include <time.h>
#include <unix.h>

int main(void)
{
	struct stat info;

	stat("Akbar:System Folder:System", &info);
		/* Get information on the System file.                            */
	
	printf("File mode:         0x%lX\n", info.st_mode);
	printf("File ID:                      0x%lX\n", info.st_ino);
	printf("Volume ref. no.:     0x%lX\n", info.st_dev);
	printf("Number of links:   %hd\n", info.st_nlink);
	printf("User ID:           %lu\n", info.st_uid);
	printf("Group ID:          %lu\n", info.st_gid);
	printf("File size:         %ld\n", info.st_size);
	printf("Access time:       %s", ctime(&info.st_atime));
	printf("Modification time: %s", ctime(&info.st_mtime));
	printf("Creation time:          %s", ctime(&info.st_ctime));

	return 0;
}
This program may print the following:
File mode:         0x800
File ID:           0x4574
Volume ref. no.:   0x0
Number of links:   1
User ID:           200
Group ID:          100
File size:         30480
Access time:       Mon Apr 17 19:46:37 1995
Modification time: Mon Apr 17 19:46:37 1995
Creation time:     Fri Oct  7 12:00:00 1994


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000