If a call to unlink() returns false for the specified path, how do you find out what the reason for the failure was (i.e. EISDIR, ENOENT, ELOOP etc.)? PHP 5.x running on redhat
This is not possible, i'm afraid. Here's the C code that handles unlink in php 5.3.
ret = VCWD_UNLINK(url); <-- calls unlink(2)
if (ret == -1) {
if (options & REPORT_ERRORS) {
php_error_docref1(NULL TSRMLS_CC, url, E_WARNING, "%s", strerror(errno));
}
return 0;
}
as you can see, errno is not returned and there's no way to access it later.
There's already a bugreport about this, but it doesn't seem to draw too much attention. ;)
See also this discussion