snprintf(tempfile, PATH_MAX - 1, "%s/.pakfire-dist.XXXXXX", target);
// Create a temporary result file
- int fd = mkostemp(tempfile, O_CLOEXEC);
- if (fd < 0)
+ FILE* f = pakfire_mktemp(tempfile);
+ if (!f)
goto ERROR;
- // Re-open as file handle
- FILE* f = fdopen(fd, "w");
-
// Write the finished package
r = pakfire_packager_finish(packager, f);
if (r) {
#include <pakfire/private.h>
#include <pakfire/pwd.h>
#include <pakfire/types.h>
+#include <pakfire/util.h>
#define BUFFER_SIZE 64 * 1024
}
// Create a new temporary file
- int fd = mkostemp(path, O_CLOEXEC);
- if (fd < 0) {
- ERROR(p->pakfire, "mkostemp() failed: %s\n", strerror(errno));
+ p->fpayload = pakfire_mktemp(path);
+ if (!p->fpayload)
return 1;
- }
// Unlink the file straight away
unlink(path);
- // Convert the file descriptor into a file handle
- p->fpayload = fdopen(fd, "w+");
- if (!p->fpayload) {
- close(fd);
-
- return 1;
- }
-
// Write archive to file
r = archive_write_open_FILE(p->payload, p->fpayload);
if (r)