0
0
mirror of https://github.com/vim/vim.git synced 2025-10-01 04:54:07 -04:00

patch 8.2.4696: delete() with "rf" argument does not report a failure

Problem:    delete() with "rf" argument does not report a failure.
Solution:   Return -1 if the directory could not be removed. (closes #10078)
This commit is contained in:
zeertzjq
2022-04-05 15:31:01 +01:00
committed by Bram Moolenaar
parent beb0ef1ab2
commit 478700336d
3 changed files with 15 additions and 1 deletions

View File

@@ -5017,13 +5017,16 @@ delete_recursive(char_u *name)
vim_snprintf((char *)NameBuff, MAXPATHL, "%s/%s", exp, vim_snprintf((char *)NameBuff, MAXPATHL, "%s/%s", exp,
((char_u **)ga.ga_data)[i]); ((char_u **)ga.ga_data)[i]);
if (delete_recursive(NameBuff) != 0) if (delete_recursive(NameBuff) != 0)
// Remember the failure but continue deleting any further
// entries.
result = -1; result = -1;
} }
ga_clear_strings(&ga); ga_clear_strings(&ga);
if (mch_rmdir(exp) != 0)
result = -1;
} }
else else
result = -1; result = -1;
(void)mch_rmdir(exp);
vim_free(exp); vim_free(exp);
} }
else else

View File

@@ -2242,6 +2242,15 @@ func Test_delete_rf()
call assert_equal(0, delete('Xdir', 'rf')) call assert_equal(0, delete('Xdir', 'rf'))
call assert_false(filereadable('Xdir/foo.txt')) call assert_false(filereadable('Xdir/foo.txt'))
call assert_false(filereadable('Xdir/[a-1]/foo.txt')) call assert_false(filereadable('Xdir/[a-1]/foo.txt'))
if has('unix')
call mkdir('Xdir/Xdir2', 'p')
silent !chmod 555 Xdir
call assert_equal(-1, delete('Xdir/Xdir2', 'rf'))
call assert_equal(-1, delete('Xdir', 'rf'))
silent !chmod 755 Xdir
call assert_equal(0, delete('Xdir', 'rf'))
endif
endfunc endfunc
func Test_call() func Test_call()

View File

@@ -746,6 +746,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4696,
/**/ /**/
4695, 4695,
/**/ /**/