mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
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:
parent
2a46f64ffa
commit
713a3fc12c
4 changed files with 373 additions and 215 deletions
|
@ -48,6 +48,9 @@
|
|||
/* Define if you have the shmctl function. */
|
||||
#undef HAVE_SHMCTL
|
||||
|
||||
/* Define if you have the mkstemp function. */
|
||||
#undef HAVE_MKSTEMP
|
||||
|
||||
/* Define if you have the statvfs function. */
|
||||
#undef HAVE_STATVFS
|
||||
|
||||
|
|
|
@ -500,7 +500,29 @@ failure:
|
|||
NSLog(@"Open (%s) attempt failed - bad path", theRealPath);
|
||||
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)
|
||||
{
|
||||
/* 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. */
|
||||
theFile = fopen(thePath, "w");
|
||||
#endif
|
||||
|
||||
if (theFile == NULL) /* Something went wrong; we weren't
|
||||
* even able to open the file. */
|
||||
|
|
|
@ -473,6 +473,7 @@ AC_CHECK_FUNCS(times)
|
|||
#--------------------------------------------------------------------
|
||||
AC_CHECK_FUNCS(shmctl)
|
||||
AC_CHECK_FUNCS(mmap)
|
||||
AC_CHECK_FUNCS(mkstemp)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# This function needed by UnixFileHandle.m
|
||||
|
|
Loading…
Reference in a new issue