diff options
author | Joursoir <chat@joursoir.net> | 2022-09-07 11:33:00 +0300 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2022-09-08 12:12:21 +0300 |
commit | 12cf23db2b618be8994cd2786d36f49b5adb6a0a (patch) | |
tree | b7420d9b247263cd955d14e32e8ae3327e478008 /src | |
parent | 1a50644a9c4a435bc892f81d0dcdbf3161cc61ec (diff) | |
download | lock-password-12cf23db2b618be8994cd2786d36f49b5adb6a0a.tar.gz lock-password-12cf23db2b618be8994cd2786d36f49b5adb6a0a.tar.bz2 lock-password-12cf23db2b618be8994cd2786d36f49b5adb6a0a.zip |
cmd_remove: drop check for empty file
From the specification:
> If path does not name a directory, remove(path) shall be equivalent
to unlink(path).
> If path names a directory, remove(path) shall be equivalent to
rmdir(path).
rmdir() will remove a directory only if it is empty, so drop
validation for it.
Diffstat (limited to 'src')
-rw-r--r-- | src/exec-cmd.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/exec-cmd.c b/src/exec-cmd.c index 90a666e..8936315 100644 --- a/src/exec-cmd.c +++ b/src/exec-cmd.c @@ -361,13 +361,9 @@ int cmd_remove(int argc, char *argv[]) print_error("Error: No such file exists\n"); return 1; } - if(result == F_ISDIR) { - if(count_dir_entries(path) != 0) { - print_error("Error: Directory not empty\n"); - return 1; - } - } + /* If path names a directory, remove() shall be equivalent + to rmdir(). */ result = remove(path); if(result) { print_error("Error: %s\n", strerror(errno)); |