Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file comparison

Status
Not open for further replies.

rtnMichael

Programmer
Aug 5, 2002
152
US
Hey,
I want to compare a file that has a time stamp in it with an incoming file from another system. The time stamps have to match, and I was wondering the best and fastest way to compare these two files.

Thanks
M
 
Michael:

You probably want to use the fstat function. From the Solaris 7 man page:
int fstat(int fildes, struct stat *buf);

DESCRIPTION
The stat() function obtains information about the file pointed to by path. Read, write, or execute permission of the named file is not required, but all directories listed in the path name leading to the file must be searchable.

The lstat() function obtains file attributes similar to
stat(), except when the named file is a symbolic link; in
that case lstat() returns information about the link, while
stat() returns information about the file the link refer-
ences.

The fstat() function obtains information about an open file
known by the file descriptor fildes, obtained from a suc-
cessful open(2), creat(2), dup(2), fcntl(2), or pipe(2)
function.

buf is a pointer to a stat() structure into which information is placed concerning the file.

The contents of the structure pointed to by buf include the following members:

mode_t st_mode; /* File mode (see mknod(2)) */
ino_t st_ino; /* Inode number */
dev_t st_dev; /* ID of device containing */
/* a directory entry for this file */
dev_t st_rdev; /* ID of device */
/* This entry is defined only for */
/* char special or block special files */
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 */
off_t st_size; /* File size in bytes */
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 */
/* Times measured in seconds since */
/* 00:00:00 UTC, Jan. 1, 1970 */
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top