• R/O
  • SSH
  • HTTPS

dzbdslauncher: 提交


Commit MetaInfo

修訂43 (tree)
時間2022-01-22 20:43:50
作者dummzeuch

Log Message

additionally check for the Delphi version anywhere in the groupproj file name name (including the path), followed by '.', '_', '\' or '-' and preceded by one of these characters or 'D', 'Delphi', 'BDS' or 'RS'.

Change Summary

差異

--- trunk/src/u_dzBdsLauncher.pas (revision 42)
+++ trunk/src/u_dzBdsLauncher.pas (revision 43)
@@ -56,6 +56,7 @@
5656 procedure CallIde(const _Param: string);
5757 function HasProductVersion(const _ProdVer: string): Boolean;
5858 function HasExtension(const _Ext: string): Boolean;
59+ function FileNameContainsDelphiVersion(const _fn: string): Boolean;
5960 property Name: string read FName;
6061 property RegKey: string read FRegKey;
6162 property DllSuffix: string read FDllSuffix;
@@ -80,6 +81,38 @@
8081 inherited;
8182 end;
8283
84+function PrecedesText(const _SubText: string; _Text: string; _Pos: Integer): Boolean;
85+var
86+ SubLen: Integer;
87+begin
88+ SubLen := Length(_SubText);
89+ Result := _Pos - SubLen > 0;
90+ if Result then begin
91+ Result := SameText(_SubText, Copy(_Text, _Pos - SubLen, SubLen));
92+ end;
93+end;
94+
95+function TDelphiInfo.FileNameContainsDelphiVersion(const _fn: string): Boolean;
96+var
97+ p: Integer;
98+ len: Integer;
99+begin
100+ Result := False;
101+ p := RPosStr(FName, _fn);
102+ if p = 0 then
103+ Exit; //==>
104+
105+ if (p = 1) or PrecedesText('Delphi', _fn, p) or PrecedesText('BDS', _fn, p) or PrecedesText('RS', _fn, p)
106+ or CharInSet(_fn[p - 1], ['D', 'd', '.', '_', '\', '-']) then begin
107+ len := Length(FName);
108+ if ((p + len) > Length(_fn)) or CharInSet(_fn[p + len], ['.', '_', '\', '-']) then begin
109+ Result := True;
110+ Exit; //==>
111+ end;
112+ end;
113+
114+end;
115+
83116 function TDelphiInfo.HasExtension(const _Ext: string): Boolean;
84117 var
85118 Ext: string;
@@ -359,6 +392,7 @@
359392 len: Integer;
360393 dir: string;
361394 dv: TDelphiVersion;
395+ Item: TPair<TDelphiVersion, TDelphiInfo>;
362396 begin
363397 sl := TStringList.Create;
364398 try
@@ -378,7 +412,16 @@
378412 s := TFileSystem.ExpandFileNameRelBaseDir(s, dir);
379413 StdOut.WriteLn(_('First project is: %s'), [s]);
380414 dv := GetDelphiVersionForDproj(s);
381- Items[dv].CallIde(_fn);
415+ if dv <> dvUnknown then begin
416+ Items[dv].CallIde(_fn);
417+ Exit; //==>
418+ end;
419+ end;
420+ end;
421+ StdOut.WriteLn(_('Checking project group filename'));
422+ for Item in Self do begin
423+ if Item.Value.FileNameContainsDelphiVersion(_fn) then begin
424+ Item.Value.CallIde(_fn);
382425 Exit; //==>
383426 end;
384427 end;
Show on old repository browser