fs/FileSystem: use UniqueFileDescriptor in TruncateFile()
This commit is contained in:
parent
df5cc3f0f6
commit
c00b6ff999
@ -22,7 +22,6 @@
|
|||||||
#include "AllocatedPath.hxx"
|
#include "AllocatedPath.hxx"
|
||||||
#include "Limits.hxx"
|
#include "Limits.hxx"
|
||||||
#include "system/Error.hxx"
|
#include "system/Error.hxx"
|
||||||
#include "system/fd_util.h"
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -73,11 +72,9 @@ TruncateFile(Path path)
|
|||||||
|
|
||||||
CloseHandle(h);
|
CloseHandle(h);
|
||||||
#else
|
#else
|
||||||
int fd = open_cloexec(path.c_str(), O_WRONLY|O_TRUNC, 0);
|
UniqueFileDescriptor fd;
|
||||||
if (fd < 0)
|
if (!fd.Open(path.c_str(), O_WRONLY|O_TRUNC))
|
||||||
throw FormatErrno("Failed to truncate %s", path.c_str());
|
throw FormatErrno("Failed to truncate %s", path.c_str());
|
||||||
|
|
||||||
close(fd);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user