mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 05:15:40 +03:00
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:
parent
ba2145032e
commit
02c077e3f8
1 changed files with 11 additions and 1 deletions
|
@ -74,6 +74,12 @@ csync_vio_handle_t *csync_vio_local_opendir(const char *name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dirname || handle->hFind == INVALID_HANDLE_VALUE) {
|
if (!dirname || handle->hFind == INVALID_HANDLE_VALUE) {
|
||||||
|
int retcode = GetLastError();
|
||||||
|
if( retcode == ERROR_FILE_NOT_FOUND ) {
|
||||||
|
errno = ENOENT;
|
||||||
|
} else {
|
||||||
|
errno = EACCES;
|
||||||
|
}
|
||||||
SAFE_FREE(handle);
|
SAFE_FREE(handle);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -99,6 +105,9 @@ int csync_vio_local_closedir(csync_vio_handle_t *dhandle) {
|
||||||
// FindClose returns non-zero on success
|
// FindClose returns non-zero on success
|
||||||
if( FindClose(handle->hFind) != 0 ) {
|
if( FindClose(handle->hFind) != 0 ) {
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
} else {
|
||||||
|
// error case, set errno
|
||||||
|
errno = EBADF;
|
||||||
}
|
}
|
||||||
|
|
||||||
SAFE_FREE(handle->path);
|
SAFE_FREE(handle->path);
|
||||||
|
@ -117,7 +126,8 @@ csync_vio_file_stat_t *csync_vio_local_readdir(csync_vio_handle_t *dhandle) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
file_stat = csync_vio_file_stat_new();
|
file_stat = csync_vio_file_stat_new();
|
||||||
if (file_stat == NULL) {
|
if (file_stat == NULL) {
|
||||||
goto err;
|
errno = ENOMEM;
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
file_stat->fields = CSYNC_VIO_FILE_STAT_FIELDS_NONE;
|
file_stat->fields = CSYNC_VIO_FILE_STAT_FIELDS_NONE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue