From b6104ccf59622c8fcc4fd2139e47d3b6c96f3bb9 Mon Sep 17 00:00:00 2001 From: lazarus Date: Wed, 21 Nov 2001 12:51:00 +0000 Subject: [PATCH] MG: added some more error messages for TProcess git-svn-id: trunk@445 - --- ide/compiler.pp | 18 ++++++++++++++---- ide/exttooldialog.pas | 35 ++++++++++++++++++++++++++++++++++- ide/main.pp | 30 ++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 5 deletions(-) diff --git a/ide/compiler.pp b/ide/compiler.pp index 379460ac78..07245abdc7 100644 --- a/ide/compiler.pp +++ b/ide/compiler.pp @@ -70,9 +70,15 @@ function ErrorTypeNameToType(const Name:string): TErrorType; implementation // to get more detailed error messages consider the os -{$IFDEF linux} -uses linux; -{$ENDIF linux} + {$IFDEF Linux} +uses + {$IFDEF Ver1_0} + Linux + {$ELSE} + Unix + {$ENDIF} + ; + {$ENDIF} function ErrorTypeNameToType(const Name:string): TErrorType; @@ -178,7 +184,8 @@ begin // TProcess does not report, if a program can not be executed // to get good error messages consider the OS {$IFDEF linux} - if not Linux.Access(CmdLine,Linux.X_OK) then begin + if not Access(CmdLine,{$IFDEF Ver1_0}Linux{$ELSE}Unix{$ENDIF}.X_OK) then + begin case LinuxError of sys_eacces: OutputLine:='execute access denied for "'+CmdLine+'"'; sys_enoent: OutputLine:='a directory component in "'+CmdLine+'"' @@ -336,6 +343,9 @@ end. { $Log$ + Revision 1.21 2001/11/21 12:51:00 lazarus + MG: added some more error messages for TProcess + Revision 1.20 2001/11/09 20:48:36 lazarus Minor fixes Shane diff --git a/ide/exttooldialog.pas b/ide/exttooldialog.pas index cedd5d160d..869a1afcbe 100644 --- a/ide/exttooldialog.pas +++ b/ide/exttooldialog.pas @@ -106,6 +106,17 @@ function ShowExtToolDialog(ExtToolList: TExternalToolList; implementation +// to get more detailed error messages consider the os + {$IFDEF Linux} +uses + {$IFDEF Ver1_0} + Linux + {$ELSE} + Unix + {$ENDIF} + ; + {$ENDIF} + function ShowExtToolDialog(ExtToolList: TExternalToolList; TransferMacros: TTransferMacroList):TModalResult; @@ -221,7 +232,7 @@ end; function TExternalToolList.Run(Index: integer; Macros: TTransferMacroList): TModalResult; -var WorkingDir, Filename, Params: string; +var WorkingDir, Filename, Params, AText: string; TheProcess: TProcess; begin Result:=mrCancel; @@ -233,6 +244,28 @@ begin and Macros.SubstituteStr(WorkingDir) and Macros.SubstituteStr(Params) then begin writeln('[TExternalToolList.Run] ',Filename,' ',Params); + // TProcess does not report, if a program can not be executed + // to get good error messages consider the OS + {$IFDEF linux} + if not {$IFDEF Ver1_0}Linux{$ELSE}Unix{$ENDIF}.Access(Filename, + {$IFDEF Ver1_0}Linux{$ELSE}Unix{$ENDIF}.X_OK) then + begin + case LinuxError of + sys_eacces: AText:='execute access denied for "'+Filename+'"'; + sys_enoent: AText:='a directory component in "'+Filename+'"' + +' does not exist or is a dangling symlink'; + sys_enotdir: AText:='a directory component in "'+Filename+'"' + +' is not a directory'; + sys_enomem: AText:='insufficient memory'; + sys_eloop: AText:='"'+Filename+'" has a circular symbolic link'; + else + AText:='unable to execute "'+Filename+'"'; + end; + MessageDlg('Error executing tool', + AText, mtError, [mbOk], 0); + exit; + end; + {$ENDIF linux} try TheProcess:=TProcess.Create(Filename+' '+Params,[poRunSuspended, poUsePipes, poNoConsole]); diff --git a/ide/main.pp b/ide/main.pp index bbe2a3e178..2ec3b3cf6c 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -380,6 +380,13 @@ var implementation uses + {$IFDEF Linux} + {$IFDEF Ver1_0} + Linux, + {$ELSE} + Unix, + {$ENDIF} + {$ENDIF} ViewUnit_dlg, Math, LResources, Designer; @@ -3562,6 +3569,26 @@ writeln('[TMainIDE.DoRunProject] A'); begin try writeln(' EXECUTING "',ProgramFilename,'"'); + // TProcess does not report, if a program can not be executed + // to get good error messages consider the OS + {$IFDEF linux} + if not {$IFDEF Ver1_0}Linux{$ELSE}Unix{$ENDIF}.Access(ProgramFilename, + {$IFDEF Ver1_0}Linux{$ELSE}Unix{$ENDIF}.X_OK) then + begin + case LinuxError of + sys_eacces: AText:='execute access denied for "'+ProgramFilename+'"'; + sys_enoent: AText:='a directory component in "'+ProgramFilename+'"' + +' does not exist or is a dangling symlink'; + sys_enotdir: AText:='a directory component in "'+ProgramFilename+'"' + +' is not a directory'; + sys_enomem: AText:='insufficient memory'; + sys_eloop: AText:='"'+ProgramFilename+'" has a circular symbolic link'; + else + AText:='unable to execute "'+ProgramFilename+'"'; + end; + raise Exception.Create(AText); + end; + {$ENDIF linux} TheProcess:=TProcess.Create(ProgramFilename, [poRunSuspended,poUsePipes,poNoConsole]); @@ -4756,6 +4783,9 @@ end. { ============================================================================= $Log$ + Revision 1.154 2001/11/21 12:51:00 lazarus + MG: added some more error messages for TProcess + Revision 1.153 2001/11/20 19:39:45 lazarus MG: DoRunProject writes the programfilename