-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathutil.pas
52 lines (45 loc) · 1.2 KB
/
util.pas
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
unit util;
interface
function stringstartis(const s,start : string) : boolean;
procedure makesourcepackagepath(sourcepackage,version: string; out dirname: string; out filepath: string);
implementation
function stringstartis(const s,start : string) : boolean;
var
i : integer;
begin
if length(s) < length(start) then begin
result := false;
exit;
end;
for i := 1 to length(start) do begin
if s[i] <> start[i] then begin
result := false;
exit;
end;
end;
result := true;
end;
procedure makesourcepackagepath(sourcepackage,version: string; out dirname: string; out filepath: string);
var
p : integer;
filename : string;
versionnoepoch : string;
begin
//writeln(sourcepackage);
//writeln(version);
p := pos(':',version);
if p = 0 then begin
versionnoepoch := version;
end else begin
versionnoepoch := copy(version,p+1,maxlongint);
end;
filename := sourcepackage+'_'+versionnoepoch+'.dsc';
if stringstartis(sourcepackage,'lib') then begin
dirname := 'lib' + sourcepackage[4];
end else begin
dirname := sourcepackage[1];
end;
dirname := dirname + '/' + sourcepackage;
filepath := dirname + '/' + filename;
end;
end.