--- nono/lib/autofd.h 2026/04/29 17:04:57 1.1.1.2 +++ nono/lib/autofd.h 2026/04/29 17:05:08 1.1.1.4 @@ -4,6 +4,10 @@ // Licensed under nono-license.txt // +// +// autofd +// + #pragma once #include @@ -20,8 +24,7 @@ class autofd } ~autofd() { - if (Valid()) - close(fd); + Close(); } autofd& operator=(int fd_) { @@ -35,7 +38,7 @@ class autofd // 明示的にクローズする int Close() { int rv = 0; - if (fd >= 0) { + if (Valid()) { rv = close(fd); fd = -1; } @@ -47,6 +50,6 @@ class autofd return (fd >= 0); } - public: + private: int fd; };