Ticket #4364: FISH VFS: cannot remove non-empty directory.

Revert "(check_dir_is_empty): minor optimization."

This reverts commit 25e419ba08.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2022-10-02 11:08:53 +03:00
parent 3a3811c528
commit d4d6cec52d

View File

@ -1484,19 +1484,21 @@ check_dir_is_empty (const vfs_path_t * vpath)
{
DIR *dir;
struct vfs_dirent *d;
int i = 0;
int i = 1;
dir = mc_opendir (vpath);
if (dir == NULL)
return -1;
/* https://stackoverflow.com/questions/6383584/check-if-a-directory-is-empty-using-c-on-linux */
while ((d = mc_readdir (dir)) != NULL)
if (++i > 2)
for (d = mc_readdir (dir); d != NULL; d = mc_readdir (dir))
if (!DIR_IS_DOT (d->d_name) && !DIR_IS_DOTDOT (d->d_name))
{
i = 0;
break;
}
mc_closedir (dir);
return i <= 2 ? 1 : 0;
return i;
}
/* --------------------------------------------------------------------------------------------- */