Remy Porter's CodeSOD column recounts a bug hunt by a developer named Greta, who works with an old Pascal development setup. Her program kept reporting that files did not exist, even though they clearly did. Tracing the fault led into the standard system library shipped with Borland's Delphi and Kylix cross-platform runtime, originally copyrighted 1995 to 2001.

The library's FileExists function does not check file presence directly. Instead it calls FileAge, which uses the Windows API function FindFirstFile to locate the file and then FileTimeToDosDateTime to convert the file's last-write time into a DOS-style date and time value. If that conversion succeeds, FileAge returns the encoded timestamp. If anything fails along the way, FileAge returns -1, and FileExists then reports the file as absent whenever FileAge returns -1.

The actual bug: FileTimeToDosDateTime returns a boolean success flag and sets a Windows error code on failure, but the Delphi library code never checks that flag or the error code. Some process on Greta's system was writing files without setting a last-write timestamp. With no valid timestamp to convert, FileTimeToDosDateTime failed silently, FileAge returned -1, and FileExists wrongly concluded the file did not exist, even though it was sitting right there on disk.