From 8a6ee3bd359d8bbb6ae38b791a5ea9c2ad182633 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Mon, 3 Jun 2013 12:58:44 +0200 Subject: [PATCH] Installer: Minor improvements to selecting a Plink executable Signed-off-by: Sebastian Schuberth --- share/WinGit/install.iss | 21 +++++++++++---------- share/WinGit/putty.inc.iss | 5 +++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/share/WinGit/install.iss b/share/WinGit/install.iss index a087eae0..a42cfd96 100644 --- a/share/WinGit/install.iss +++ b/share/WinGit/install.iss @@ -11,7 +11,7 @@ #define APP_BUILTINS 'etc\fileList-builtins.txt' #define APP_BINDIMAGE 'etc\fileList-bindimage.txt' -#define PLINK_PATH_ERROR_MSG 'Please enter a valid path to a version of Plink.' +#define PLINK_PATH_ERROR_MSG 'Please enter a valid path to a Plink executable.' #define DROP_HANDLER_GUID '{{86C86720-42A0-1069-A2E8-08002B30309D}' @@ -247,18 +247,19 @@ procedure BrowseForPuTTYFolder(Sender:TObject); var Name:String; begin - GetOpenFileName( - 'Please select the Plink executable:', + if GetOpenFileName( + 'Please select a Plink executable', Name, ExtractFilePath(EdtPlink.Text), 'Executable Files|*.exe', 'exe' - ); - if Pos('plink',LowerCase(Name))>0 then begin - EdtPlink.Text:=Name; - RdbSSH[GS_Plink].Checked:=True; - end else begin - MsgBox('{#PLINK_PATH_ERROR_MSG}',mbError,MB_OK); + ) then begin + if IsPlinkExecutable(Name) then begin + EdtPlink.Text:=Name; + RdbSSH[GS_Plink].Checked:=True; + end else begin + MsgBox('{#PLINK_PATH_ERROR_MSG}',mbError,MB_OK); + end; end; end; @@ -556,7 +557,7 @@ begin Parent:=PuTTYPage.Surface; EnvSSH:=GetEnvStrings('GIT_SSH',IsAdminLoggedOn); - if (GetArrayLength(EnvSSH)=1) and (Pos('plink',LowerCase(EnvSSH[0]))>0) then begin + if (GetArrayLength(EnvSSH)=1) and IsPlinkExecutable(EnvSSH[0]) then begin Text:=EnvSSH[0]; end; if not FileExists(Text) then begin diff --git a/share/WinGit/putty.inc.iss b/share/WinGit/putty.inc.iss index dfc459d1..42e76616 100644 --- a/share/WinGit/putty.inc.iss +++ b/share/WinGit/putty.inc.iss @@ -52,3 +52,8 @@ begin Result:=Result+'plink.exe' end; + +function IsPlinkExecutable(Path:String):Boolean; +begin + Result:=(Pos('plink',LowerCase(ExtractFileName(Path)))>0); +end; -- 2.11.4.GIT