blob: 9c307420e8a4f26780d0ecac5c300e0e0c0d86cd (
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
50
51
|
/*
* ========================================================================
* Copyright 2006-2008 University of Washington
* Copyright 2013-2022 Eduardo Chappa
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* ========================================================================
*/
#include <system.h>
#if HAVE_TMPFILE
#else
#include "temp_nam.h"
#endif
#include "../charconv/filesys.h"
#include "tempfile.h"
/*----------------------------------------------------------------------
Create a temporary file, the name of which we don't care about
and that goes away when it is closed. Just like ANSI C tmpfile.
----*/
FILE *
create_tmpfile(void)
{
#if HAVE_TMPFILE
return(tmpfile());
#else
char *file_name;
FILE *stream = NULL;
file_name = temp_nam(NULL, "pine-tmp");
if(file_name){
stream = our_fopen(file_name, "w+b");
our_unlink(file_name);
fs_give((void **) &file_name);
}
return(stream);
#endif
}
|