mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
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:
parent
3a3811c528
commit
d4d6cec52d
@ -1484,19 +1484,21 @@ check_dir_is_empty (const vfs_path_t * vpath)
|
|||||||
{
|
{
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct vfs_dirent *d;
|
struct vfs_dirent *d;
|
||||||
int i = 0;
|
int i = 1;
|
||||||
|
|
||||||
dir = mc_opendir (vpath);
|
dir = mc_opendir (vpath);
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* https://stackoverflow.com/questions/6383584/check-if-a-directory-is-empty-using-c-on-linux */
|
for (d = mc_readdir (dir); d != NULL; d = mc_readdir (dir))
|
||||||
while ((d = mc_readdir (dir)) != NULL)
|
if (!DIR_IS_DOT (d->d_name) && !DIR_IS_DOTDOT (d->d_name))
|
||||||
if (++i > 2)
|
{
|
||||||
|
i = 0;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
mc_closedir (dir);
|
mc_closedir (dir);
|
||||||
return i <= 2 ? 1 : 0;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
Loading…
Reference in New Issue
Block a user