summaryrefslogtreecommitdiff
path: root/man/mpu_tmpfile.3
blob: d979849982785fdc74968f6b7440795d93bcf39d (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
43
44
45
46
47
48
49
.TH MPU_TMPFILE 3 "August 2026" "libmpuio" "LIBMPUIO Programmer's Manual"
.SH NAME
mpu_tmpfile \- create an anonymous temporary LIBMPUIO real-file stream
.SH SYNOPSIS
.nf
#include <libmpuio.h>

mpu_FILE *mpu_tmpfile( void );
.fi
.SH DESCRIPTION
.B mpu_tmpfile
creates a temporary POSIX file, removes its directory entry immediately, and
returns a LIBMPUIO real-file stream opened for both reading and writing.
The file therefore has no persistent pathname after successful creation and is
removed automatically when the last descriptor is closed.
.PP
The returned stream is a normal descriptor-backed LIBMPUIO stream.  Text
operations convert UCS-2 to/from UTF-8; raw
.BR mpu_fread (3)
and
.BR mpu_fwrite (3)
operate on bytes.
.SH RETURN VALUE
A stream pointer is returned on success.  NULL is returned on failure and
.B errno
is set.
.SH NOTES
The implementation uses the system temporary directory convention and creates
an exclusive temporary file before unlinking it.  The descriptor is owned by
the returned stream and is closed by
.BR mpu_fclose (3).
.SH EXAMPLE
.nf
mpu_FILE       *fp = mpu_tmpfile();
__mpu_char16_t  line[32];

if( fp != NULL )
{
  mpu_fputs( MPU_UCS2("temporary"), fp );
  mpu_rewind( fp );
  mpu_fgets( line, 32, fp );
  mpu_fclose( fp );
}
.fi
.SH SEE ALSO
.BR libmpuio (3),
.BR mpu_fopen (3),
.BR mpu_fclose (3),
.BR mpu_fseek (3)