52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
/* This file is part of epubgrep.
|
|
* Copyright © 2021 tastytea <tastytea@tastytea.de>
|
|
*
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "files.hpp"
|
|
|
|
#include "fs-compat.hpp"
|
|
|
|
#include <exception>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
namespace epubgrep::files
|
|
{
|
|
|
|
std::vector<fs::path> 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<fs::path> paths;
|
|
for (const auto &path : dir_iter)
|
|
{
|
|
if (!path.is_directory())
|
|
{
|
|
paths.emplace_back(path);
|
|
}
|
|
}
|
|
|
|
return paths;
|
|
}
|
|
|
|
} // namespace epubgrep::files
|