The IO [full module]
(module io mzscheme (provide read-all ;; String -> [Listof String] ;; read a file as a list of strings print-all ;; OutputPort [Listof String] -> Void ;; print a list of lines to output port directory-exists? ;; String -> Boolean ;; does the string represent a legal path to a directory/folder? file-exists? ;; String -> Boolean ;; does the string represent a legal path to a file? )
(require (lib "etc.ss") (lib "list.ss") (lib "file.ss")) (define (read-all file) (local (;; InputPort -> [Listof String] (define (read-all) (local ((define next (read-line))) (cond [(eof-object? next) empty] [else (cons next (read-all))])))) (with-input-from-file file read-all))) (define (print-all op line*) (for-each (lambda (line) (fprintf op "~a\r\n" line)) line*)) )