(42 lines)
1 '\" t2 .\" Copyright (c) 2025 Bruce Hill3 .\" All rights reserved.4 .\"5 .TH Path.writer 3 2025-12-22 "Tomo man-pages"6 .SH NAME7 Path.writer \- create a file writer8 .SH LIBRARY9 Tomo Standard Library10 .SH SYNOPSIS11 .nf12 .BI Path.writer\ :\ func(path:\ Path,\ append:\ Bool\ =\ no,\ permissions:\ Int32\ =\ Int32(0o644)\ ->\ func(text:Text,\ close:Bool=no\ ->\ Result))13 .fi14 .SH DESCRIPTION15 Returns a function that can be used to repeatedly write to the same file.18 .SH ARGUMENTS20 .TS21 allbox;22 lb lb lbx lb23 l l l l.24 Name Type Description Default25 path Path The path of the file to write to. -26 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. no27 permissions Int32 The permissions to set on the file if it is created. Int32(0o644)28 .TE29 .SH RETURN30 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.32 .SH NOTES33 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.35 .SH EXAMPLES36 .EX37 write := (./file.txt).writer()38 write("Hello\[rs]n")!39 write("world\[rs]n", close=yes)!40 .EE41 .SH SEE ALSO42 .BR Tomo-Path (3)