-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathUCommon.pas
More file actions
37 lines (25 loc) · 756 Bytes
/
UCommon.pas
File metadata and controls
37 lines (25 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
unit UCommon;
interface
const BDS_KEY = 'Software\Embarcadero\BDS';
const INI_FILE_NAME = 'CompInstall.ini';
var AppDir: string;
function HasInList(const Item, List: string): Boolean;
function NormalizeAndRemoveFirstDir(Path: string): string;
implementation
uses System.SysUtils;
function HasInList(const Item, List: string): Boolean;
const SEP = ';';
begin
//returns if Item is contained in the List splited by SEP character
Result := Pos(SEP+Item+SEP, SEP+List+SEP)>0;
end;
function NormalizeAndRemoveFirstDir(Path: string): string;
var
I: Integer;
begin
Path := Path.Replace('/', '\');
I := Path.IndexOf('\');
if I=-1 then raise Exception.Create('First directory separator not found');
Result := Path.Remove(0, I+1);
end;
end.