1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include "util/scoped.hh" #include <err.h> #include <unistd.h> namespace util { scoped_fd::~scoped_fd() { if (fd_ != -1 && close(fd_)) err(1, "Could not close file %i", fd_); } scoped_FILE::~scoped_FILE() { if (file_ && fclose(file_)) err(1, "Could not close file"); } } // namespace util