mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: Using relative paths in create symlink, hardlink.
UPD: Added const to some string parameters.
This commit is contained in:
parent
836b2ab1cb
commit
f9728e0c63
3 changed files with 28 additions and 32 deletions
|
|
@ -70,10 +70,8 @@ begin
|
|||
|
||||
if CompareFilenames(sSrc, sDst) = 0 then Exit;
|
||||
|
||||
if GetPathType(sSrc) <> ptAbsolute then
|
||||
sSrc := FCurrentPath + sSrc;
|
||||
if GetPathType(sDst) <> ptAbsolute then
|
||||
sDst := FCurrentPath + sDst;
|
||||
sSrc := GetAbsoluteFileName(FCurrentPath, sSrc);
|
||||
sDst := GetAbsoluteFileName(FCurrentPath, sDst);
|
||||
|
||||
if CreateHardLink(sSrc, sDst) then
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -70,10 +70,8 @@ begin
|
|||
|
||||
if CompareFilenames(sSrc, sDst) = 0 then Exit;
|
||||
|
||||
if GetPathType(sSrc) <> ptAbsolute then
|
||||
sSrc := FCurrentPath + sSrc;
|
||||
if GetPathType(sDst) <> ptAbsolute then
|
||||
sDst := FCurrentPath + sDst;
|
||||
sSrc := GetAbsoluteFileName(FCurrentPath, sSrc);
|
||||
sDst := GetAbsoluteFileName(FCurrentPath, sDst);
|
||||
|
||||
if CreateSymLink(sSrc, sDst) then
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ function GetDirs (DirName : String; var Dirs : TStringList) : Longint;
|
|||
@param(sRelativeFileName Relative file name)
|
||||
@returns(Absolute file name)
|
||||
}
|
||||
function GetAbsoluteFileName(sPath, sRelativeFileName : String) : String;
|
||||
function GetAbsoluteFileName(const sPath, sRelativeFileName : String) : String;
|
||||
{en
|
||||
Checks if a path to a directory or file is absolute or relative.
|
||||
@returns(ptNone if a path is just a directory or file name (MyDir)
|
||||
|
|
@ -155,7 +155,7 @@ function MinimizeFilePath(const PathToMince: String; Canvas: TCanvas;
|
|||
|
||||
@param(Path path to expand.)
|
||||
}
|
||||
function ExpandAbsolutePath(Path: String): String;
|
||||
function ExpandAbsolutePath(const Path: String): String;
|
||||
|
||||
{en
|
||||
Checks if a file or directory belongs in the specified path.
|
||||
|
|
@ -551,7 +551,7 @@ begin
|
|||
if Result > -1 then inc(Result);
|
||||
end;
|
||||
|
||||
function GetAbsoluteFileName(sPath, sRelativeFileName : String) : String;
|
||||
function GetAbsoluteFileName(const sPath, sRelativeFileName : String) : String;
|
||||
begin
|
||||
case GetPathType(sRelativeFileName) of
|
||||
ptNone:
|
||||
|
|
@ -738,35 +738,35 @@ Begin
|
|||
end;
|
||||
End;
|
||||
|
||||
function ExpandAbsolutePath(Path: String): String;
|
||||
function ExpandAbsolutePath(const Path: String): String;
|
||||
var
|
||||
I, J: Integer;
|
||||
begin
|
||||
Result := Path;
|
||||
|
||||
{First remove all references to '\.\'}
|
||||
I := Pos (DirectorySeparator + '.' + DirectorySeparator, Path);
|
||||
I := Pos (DirectorySeparator + '.' + DirectorySeparator, Result);
|
||||
while I <> 0 do
|
||||
begin
|
||||
Delete (Path, I, 2);
|
||||
I := Pos (DirectorySeparator + '.' + DirectorySeparator, Path);
|
||||
end;
|
||||
if StrEnds(Path, DirectorySeparator + '.') then
|
||||
Delete (Path, Length(Path) - 1, 2);
|
||||
begin
|
||||
Delete (Result, I, 2);
|
||||
I := Pos (DirectorySeparator + '.' + DirectorySeparator, Result);
|
||||
end;
|
||||
if StrEnds(Result, DirectorySeparator + '.') then
|
||||
Delete (Result, Length(Result) - 1, 2);
|
||||
|
||||
{Then remove all references to '\..\'}
|
||||
I := Pos (DirectorySeparator + '..', Path);
|
||||
I := Pos (DirectorySeparator + '..', Result);
|
||||
while (I <> 0) do
|
||||
begin
|
||||
J := Pred (I);
|
||||
while (J > 0) and (Path [J] <> DirectorySeparator) do
|
||||
Dec (J);
|
||||
if (J = 0) then
|
||||
Delete (Path, I, 3)
|
||||
else
|
||||
Delete (Path, J, I - J + 3);
|
||||
I := Pos (DirectorySeparator + '..', Path);
|
||||
end;
|
||||
|
||||
Result := Path;
|
||||
begin
|
||||
J := Pred (I);
|
||||
while (J > 0) and (Result [J] <> DirectorySeparator) do
|
||||
Dec (J);
|
||||
if (J = 0) then
|
||||
Delete (Result, I, 3)
|
||||
else
|
||||
Delete (Result, J, I - J + 3);
|
||||
I := Pos (DirectorySeparator + '..', Result);
|
||||
end;
|
||||
end;
|
||||
|
||||
function IsInPath(sBasePath : String; sPathToCheck : String; AllowSubDirs: Boolean) : Boolean;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue