summaryrefslogtreecommitdiff
path: root/klm/util/scoped.cc
blob: 2c6d53948b872373c90b1e003395471491dc28bf (plain)
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