File tree Expand file tree Collapse file tree
include/osmium/index/detail Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ DEALINGS IN THE SOFTWARE.
3333
3434*/
3535
36+ #include < osmium/io/detail/read_write.hpp>
37+
3638#include < cerrno>
3739#include < cstdio>
3840#include < system_error>
@@ -43,16 +45,19 @@ namespace osmium {
4345
4446 /* *
4547 * Create and open a temporary file. It is removed after opening.
48+ * After use close the file by calling close().
4649 *
4750 * @returns File descriptor of temporary file.
4851 * @throws std::system_error if something went wrong.
4952 */
5053 inline int create_tmp_file () {
51- FILE* file = ::tmpfile ();
54+ FILE* file = std ::tmpfile ();
5255 if (!file) {
5356 throw std::system_error{errno, std::system_category (), " tempfile failed" };
5457 }
55- return fileno (file);
58+ const int fd = osmium::io::detail::reliable_dup (fileno (file));
59+ std::fclose (file);
60+ return fd;
5661 }
5762
5863 } // namespace detail
You can’t perform that action at this time.
0 commit comments