system.ss
#lang scheme/base
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; FILE.plt - file, path, and atomic file operation utilities 
;;
;;
;; Bonzai Lab, LLC.  All rights reserved.
;;
;; Licensed under LGPL.
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; system.ss - simplified system calls.
;; yc 9/21/2009 - first version
(require "depend.ss" "path.ss" scheme/system)

(define (sys/call exe . args) 
  (let ((cout (open-output-bytes))
        (cerr (open-output-bytes))
        (path (exe-path exe)))
    (if (not path) 
        (error 'sys/call "Unknown program: ~a" exe)
        (parameterize ((current-output-port cout)
                       (current-error-port cerr))
          (let ((code (apply system*/exit-code (exe-path exe) args)))
            (values (= code 0) 
                    code
                    (get-output-bytes cout)
                    (get-output-bytes cerr)))))))

;; now - how to pass the process stuff into the object?
;; we will have to open stdin... hmm...

(provide/contract
 (sys/call (->* (string?)
                ()
                #:rest (listof string?)
                (values boolean?
                        number?
                        bytes?
                        bytes?)))
 )