mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 11:30:28 +02:00
IDE: open project: added check if lpi file is symlink, fixing bug #10855
git-svn-id: trunk@14197 -
This commit is contained in:
parent
6632151a96
commit
12979678e5
@ -87,6 +87,7 @@ function CheckCreatingFile(const AFilename: string;
|
|||||||
): TModalResult;
|
): TModalResult;
|
||||||
function CheckFileIsWritable(const Filename: string;
|
function CheckFileIsWritable(const Filename: string;
|
||||||
ErrorButtons: TMsgDlgButtons): TModalResult;
|
ErrorButtons: TMsgDlgButtons): TModalResult;
|
||||||
|
function ChooseSymlink(var Filename: string): TModalResult;
|
||||||
function ForceDirectoryInteractive(Directory: string;
|
function ForceDirectoryInteractive(Directory: string;
|
||||||
ErrorButtons: TMsgDlgButtons): TModalResult;
|
ErrorButtons: TMsgDlgButtons): TModalResult;
|
||||||
function DeleteFileInteractive(const Filename: string;
|
function DeleteFileInteractive(const Filename: string;
|
||||||
@ -467,6 +468,35 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ChooseSymlink(var Filename: string): TModalResult;
|
||||||
|
var
|
||||||
|
TargetFilename: String;
|
||||||
|
begin
|
||||||
|
Result:=mrCancel;
|
||||||
|
try
|
||||||
|
TargetFilename:=ReadAllLinks(Filename,true);
|
||||||
|
DebugLn(['ChooseSymlink ',Filename,' ',TargetFilename]);
|
||||||
|
if TargetFilename<>Filename then begin
|
||||||
|
case QuestionDlg('File is symlink',
|
||||||
|
'The file "'+Filename+'" is a symlink.'#13
|
||||||
|
+#13
|
||||||
|
+'Open "'+TargetFilename+'" instead?',
|
||||||
|
mtConfirmation,[mbYes,'Open target',mbNo,'Open symlink',mbCancel],0)
|
||||||
|
of
|
||||||
|
mrYes: Filename:=TargetFilename;
|
||||||
|
mrNo: ;
|
||||||
|
else exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Result:=mrOk;
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
MessageDlg('File link error',
|
||||||
|
E.Message,mtError,[mbCancel],0);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function ForceDirectoryInteractive(Directory: string;
|
function ForceDirectoryInteractive(Directory: string;
|
||||||
ErrorButtons: TMsgDlgButtons): TModalResult;
|
ErrorButtons: TMsgDlgButtons): TModalResult;
|
||||||
var i: integer;
|
var i: integer;
|
||||||
|
@ -7748,6 +7748,10 @@ begin
|
|||||||
Result:=MessageDlg(ACaption, AText, mtError, [mbAbort], 0);
|
Result:=MessageDlg(ACaption, AText, mtError, [mbAbort], 0);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// check symbolic link
|
||||||
|
Result:=ChooseSymlink(AFilename);
|
||||||
|
if Result<>mrOk then exit;
|
||||||
|
|
||||||
// if there is a project info file, load that instead
|
// if there is a project info file, load that instead
|
||||||
if (Ext<>'.lpi') and (FileExists(ChangeFileExt(AFileName,'.lpi'))) then begin
|
if (Ext<>'.lpi') and (FileExists(ChangeFileExt(AFileName,'.lpi'))) then begin
|
||||||
|
@ -699,7 +699,7 @@ begin
|
|||||||
Result:='';
|
Result:='';
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
raise Exception.Create(AText);
|
raise EFOpenError.Create(AText);
|
||||||
end else begin
|
end else begin
|
||||||
if not FilenameIsAbsolute(LinkFilename) then
|
if not FilenameIsAbsolute(LinkFilename) then
|
||||||
Result:=ExpandFilename(ExtractFilePath(Result)+LinkFilename)
|
Result:=ExpandFilename(ExtractFilePath(Result)+LinkFilename)
|
||||||
|
Loading…
Reference in New Issue
Block a user