code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(42 lines)
1 '\" t
2 .\" Copyright (c) 2025 Bruce Hill
3 .\" All rights reserved.
4 .\"
5 .TH Path.byte_writer 3 2025-12-22 "Tomo man-pages"
6 .SH NAME
7 Path.byte_writer \- create a byte-based file writer
8 .SH LIBRARY
9 Tomo Standard Library
10 .SH SYNOPSIS
11 .nf
12 .BI Path.byte_writer\ :\ func(path:\ Path,\ append:\ Bool\ =\ no,\ permissions:\ Int32\ =\ Int32(0o644)\ ->\ func(bytes:[Byte],\ close:Bool=no\ ->\ Result))
13 .fi
14 .SH DESCRIPTION
15 Returns a function that can be used to repeatedly write bytes to the same file.
18 .SH ARGUMENTS
20 .TS
21 allbox;
22 lb lb lbx lb
23 l l l l.
24 Name Type Description Default
25 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. no
27 permissions Int32 The permissions to set on the file if it is created. Int32(0o644)
28 .TE
29 .SH RETURN
30 Returns a function that can repeatedly write bytes 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 NOTES
33 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 EXAMPLES
36 .EX
37 write := (./file.txt).byte_writer()
38 write("Hello\[rs]n".utf8())!
39 write("world\[rs]n".utf8(), close=yes)!
40 .EE
41 .SH SEE ALSO
42 .BR Tomo-Path (3)