;;; copy-file.mhtml: -*- Meta-HTML -*-  Copy a file.
;;;
;;;  Copyright (c) 1996 Brian J. Fox
;;;  Author: Brian J. Fox (bfox@ai.mit.edu) Tue Feb  6 04:49:42 1996.

;;; <copy-file from to>
<defsubst copy-file whitespace=delete>
  ;;; Read the existing stream.
  <with-open-stream stream %0 type=file mode=read>
    <stream-get-contents stream cf::file-contents>
  </with-open-stream>

  ;;; Find out how big the file is.
  <set-var cf::file-info[]=<symbol-info cf::file-contents>>

  ;;; If the file existed, and/or it had some size, write the output file.
  <when <gt cf::file-info[1] 0>>
    <with-open-stream stream %1 type=file mode=write-create>
      <stream-put-contents stream cf::file-contents>
    </with-open-stream>
    <get-var cf::file-info[1]> bytes transferred.
  </when>
</defsubst>

    