summaryrefslogtreecommitdiff
path: root/klm/util/scoped.cc
blob: a4cc50168f1e1efb95ad1cd914ea63f001543aed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "util/scoped.hh"

#include <iostream>

#include <stdlib.h>
#include <unistd.h>

namespace util {

scoped_fd::~scoped_fd() {
  if (fd_ != -1 && close(fd_)) {
    std::cerr << "Could not close file " << fd_ << std::endl;
    abort();
  }
}

scoped_FILE::~scoped_FILE() {
  if (file_ && fclose(file_)) {
    std::cerr << "Could not close file " << std::endl;
    abort();
  }
}

} // namespace util