tmpfile 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. .TH TMPFILE 2
  2. .SH NAME
  3. tmpfile, tmpnam \- Stdio temporary files
  4. .SH SYNOPSIS
  5. .B #include <u.h>
  6. .br
  7. .B #include <stdio.h>
  8. .PP
  9. .ta \w'\fLFILE 'u
  10. .B
  11. FILE *tmpfile(void)
  12. .PP
  13. .B
  14. char *tmpnam(char *s)
  15. .SH DESCRIPTION
  16. .I Tmpfile
  17. creates a temporary file that will automatically
  18. be removed when the file is closed or the program exits.
  19. The return value is a Stdio
  20. .B FILE*
  21. opened in update mode (see
  22. .IR fopen (2)).
  23. .PP
  24. .I Tmpnam
  25. generates a string that is a valid file name and that is not
  26. the same as the name of an existing file.
  27. If
  28. .I s
  29. is zero, it returns a pointer to a string which may be overwritten by
  30. subsequent calls to
  31. .IR tmpnam .
  32. If
  33. .I s
  34. is non-zero, it should point to an array of at least
  35. .B L_tmpnam
  36. (defined in
  37. .BR <stdio.h> )
  38. characters, and the answer will be copied there.
  39. .SH FILES
  40. .TF /tmp/tf000000000000
  41. .TP
  42. .B /tmp/tf000000000000
  43. template for
  44. .I tmpfile
  45. file names.
  46. .TP
  47. .B /tmp/tn000000000000
  48. template for
  49. .I tmpnam
  50. file names.
  51. .SH SOURCE
  52. .B /sys/src/libstdio
  53. .SH BUGS
  54. The files created by
  55. .I tmpfile
  56. are not removed until
  57. .IR exits (2)
  58. is executed; in particular, they are not removed on
  59. .I fclose
  60. or if the program terminates abnormally.