vio_local_win: Properly set errno in case of error happened.

Without a proper errno value, the calling function can not detect
the kind of problem.
This commit is contained in:
Klaas Freitag 2015-09-09 14:10:23 +02:00
parent ba2145032e
commit 02c077e3f8

View file

@ -74,6 +74,12 @@ csync_vio_handle_t *csync_vio_local_opendir(const char *name) {
}
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;
}
@ -99,6 +105,9 @@ int csync_vio_local_closedir(csync_vio_handle_t *dhandle) {
// FindClose returns non-zero on success
if( FindClose(handle->hFind) != 0 ) {
rc = 0;
} else {
// error case, set errno
errno = EBADF;
}
SAFE_FREE(handle->path);
@ -117,7 +126,8 @@ csync_vio_file_stat_t *csync_vio_local_readdir(csync_vio_handle_t *dhandle) {
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;