File indexing completed on 2024-04-14 05:41:25

0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0002 // SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org>
0003 
0004 #pragma once
0005 
0006 #include <dirent.h>
0007 #include <fcntl.h>
0008 #include <set>
0009 #include <sys/stat.h>
0010 #include <sys/types.h>
0011 #include <unistd.h>
0012 
0013 #include <cerrno>
0014 
0015 #include "directoryEntry.h"
0016 
0017 class POSIXWalker
0018 {
0019 public:
0020     explicit POSIXWalker(const QByteArray &path);
0021     ~POSIXWalker();
0022 
0023     void next();
0024 
0025     QByteArray m_path;
0026     DirectoryEntry m_entry;
0027 
0028 private:
0029     void close();
0030 
0031     DIR *m_dir = nullptr;
0032     int m_dirfd = -1;
0033     // Hard link files we have already counted, so we will ignore them
0034     std::set<ino_t> m_countedHardlinks;
0035 
0036     struct stat statbuf {
0037     };
0038     Q_DISABLE_COPY_MOVE(POSIXWalker) // we hold a pointer, disable sharing
0039 };