49 |
#define TMP_MAX 16384 |
#define TMP_MAX 16384 |
50 |
#endif |
#endif |
51 |
|
|
52 |
/* Generate a unique temporary file name from TEMPLATE. |
/* |
53 |
|
|
54 |
TEMPLATE has the form: |
@deftypefn Replacement int mkstemps (char *@var{template}, int @var{suffix_len}) |
55 |
|
|
56 |
<path>/ccXXXXXX<suffix> |
Generate a unique temporary file name from @var{template}. |
57 |
|
@var{template} has the form: |
58 |
|
|
59 |
SUFFIX_LEN tells us how long <suffix> is (it can be zero length). |
@example |
60 |
|
@var{path}/ccXXXXXX@var{suffix} |
61 |
|
@end example |
62 |
|
|
63 |
The last six characters of TEMPLATE before <suffix> must be "XXXXXX"; |
@var{suffix_len} tells us how long @var{suffix} is (it can be zero |
64 |
they are replaced with a string that makes the filename unique. |
length). The last six characters of @var{template} before @var{suffix} |
65 |
|
must be @samp{XXXXXX}; they are replaced with a string that makes the |
66 |
|
filename unique. Returns a file descriptor open on the file for |
67 |
|
reading and writing. |
68 |
|
|
69 |
|
@end deftypefn |
70 |
|
|
71 |
|
*/ |
72 |
|
|
|
Returns a file descriptor open on the file for reading and writing. */ |
|
73 |
int |
int |
74 |
mkstemps (template, suffix_len) |
mkstemps (template, suffix_len) |
75 |
char *template; |
char *template; |
121 |
v /= 62; |
v /= 62; |
122 |
XXXXXX[5] = letters[v % 62]; |
XXXXXX[5] = letters[v % 62]; |
123 |
|
|
124 |
|
#ifdef VMS |
125 |
|
fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600, "fop=tmd"); |
126 |
|
#else |
127 |
fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600); |
fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600); |
128 |
|
#endif |
129 |
if (fd >= 0) |
if (fd >= 0) |
130 |
/* The file does not exist. */ |
/* The file does not exist. */ |
131 |
return fd; |
return fd; |