Parcourir la source

atari: implemented sysutils/ExecuteProcess

git-svn-id: trunk@35208 -
Károly Balogh il y a 8 ans
Parent
commit
c663c09b7b
2 fichiers modifiés avec 24 ajouts et 3 suppressions
  1. 2 1
      rtl/atari/gemdos.inc
  2. 22 2
      rtl/atari/sysutils.pp

+ 2 - 1
rtl/atari/gemdos.inc

@@ -133,6 +133,7 @@ function gemdos_tgetdate: longint; syscall 1 42;
 function gemdos_tgettime: longint; syscall 1 44;
 
 function gemdos_getdta: PDTA; syscall 1 47;
+function gemdos_sversion: smallint; syscall 1 48;
 
 function gemdos_dfree(buf: PDISKINFO; driveno: smallint): smallint; syscall 1 54;
 
@@ -152,7 +153,7 @@ function gemdos_dgetpath(path: pchar; driveno: smallint): smallint; syscall 1 71
 function gemdos_malloc(number: dword): pointer; syscall 1 72;
 function gemdos_free(block: pointer): dword; syscall 1 73;
 function gemdos_mshrink(zero: word; block: pointer; newsiz: longint): longint; syscall 1 74;
-
+function gemdos_pexec(mode: word; name: pchar; cmdline: pchar; env: pchar): longint; syscall 1 75;
 procedure gemdos_pterm(returncode: smallint); syscall 1 76;
 
 function gemdos_fsfirst(filename: pchar; attr: smallint): longint; syscall 1 78;

+ 22 - 2
rtl/atari/sysutils.pp

@@ -469,9 +469,29 @@ end;
 
 function ExecuteProcess (const Path: RawByteString; const ComLine: RawByteString;Flags:TExecuteFlags=[]):
                                                                        integer;
+var
+  tmpPath: RawByteString;
+  pcmdline: ShortString;
+  CommandLine: RawByteString;
+  E: EOSError;
 begin
-  {writeln('Unimplemented ExecuteProcess');}
-  result:=-1;
+  tmpPath:=ToSingleByteFileSystemEncodedFileName(Path);
+  pcmdline:=ToSingleByteFileSystemEncodedFileName(ComLine);
+
+  { the zero offset for cmdline is actually correct here. pexec() expects
+    pascal formatted string for cmdline, so length in first byte }
+  result:=gemdos_pexec(0,PChar(tmpPath),@pcmdline[0],nil);
+
+  if result < 0 then begin
+    if ComLine = '' then
+      CommandLine := Path
+    else
+      CommandLine := Path + ' ' + ComLine;
+
+    E := EOSError.CreateFmt (SExecuteProcessFailed, [CommandLine, result]);
+    E.ErrorCode := result;
+    raise E;
+  end;
 end;
 
 function ExecuteProcess (const Path: RawByteString;