Installer: Minor improvements to selecting a Plink executable
authorSebastian Schuberth <sschuberth@gmail.com>
Mon, 3 Jun 2013 10:58:44 +0000 (3 12:58 +0200)
committerSebastian Schuberth <sschuberth@gmail.com>
Mon, 3 Jun 2013 11:07:34 +0000 (3 13:07 +0200)
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
share/WinGit/install.iss
share/WinGit/putty.inc.iss

index a087eae..a42cfd9 100644 (file)
@@ -11,7 +11,7 @@
 #define APP_BUILTINS  'etc\fileList-builtins.txt'\r
 #define APP_BINDIMAGE 'etc\fileList-bindimage.txt'\r
 \r
-#define PLINK_PATH_ERROR_MSG 'Please enter a valid path to a version of Plink.'\r
+#define PLINK_PATH_ERROR_MSG 'Please enter a valid path to a Plink executable.'\r
 \r
 #define DROP_HANDLER_GUID '{{86C86720-42A0-1069-A2E8-08002B30309D}'\r
 \r
@@ -247,18 +247,19 @@ procedure BrowseForPuTTYFolder(Sender:TObject);
 var\r
     Name:String;\r
 begin\r
-    GetOpenFileName(\r
-        'Please select the Plink executable:',\r
+    if GetOpenFileName(\r
+        'Please select a Plink executable',\r
         Name,\r
         ExtractFilePath(EdtPlink.Text),\r
         'Executable Files|*.exe',\r
         'exe'\r
-    );\r
-    if Pos('plink',LowerCase(Name))>0 then begin\r
-        EdtPlink.Text:=Name;\r
-        RdbSSH[GS_Plink].Checked:=True;\r
-    end else begin\r
-        MsgBox('{#PLINK_PATH_ERROR_MSG}',mbError,MB_OK);\r
+    ) then begin\r
+        if IsPlinkExecutable(Name) then begin\r
+            EdtPlink.Text:=Name;\r
+            RdbSSH[GS_Plink].Checked:=True;\r
+        end else begin\r
+            MsgBox('{#PLINK_PATH_ERROR_MSG}',mbError,MB_OK);\r
+        end;\r
     end;\r
 end;\r
 \r
@@ -556,7 +557,7 @@ begin
             Parent:=PuTTYPage.Surface;\r
 \r
             EnvSSH:=GetEnvStrings('GIT_SSH',IsAdminLoggedOn);\r
-            if (GetArrayLength(EnvSSH)=1) and (Pos('plink',LowerCase(EnvSSH[0]))>0) then begin\r
+            if (GetArrayLength(EnvSSH)=1) and IsPlinkExecutable(EnvSSH[0]) then begin\r
                 Text:=EnvSSH[0];\r
             end;\r
             if not FileExists(Text) then begin\r
index dfc459d..42e7661 100644 (file)
@@ -52,3 +52,8 @@ begin
 \r
     Result:=Result+'plink.exe'\r
 end;\r
+\r
+function IsPlinkExecutable(Path:String):Boolean;\r
+begin\r
+    Result:=(Pos('plink',LowerCase(ExtractFileName(Path)))>0);\r
+end;\r