[comp.sys.amiga.tech] help: read file date

alh@hprmokg.HP.COM (Al Harrington) (04/25/89)

A friend of mine needs to read the date of a file (he's writting a BBS)
using Manx C.

Can someone send me a little routine to do that?  (or a c structure of an
AmigaDOS file)

Thanks.


+-----------------------------------------+---------------------------------+
| -Al Harrington                     //// |       Instant Guru BBS          |
|    ________                       ////  |        (916) 488-9278           |
|    |__/\__|                 \\\\ ////   |    120 Megs - All Amiga!        |
|                              \\\X///    |    Over 1000 files online       |
| alh@hprmo.HP.COM              \XXX/     |   Baud: 1200/2400 Hours: 24     |
| ..{hplabs,hp-sde}!hprmo!alh             |  PCPursuit:  CASAC 1200/2400    |
+-----------------------------------------+---------------------------------+
|  My comments in no way reflect the views or opinions of Hewlett-Packard   |
+---------------------------------------------------------------------------+

new@udel.EDU (Darren New) (04/27/89)

In article <8990002@hprmokg.HP.COM> alh@hprmokg.HP.COM (Al Harrington) writes:
>A friend of mine needs to read the date of a file (he's writting a BBS)
>using Manx C.

Simple!!!	(yeah, sure, once you've done it already)

Lock() the file, and then Examine() it.
Look at the datestamp in the FileInfoBlock
returned by Examine. Don't forget to UnLock()
the file. See DOS DateStamp() function
description for information on how to
interpret the values in the DateStamp
structure. This should work regardless
of the compiler, as it is all AmigaDOS.

If you are scanning a directory (like LIST does),
you don't have to individually lock the files
because the ExNext call returns the fib for
the file you want.

Below is something I just typed in, so there may be
minor typos. Also, I leave it up to you
to track down all the #%@$# includes you need
to do this :-).

(In case you don't have DateStamp description,
  ds_Days is days since some particular day
       which I don't remember offhand but could 
       find out for you,
  ds_Minute is minutes since midnite of ds_Days,
  ds_Tick is ticks (50/sec) since ds_Minute,
    which I'm not sure ever works right.)

extern day, minute, tick;

int GetDateFromFile(fname)
	char * fname;
{
	BPTR lck;
	struct FileInfoBlock * fib;

	fib = (struct FileInfoBlock *)
		AllocMem(sizeof(struct FileInfoBlock), MEMF_PUBLIC);
	if (fib == NULL) return 0;
	lck = Lock(fname, ACCESS_READ);
	if (lck == NULL) {
		FreeMem(fib, sizeof(...));
		return 0;
		}
	if (!Examine(lck, fib)) {
		UnLock(lck);
		FreeMem(fib, ...);
		return 0;
		}
	day = fib->fib_DateStamp.ds_Days;
	minute = fib->fib_DateStamp.ds_Minute;
	tick = fib->fib_DateStamp.ds_Tick;
	UnLock(lck);
	FreeMem(fib, ...);
	return 1;
	}


------- End of Unsent Draft