9.2
1 Enigma API: Stamp
| (require enigma/compiler/stamp/stamp) | package: enigma-app |
procedure
(create-stamp file-path stamp-type) → hash?
file-path : path-string? stamp-type : string?
Create a stamp for file-path using the stamp-type.
Returns a hash with stamp data.
The source code of this module:
#lang racket/base (require racket/contract/base) (require racket/file) (require json) (require threading) (require "../../system/utils/path.rkt") (provide (contract-out [create-stamp (-> path-string? string? hash?)])) (define (create-stamp file-path stamp-type) (define cache-dir (~> file-path path->directory (build-path ".cache"))) (define stamp-path (~> file-path path->name (path-replace-extension _ (format ".~a.stamp" stamp-type)) (build-path cache-dir _))) (define source-size (file-size file-path)) (define source-time (file-or-directory-modify-seconds file-path)) (define creation-time (current-seconds)) (define stamp-data (hash 'creation-time creation-time 'source-size source-size 'source-time source-time)) (eprintf " Creating stamp: ~a\n" stamp-path) (make-directory* cache-dir) (call-with-output-file stamp-path #:exists 'replace #:mode 'text (lambda (out) (displayln (jsexpr->string stamp-data) out))) stamp-data)