Add mkostemp and mkostemps.
* mktemp.cc (_gettemp): Add flags argument. All callers updated. (mkostemp, mkostemps): New functions. * cygwin.din (mkostemp, mkostemps): Export. * posix.sgml: Document them. * include/cygwin/version.h: Bump version.
This commit is contained in:
parent
8092f46770
commit
3083fa9447
|
@ -1,3 +1,11 @@
|
|||
2010-07-19 Eric Blake <eblake@redhat.com>
|
||||
|
||||
* mktemp.cc (_gettemp): Add flags argument. All callers updated.
|
||||
(mkostemp, mkostemps): New functions.
|
||||
* cygwin.din (mkostemp, mkostemps): Export.
|
||||
* posix.sgml: Document them.
|
||||
* include/cygwin/version.h: Bump version.
|
||||
|
||||
2010-07-18 Christopher Faylor <me+cygwin@cgf.cx>
|
||||
|
||||
* autoload.cc (noload): Use "pushl" rather than "push".
|
||||
|
|
|
@ -995,6 +995,8 @@ mknod SIGFE
|
|||
_mknod = mknod SIGFE
|
||||
_mknod32 = mknod32 SIGFE
|
||||
mknodat SIGFE
|
||||
mkostemp SIGFE
|
||||
mkostemps SIGFE
|
||||
mkstemp SIGFE
|
||||
_mkstemp = mkstemp SIGFE
|
||||
mkstemps SIGFE
|
||||
|
|
|
@ -388,12 +388,13 @@ details. */
|
|||
226: Export __locale_mb_cur_max.
|
||||
227: Add pseudo_reloc_start, pseudo_reloc_end, image_base to per_process.
|
||||
228: CW_STRERROR added.
|
||||
229: Add mkostemp, mkostemps.
|
||||
*/
|
||||
|
||||
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
|
||||
|
||||
#define CYGWIN_VERSION_API_MAJOR 0
|
||||
#define CYGWIN_VERSION_API_MINOR 228
|
||||
#define CYGWIN_VERSION_API_MINOR 229
|
||||
|
||||
/* There is also a compatibity version number associated with the
|
||||
shared memory regions. It is incremented when incompatible
|
||||
|
|
|
@ -10,7 +10,7 @@ See the copyright at the bottom of this file. */
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int _gettemp(char *, int *, int, size_t);
|
||||
static int _gettemp(char *, int *, int, size_t, int);
|
||||
static uint32_t arc4random ();
|
||||
|
||||
static const char padchar[] =
|
||||
|
@ -20,30 +20,44 @@ extern "C" int
|
|||
mkstemp(char *path)
|
||||
{
|
||||
int fd;
|
||||
return _gettemp(path, &fd, 0, 0) ? fd : -1;
|
||||
return _gettemp(path, &fd, 0, 0, O_BINARY) ? fd : -1;
|
||||
}
|
||||
|
||||
extern "C" char *
|
||||
mkdtemp(char *path)
|
||||
{
|
||||
return _gettemp(path, NULL, 1, 0) ? path : NULL;
|
||||
return _gettemp(path, NULL, 1, 0, 0) ? path : NULL;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
mkstemps(char *path, int len)
|
||||
{
|
||||
int fd;
|
||||
return _gettemp(path, &fd, 0, len) ? fd : -1;
|
||||
return _gettemp(path, &fd, 0, len, O_BINARY) ? fd : -1;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
mkostemp(char *path, int flags)
|
||||
{
|
||||
int fd;
|
||||
return _gettemp(path, &fd, 0, 0, flags & ~O_ACCMODE) ? fd : -1;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
mkostemps(char *path, int len, int flags)
|
||||
{
|
||||
int fd;
|
||||
return _gettemp(path, &fd, 0, len, flags & ~O_ACCMODE) ? fd : -1;
|
||||
}
|
||||
|
||||
extern "C" char *
|
||||
mktemp(char *path)
|
||||
{
|
||||
return _gettemp(path, NULL, 0, 0) ? path : (char *) NULL;
|
||||
return _gettemp(path, NULL, 0, 0, 0) ? path : (char *) NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
_gettemp(char *path, int *doopen, int domkdir, size_t suffixlen)
|
||||
_gettemp(char *path, int *doopen, int domkdir, size_t suffixlen, int flags)
|
||||
{
|
||||
char *start, *trv, *suffp;
|
||||
char *pad;
|
||||
|
@ -105,7 +119,7 @@ _gettemp(char *path, int *doopen, int domkdir, size_t suffixlen)
|
|||
{
|
||||
if (doopen)
|
||||
{
|
||||
if ((*doopen = open (path, O_CREAT | O_EXCL | O_RDWR | O_BINARY,
|
||||
if ((*doopen = open (path, O_CREAT | O_EXCL | O_RDWR | flags,
|
||||
S_IRUSR | S_IWUSR)) >= 0)
|
||||
return 1;
|
||||
if (errno != EEXIST)
|
||||
|
|
|
@ -1043,6 +1043,8 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
|
|||
lsetxattr
|
||||
memmem
|
||||
mempcpy
|
||||
mkostemp
|
||||
mkostemps
|
||||
pipe2
|
||||
pow10
|
||||
pow10f
|
||||
|
|
Loading…
Reference in New Issue