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'.
@@ -56,6 +56,7 @@ | ||
56 | 56 | procedure CallIde(const _Param: string); |
57 | 57 | function HasProductVersion(const _ProdVer: string): Boolean; |
58 | 58 | function HasExtension(const _Ext: string): Boolean; |
59 | + function FileNameContainsDelphiVersion(const _fn: string): Boolean; | |
59 | 60 | property Name: string read FName; |
60 | 61 | property RegKey: string read FRegKey; |
61 | 62 | property DllSuffix: string read FDllSuffix; |
@@ -80,6 +81,38 @@ | ||
80 | 81 | inherited; |
81 | 82 | end; |
82 | 83 | |
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 | + | |
83 | 116 | function TDelphiInfo.HasExtension(const _Ext: string): Boolean; |
84 | 117 | var |
85 | 118 | Ext: string; |
@@ -359,6 +392,7 @@ | ||
359 | 392 | len: Integer; |
360 | 393 | dir: string; |
361 | 394 | dv: TDelphiVersion; |
395 | + Item: TPair<TDelphiVersion, TDelphiInfo>; | |
362 | 396 | begin |
363 | 397 | sl := TStringList.Create; |
364 | 398 | try |
@@ -378,7 +412,16 @@ | ||
378 | 412 | s := TFileSystem.ExpandFileNameRelBaseDir(s, dir); |
379 | 413 | StdOut.WriteLn(_('First project is: %s'), [s]); |
380 | 414 | 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); | |
382 | 425 | Exit; //==> |
383 | 426 | end; |
384 | 427 | end; |