mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 17:18:19 +02:00
Adds some comments to RunCmdFromPath
git-svn-id: trunk@25496 -
This commit is contained in:
parent
0448deb6c3
commit
d0acf76b12
@ -160,6 +160,11 @@ begin
|
|||||||
Result:='';
|
Result:='';
|
||||||
end;
|
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);
|
procedure RunCmdFromPath(ProgramFilename, CmdLineParameters: string);
|
||||||
var
|
var
|
||||||
OldProgramFilename: String;
|
OldProgramFilename: String;
|
||||||
@ -167,16 +172,20 @@ var
|
|||||||
begin
|
begin
|
||||||
OldProgramFilename:=ProgramFilename;
|
OldProgramFilename:=ProgramFilename;
|
||||||
ProgramFilename:=FindFilenameOfCmd(ProgramFilename);
|
ProgramFilename:=FindFilenameOfCmd(ProgramFilename);
|
||||||
|
|
||||||
if ProgramFilename='' then
|
if ProgramFilename='' then
|
||||||
raise EFOpenError.Create(Format(lisProgramFileNotFound, [OldProgramFilename]
|
raise EFOpenError.Create(Format(lisProgramFileNotFound, [OldProgramFilename]
|
||||||
));
|
));
|
||||||
if not FileIsExecutable(ProgramFilename) then
|
if not FileIsExecutable(ProgramFilename) then
|
||||||
raise EFOpenError.Create(Format(lisCanNotExecute, [ProgramFilename]));
|
raise EFOpenError.Create(Format(lisCanNotExecute, [ProgramFilename]));
|
||||||
|
|
||||||
// run
|
// run
|
||||||
BrowserProcess := TProcessUTF8.Create(nil);
|
BrowserProcess := TProcessUTF8.Create(nil);
|
||||||
try
|
try
|
||||||
|
// Encloses the executable with "" if it's name has spaces
|
||||||
if Pos(' ',ProgramFilename)>0 then
|
if Pos(' ',ProgramFilename)>0 then
|
||||||
ProgramFilename:='"'+ProgramFilename+'"';
|
ProgramFilename:='"'+ProgramFilename+'"';
|
||||||
|
|
||||||
BrowserProcess.CommandLine := ProgramFilename;
|
BrowserProcess.CommandLine := ProgramFilename;
|
||||||
if CmdLineParameters<>'' then
|
if CmdLineParameters<>'' then
|
||||||
BrowserProcess.CommandLine := BrowserProcess.CommandLine + ' ' + CmdLineParameters;
|
BrowserProcess.CommandLine := BrowserProcess.CommandLine + ' ' + CmdLineParameters;
|
||||||
|
Loading…
Reference in New Issue
Block a user