(module binary mzscheme (require-for-syntax "bytes-vector.ss") (require "bytes-vector.ss") (define-syntax (compile-bytes-list stx) (syntax-case stx () [(_ in) #'(compile-bytes-list 1024 in)] [(_ chunk-size in) (and (string? (syntax-object->datum #'in)) (integer? (syntax-object->datum #'chunk-size))) (with-syntax ([(chunk ...) (with-input-from-file (syntax-object->datum #'in) (lambda () (read-bytes-list (syntax-object->datum #'chunk-size))))]) #'(list chunk ...))])) (define-syntax (compile-bytes-vector stx) (syntax-case stx () [(_ in) #'(compile-bytes-vector 1024 in)] [(_ chunk-size in) (and (string? (syntax-object->datum #'in)) (integer? (syntax-object->datum #'chunk-size))) (with-syntax ([(chunk ...) (with-input-from-file (syntax-object->datum #'in) (lambda () (read-bytes-list (syntax-object->datum #'chunk-size))))]) #'(vector chunk ...))])) (define-syntax (compile-bytes stx) (syntax-case stx () [(_ in) #'(compile-bytes 1024 in)] [(_ max in) (and (string? (syntax-object->datum #'in)) (integer? (syntax-object->datum #'max))) (with-syntax ([b (with-input-from-file (syntax-object->datum #'in) (lambda () (read-bytes (syntax-object->datum #'max))))]) (datum->syntax-object stx #'b))])) (provide read-bytes-list read-bytes-vector) (provide compile-bytes compile-bytes-list compile-bytes-vector))