[fpc-devel] Question regarding FileSetDate implementation

Sergei Gorelkin sergei_gorelkin at mail.ru
Tue Nov 9 10:42:05 CET 2010


Sven Barth пишет:
> Hello together!
> 
> As you might have noticed, I'm working on the NativeNT RTL again and 
> discover some nice FPC_HAS_FEATURE_* and THandle problems on the way. 
> Now I've found another one and I'd like to know how this should be fixed:
> 
> FileSetDate in SysUtils (the filename variant) returns a LongInt, but 
> someone thought it was a good idea to return the (invalid) file handle 
> if the FileOpen call fails. Thus I get a compile error, cause my handle 
> type on NativeNT is a Pointer.
> 
> The documentation states that a negative value is returned in case of an 
> error. Granted, INVALID_HANDLE_VALUE is negative, but that's no reason 
> to assign the value of the handle there (what if some OS decides that an 
> invalid handle is 42 instead of LongWord(-1)?)
> 
According to Delphi documentation, it should return zero on success, non-zero error code otherwise.
Windows handle-based implementation conforms to that. The proper fix would be returning value of 
GetLastOSError, but it may be not available for all platforms.

Regards,
Sergei




More information about the fpc-devel mailing list