Commit c00b6ff9 authored by Max Kellermann's avatar Max Kellermann

fs/FileSystem: use UniqueFileDescriptor in TruncateFile()

parent df5cc3f0
......@@ -22,7 +22,6 @@
#include "AllocatedPath.hxx"
#include "Limits.hxx"
#include "system/Error.hxx"
#include "system/fd_util.h"
#include <errno.h>
#include <fcntl.h>
......@@ -73,11 +72,9 @@ TruncateFile(Path path)
CloseHandle(h);
#else
int fd = open_cloexec(path.c_str(), O_WRONLY|O_TRUNC, 0);
if (fd < 0)
UniqueFileDescriptor fd;
if (!fd.Open(path.c_str(), O_WRONLY|O_TRUNC))
throw FormatErrno("Failed to truncate %s", path.c_str());
close(fd);
#endif
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment