Use mkstemp if available

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3634 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-02-01 14:00:17 +00:00
parent 205c020662
commit a6e2199d65
4 changed files with 373 additions and 215 deletions

View file

@ -48,6 +48,9 @@
/* Define if you have the shmctl function. */ /* Define if you have the shmctl function. */
#undef HAVE_SHMCTL #undef HAVE_SHMCTL
/* Define if you have the mkstemp function. */
#undef HAVE_MKSTEMP
/* Define if you have the statvfs function. */ /* Define if you have the statvfs function. */
#undef HAVE_STATVFS #undef HAVE_STATVFS

View file

@ -500,7 +500,29 @@ failure:
NSLog(@"Open (%s) attempt failed - bad path", theRealPath); NSLog(@"Open (%s) attempt failed - bad path", theRealPath);
return NO; return NO;
} }
#ifdef HAVE_MKSTEMP
if (useAuxiliaryFile)
{
int desc;
strcpy(thePath, theRealPath);
strcat(thePath, "XXXXXX");
if ((desc = mktemp(thePath)) < 0)
{
NSLog(@"mkstemp (%s) failed - %s", thePath, strerror(errno));
goto failure;
}
if ((theFile = fdopen(desc, "w")) == 0)
{
close(desc);
}
}
else
{
strcpy(thePath, theRealPath);
theFile = fopen(thePath, "w");
}
#else
if (useAuxiliaryFile) if (useAuxiliaryFile)
{ {
/* Use the path name of the destination file as a prefix for the /* Use the path name of the destination file as a prefix for the
@ -521,6 +543,7 @@ failure:
/* Open the file (whether temp or real) for writing. */ /* Open the file (whether temp or real) for writing. */
theFile = fopen(thePath, "w"); theFile = fopen(thePath, "w");
#endif
if (theFile == NULL) /* Something went wrong; we weren't if (theFile == NULL) /* Something went wrong; we weren't
* even able to open the file. */ * even able to open the file. */

561
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -473,6 +473,7 @@ AC_CHECK_FUNCS(times)
#-------------------------------------------------------------------- #--------------------------------------------------------------------
AC_CHECK_FUNCS(shmctl) AC_CHECK_FUNCS(shmctl)
AC_CHECK_FUNCS(mmap) AC_CHECK_FUNCS(mmap)
AC_CHECK_FUNCS(mkstemp)
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# This function needed by UnixFileHandle.m # This function needed by UnixFileHandle.m