From d0acf76b12c1a7b447ef9291ce056ed7e8221d40 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Tue, 18 May 2010 09:07:59 +0000 Subject: [PATCH] Adds some comments to RunCmdFromPath git-svn-id: trunk@25496 - --- lcl/utf8process.pp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lcl/utf8process.pp b/lcl/utf8process.pp index e79d58bd92..bd2cc56b1a 100644 --- a/lcl/utf8process.pp +++ b/lcl/utf8process.pp @@ -160,6 +160,11 @@ begin Result:=''; end; +// Runs a short command which should point to an executable in +// the environment PATH +// For example: ProgramFilename=ls CmdLineParameters=-l /home +// Will locate and execute the file /bin/ls +// If the command isn't found, an exception will be raised procedure RunCmdFromPath(ProgramFilename, CmdLineParameters: string); var OldProgramFilename: String; @@ -167,16 +172,20 @@ var begin OldProgramFilename:=ProgramFilename; ProgramFilename:=FindFilenameOfCmd(ProgramFilename); + if ProgramFilename='' then raise EFOpenError.Create(Format(lisProgramFileNotFound, [OldProgramFilename] )); if not FileIsExecutable(ProgramFilename) then raise EFOpenError.Create(Format(lisCanNotExecute, [ProgramFilename])); + // run BrowserProcess := TProcessUTF8.Create(nil); try + // Encloses the executable with "" if it's name has spaces if Pos(' ',ProgramFilename)>0 then ProgramFilename:='"'+ProgramFilename+'"'; + BrowserProcess.CommandLine := ProgramFilename; if CmdLineParameters<>'' then BrowserProcess.CommandLine := BrowserProcess.CommandLine + ' ' + CmdLineParameters;