diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2019-02-26 12:04:55 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2019-02-26 16:31:20 +0100 |
commit | eba6aa6b49bf23d1ece40389b3d2959f5d125f50 (patch) | |
tree | e3bdeb4515bc8e3b927f3cafabf4810c96ccf81e /apt-pkg | |
parent | e217a3a425ba72e8b6ce395e1ecd411fbe58e916 (diff) |
clean: Fold pkgArchiveCleaner2 into pkgArchiveCleaner
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/clean.cc | 19 | ||||
-rw-r--r-- | apt-pkg/clean.h | 16 |
2 files changed, 5 insertions, 30 deletions
diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc index f335554a3..9dd56e609 100644 --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@ -43,17 +43,9 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache) if (FileExists(Dir) == false) return true; - auto const withoutChangingDir = dynamic_cast<pkgArchiveCleaner2*>(this); int const dirfd = open(Dir.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC); if (dirfd == -1) return _error->Errno("open",_("Unable to read %s"),Dir.c_str()); - std::string CWD; - if (withoutChangingDir == nullptr) - { - CWD = SafeGetCWD(); - if (fchdir(dirfd) != 0) - return _error->Errno("fchdir",_("Unable to change to %s"),Dir.c_str()); - } DIR * const D = fdopendir(dirfd); if (D == nullptr) return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str()); @@ -131,18 +123,9 @@ bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache) continue; } - if (withoutChangingDir == nullptr) - { - APT_IGNORE_DEPRECATED_PUSH - Erase(Dir->d_name, Pkg, Ver, St); - APT_IGNORE_DEPRECATED_POP - } - else - withoutChangingDir->Erase(dirfd, Dir->d_name, Pkg, Ver, St); + Erase(dirfd, Dir->d_name, Pkg, Ver, St); } closedir(D); - if (withoutChangingDir == nullptr && chdir(CWD.c_str()) != 0) - return _error->Errno("chdir", _("Unable to change to %s"),Dir.c_str()); return true; } /*}}}*/ diff --git a/apt-pkg/clean.h b/apt-pkg/clean.h index d6490a0c5..a64e6a935 100644 --- a/apt-pkg/clean.h +++ b/apt-pkg/clean.h @@ -25,8 +25,9 @@ class pkgArchiveCleaner void * const d; protected: - - APT_DEPRECATED_MSG("Use pkgArchiveCleaner2 to avoid CWD expectations and chdir") virtual void Erase(const char * /*File*/,std::string /*Pkg*/,std::string /*Ver*/,struct stat & /*St*/) {}; + virtual void Erase(int const dirfd, char const * const File, + std::string const &Pkg,std::string const &Ver, + struct stat const &St) = 0; public: @@ -35,15 +36,6 @@ class pkgArchiveCleaner pkgArchiveCleaner(); virtual ~pkgArchiveCleaner(); }; -// TODO: merge classes and "erase" the old way -class pkgArchiveCleaner2: public pkgArchiveCleaner -{ - friend class pkgArchiveCleaner; -protected: - using pkgArchiveCleaner::Erase; - virtual void Erase(int const dirfd, char const * const File, - std::string const &Pkg,std::string const &Ver, - struct stat const &St) = 0; -}; + #endif |