• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Error-checking
        • Apt
        • Abnf
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Prime-field-constraint-systems
        • Soft
        • Bv
        • Imp-language
        • Event-macros
        • Bitcoin
        • Ethereum
        • Yul
        • Zcash
        • ACL2-programming-language
        • Prime-fields
        • Java
        • C
        • Syntheto
        • Number-theory
        • Cryptography
        • Lists-light
        • File-io-light
          • Read-file-into-byte-array-stobj
          • Read-file-into-character-array-stobj
          • Write-strings-to-file!
          • Write-strings-to-file
          • Write-bytes-to-file!
            • Read-object-from-file
            • Write-strings-to-channel
            • Write-bytes-to-file
            • Write-bytes-to-channel
            • Read-objects-from-file
            • Read-file-into-byte-list
            • Read-file-into-character-list
          • Json
          • Built-ins
          • Solidity
          • Axe
          • Std-extensions
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Execloader
        • Axe
      • Testing-utilities
      • Math
    • File-io-light

    Write-bytes-to-file!

    Write bytes to a file when not allowed without a trust tag.

    ;; Writes the BYTES to file FILENAME, overwriting its previous contents.
    ;; Returns (mv erp state).  The ttag is needed because this calls
    ;; open-output-channel!, but that makes this version usable during make-event
    ;; expansion, clause-processors, etc.
    (defun write-bytes-to-file! (bytes filename ctx state)
      (declare (xargs :stobjs state
                      :guard (and (all-bytep bytes)
                                  (stringp filename))))
      (mv-let (channel state)
        (open-output-channel! filename :byte state)
        (if (not channel)
            (prog2$ (er hard? ctx "Unable to open file ~s0 for :byte output." filename)
                    (mv t state))
          (pprogn (write-bytes-to-channel bytes channel state)
                  (close-output-channel channel state)
                  (mv nil state)))))