Link to home
Start Free TrialLog in
Avatar of jimdgar
jimdgar

asked on

Problem with timestamp code under SunOS...

Hi,

I'm using the following code to compare timestamps between two files.

  struct stat fbuf;
  int i,fres;
  long time1=0,time2=0;

  fres = stat ("file1.c",&fbuf);
  if (fres == 0) {
    if (debug) printf ("file1.c, size=%d, date=%s (%d)\n",fbuf.st_size,ctime(&fbuf.st_atime),fbuf.st_atime);
    time1 = fbuf.st_atime;
  }
  fres = stat ("file2",&fbuf);
  if (fres == 0) {
    if (debug) printf ("file2, size=%d, date=%s (%d)\n",fbuf.st_size,ctime(&fbuf.st_atime),fbuf.st_atime);
    time2 = fbuf.st_atime;
  }

File1.c is a C module which is compiled and made with other modules to create an executable, File2. The problem is that sometimes this code returns the correct timestamp on File1.c, sometimes not. Here's one example (this is running on SunOS, I have not see the problem occur under Linux):

Debug dump from program execution:
file1.c, size=10888, date=Wed Apr 13 17:02:36 2005
 (1113436956)
file2, size=7273948, date=Thu Apr 14 15:07:32 2005
 (1113516452)

Timestamps from SunOS:
> ls -alrt file*
-rwxr-xr-x   1 userj    pedft    7273948 Apr 14 15:07 file2
-rwxr-xr-x   1 uesrj    pedft      10888 Apr 14 15:25 file1.c

jimdgar


ASKER CERTIFIED SOLUTION
Avatar of grg99
grg99

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial