/[gnats]/gnats/libiberty/mkstemps.c
ViewVC logotype

Diff of /gnats/libiberty/mkstemps.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by pdm, Mon Dec 10 23:03:26 2001 UTC revision 1.3 by chewie, Sat Nov 13 05:14:17 2004 UTC
# Line 49  typedef unsigned long gcc_uint64_t; Line 49  typedef unsigned long gcc_uint64_t;
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;
# Line 112  mkstemps (template, suffix_len) Line 121  mkstemps (template, suffix_len)
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;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26