forked from premiere/premiere-libtorrent
remove use of deprecated function readdir_r
Ports 140b8ace
onto RC_1_1 branch
This commit is contained in:
parent
4cef1814b0
commit
396c5dd3af
|
@ -762,13 +762,10 @@ std::vector<std::string> list_dir(std::string path
|
|||
return ret;
|
||||
}
|
||||
|
||||
struct dirent de;
|
||||
dirent* dummy;
|
||||
while (readdir_r(handle, &de, &dummy) == 0)
|
||||
struct dirent* de;
|
||||
while ((de = readdir(handle)))
|
||||
{
|
||||
if (dummy == 0) break;
|
||||
|
||||
std::string p = de.d_name;
|
||||
std::string p = de->d_name;
|
||||
if (filter_fun(p))
|
||||
ret.push_back(p);
|
||||
}
|
||||
|
|
|
@ -193,11 +193,8 @@ namespace libtorrent
|
|||
#endif
|
||||
#else
|
||||
DIR* m_handle;
|
||||
// the dirent struct contains a zero-sized
|
||||
// array at the end, it will end up referring
|
||||
// to the m_name field
|
||||
struct dirent m_dirent;
|
||||
char m_name[TORRENT_MAX_PATH + 1]; // +1 to make room for null
|
||||
ino_t m_inode;
|
||||
std::string m_name;
|
||||
#endif
|
||||
bool m_done;
|
||||
};
|
||||
|
|
22
src/file.cpp
22
src/file.cpp
|
@ -1185,9 +1185,6 @@ namespace libtorrent
|
|||
}
|
||||
#else
|
||||
|
||||
memset(&m_dirent, 0, sizeof(dirent));
|
||||
m_name[0] = 0;
|
||||
|
||||
// the path passed to opendir() may not
|
||||
// end with a /
|
||||
std::string p = path;
|
||||
|
@ -1219,11 +1216,7 @@ namespace libtorrent
|
|||
|
||||
boost::uint64_t directory::inode() const
|
||||
{
|
||||
#ifdef TORRENT_WINDOWS
|
||||
return m_inode;
|
||||
#else
|
||||
return m_dirent.d_ino;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string directory::file() const
|
||||
|
@ -1235,7 +1228,7 @@ namespace libtorrent
|
|||
return convert_from_native(m_fd.cFileName);
|
||||
#endif
|
||||
#else
|
||||
return convert_from_native(m_dirent.d_name);
|
||||
return convert_from_native(m_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1257,13 +1250,18 @@ namespace libtorrent
|
|||
}
|
||||
++m_inode;
|
||||
#else
|
||||
dirent* dummy;
|
||||
if (readdir_r(m_handle, &m_dirent, &dummy) != 0)
|
||||
struct dirent* de;
|
||||
errno = 0;
|
||||
if ((de = ::readdir(m_handle)))
|
||||
{
|
||||
ec.assign(errno, system_category());
|
||||
m_inode = de->d_ino;
|
||||
m_name = de->d_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (errno) ec.assign(errno, system_category());
|
||||
m_done = true;
|
||||
}
|
||||
if (dummy == 0) m_done = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue