blob: 8b3d53d8a8ebc46d1b98f3c691cd3095f46d0eda (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH Path.writer 3 2025-12-22 "Tomo man-pages"
.SH NAME
Path.writer \- create a file writer
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI Path.writer\ :\ func(path:\ Path,\ append:\ Bool\ =\ no,\ permissions:\ Int32\ =\ Int32(0o644)\ ->\ func(text:Text,\ close:Bool=no\ ->\ Result))
.fi
.SH DESCRIPTION
Returns a function that can be used to repeatedly write to the same file.
.SH ARGUMENTS
.TS
allbox;
lb lb lbx lb
l l l l.
Name Type Description Default
path Path The path of the file to write to. -
append Bool If set to \fByes\fR, writes to the file will append. If set to \fBno\fR, then the first write to the file will overwrite its contents and subsequent calls will append. no
permissions Int32 The permissions to set on the file if it is created. Int32(0o644)
.TE
.SH RETURN
Returns a function that can repeatedly write to the same file. If `close` is set to `yes`, then the file will be closed after writing. If this function is called again after closing, the file will be reopened for appending.
.SH NOTES
The file writer will keep its file descriptor open after each write (unless the `close` argument is set to `yes`). If the file writer is never closed, it will be automatically closed when the file writer is garbage collected.
.SH EXAMPLES
.EX
write := (./file.txt).writer()
write("Hello\[rs]n")!
write("world\[rs]n", close=yes)!
.EE
.SH SEE ALSO
.BR Tomo-Path (3)
|