io/FileOutputStream: simplify OpenTempFile() call
This commit is contained in:
parent
bd3e096411
commit
2670bbdcc8
@ -190,13 +190,16 @@ OpenTempFile(FileDescriptor directory_fd,
|
|||||||
#endif /* HAVE_O_TMPFILE */
|
#endif /* HAVE_O_TMPFILE */
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
FileOutputStream::OpenCreate(bool visible)
|
FileOutputStream::OpenCreate([[maybe_unused]] bool visible)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_O_TMPFILE
|
#ifdef HAVE_O_TMPFILE
|
||||||
/* try Linux's O_TMPFILE first */
|
/* try Linux's O_TMPFILE first */
|
||||||
is_tmpfile = !visible && OpenTempFile(directory_fd, fd, GetPath());
|
if (!visible && OpenTempFile(directory_fd, fd, GetPath())) {
|
||||||
if (!is_tmpfile) {
|
is_tmpfile = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* fall back to plain POSIX */
|
/* fall back to plain POSIX */
|
||||||
if (!fd.Open(
|
if (!fd.Open(
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -207,11 +210,6 @@ FileOutputStream::OpenCreate(bool visible)
|
|||||||
0666))
|
0666))
|
||||||
throw FormatErrno("Failed to create %s",
|
throw FormatErrno("Failed to create %s",
|
||||||
GetPath().c_str());
|
GetPath().c_str());
|
||||||
#ifdef HAVE_O_TMPFILE
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
(void)visible;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
Loading…
Reference in New Issue
Block a user