Chapter Contents |
Previous |
Next |
stat |
Portability: | POSIX.1 conforming, UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
SYNOPSIS |
#include <sys/types.h> #include <sys/stat.h> int stat(char pathname, struct stat *info);
DESCRIPTION |
stat
gets status information for an USS HFS file and returns it in a
stat
structure, defined in
<stat.h>
. The file pathname is
pathname
.
You must specify the pathname as an USS HFS file. For programs not compiled
with the
posix
option, a style prefix may
be required. See File Naming Conventions for information on specifying USS filenames.
info
is the area of memory in which the status information is
stored.
The
<sys/stat.h>
header file contains
a collection of macros that you can use to examine properties of a
mode_t
value from the
st_mode
field.
See fstat for information about these macros.
RETURN VALUE |
stat
returns 0 if it is successful and -1 if it is not successful.
EXAMPLE |
The following example is a function that
you can call to determine whether two pathnames represent the same file.
(Two different pathnames might represent the same file due to the use of links,
or the use of
"."
or
".."
in the paths.) In this example, two different HFS files must
have either different device numbers or different inode numbers:
#include <sys/types.h> #include <sys/stat.h> #include <stdio.h> int samefile(const char *path1, const char *path2) { struct stat stat1, stat2; int rc; rc = stat(path1, &stat1); if (rc == -1) { perror("stat error"); return -1; } rc = stat(path2, &stat2); if (rc == -1) { perror("stat error"); return -1; } if (stat1.st_dev == stat2.st_dev && stat1.st_ino == stat2.st_ino) return 1; else return 0; }
RELATED FUNCTIONS |
cmsstat
,
fattr
,
fstat
,
lstat
,
osddinfo
,
osdsinfo
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.