Without a proper errno value, the calling function can not detect
the kind of problem.
}
if (!dirname || handle->hFind == INVALID_HANDLE_VALUE) {
+ int retcode = GetLastError();
+ if( retcode == ERROR_FILE_NOT_FOUND ) {
+ errno = ENOENT;
+ } else {
+ errno = EACCES;
+ }
SAFE_FREE(handle);
return NULL;
}
// FindClose returns non-zero on success
if( FindClose(handle->hFind) != 0 ) {
rc = 0;
+ } else {
+ // error case, set errno
+ errno = EBADF;
}
SAFE_FREE(handle->path);
errno = 0;
file_stat = csync_vio_file_stat_new();
if (file_stat == NULL) {
- goto err;
+ errno = ENOMEM;
+ goto err;
}
file_stat->fields = CSYNC_VIO_FILE_STAT_FIELDS_NONE;