ffmt_io Module

Reading and writing whole files as bytes, so that line endings are preserved on every platform.


Used by

  • module~~ffmt_io~~UsedByGraph module~ffmt_io ffmt_io module~ffmt_cli ffmt_cli module~ffmt_cli->module~ffmt_io

Subroutines

public subroutine read_file(path, text, stat, errmsg)

All bytes of file path.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: path

the file to read

character(len=:), intent(out), allocatable :: text

the contents; '' if the file cannot be opened

integer, intent(out) :: stat

iostat of the open or read: nonzero on failure

character(len=:), intent(out), allocatable :: errmsg

the system's message, if stat is nonzero

public subroutine read_stdin(text)

All of standard input. Lines are read as text, so each line ends with a line feed, except a last line without one; carriage returns of CRLF line endings are kept as part of the line.

Arguments

Type IntentOptional Attributes Name
character(len=:), intent(out), allocatable :: text

the input

public subroutine write_file(path, text, stat, errmsg)

Replace the contents of file path (created if needed) with the bytes of text.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: path

the file to write

character(len=*), intent(in) :: text

the new contents

integer, intent(out) :: stat

iostat of the open or write: nonzero on failure

character(len=:), intent(out), allocatable :: errmsg

the system's message, if stat is nonzero