Ver Fonte

+ fixed Sysutils' ExecuteProcess() to allow longer ComLine than 256 chars (smartlinking needs this badly)

git-svn-id: trunk@11867 -
Károly Balogh há 17 anos atrás
pai
commit
a096096de1
1 ficheiros alterados com 29 adições e 4 exclusões
  1. 29 4
      rtl/morphos/sysutils.pp

+ 29 - 4
rtl/morphos/sysutils.pp

@@ -588,18 +588,43 @@ end;
 function ExecuteProcess (const Path: AnsiString; const ComLine: AnsiString):
                                                                        integer;
 var
+  tmpPath: AnsiString;
+  convPath: AnsiString;
   CommandLine: AnsiString;
-  E: EOSError;
+  tmpLock: longint;
 
+  E: EOSError;
 begin
-  Dos.Exec (Path, ComLine);
+  DosError:= 0;
+  
+  convPath:=PathConv(Path);
+  tmpPath:=convPath+' '+ComLine;
+  
+  { Here we must first check if the command we wish to execute }
+  { actually exists, because this is NOT handled by the        }
+  { _SystemTagList call (program will abort!!)                 }
+
+  { Try to open with shared lock }
+  tmpLock:=Lock(PChar(convPath),SHARED_LOCK);
+  if tmpLock<>0 then
+    begin
+      { File exists - therefore unlock it }
+      Unlock(tmpLock);
+      result:=SystemTagList(PChar(tmpPath),nil);
+      { on return of -1 the shell could not be executed }
+      { probably because there was not enough memory    }
+      if result = -1 then
+        DosError:=8;
+    end
+  else
+    DosError:=3;
+  
   if DosError <> 0 then begin
-
     if ComLine = '' then
       CommandLine := Path
     else
       CommandLine := Path + ' ' + ComLine;
-
+    
     E := EOSError.CreateFmt (SExecuteProcessFailed, [CommandLine, DosError]);
     E.ErrorCode := DosError;
     raise E;