mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-11 10:29:21 +02:00
* added function IncludeLeadingPathDelimiter: it adds a path delimiter in front of a path
* added function ExcludeLeadingPathDelimiter: it removes a path delimiter in front of a path * added function ConcatPaths: it concats multiple path fragments, path delimiters are added if necessary git-svn-id: trunk@15167 -
This commit is contained in:
parent
fecd661bcb
commit
980c353421
@ -274,12 +274,49 @@ begin
|
|||||||
Result:=Copy(Path,1,L);
|
Result:=Copy(Path,1,L);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function IncludeLeadingPathDelimiter(Const Path : String) : String;
|
||||||
|
|
||||||
|
Var
|
||||||
|
l : Integer;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=Path;
|
||||||
|
l:=Length(Result);
|
||||||
|
If (L=0) or not(Result[1] in AllowDirectorySeparators) then
|
||||||
|
Result:=DirectorySeparator+Result;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ExcludeLeadingPathDelimiter(Const Path: string): string;
|
||||||
|
|
||||||
|
Var
|
||||||
|
L : Integer;
|
||||||
|
|
||||||
|
begin
|
||||||
|
L:=Length(Path);
|
||||||
|
If (L>0) and (Path[1] in AllowDirectorySeparators) then
|
||||||
|
Dec(L);
|
||||||
|
Result:=Copy(Path,2,L);
|
||||||
|
end;
|
||||||
|
|
||||||
function IsPathDelimiter(Const Path: string; Index: Integer): Boolean;
|
function IsPathDelimiter(Const Path: string; Index: Integer): Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=(Index>0) and (Index<=Length(Path)) and (Path[Index] in AllowDirectorySeparators);
|
Result:=(Index>0) and (Index<=Length(Path)) and (Path[Index] in AllowDirectorySeparators);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ConcatPaths(const Paths: array of String): String;
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
if Length(Paths) > 0 then
|
||||||
|
begin
|
||||||
|
Result := Paths[0];
|
||||||
|
for I := 1 to Length(Paths) - 1 do
|
||||||
|
Result := IncludeTrailingPathDelimiter(Result) + ExcludeLeadingPathDelimiter(Paths[I]);
|
||||||
|
end else
|
||||||
|
Result := '';
|
||||||
|
end;
|
||||||
|
|
||||||
Function GetFileHandle(var f : File):Longint;
|
Function GetFileHandle(var f : File):Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -34,9 +34,12 @@ function IncludeTrailingPathDelimiter(Const Path : String) : String;
|
|||||||
function IncludeTrailingBackslash(Const Path : String) : String;
|
function IncludeTrailingBackslash(Const Path : String) : String;
|
||||||
function ExcludeTrailingBackslash(Const Path: string): string;
|
function ExcludeTrailingBackslash(Const Path: string): string;
|
||||||
function ExcludeTrailingPathDelimiter(Const Path: string): string;
|
function ExcludeTrailingPathDelimiter(Const Path: string): string;
|
||||||
|
function IncludeLeadingPathDelimiter(Const Path : String) : String;
|
||||||
|
function ExcludeLeadingPathDelimiter(Const Path: string): string;
|
||||||
function IsPathDelimiter(Const Path: string; Index: Integer): Boolean;
|
function IsPathDelimiter(Const Path: string; Index: Integer): Boolean;
|
||||||
Procedure DoDirSeparators (Var FileName : String);
|
Procedure DoDirSeparators (Var FileName : String);
|
||||||
Function SetDirSeparators (Const FileName : String) : String;
|
Function SetDirSeparators (Const FileName : String) : String;
|
||||||
Function GetDirs (Var DirName : String; Var Dirs : Array of pchar) : Longint;
|
Function GetDirs (Var DirName : String; Var Dirs : Array of pchar) : Longint;
|
||||||
Function SameFileName(const S1, S2: string): Boolean;
|
Function SameFileName(const S1, S2: string): Boolean;
|
||||||
|
function ConcatPaths(const Paths: array of String): String;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user