diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-10-22T10·48+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-10-22T10·48+0000 |
commit | 4a8948b7a60e751dd809f279f1baa434ea09a4d3 (patch) | |
tree | 3c8475fe2280f2e48654f287c46edc580bf4382c /src/libnix/store.cc | |
parent | c62433751d5fce8c25a802989c50fee993f39c2d (diff) |
* Some wrapper classes to ensure that file descriptors / directory
handles are closed when they go out of scope.
Diffstat (limited to 'src/libnix/store.cc')
-rw-r--r-- | src/libnix/store.cc | 4 |
1 files changed, 1 insertions, 3 deletions
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(); |