I have some old code (dating back to Delphi 1 or maybe even BP days)
that performs a recursive scan of a disk volume, and returns a Tlist
full of objects representing each file.
Some newer code uses that data and does some further work. One of the
checks verifies that the file is present.
Bottom line, I have some files that are found with FindFirst, but are
not found by FileExists. I'm trying to understand why.
When matchstring is 'Q:\SOME\LONG\PATH\SOMEFILE.TXT',
FindFirst (matchstring, FAAnyFile or FADirectory, FileInfo);
succeeds and provides a valid TSearchRec into FileInfo.
A few lines later the same program I can call FileExists(matchstring),
and it will return False.
FileExists calls FileAge to determine if a file exists. FileAge
returns -1 for this file.
Digging deeper, FindFirstFile(PChar(matchstring), FindData) returns
ftLastWriteTime as part of the FindData record. The value of
ftLastWriteTime is 12/31/1979 11:27:32 PM
Opening the same file with FindFirst (matchstring, FAAnyFile or
FADirectory, FileInfo), FileInfo.time is set to 0.
The files that have this problem are all old, possibly from the 1980s,
but definitely not from 1979. Is there a special meaning for
FileInfo.time = 0?
I thought I could fix the problem by setting the dates to something
later - maybe 1/1/1981?
I used
NewDate := DateTimeToFileDate(StrToDate('1/1/1981'));
WinError := FilesetDate(Handle,Newdate);
I get error 6, invalid handle. This is using the same handle that
FindFirstFile gave me along with a valid FindData record a few lines
before. Why is there now an error on setting the date?
Am I approaching this wrong?