Debian Codegraph @

upstream/debian-unstable/man3/readfile.3am

raw
1 .TH READFILE 3am "Feb 02 2018" "Free Software Foundation" "GNU Awk Extension Modules"
2 .SH NAME
3 readfile \- return the entire contents of a file as a string
4 .SH SYNOPSIS
5 .ft CW
6 @load "readfile"
7 .sp
8 result = readfile("/some/path")
9 .sp
10 .ft R
11 For making whole files be single records:
12 .sp
13 .ft CW
14 @load "readfile"
15 .br
16 BEGIN { PROCINFO["readfile"] = 1 }
17 .ft R
18 .SH DESCRIPTION
19 The
20 .I readfile
21 extension adds a single function named
22 .BR readfile() .
23 The argument is the name of the file to read.
24 The return value is a string containing the entire contents of
25 the requested file.
26 .PP
27 Upon error, the function returns the empty string and sets
28 .BR ERRNO .
29 .PP
30 In addition, it adds an input parser that is activated if
31 .ft CW
32 PROCINFO["readfile"]
33 .ft R
34 exists.
35 When activated, each input file is returned in its entirety as \f(CW$0\fR.
36 \f(CWRT\fP is set to the null string.
37 .\" .SH NOTES
38 .\" .SH BUGS
39 .SH EXAMPLE
40 .ft CW
41 .nf
42 @load "readfile"
43 \&...
44 contents = readfile("/path/to/file");
45 if (contents == "" && ERRNO != "") {
46 print("problem reading file", ERRNO) > "/dev/stderr"
47 ...
48 }
49 .fi
50 .ft R
51 .SH "SEE ALSO"
52 .IR "GAWK: Effective AWK Programming" ,
53 .IR filefuncs (3am),
54 .IR fnmatch (3am),
55 .IR fork (3am),
56 .IR inplace (3am),
57 .IR ordchr (3am),
58 .IR readdir (3am),
59 .IR revoutput (3am),
60 .IR rwarray (3am),
61 .IR time (3am).
62 .SH AUTHOR
63 Arnold Robbins,
64 .BR [email protected] .
65 .SH COPYING PERMISSIONS
66 Copyright \(co 2012, 2013, 2014, 2018,
67 Free Software Foundation, Inc.
68 .PP
69 Permission is granted to make and distribute verbatim copies of
70 this manual page provided the copyright notice and this permission
71 notice are preserved on all copies.
72 .ig
73 Permission is granted to process this file through troff and print the
74 results, provided the printed document carries copying permission
75 notice identical to this one except for the removal of this paragraph
76 (this paragraph not being relevant to the printed manual page).
77 ..
78 .PP
79 Permission is granted to copy and distribute modified versions of this
80 manual page under the conditions for verbatim copying, provided that
81 the entire resulting derived work is distributed under the terms of a
82 permission notice identical to this one.
83 .PP
84 Permission is granted to copy and distribute translations of this
85 manual page into another language, under the above conditions for
86 modified versions, except that this permission notice may be stated in
87 a translation approved by the Foundation.
88 .\" vim: set filetype=nroff :