I have to delete the file/directory pointed to by path. So I call remove(path), and if this fails with ENOTEMPTY, then it is a non-empty directory and I handle it accordingly.
status = remove(path);
if (status == -1 && errno == ENOTEMPTY)
ftw(path, recursive_dir_delete, 64);
On compilation, I get ENOTEMPTY undeclared. ENOTEMPTY is defined in unistd.h (man 2 rmdir), which I have #included, but still I get the error. What is the correct way of checking if errno was set to ENOTEMPTY?
gcc 4.6.3, 64-bit Ubuntu.
Error constants are declared in the C standard header
<errno.h>. You have to#includethat file in your project.