• 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-strings-to-file

    Write strings to a file.

    ;; Writes the STRINGS to FILENAME, overwriting its previous contents.
    ;; Effectively, all the STRINGS get concatenated and the result becomes the new
    ;; contents of the file.  Returns (mv erp state).  CTX is a context for error
    ;; printing.
    (defund write-strings-to-file (strings filename ctx state)
      (declare (xargs :guard (and (string-listp strings)
                                  (stringp filename))
                      :stobjs state))
      (mv-let (channel state)
        (open-output-channel filename :character state)
        (if (not channel)
            (prog2$ (er hard? ctx "Unable to open file ~s0 for :character output." filename)
                    (mv t state))
          (if (eq channel 'acl2-output-channel::standard-character-output-0) ;todo: prove that this doesn't happen
              (prog2$ (er hard? ctx "Unexpected output channel name: ~x0." channel)
                      (mv t state))
            (pprogn (write-strings-to-channel strings channel state)
                    (close-output-channel channel state)
                    (mv nil state))))))