<commit_before>! (c)2010 <NAME> bsd license
USING: alien.c-types alien.data bootstrap.image
bootstrap.image.private destructors io io.directories
io.encodings.binary io.files locals system ;
IN: tools.deploy.embed

:: embed-image ( from-image to-executable -- )
    vm to-executable copy-file
    to-executable binary <file-appender> [| out |
        out stream-tell :> offset
        from-image binary <file-reader> [| in |
            in out stream-copy*
        ] with-disposal
        image-magic uintptr_t <ref> out stream-write
        offset uintptr_t <ref> out stream-write
    ] with-disposal ;
<commit_msg>tools.deploy.embed: useful factors Separate the embedding of an image into a VM executable (embed-image) from the copy-and-embed logic (make-embedded-image).<commit_after>! (c)2010 <NAME> bsd license
USING: alien.c-types alien.data bootstrap.image
bootstrap.image.private destructors io io.directories
io.encodings.binary io.files locals system ;
IN: tools.deploy.embed

:: embed-image ( image executable -- )
    executable binary <file-appender> [| out |
        out stream-tell :> offset
        image binary <file-reader> [| in |
            in out stream-copy*
        ] with-disposal
        image-magic uintptr_t <ref> out stream-write
        offset uintptr_t <ref> out stream-write
    ] with-disposal ;

: make-embedded-image* ( from-image from-executable to-executable -- )
    swap [ copy-file ] keep embed-image ;

: make-embedded-image ( from-image to-executable -- )
    vm swap make-embedded-image* ;
{'fraction_non_alphanumeric': 0.10835509138381201, 'fraction_numerical': 0.005221932114882507, 'mean_word_length': 2.9921875, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7232748', 'n_tokens_mistral': 486, 'n_tokens_neox': 459, 'n_words': 131}