@@ -35,6 +35,8 @@ TBorlandCompiler = class(TCompilerBase)
3535 var
3636 fId: TCompilerID;
3737 { Identifies compiler}
38+ // Flags whether user permits compiler to be auto installed.
39+ fCanAutoInstall: Boolean;
3840 function InstallPathFromReg (const RootKey: HKEY): string;
3941 { Gets compiler install root path from given registry root key, if present.
4042 @param RootKey [in] Given registry root key.
@@ -70,10 +72,35 @@ TBorlandCompiler = class(TCompilerBase)
7072 @param Obj Compiler object to copy.
7173 }
7274 { ICompilerAutoDetect }
75+ // / <summary>Detects and records path to command line compiler exe file,
76+ // / if compiler is registered as installed.</summary>
77+ // / <returns>Boolean. True if compiler is registered as installed, False
78+ // / otherwise.</returns>
79+ // / <remarks>
80+ // / <para>Does not check if the compiler exe file actually exists.</para>
81+ // / <para>Does not set compiler exe file if compiler is not installed.
82+ // / </para>
83+ // / <para>Method of ICompilerAutoDetect.</para>
84+ // / </remarks>
7385 function DetectExeFile : Boolean;
74- { Detects and records path to command line compiler if present.
75- @return True if compiler path found, false otherwise.
76- }
86+ // / <summary>Checks if the compiler is installed on the user's system.
87+ // / </summary>
88+ // / <returns>Boolean. True if compiler is physically installed, False
89+ // / otherwise.</returns>
90+ // / <remarks>
91+ // / <para>Checks if compiler exe is actually present.</para>
92+ // / <para>Method of ICompilerAutoDetect.</para>
93+ // / </remarks>
94+ function IsInstalled : Boolean;
95+ // / <summary>Checks if the compiler is permitted to be automatically
96+ // / installed.</summary>
97+ // / <remarks>Method of ICompilerAutoDetect.</remarks>
98+ function GetCanAutoInstall : Boolean;
99+ // / <summary>Determines whether the compiler can be automatically
100+ // / installed.</summary>
101+ // / <remarks>Method of ICompilerAutoDetect.</remarks>
102+ procedure SetCanAutoInstall (const Value : Boolean);
103+
77104 { ICompiler }
78105 function GetDefaultSwitches : string; override;
79106 { Returns default command line switches for compiler.
@@ -97,7 +124,7 @@ implementation
97124
98125uses
99126 // Delphi
100- SysUtils, Registry,
127+ SysUtils, Registry, IOUtils,
101128 // Project
102129 UIStringList, UStrUtils, USystemInfo;
103130
@@ -118,6 +145,7 @@ constructor TBorlandCompiler.CreateCopy(const Obj: TBorlandCompiler);
118145begin
119146 inherited CreateCopy(Obj);
120147 fId := Obj.GetID;
148+ fCanAutoInstall := Obj.GetCanAutoInstall;
121149end ;
122150
123151procedure TBorlandCompiler.DeleteObjFiles (const Path, Project: string);
@@ -144,6 +172,11 @@ function TBorlandCompiler.DetectExeFile: Boolean;
144172 SetExecFile(ExePath);
145173end ;
146174
175+ function TBorlandCompiler.GetCanAutoInstall : Boolean;
176+ begin
177+ Result := fCanAutoInstall;
178+ end ;
179+
147180function TBorlandCompiler.GetDefaultSwitches : string;
148181 { Returns default command line switches for Borland compilers.
149182 @return Switches separated by commas.
@@ -211,6 +244,15 @@ function TBorlandCompiler.InstallPathFromReg(const RootKey: HKEY): string;
211244 end ;
212245end ;
213246
247+ function TBorlandCompiler.IsInstalled : Boolean;
248+ var
249+ ExePath: string;
250+ begin
251+ if not GetExePathIfInstalled(ExePath) then
252+ Exit(False);
253+ Result := TFile.Exists(ExePath, False);
254+ end ;
255+
214256function TBorlandCompiler.SearchDirParams : string;
215257 { One of more parameters that define any search directories to be passed to
216258 compiler on command line.
@@ -228,5 +270,10 @@ function TBorlandCompiler.SearchDirParams: string;
228270 + ' ' + StrQuoteSpaced(' -R' + Dirs.GetText(' ;' , False));
229271end ;
230272
273+ procedure TBorlandCompiler.SetCanAutoInstall (const Value : Boolean);
274+ begin
275+ fCanAutoInstall := Value ;
276+ end ;
277+
231278end .
232279
0 commit comments