[comp.sys.ibm.pc] findfirst/findnext in Turbo C

dkrause@orion.oac.uci.edu (Doug Krause) (10/23/89)

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?

Douglas Krause                     One yuppie can ruin your whole day.
----------------------------------------------------------------------
University of California, Irvine   Internet: dkrause@orion.oac.uci.edu
Welcome to Irvine, Yuppieland USA  BITNET: DJKrause@ucivmsa

few@quad1.quad.com (Frank Whaley) (10/24/89)

In article <3540@orion.cf.uci.edu> dkrause@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@quad1.quad.com
uunet!ccicpg!quad1!few

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

austin@bucsf.bu.edu (Austin Ziegler) (10/24/89)

>>>>> On 23 Oct 89 13:12:05 GMT, dkrause@orion.oac.uci.edu (Doug Krause) said:

Doug> I'm using Turbo C 2.0 on a PC clone.  My question:  I'm using findfirst
Doug> and findnext to read the disk directory.  In the structure returned are
Doug> two integers that tell the file date and file time.  Is there a function
Doug> to convert these numbers into something more useful like hh:mm?

     I think that there are functions (packtime and unpacktime or something
like that) to do this.  I don't have my compiler in front of me now, but go
into the help mode, Header files, Dir.H, and then go to findfirst or
find/next.  If it is not in that help section, look under DOS.H.  If you
would post the proper answer, I would appreciate it.  (I program in Pascal
more often...)

	  Elminster, the Sage of Shadowdale (austin@bucsf.bu.edu)
	       700 Commonwealth Box 2094, Boston, MA  02215
				     
		Pascal Guru here, I want to be a C guru...