From 4a8948b7a60e751dd809f279f1baa434ea09a4d3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 22 Oct 2003 10:48:22 +0000 Subject: * Some wrapper classes to ensure that file descriptors / directory handles are closed when they go out of scope. --- src/libnix/store.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/libnix/store.cc') diff --git a/src/libnix/store.cc b/src/libnix/store.cc index 2d223313b612..c40d9efbebcf 100644 --- a/src/libnix/store.cc +++ b/src/libnix/store.cc @@ -304,14 +304,12 @@ void addTextToStore(const Path & dstPath, const string & s) /* !!! locking? -> parallel writes are probably idempotent */ - int fd = open(dstPath.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0666); + AutoCloseFD fd = open(dstPath.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0666); if (fd == -1) throw SysError(format("creating store file `%1%'") % dstPath); if (write(fd, s.c_str(), s.size()) != (ssize_t) s.size()) throw SysError(format("writing store file `%1%'") % dstPath); - close(fd); /* !!! close on exception */ - Transaction txn(nixDB); registerValidPath(txn, dstPath); txn.commit(); -- cgit 1.4.1