Permalink
Browse files

Remove usage of deprecated function readdir_r (and ugly Blackberry ha…

…ck diren_large)
  • Loading branch information...
hrydgard committed Jan 8, 2019
1 parent cb63df2 commit b572dc52a527ab6f0f1b0c19d40ea773a7139432
Showing with 5 additions and 12 deletions.
  1. +3 −5 Common/FileUtil.cpp
  2. +1 −4 Core/FileSystems/DirectoryFileSystem.cpp
  3. +1 −3 ext/native/file/file_util.cpp
@@ -661,13 +661,13 @@ bool DeleteDirRecursively(const std::string &directory)
{
const std::string virtualName = ConvertWStringToUTF8(ffd.cFileName);
#else
struct dirent dirent, *result = NULL;
struct dirent *result = NULL;
DIR *dirp = opendir(directory.c_str());
if (!dirp)
return false;

// non windows loop
while (!readdir_r(dirp, &dirent, &result) && result)
while ((result = readdir(dirp)))
{
const std::string virtualName = result->d_name;
#endif
@@ -723,13 +723,11 @@ void CopyDir(const std::string &source_path, const std::string &dest_path)
if (!File::Exists(source_path)) return;
if (!File::Exists(dest_path)) File::CreateFullPath(dest_path);

struct dirent_large { struct dirent entry; char padding[FILENAME_MAX+1]; };
struct dirent_large diren;
struct dirent *result = NULL;
DIR *dirp = opendir(source_path.c_str());
if (!dirp) return;

while (!readdir_r(dirp, (dirent*) &diren, &result) && result)
while ((result = readdir(dirp)))
{
const std::string virtualName(result->d_name);
// check for "." and ".."
@@ -66,9 +66,6 @@ static bool FixFilenameCase(const std::string &path, std::string &filename)
}

//TODO: lookup filename in cache for "path"

struct dirent_large { struct dirent entry; char padding[FILENAME_MAX+1]; } diren;
struct dirent_large;
struct dirent *result = NULL;

DIR *dirp = opendir(path.c_str());
@@ -77,7 +74,7 @@ static bool FixFilenameCase(const std::string &path, std::string &filename)

bool retValue = false;

while (!readdir_r(dirp, (dirent*) &diren, &result) && result)
while ((result = readdir(dirp)))
{
if (strlen(result->d_name) != filenameSize)
continue;
@@ -238,8 +238,6 @@ size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files, const
{
const std::string virtualName = ConvertWStringToUTF8(ffd.cFileName);
#else
struct dirent_large { struct dirent entry; char padding[FILENAME_MAX+1]; };
struct dirent_large diren;
struct dirent *result = NULL;

//std::string directoryWithSlash = directory;
@@ -250,7 +248,7 @@ size_t getFilesInDir(const char *directory, std::vector<FileInfo> *files, const
if (!dirp)
return 0;
// non windows loop
while (!readdir_r(dirp, (dirent*) &diren, &result) && result)
while ((result = readdir(dirp)))
{
const std::string virtualName(result->d_name);
#endif

0 comments on commit b572dc5

Please sign in to comment.