mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +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
205c020662
commit
a6e2199d65
4 changed files with 373 additions and 215 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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. */
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue