Commit 508ceb35 authored by Samuel Newbold's avatar Samuel Newbold

Stop using the deprecated readdir_r()

parent 762c9e3d
// The template used to open a directory, and copy its entries into the
// container specified by dest.
// Copyright (C) 2005-2016 Samuel Newbold
// Copyright (C) 2005-2018 Samuel Newbold
template<class Out> int read_dir(const std::string& filename, Out dest) {
std::string file = filename + '/';
DIR *src = opendir(file.c_str());
if (!src) throw Exception(Argm::Unreadable_dir, file, errno);
struct dirent entry, *result = &entry;
while (!readdir_r(src, &entry, &result) && result) *dest++ = entry.d_name;
struct dirent *result = nullptr;
while (result = readdir(src)) *dest++ = result->d_name;
return closedir(src);}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment