findfirst/findnext in Turbo C

Frank Whaley few at quad1.quad.com
Tue Oct 24 10:03:01 AEST 1989


In article <3540 at orion.cf.uci.edu> dkrause at orion.oac.uci.edu (Doug Krause) writes:
>I'm using Turbo C 2.0 on a PC clone.  My question:  I'm using findfirst
>and findnext to read the disk directory.  In the structure returned are
>two integers that tell the file date and file time.  Is there a function
>to convert these numbers into something more useful like hh:mm?

Sure, sprintf()...

assuming a filled-in struct ffblk F:

	sprintf(buf, "%02d/%02d/%02d %02d:%02d",
		(F.ff_fdate >> 5) & 0xf,
		F.ff_fdate & 0x1f,
		(F.ff_fdate >> 9) + 80,
		(F.ff_ftime >> 11) & 0x1f,
		(F.ff_ftime >> 5) & 0x3f);

Of course, also assuming American date format :-)

Another interesting (hidden) function is:
	extern long pascal __DOSTIMETOU(unsigned date, unsigned time);
which takes a MS-DOS directory date/time and turns it into a Un*x-like
time value.

-- 
Frank Whaley
Senior Development Engineer
Quadratron Systems Incorporated
few at quad1.quad.com
uunet!ccicpg!quad1!few

Water separates the people of the world;
Wine unites them.



More information about the Comp.lang.c mailing list