/* This file is part of epubgrep. * Copyright © 2021 tastytea * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ #include "files.hpp" #include "fs-compat.hpp" #include #include #include namespace epubgrep::files { std::vector list_recursive(const fs::path &directory, const bool follow_symlinks) { fs::directory_options dir_options{ fs::directory_options::skip_permission_denied}; if (follow_symlinks) { dir_options |= fs::directory_options::follow_directory_symlink; } fs::recursive_directory_iterator dir_iter{directory, dir_options}; std::vector paths; for (const auto &path : dir_iter) { if (!path.is_directory()) { paths.emplace_back(path); } } return paths; } } // namespace epubgrep::files