Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problem with setting file timestamp (Adaptec DirectCD, Read/Write CD-ROM)

16 views
Skip to first unread message

Joe Hatem

unread,
May 1, 2000, 3:00:00 AM5/1/00
to
Happy Easter (where applicable).

We designed this file-sync utility, Update2 (which you may download from our
site).
One of the users is facing a problem with setting the timestamp of copied
files, when files are copied to an "Adaptec DirectCD version 2.5d" CD-ROM
Read/Write drive:

The problem is that setting the timestamp of the copied-to target file to
the same as the timestamp of the copied-from source file fails, and the
copied-to target file always assumes the timestamp of the moment when the
copy ended, i.e. the "current" timestamp.

We use FileSetDate to readjust the timestamp of the copied-to file. While
this worked fine on so many varied platforms and drives, it failed on that
particular one.

Last but not least, we do not have a CD-ROM Read/Write drive similar to the
one causing the problem, so tracking and debugging are not possible.

I myself have hunches with the fact that
- FileSetDate needs a Handle,
- getting a Handle implies opening file
- an open file must eventually be closed
- and maybe this Adaptec driver is playing smart, and enforcing Now as a
timestamp anytime a file is closed...
but I could be totally wrong, and be missing something more obvious.

Any better hunch, anyone?
--
Joe Hatem, www.profiles.com.lb

Peter Below (TeamB)

unread,
May 1, 2000, 3:00:00 AM5/1/00
to
In article <8ej91t$n9...@bornews.borland.com>, Joe Hatem wrote:
> We designed this file-sync utility, Update2 (which you may download from our
> site).
> One of the users is facing a problem with setting the timestamp of copied
> files, when files are copied to an "Adaptec DirectCD version 2.5d" CD-ROM
> Read/Write drive:
> I myself have hunches with the fact that
> - FileSetDate needs a Handle,
> - getting a Handle implies opening file
> - an open file must eventually be closed
> - and maybe this Adaptec driver is playing smart, and enforcing Now as a
> timestamp anytime a file is closed...
> but I could be totally wrong, and be missing something more obvious.

Indeed. You miss the fact that files on a CD are read-only <G>. The
directory entry for them, once created, cannot be changed later.
You should be able to circumvent this by using a different copy strategy.
You are probably now using CopyFile followed by Get/Set file date. What
you need to do is copy the file youself, e.g. using a filestream. This way
you can set the target files date before you close the target stream, and
that should create the directory entry for it with the correct timestamp
to start with.

Procedure FileCopy( COnst sourcefilename, targetfilename: String );
Var
S,T: TFileStream;
Begin
S := TFileStream.Create( sourcefilename, fmOpenRead );
try
T := TFileStream.Create( targetfilename, fmOpenWrite or fmCreate );
try
T.CopyFrom(S, S.Size ) ;
FileSetDate(T.Handle, FileGetDate( S.Handle ));
finally
T.Free;
end;
finally
S.Free;
end;
End;


Peter Below (TeamB) 10011...@compuserve.com)
No replies in private e-mail, please, unless explicitly requested!


Dejan Maksimovic

unread,
May 1, 2000, 3:00:00 AM5/1/00
to
> Happy Easter (where applicable).

Vaistinu vaskrese (or, in laim English, thanks, likewise).

> One of the users is facing a problem with setting the timestamp of copied
> files, when files are copied to an "Adaptec DirectCD version 2.5d" CD-ROM
> Read/Write drive:

This subject has been talked of before, however, it has resulted in a
thinking that it's a problem with DirectCD itself. What CD-Rom model is the one
causing the problem?

> - FileSetDate needs a Handle,

Right.

> - getting a Handle implies opening file

Right.

> - an open file must eventually be closed

Well, evetually right.

> - and maybe this Adaptec driver is playing smart, and enforcing Now as a
> timestamp anytime a file is closed... but I could be totally wrong, and be
> missing something more obvious.

Well, I suppose that You are opening the file Yourself (i.e. the
application), when You start to copy it. So, use the same handle to set the file
dates, without closing it first/reopening.

> Any better hunch, anyone?

Yes. You say that You change the file's date? I think what You are changing
is Creation date/time, and what You want to change is Last access time, right?
Or, maybe not.

--
Look forward to Your response.
Regards, Dejan Maksimovic, CP Alfa Co.
E-mail : alfa...@ptt.yu
dmaks...@alfaunits.co.yu
Development : alf...@alfaunits.co.yu
Member of ASP, since April 13th 2000.
ICQ# : 56570367 -> Requires authorization
Tel. +381-18-363247
Fax : 1-435-4070614
Enterprise file&system components for Delphi, BCB,
MSVC++, MSVB etc.

Alfa File Monitor - The only Delphi/BCB real-time
file event notification component.
http://www.alfaunits.co.yu//afm.htm

Visit the Alfa Units home page :
http://www.alfaunits.co.yu/au.htm
The best in directory, over 2GB file, monitoring,
and registry handling. Also great in
large integer operations.
Please send me Your comments, ideas,
requests, bug reports etc.

Joe Hatem

unread,
May 3, 2000, 3:00:00 AM5/3/00
to
Hi Dejan,

Dejan Maksimovic <alfa...@ptt.yu> wrote:
--------------------------------------------


> > - and maybe this Adaptec driver is playing smart, and enforcing Now as a
> > timestamp anytime a file is closed... but I could be totally wrong, and
be
> > missing something more obvious.
>
> Well, I suppose that You are opening the file Yourself (i.e. the
> application), when You start to copy it. So, use the same handle to set
the file
> dates, without closing it first/reopening.

We are opening the target file, copying data into it, changing its date,
then closing it.
This has worked beautifully on many targets: Windows 9x, NT4, Novell 3.xx,
and even a CD-ROM with an Adaptec DirectCD driver version 2.1
Our user is having this problem using "Adaptec DirectCD version 2.5d".
That's why its weird, and that's why I suspect the Adaptec driver.

--------------------------------------------


> > Any better hunch, anyone?
>
> Yes. You say that You change the file's date? I think what You are
changing
> is Creation date/time, and what You want to change is Last access time,
right?
> Or, maybe not.

Neither, nor. What we are changing is neither the 'Created' timestamp, nor
the 'Accessed' one, but the 'Modified' timestamp (as may be seen on the
Properties panel of any Windows file).
The Modified timestamp is also known as the LastWrite timestamp.

--
Joe Hatem, www.profiles.com.lb

Joe Hatem

unread,
May 4, 2000, 3:00:00 AM5/4/00
to
Hello Peter,

We *are* doing the copy ourselves, using FileCreate, FileWrite (in a loop),
FileSetDate, CloseHandle.
In this order.
Which is about the same as the strategy you recommend.
(except for CopyFrom. In fact, using BlockRead and FileWrite in a loop
allowed us to monitor the [Cancel] button).
TFileStream is using mostly the same functions as we do.

What I probably failed to mention is that this tool worked fine with another
CD-ROM driver, the "Adaptec DirectCD 2.1".
It failed with someone using the "Adaptec DirectCD version 2.5d" driver,
which makes me suspect the driver itself.
My hunch is that, when we call CloseHandle, the driver overrides any
date/time setting with the current date/time, before letting Windows create
the directory entry.

What could be next step?

Joe.
------------------------------------------


Peter Below (TeamB) wrote:
> Indeed. You miss the fact that files on a CD are read-only <G>. The
> directory entry for them, once created, cannot be changed later.
> You should be able to circumvent this by using a different copy strategy.
> You are probably now using CopyFile followed by Get/Set file date. What
> you need to do is copy the file youself, e.g. using a filestream. This way
> you can set the target files date before you close the target stream, and
> that should create the directory entry for it with the correct timestamp
> to start with.

------------------------------------------

Dejan Maksimovic

unread,
May 4, 2000, 3:00:00 AM5/4/00
to

Well, You'd better ask Adaptec then.

Best wishes, Dejan.

Joe Hatem wrote:

--
Best wishes, Dejan Maksimovic, CP Alfa Co.


E-mail : alfa...@ptt.yu
dmaks...@alfaunits.co.yu
Development : alf...@alfaunits.co.yu

Web http://www.alfaunits.co.yu


Member of ASP, since April 13th 2000.
ICQ# : 56570367 -> Requires authorization
Tel. +381-18-363247
Fax : 1-435-4070614
Enterprise file&system components for Delphi, BCB,
MSVC++, MSVB etc.

Alfa File Monitor - The only Delphi/BCB real-time
file event notification component.

http://www.alfaunits.co.yu/eafm.htm

Visit the Alfa Units home page :

http://www.alfaunits.co.yu/eau.htm

Peter Below (TeamB)

unread,
May 4, 2000, 3:00:00 AM5/4/00
to
In article <8eq6cl$sp...@bornews.borland.com>, Joe Hatem wrote:
> What I probably failed to mention is that this tool worked fine with another
> CD-ROM driver, the "Adaptec DirectCD 2.1".
> It failed with someone using the "Adaptec DirectCD version 2.5d" driver,
> which makes me suspect the driver itself.
> My hunch is that, when we call CloseHandle, the driver overrides any
> date/time setting with the current date/time, before letting Windows create
> the directory entry.
>

Yes, giving this info i think your suspicion is on target. I see no way to get
around that.

0 new messages