[comp.sys.amiga] Getting a timestamp of a file

bruss@beowulf.ucsd.edu (Brian Russ) (03/19/87)

	I wish to find the last time a file has been modified, from
within a C program.  From what I've been able to figure, I need
to call Examine() which returns me a struct FileInfoBlock.  I 
see that this structure has one field called fib_Date or some-
thing (where is this structure documented?  RKM and Developer's
Manual were of no help) -- is this the file creation date or
file modification date?  How do I transform this structure
(a DateStamp struct, I believe) into human-readable (i.e. month
and day) format?  Finally, to call Examine() (and Lock() since
that's what Examine() needs) do I need to open some library?

	Thanks in advance.

					Brian Russ
					EECS Department, UC San Diego
					...!sdcsvax!bruss

cmcmanis@sun.uucp (Chuck McManis) (03/19/87)

In article <2867@sdcsvax.UCSD.EDU>, Brian Russ writes:
> 
> 	I wish to find the last time a file has been modified, from
> within a C program.  From what I've been able to figure, I need
> to call Examine() which returns me a struct FileInfoBlock.  I 
> see that this structure has one field called fib_Date or some-
> thing (where is this structure documented?  RKM and Developer's
> Manual were of no help) -- is this the file creation date or
> file modification date?  How do I transform this structure
> (a DateStamp struct, I believe) into human-readable (i.e. month
> and day) format?  Finally, to call Examine() (and Lock() since
> that's what Examine() needs) do I need to open some library?
> 
> 					Brian Russ

Yup, the Lock(), UnLock(), and Examine() calls are part of the dos.library.
Fortunately every version of C startup code I have seen opens the 
dos.library first thing so you don't have to worry about it. The routines
are documented in the AmigaDOS Developers Manual which is part of the
Bantam Book (which also documents the file system, disked, the CLI, and
the system data structures). The timestamp is composed of two longwords
one for number of days past 1/1/78 (which happens to be a Sunday) and 
the second is number of ticks past midnight (1 tick = 1/50th of a second)

The date conversion consists of dividing the days by 365 to get the year
taking into account leap years , which are more important in calculating 
the month and date. The day of the week is simply Number_of_Days % 7.
Also you can look in the file /libraries/dos.h and /libraries/dosextens.h
for this kind of info too!


-- 
--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.