* Open a file using Linux's O_TMPFILE for writing the given file. */
| 171 | * Open a file using Linux's O_TMPFILE for writing the given file. |
| 172 | */ |
| 173 | static bool |
| 174 | OpenTempFile(FileDescriptor directory_fd, |
| 175 | FileDescriptor &fd, Path path) noexcept |
| 176 | { |
| 177 | if (directory_fd != FileDescriptor(AT_FDCWD)) |
| 178 | return fd.Open(directory_fd, ".", O_TMPFILE|O_WRONLY, 0666); |
| 179 | |
| 180 | const auto directory = path.GetDirectoryName(); |
| 181 | if (directory.IsNull()) |
| 182 | return false; |
| 183 | |
| 184 | return fd.Open(directory.c_str(), O_TMPFILE|O_WRONLY, 0666); |
| 185 | } |
| 186 | |
| 187 | #endif /* HAVE_O_TMPFILE */ |
| 188 |
no test coverage detected