IDE: using FileAgeCached

git-svn-id: trunk@24344 -
This commit is contained in:
mattias 2010-04-01 11:42:03 +00:00
parent 7906cc5720
commit a7a60cd4d3
6 changed files with 42 additions and 39 deletions

View File

@ -700,7 +700,7 @@ var
var var
CurDate: LongInt; CurDate: LongInt;
begin begin
CurDate:=FileAgeUTF8(aFilename); CurDate:=FileAgeCached(aFilename);
//DebugLn(['CheckFileAge ',aFilename,' ',CurDate]); //DebugLn(['CheckFileAge ',aFilename,' ',CurDate]);
if (CurDate=-1) then exit; if (CurDate=-1) then exit;
if (MinPPUDate=-1) or (MinPPUDate>CurDate) then begin if (MinPPUDate=-1) or (MinPPUDate>CurDate) then begin
@ -731,7 +731,7 @@ begin
Result:=mrCancel; Result:=mrCancel;
CompilerDate:=FileAgeUTF8(CompilerFilename); CompilerDate:=FileAgeCached(CompilerFilename);
if CompilerDate=-1 then begin if CompilerDate=-1 then begin
Result:=MessageDlg(lisCCOErrorCaption,Format(lisCCOUnableToGetFileDate,[CompilerFilename]), Result:=MessageDlg(lisCCOErrorCaption,Format(lisCCOUnableToGetFileDate,[CompilerFilename]),
mtError,[mbIgnore,mbAbort],0); mtError,[mbIgnore,mbAbort],0);

View File

@ -34,7 +34,7 @@ uses
{$IFDEF IDE_MEM_CHECK} {$IFDEF IDE_MEM_CHECK}
MemCheck, MemCheck,
{$ENDIF} {$ENDIF}
Classes, SysUtils, Graphics, Controls, Forms, LCLProc, FileUtil, Dialogs, Classes, SysUtils, Graphics, Controls, Forms, LCLProc, FileProcs, Dialogs,
Laz_XMLCfg, AvgLvlTree, ProjectIntf, Laz_XMLCfg, AvgLvlTree, ProjectIntf,
IDEProcs, LazarusIDEStrConsts, IDETranslations, LazConf, IDEProcs, LazarusIDEStrConsts, IDETranslations, LazConf,
ObjectInspector, IDEOptionDefs, IDEWindowIntf, ExtToolDialog, TransferMacros, ObjectInspector, IDEOptionDefs, IDEWindowIntf, ExtToolDialog, TransferMacros,
@ -1488,7 +1488,7 @@ end;
function TEnvironmentOptions.FileHasChangedOnDisk: boolean; function TEnvironmentOptions.FileHasChangedOnDisk: boolean;
begin begin
Result:=FFileHasChangedOnDisk Result:=FFileHasChangedOnDisk
or ((FFilename<>'') and (FFileAge<>0) and (FileAgeUTF8(FFilename)<>FFileAge)); or ((FFilename<>'') and (FFileAge<>0) and (FileAgeCached(FFilename)<>FFileAge));
FFileHasChangedOnDisk:=Result; FFileHasChangedOnDisk:=Result;
end; end;
@ -1512,7 +1512,7 @@ procedure TEnvironmentOptions.FileUpdated;
begin begin
FFileHasChangedOnDisk:=false; FFileHasChangedOnDisk:=false;
if FFilename<>'' then if FFilename<>'' then
FFileAge:=FileAgeUTF8(FFilename) FFileAge:=FileAgeCached(FFilename)
else else
FFileAge:=0; FFileAge:=0;
end; end;

View File

@ -31,7 +31,7 @@ interface
uses uses
Classes, SysUtils, GetText, LCLProc, Translations, Classes, SysUtils, GetText, LCLProc, Translations,
IDEProcs, FileUtil, IDEProcs, FileProcs,
avl_tree, LazarusIDEStrConsts; avl_tree, LazarusIDEStrConsts;
{ IDE Language (Human, not computer) } { IDE Language (Human, not computer) }
@ -224,7 +224,7 @@ begin
//DebugLn(['ConvertPackageRSTFiles RSTFilename=',RSTFilename,' OutputFilename=',OutputFilename]); //DebugLn(['ConvertPackageRSTFiles RSTFilename=',RSTFilename,' OutputFilename=',OutputFilename]);
if (not FileExistsUTF8(OutputFilename)) if (not FileExistsUTF8(OutputFilename))
or (FileAgeUTF8(RSTFilename)>FileAgeUTF8(OutputFilename)) then or (FileAgeCached(RSTFilename)>FileAgeCached(OutputFilename)) then
begin begin
FileList.Add(RSTFilename); FileList.Add(RSTFilename);
{$ifndef SinglePOFile} {$ifndef SinglePOFile}

View File

@ -35,7 +35,7 @@ unit InputHistory;
interface interface
uses uses
Classes, SysUtils, FileUtil, DiffPatch, IDEProcs, AvgLvlTree, Classes, SysUtils, FileUtil, FileProcs, DiffPatch, IDEProcs, AvgLvlTree,
SynEditTypes, Laz_XMLCfg, LazConf, Dialogs, LCLProc; SynEditTypes, Laz_XMLCfg, LazConf, Dialogs, LCLProc;
{$ifdef Windows} {$ifdef Windows}
@ -851,8 +851,8 @@ begin
Clear; Clear;
FCompilerPath:=AValue; FCompilerPath:=AValue;
ResolvedFilename:=ReadAllLinks(FCompilerPath,false); ResolvedFilename:=ReadAllLinks(FCompilerPath,false);
if FileExistsUTF8(ResolvedFilename) then if FileExistsCached(ResolvedFilename) then
FCompilerAge:=FileAgeUTF8(ResolvedFilename) FCompilerAge:=FileAgeCached(ResolvedFilename)
else else
FCompilerAge:=-1; FCompilerAge:=-1;
end; end;
@ -947,7 +947,7 @@ begin
if Result and CheckCompiler then begin if Result and CheckCompiler then begin
ResolvedFilename:=ReadAllLinks(FCompilerPath,false); ResolvedFilename:=ReadAllLinks(FCompilerPath,false);
if FileExistsUTF8(ResolvedFilename) if FileExistsUTF8(ResolvedFilename)
and (FileAgeUTF8(ResolvedFilename)=FCompilerAge) then and (FileAgeCached(ResolvedFilename)=FCompilerAge) then
exit; exit;
FCompilerAge:=-1; FCompilerAge:=-1;
Result:=false; Result:=false;

View File

@ -59,13 +59,13 @@ uses
MemCheck, MemCheck,
{$ENDIF} {$ENDIF}
// fpc packages // fpc packages
Math, Classes, SysUtils, Process, AsyncProcess, TypInfo, Math, Classes, SysUtils, Process, AsyncProcess, TypInfo, AVL_Tree,
// lcl // lcl
LCLProc, LCLMemManager, LCLType, LCLIntf, LConvEncoding, LMessages, ComCtrls, LCLProc, LCLMemManager, LCLType, LCLIntf, LConvEncoding, LMessages, ComCtrls,
LResources, StdCtrls, Forms, Buttons, Menus, FileUtil, Controls, GraphType, FileUtil, LResources, StdCtrls, Forms, Buttons, Menus, Controls, GraphType,
HelpIntfs, Graphics, ExtCtrls, Dialogs, InterfaceBase, LDockCtrl, UTF8Process, HelpIntfs, Graphics, ExtCtrls, Dialogs, InterfaceBase, LDockCtrl, UTF8Process,
// codetools // codetools
CodeBeautifier, FindDeclarationTool, LinkScanner, BasicCodeTools, AVL_Tree, FileProcs, CodeBeautifier, FindDeclarationTool, LinkScanner, BasicCodeTools,
Laz_XMLCfg, CodeToolsStructs, CodeToolManager, CodeCache, DefineTemplates, Laz_XMLCfg, CodeToolsStructs, CodeToolManager, CodeCache, DefineTemplates,
// synedit // synedit
SynEditKeyCmds, SynBeautifier, SynEditMarks, SynEditKeyCmds, SynBeautifier, SynEditMarks,
@ -3648,7 +3648,7 @@ begin
+lisAllFiles+'|'+GetAllFilesMask; +lisAllFiles+'|'+GetAllFilesMask;
if OpenDialog.Execute then begin if OpenDialog.Execute then begin
AFilename:=ExpandFileNameUTF8(OpenDialog.Filename); AFilename:=ExpandFileNameUTF8(OpenDialog.Filename);
if CompareFileExt(AFilename,'.lpi')<>0 then begin if FileUtil.CompareFileExt(AFilename,'.lpi')<>0 then begin
// not a lpi file // not a lpi file
// check if it is a program source // check if it is a program source
@ -3828,7 +3828,7 @@ begin
POFileAgeValid:=false; POFileAgeValid:=false;
if FileExistsCached(POFilename) then begin if FileExistsCached(POFilename) then begin
POFileAge:=FileAgeUTF8(POFilename); POFileAge:=FileAgeCached(POFilename);
POFileAgeValid:=true; POFileAgeValid:=true;
end; end;
@ -3844,7 +3844,7 @@ begin
// check .lst file // check .lst file
LRTFilename:=ChangeFileExt(CurFilename,'.lrt'); LRTFilename:=ChangeFileExt(CurFilename,'.lrt');
if FileExistsCached(LRTFilename) if FileExistsCached(LRTFilename)
and ((not POFileAgeValid) or (FileAgeUTF8(LRTFilename)>POFileAge)) then and ((not POFileAgeValid) or (FileAgeCached(LRTFilename)>POFileAge)) then
Files.Add(LRTFilename); Files.Add(LRTFilename);
// check .rst file // check .rst file
RSTFilename:=ExtractFileName(ChangeFileExt(CurFilename,'.rst')); RSTFilename:=ExtractFileName(ChangeFileExt(CurFilename,'.rst'));
@ -3859,7 +3859,7 @@ begin
//DebugLn(['TMainIDE.UpdateProjectPOFile Looking for .rst file ="',RSTFilename,'"']); //DebugLn(['TMainIDE.UpdateProjectPOFile Looking for .rst file ="',RSTFilename,'"']);
if FileExistsCached(RSTFilename) if FileExistsCached(RSTFilename)
and ((not POFileAgeValid) or (FileAgeUTF8(RSTFilename)>POFileAge)) then and ((not POFileAgeValid) or (FileAgeCached(RSTFilename)>POFileAge)) then
Files.Add(RSTFilename); Files.Add(RSTFilename);
end; end;
AnUnitInfo:=AnUnitInfo.NextPartOfProject; AnUnitInfo:=AnUnitInfo.NextPartOfProject;
@ -9548,7 +9548,8 @@ begin
Ext:='.lpi'; Ext:='.lpi';
end; end;
if (not FileIsText(AFilename,FileReadable)) and FileReadable then begin if (not FileUtil.FileIsText(AFilename,FileReadable)) and FileReadable then
begin
ACaption:=lisFileNotText; ACaption:=lisFileNotText;
AText:=Format(lisFileDoesNotLookLikeATextFileOpenItAnyway, ['"', AFilename, AText:=Format(lisFileDoesNotLookLikeATextFileOpenItAnyway, ['"', AFilename,
'"', #13, #13]); '"', #13, #13]);
@ -10113,7 +10114,7 @@ begin
or (AProject.LastCompilerParams<>CompilerParams) or (AProject.LastCompilerParams<>CompilerParams)
or ((AProject.LastCompilerFileDate>0) or ((AProject.LastCompilerFileDate>0)
and FileExistsCached(CompilerFilename) and FileExistsCached(CompilerFilename)
and (FileAgeUTF8(CompilerFilename)<>AProject.LastCompilerFileDate)) and (FileAgeCached(CompilerFilename)<>AProject.LastCompilerFileDate))
then then
NeedBuildAllFlag:=true; NeedBuildAllFlag:=true;
@ -10126,10 +10127,10 @@ begin
exit(mrYes); exit(mrYes);
end; end;
StateFileAge:=FileAgeUTF8(StateFilename); StateFileAge:=FileAgeCached(StateFilename);
// check main source file // check main source file
if FileExistsUTF8(SrcFilename) and (StateFileAge<FileAgeUTF8(SrcFilename)) then if FileExistsCached(SrcFilename) and (StateFileAge<FileAgeCached(SrcFilename)) then
begin begin
DebugLn('TMainIDE.CheckIfProjectNeedsCompilation SrcFile outdated ',AProject.IDAsString); DebugLn('TMainIDE.CheckIfProjectNeedsCompilation SrcFile outdated ',AProject.IDAsString);
exit(mrYes); exit(mrYes);
@ -10147,7 +10148,7 @@ begin
DebugLn(' File="',CompilerFilename,'"'); DebugLn(' File="',CompilerFilename,'"');
exit(mrYes); exit(mrYes);
end; end;
if FileAgeUTF8(CompilerFilename)<>AProject.LastCompilerFileDate then begin if FileAgeCached(CompilerFilename)<>AProject.LastCompilerFileDate then begin
DebugLn('TMainIDE.CheckIfProjectNeedsCompilation Compiler file changed for ',AProject.IDAsString); DebugLn('TMainIDE.CheckIfProjectNeedsCompilation Compiler file changed for ',AProject.IDAsString);
DebugLn(' File="',CompilerFilename,'"'); DebugLn(' File="',CompilerFilename,'"');
exit(mrYes); exit(mrYes);
@ -10171,8 +10172,8 @@ begin
// check project files // check project files
AnUnitInfo:=AProject.FirstPartOfProject; AnUnitInfo:=AProject.FirstPartOfProject;
while AnUnitInfo<>nil do begin while AnUnitInfo<>nil do begin
if FileExistsUTF8(AnUnitInfo.Filename) if FileExistsCached(AnUnitInfo.Filename)
and (StateFileAge<FileAgeUTF8(AnUnitInfo.Filename)) then begin and (StateFileAge<FileAgeCached(AnUnitInfo.Filename)) then begin
DebugLn('TMainIDE.CheckIfProjectNeedsCompilation Src has changed ',AProject.IDAsString,' ',AnUnitInfo.Filename); DebugLn('TMainIDE.CheckIfProjectNeedsCompilation Src has changed ',AProject.IDAsString,' ',AnUnitInfo.Filename);
exit(mrYes); exit(mrYes);
end; end;
@ -10183,8 +10184,8 @@ begin
AnUnitInfo:=AProject.FirstUnitWithEditorIndex; AnUnitInfo:=AProject.FirstUnitWithEditorIndex;
while AnUnitInfo<>nil do begin while AnUnitInfo<>nil do begin
if (not AnUnitInfo.IsPartOfProject) if (not AnUnitInfo.IsPartOfProject)
and FileExistsUTF8(AnUnitInfo.Filename) and FileExistsCached(AnUnitInfo.Filename)
and (StateFileAge<FileAgeUTF8(AnUnitInfo.Filename)) then begin and (StateFileAge<FileAgeCached(AnUnitInfo.Filename)) then begin
DebugLn('TMainIDE.CheckIfProjectNeedsCompilation Editor Src has changed ',AProject.IDAsString,' ',AnUnitInfo.Filename); DebugLn('TMainIDE.CheckIfProjectNeedsCompilation Editor Src has changed ',AProject.IDAsString,' ',AnUnitInfo.Filename);
exit(mrYes); exit(mrYes);
end; end;
@ -10524,7 +10525,7 @@ begin
// save state, so that next time the project is not compiled clean // save state, so that next time the project is not compiled clean
Project1.LastCompilerFilename:=CompilerFilename; Project1.LastCompilerFilename:=CompilerFilename;
Project1.LastCompilerParams:=CompilerParams; Project1.LastCompilerParams:=CompilerParams;
Project1.LastCompilerFileDate:=FileAgeUTF8(CompilerFilename); Project1.LastCompilerFileDate:=FileAgeCached(CompilerFilename);
DoJumpToCompilerMessage(-1,true); DoJumpToCompilerMessage(-1,true);
CompileProgress.Ready(lisInfoBuildError); CompileProgress.Ready(lisInfoBuildError);
exit; exit;
@ -12568,7 +12569,7 @@ var
SearchFile:=AFilename; SearchFile:=AFilename;
SearchPath:=AllIncPaths; SearchPath:=AllIncPaths;
Result:=SearchFileInPath(SearchFile,BaseDir,SearchPath,';',[]); Result:=FileUtil.SearchFileInPath(SearchFile,BaseDir,SearchPath,';',[]);
{$IFDEF VerboseFindSourceFile} {$IFDEF VerboseFindSourceFile}
debugln(['TMainIDE.SearchIndirectIncludeFile Result="',Result,'"']); debugln(['TMainIDE.SearchIndirectIncludeFile Result="',Result,'"']);
{$ENDIF} {$ENDIF}
@ -12583,7 +12584,7 @@ var
Filename:=''; Filename:='';
SearchPath:=RemoveSearchPaths(TheSearchPath,AlreadySearchedPaths); SearchPath:=RemoveSearchPaths(TheSearchPath,AlreadySearchedPaths);
if SearchPath<>'' then begin if SearchPath<>'' then begin
Filename:=SearchFileInPath(SearchFile,BaseDir,SearchPath,';',[]); Filename:=FileUtil.SearchFileInPath(SearchFile,BaseDir,SearchPath,';',[]);
{$IFDEF VerboseFindSourceFile} {$IFDEF VerboseFindSourceFile}
debugln(['TMainIDE.FindSourceFile trying "',SearchPath,'" Filename="',Filename,'"']); debugln(['TMainIDE.FindSourceFile trying "',SearchPath,'" Filename="',Filename,'"']);
{$ENDIF} {$ENDIF}

View File

@ -49,8 +49,10 @@ uses
MemCheck, MemCheck,
{$ENDIF} {$ENDIF}
Classes, SysUtils, TypInfo, FPCAdds, LCLProc, LCLIntf, LCLType, Forms, Classes, SysUtils, TypInfo, FPCAdds, LCLProc, LCLIntf, LCLType, Forms,
Controls, Dialogs, InterfaceBase, FileUtil, Controls, Dialogs, InterfaceBase,
Laz_XMLCfg, ExprEval, FileUtil, DefineTemplates, CodeToolManager, CodeCache, ProjectIntf, MacroIntf, LazIDEIntf, Laz_XMLCfg, ExprEval, FileProcs, DefineTemplates, CodeToolManager, CodeCache,
// IDEIntf
ProjectIntf, MacroIntf, LazIDEIntf,
// IDE // IDE
CompOptsModes, ProjectResources, LazConf, frmCustomApplicationOptions, CompOptsModes, ProjectResources, LazConf, frmCustomApplicationOptions,
LazarusIDEStrConsts, CompilerOptions, LazarusIDEStrConsts, CompilerOptions,
@ -2631,7 +2633,7 @@ begin
if CompareFilenames(ProjectInfoFile,xmlconfig.Filename)=0 then begin if CompareFilenames(ProjectInfoFile,xmlconfig.Filename)=0 then begin
fProjectInfoFileBuffer:=CodeToolBoss.LoadFile(ProjectInfoFile,true,true); fProjectInfoFileBuffer:=CodeToolBoss.LoadFile(ProjectInfoFile,true,true);
try try
fProjectInfoFileDate:=FileAgeUTF8(ProjectInfoFile); fProjectInfoFileDate:=FileAgeCached(ProjectInfoFile);
except except
end; end;
end; end;
@ -2965,7 +2967,7 @@ begin
ProjectInfoFile:=NewProjectInfoFile; ProjectInfoFile:=NewProjectInfoFile;
fProjectInfoFileBuffer:=CodeToolBoss.LoadFile(ProjectInfoFile,true,true); fProjectInfoFileBuffer:=CodeToolBoss.LoadFile(ProjectInfoFile,true,true);
try try
fProjectInfoFileDate:=FileAgeUTF8(ProjectInfoFile); fProjectInfoFileDate:=FileAgeCached(ProjectInfoFile);
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject A reading lpi');{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject A reading lpi');{$ENDIF}
if fProjectInfoFileBuffer=nil then if fProjectInfoFileBuffer=nil then
xmlconfig := TXMLConfig.CreateClean(ProjectInfoFile) xmlconfig := TXMLConfig.CreateClean(ProjectInfoFile)
@ -4052,7 +4054,7 @@ begin
end; end;
if not FileExistsCached(ProjectInfoFile) then exit; if not FileExistsCached(ProjectInfoFile) then exit;
if fProjectInfoFileDate=FileAgeUTF8(ProjectInfoFile) then exit; if fProjectInfoFileDate=FileAgeCached(ProjectInfoFile) then exit;
//DebugLn(['TProject.HasProjectInfoFileChangedOnDisk ',ProjectInfoFile,' fProjectInfoFileDate=',fProjectInfoFileDate,' ',FileAgeUTF8(ProjectInfoFile)]); //DebugLn(['TProject.HasProjectInfoFileChangedOnDisk ',ProjectInfoFile,' fProjectInfoFileDate=',fProjectInfoFileDate,' ',FileAgeUTF8(ProjectInfoFile)]);
Result:=true; Result:=true;
@ -4060,7 +4062,7 @@ end;
procedure TProject.IgnoreProjectInfoFileOnDisk; procedure TProject.IgnoreProjectInfoFileOnDisk;
begin begin
fProjectInfoFileDate:=FileAgeUTF8(ProjectInfoFile); fProjectInfoFileDate:=FileAgeCached(ProjectInfoFile);
end; end;
function TProject.FindDependencyByName(const PackageName: string function TProject.FindDependencyByName(const PackageName: string
@ -4550,7 +4552,7 @@ begin
end; end;
// read the state file // read the state file
CurStateFileAge:=FileAgeUTF8(StateFile); CurStateFileAge:=FileAgeCached(StateFile);
if (not (lpsfStateFileLoaded in StateFlags)) if (not (lpsfStateFileLoaded in StateFlags))
or (StateFileDate<>CurStateFileAge) then or (StateFileDate<>CurStateFileAge) then
begin begin
@ -4593,7 +4595,7 @@ var
begin begin
StateFile:=GetStateFilename; StateFile:=GetStateFilename;
try try
CompilerFileDate:=FileAgeUTF8(CompilerFilename); CompilerFileDate:=FileAgeCached(CompilerFilename);
XMLConfig:=TXMLConfig.CreateClean(StateFile); XMLConfig:=TXMLConfig.CreateClean(StateFile);
try try
XMLConfig.SetValue('Compiler/Value',CompilerFilename); XMLConfig.SetValue('Compiler/Value',CompilerFilename);
@ -4607,7 +4609,7 @@ begin
LastCompilerFilename:=CompilerFilename; LastCompilerFilename:=CompilerFilename;
LastCompilerFileDate:=CompilerFileDate; LastCompilerFileDate:=CompilerFileDate;
LastCompilerParams:=CompilerParams; LastCompilerParams:=CompilerParams;
StateFileDate:=FileAgeUTF8(StateFile); StateFileDate:=FileAgeCached(StateFile);
StateFlags:=StateFlags+[lpsfStateFileLoaded]; StateFlags:=StateFlags+[lpsfStateFileLoaded];
except except
on E: Exception do begin on E: Exception do begin