-
Notifications
You must be signed in to change notification settings - Fork 6
/
ufileutils.pas
52 lines (49 loc) · 1.47 KB
/
ufileutils.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 ufileutils;
{$mode objfpc}{$H+}
interface
uses
LazUTF8,sysutils;
function GetPartOfPath(out part:String;var path:String;const separator:String):String;
function FindInSupportPath(PPaths:String;FileName:String):String;
implementation
function GetPartOfPath(out part:String;var path:String;const separator:String):String;
var
i:Integer;
begin
i:=pos(separator,path);
if i<>0 then
begin
part:=copy(path,1,i-1);
path:=copy(path,i+1,length(path)-i);
end
else
begin
part:=path;
path:='';
end;
result:=part;
end;
function FindInSupportPath(PPaths:String;FileName:String):String;
var
s,ts:string;
begin
if FileExists(utf8tosys(FileName)) then
begin
result:=FileName;
exit;
end;
begin
s:=PPaths;
repeat
GetPartOfPath(ts,s,';');
ts:=ts+FileName;
if FileExists(utf8tosys(ts)) then
begin
result:=ts;
exit;
end;
until s='';
end;
result:='';
end;
end.