code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(39 lines)
1 '\" t
2 .\" Copyright (c) 2026 Bruce Hill
3 .\" All rights reserved.
4 .\"
5 .TH Path.write_unique 3 2026-03-08 "Tomo man-pages"
6 .SH NAME
7 Path.write_unique \- write to a uniquely named file
8 .SH LIBRARY
9 Tomo Standard Library
10 .SH SYNOPSIS
11 .nf
12 .BI Path.write_unique\ :\ func(path:\ Path,\ text:\ Text\ ->\ Path)
13 .fi
14 .SH DESCRIPTION
15 Writes the given text to a unique file path based on the specified path. The file is created if it doesn't exist. This is useful for creating temporary files.
18 .SH ARGUMENTS
20 .TS
21 allbox;
22 lb lb lbx
23 l l l.
24 Name Type Description
25 path Path The base path for generating the unique file. This path must include the string \fBXXXXXX\fR in the file base name.
26 text Text The text to write to the file.
27 .TE
28 .SH RETURN
29 The path of the newly created unique file.
31 .SH EXAMPLES
32 .EX
33 created := (./file-XXXXXX.txt).write_unique("Hello, world!")!
34 assert created == (./file-27QHtq.txt)
35 assert created.read()! == "Hello, world!"
36 created.remove()!
37 .EE
38 .SH SEE ALSO
39 .BR Tomo-Path (3)