[DUG] Help in getting file age
Jianming Lin (FMI)
jianmingl at fmi.co.nz
Fri May 1 17:15:50 NZST 2009
Sorry, guys, made mistake.
If a file is saved in FAT32, file time is recorded as local time.
Win32 API function FindFirstFile will automatically test that if a file
is in FAT32 system, it will convert the local time to UTC time, and put
it in the variable of
TWin32FindData. ftLastWriteTime.
We don't need to call
LocalFileTimeToFileTime(LocalFileTime, UTC_FTime); //convert to UTC
time
As in
function FAT_GetFileUTC_Time(const FileName: string; var FileUTC_Time:
TSystemTime): boolean;
You can see that if a file is saved in FAT32 media, say at 3:00pm
25/09/09.
After day light saving time started for example on 01/11/09,
Use function GetFileUTC_Time will return 2:00am 25/09/09.
Use the following method will return 3:00am 25/09/09 which is correct.
//----------------------------------------------------------------------
-----------------
function GetFileUTC_Time(FileName:string; var FileRaw_Time: Integer):
boolean;
var fHdl: integer;
fInfo: TByHandleFileInformation;
begin
result := false;
fHdl := fileopen(FileName, fmOpenRead );
try
if GetFileInformationByHandle(fHdl, fInfo) then
//FileTimeToSystemTime(fInfo.ftLastWriteTime, FileRaw_Time);
result := FileTimeToDosDateTime(fInfo.ftLastWriteTime,
LongRec(FileRaw_Time).Hi, LongRec(FileRaw_Time).Lo);
finally
fileClose(fHdl);
end;
end;
________________________________
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of Vikas...
Sent: Friday, 1 May 2009 2:07 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Help in getting file age
Dear Everyone,
I need a help in calculating the age of file.
I have checked the function file age. But it dint serve the purpose.
Reason being is. Let say i am sitting in India changed a file on 30th
April at 7:15pm. But on the other hand some one from america modifies
the same files at 9:30am on 30th April since we have time difference of
12 hours from US. So how do i make sure this file modified at 9:30am is
the new one.
Since according the file age filed modified at 7:15pm that is later one
is new. Which is not right.
Anyone ever worked on such things before.
I hope my query makes sense.
Cheers
Vik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20090501/596324bc/attachment.html
More information about the Delphi
mailing list