From: <dav...@us...> - 2009-08-17 03:57:57
|
Revision: 832 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=832&view=rev Author: davidvtaylor Date: 2009-08-17 03:57:48 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Fix for FileAge deprecation warning in InstantModelExpert. Single argument version was deprecated in D2006. - Added InstantFileAge function to InstantUtils with same signature as new FileAge function - Replaced calls to FileAge with calls to InstantFileAge Modified Paths: -------------- trunk/Source/Core/InstantUtils.pas trunk/Source/Design/InstantModelExpert.pas Modified: trunk/Source/Core/InstantUtils.pas =================================================================== --- trunk/Source/Core/InstantUtils.pas 2009-08-16 17:38:57 UTC (rev 831) +++ trunk/Source/Core/InstantUtils.pas 2009-08-17 03:57:48 UTC (rev 832) @@ -25,7 +25,7 @@ * * Contributor(s): * Carlo Barazzetta, Adrea Petrelli, Nando Dessena, Uberto Barbini, - * Brian Andersen + * Brian Andersen, David Taylor * * ***** END LICENSE BLOCK ***** *) @@ -60,6 +60,7 @@ function InstantConstArrayToVariant(AValues : array of const) : Variant; function InstantDateTimeToStr(DateTime: TDateTime): string; function InstantEmbrace(const S, Delimiters: string): string; +function InstantFileAge(const FileName: string; out FileDateTime: TDateTime): boolean; {$IFDEF MSWINDOWS} function InstantFileVersionValue(const FileName, ValueName: string): string; function InstantFileVersion(const FileName: string): TInstantVersion; @@ -269,6 +270,22 @@ Result := LeftDelimiter + S + RightDelimiter; end; +function InstantFileAge(const FileName: string; out FileDateTime: TDateTime): boolean; +{$IFNDEF D10+} +var + LFileAge : integer; +{$ENDIF} +begin + {$IFDEF D10+} // Single param FileAge deprecated in D2006 + Result := FileAge(FileName, FileDateTime); + {$ELSE} + LFileAge := FileAge(FileName); + Result := (LFileAge <> -1); + if (Result) then + FileDateTime := FileDateToDateTime(LFileAge); + {$ENDIF} +end; + {$IFDEF MSWINDOWS} function InstantFileVersionStr(const FileName: string): string; begin Modified: trunk/Source/Design/InstantModelExpert.pas =================================================================== --- trunk/Source/Design/InstantModelExpert.pas 2009-08-16 17:38:57 UTC (rev 831) +++ trunk/Source/Design/InstantModelExpert.pas 2009-08-17 03:57:48 UTC (rev 832) @@ -692,17 +692,16 @@ var Model: TInstantCodeModel; ResFileName: string; - ResFileAge: Integer; ResFileTime: TDateTime; begin DisableUpdate; Model := TInstantCodeModel.Create; try ResFileName := ChangeFileExt(Project.FileName, SResFileExt); - ResFileAge := FileAge(ResFileName); - if ResFileAge = -1 then - ResFileTime := 0 else - ResFileTime := FileDateToDateTime(ResFileAge); + + if (not InstantFileAge(ResFileName, ResFileTime)) then + ResFileTime := 0; + try if LoadModel(Model, Project, ResFileTime) then Model.SaveToResFile(ResFileName); @@ -1037,13 +1036,12 @@ function FileModified(const FileName: string; Since: TDateTime): Boolean; var - Age: Integer; + FileTime: TDateTime; begin - Age := FileAge(FileName); - if Age = -1 then + if (not InstantFileAge(FileName, FileTime)) then Result := False else - Result := FileDateToDateTime(Age) > Since; + Result := (FileTime > Since); end; function ModuleModified(Module: IOTAModule; Since: TDateTime): Boolean; |