[comp.sys.atari.st] Fdatime under Laser C

bovet@hao.ucar.edu (Ray Bovet) (11/13/88)

I'm having a terrible time trying to get Fdatime to modify
a file modification time and date stamp using Laser C.  I note
that the ABACUS book reverses the order of the read and write flag
values relative to what Megamax shows but as near as I can tell the
Megamax documentation is correct.  At any rate, I can read the time
and date just fine (and can verify that it matches what I find in the
DTA using FSFIRST - FSNEXT.  However, when I try to write a different
value into the field, I get no complaints but the value doesn't get changed.
It doesn;t seem to matter whether I Fopen the file for read only or for
write first.  Has anyone else succesfully used this call?  If so, could
you please include a brief, functional, code fragment?  Thanks very much!

				Ray

apratt@atari.UUCP (Allan Pratt) (11/15/88)

In article <992@ncar.ucar.edu> bovet@hao.ucar.edu (Ray Bovet) writes:
> I'm having a terrible time trying to get Fdatime to modify
> a file modification time and date stamp using Laser C.

Fdatime had some problems in TOS 1.0 and 1.2 -- it's been changed for
TOS 1.4 to be more sane.  I don't remember exactly what the problem was,
besides the documentation having the arguments wrong...  The new Fdatime
doesn't write to the disk at all: it writes to the open-file data
structure, which gets written to disk when you close the file.  This
means that checking your write with Fsfirst won't work, because what's
on the disk won't get updated until the file is closed. 

The correct usage is:

	Fwrite(timebuf,handle,flag);
	int *timebuf;		/* ptr to two ints: time & date */
	int handle;		/* handle of file */
	int flag;		/* nonzero to write from timebuf */

If 'flag' is zero, the file's date & time are copied into the two ints
at timebuf.  If 'flag' is nonzero, the ints at timebuf are copied into
the file's date & time fields.  Since the date & time are updated each
time the file is written to, you should make this call immediately
before closing the file. 

============================================
Opinions expressed above do not necessarily	-- Allan Pratt, Atari Corp.
reflect those of Atari Corp. or anyone else.	  ...ames!atari!apratt

kloppen@gmdzi.UUCP (Jelske Kloppenburg) (11/21/88)

From article <1231@atari.UUCP>, by apratt@atari.UUCP (Allan Pratt):
> In article <992@ncar.ucar.edu> bovet@hao.ucar.edu (Ray Bovet) writes:
>> I'm having a terrible time trying to get Fdatime to modify
>> a file modification time and date stamp using Laser C.
> 
> Fdatime had some problems in TOS 1.0 and 1.2 -- it's been changed for
> TOS 1.4 to be more sane.  I don't remember exactly what the problem was,
  . . .


Just one day before I had to write a copy procedure in MODULA-2
for my project, I read the article concerning Fdatime. So I avoided
much trouble. Many thanks.
I also found an error in the DaTime PROCEDURE of the TDIModula-2/ST.
But the sequence Fcreate, Fwrite, Fdatime, Fclose didn't work.
When I do Fcreate, Fwrite, Fclose, Fopen, Fdatime, Fclose
then the time and date stamp is as I want it.
I am not shure about the TOS Version I have, I think it is 1.3 (german).
Without setting the clock, files are created on 6.Feb.1986.

Jelske Kloppenburg   |   kloppenburg@kmx.gmd.dbp.de
                     |   kloppen@gmdzi.uucp