Blame extension/readfile.3am

Packit 575503
.TH READFILE 3am "Mar 24 2013" "Free Software Foundation" "GNU Awk Extension Modules"
Packit 575503
.SH NAME
Packit 575503
readfile \- return the entire contents of a file as a string
Packit 575503
.SH SYNOPSIS
Packit 575503
.ft CW
Packit 575503
@load "readfile"
Packit 575503
.sp
Packit 575503
result = readfile("/some/path")
Packit 575503
.sp
Packit 575503
.ft R
Packit 575503
For making whole files be single records:
Packit 575503
.sp
Packit 575503
.ft CW
Packit 575503
@load "readfile"
Packit 575503
.br
Packit 575503
BEGIN { PROCINFO["readfile"] = 1 }
Packit 575503
.ft R
Packit 575503
.SH DESCRIPTION
Packit 575503
The
Packit 575503
.I readfile
Packit 575503
extension adds a single function named
Packit 575503
.BR readfile() .
Packit 575503
The argument is the name of the file to read.
Packit 575503
The return value is a string containing the entire contents of
Packit 575503
the requested file.
Packit 575503
.PP
Packit 575503
Upon error, the function returns the empty string and sets
Packit 575503
.BR ERRNO .
Packit 575503
.PP
Packit 575503
In addition, it adds an input parser that is activated if
Packit 575503
.ft CW
Packit 575503
PROCINFO["readfile"]
Packit 575503
.ft R
Packit 575503
exists.
Packit 575503
When activated, each input file is returned in its entirety as \f(CW$0\fR.
Packit 575503
\f(CWRT\fP is set to the null string.
Packit 575503
.\" .SH NOTES
Packit 575503
.\" .SH BUGS
Packit 575503
.SH EXAMPLE
Packit 575503
.ft CW
Packit 575503
.nf
Packit 575503
@load "readfile"
Packit 575503
\&...
Packit 575503
contents = readfile("/path/to/file");
Packit 575503
if (contents == "" && ERRNO != "") {
Packit 575503
    print("problem reading file", ERRNO) > "/dev/stderr"
Packit 575503
    ...
Packit 575503
}
Packit 575503
.fi
Packit 575503
.ft R
Packit 575503
.SH "SEE ALSO"
Packit 575503
.IR "GAWK: Effective AWK Programming" ,
Packit 575503
.IR filefuncs (3am),
Packit 575503
.IR fnmatch (3am),
Packit 575503
.IR fork (3am),
Packit 575503
.IR inplace (3am),
Packit 575503
.IR ordchr (3am),
Packit 575503
.IR readdir (3am),
Packit 575503
.IR revoutput (3am),
Packit 575503
.IR rwarray (3am),
Packit 575503
.IR time (3am).
Packit 575503
.SH AUTHOR
Packit 575503
Arnold Robbins,
Packit 575503
.BR arnold@skeeve.com .
Packit 575503
.SH COPYING PERMISSIONS
Packit 575503
Copyright \(co 2012, 2013, 2014,
Packit 575503
Free Software Foundation, Inc.
Packit 575503
.PP
Packit 575503
Permission is granted to make and distribute verbatim copies of
Packit 575503
this manual page provided the copyright notice and this permission
Packit 575503
notice are preserved on all copies.
Packit 575503
.ig
Packit 575503
Permission is granted to process this file through troff and print the
Packit 575503
results, provided the printed document carries copying permission
Packit 575503
notice identical to this one except for the removal of this paragraph
Packit 575503
(this paragraph not being relevant to the printed manual page).
Packit 575503
..
Packit 575503
.PP
Packit 575503
Permission is granted to copy and distribute modified versions of this
Packit 575503
manual page under the conditions for verbatim copying, provided that
Packit 575503
the entire resulting derived work is distributed under the terms of a
Packit 575503
permission notice identical to this one.
Packit 575503
.PP
Packit 575503
Permission is granted to copy and distribute translations of this
Packit 575503
manual page into another language, under the above conditions for
Packit 575503
modified versions, except that this permission notice may be stated in
Packit 575503
a translation approved by the Foundation.
Packit 575503
.\" vim: set filetype=nroff :