mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Modernize AutoCloseFD
This commit is contained in:
parent
8a41792d43
commit
cb5e7254b6
11 changed files with 139 additions and 153 deletions
|
@ -255,11 +255,11 @@ Hash hashFile(HashType ht, const Path & path)
|
|||
start(ht, ctx);
|
||||
|
||||
AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC);
|
||||
if (fd == -1) throw SysError(format("opening file ‘%1%’") % path);
|
||||
if (!fd) throw SysError(format("opening file ‘%1%’") % path);
|
||||
|
||||
unsigned char buf[8192];
|
||||
ssize_t n;
|
||||
while ((n = read(fd, buf, sizeof(buf)))) {
|
||||
while ((n = read(fd.get(), buf, sizeof(buf)))) {
|
||||
checkInterrupt();
|
||||
if (n == -1) throw SysError(format("reading file ‘%1%’") % path);
|
||||
update(ht, ctx, buf, n);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue