diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-01-16T21·39+0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-01-16T21·39+0100 |
commit | 8079ab87a2a7cd288a35334517da7a808af8e1e0 (patch) | |
tree | 011aa471421d7d51033077994464ecdd3fe9a1eb /src/libutil/util.cc | |
parent | 2b9d0a99cbf7649c20492bc539e2823a2d2e57c5 (diff) |
AutoCloseDir: Use std::unique_ptr
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r-- | src/libutil/util.cc | 46 |
1 files changed, 2 insertions, 44 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 0e1849df09ea..961c14e3a47f 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -234,11 +234,11 @@ DirEntries readDirectory(const Path & path) DirEntries entries; entries.reserve(64); - AutoCloseDir dir = opendir(path.c_str()); + AutoCloseDir dir(opendir(path.c_str())); if (!dir) throw SysError(format("opening directory ‘%1%’") % path); struct dirent * dirent; - while (errno = 0, dirent = readdir(dir)) { /* sic */ + while (errno = 0, dirent = readdir(dir.get())) { /* sic */ checkInterrupt(); string name = dirent->d_name; if (name == "." || name == "..") continue; @@ -645,48 +645,6 @@ void Pipe::create() ////////////////////////////////////////////////////////////////////// -AutoCloseDir::AutoCloseDir() -{ - dir = 0; -} - - -AutoCloseDir::AutoCloseDir(DIR * dir) -{ - this->dir = dir; -} - - -AutoCloseDir::~AutoCloseDir() -{ - close(); -} - - -void AutoCloseDir::operator =(DIR * dir) -{ - this->dir = dir; -} - - -AutoCloseDir::operator DIR *() -{ - return dir; -} - - -void AutoCloseDir::close() -{ - if (dir) { - closedir(dir); - dir = 0; - } -} - - -////////////////////////////////////////////////////////////////////// - - Pid::Pid() : pid(-1), separatePG(false), killSignal(SIGKILL) { |