| 19 | namespace dena { |
| 20 | |
| 21 | struct auto_file : private noncopyable { |
| 22 | auto_file() : fd(-1) { } |
| 23 | ~auto_file() { |
| 24 | reset(); |
| 25 | } |
| 26 | int get() const { return fd; } |
| 27 | int close() { |
| 28 | if (fd < 0) { |
| 29 | return 0; |
| 30 | } |
| 31 | const int r = ::close(fd); |
| 32 | fd = -1; |
| 33 | return r; |
| 34 | } |
| 35 | void reset(int x = -1) { |
| 36 | if (fd >= 0) { |
| 37 | this->close(); |
| 38 | } |
| 39 | fd = x; |
| 40 | } |
| 41 | private: |
| 42 | int fd; |
| 43 | }; |
| 44 | |
| 45 | struct auto_dir : private noncopyable { |
| 46 | auto_dir() : dp(0) { } |
nothing calls this directly
no outgoing calls
no test coverage detected