Return an appropriate error when stat() fails

Tested on Linux and Windows

[Fixes #6517]
unstable
James Lee 2012-03-13 01:10:22 -06:00
parent b815955e09
commit 3ba471176e
2 changed files with 8 additions and 7 deletions

View File

@ -271,11 +271,8 @@ DWORD request_fs_stat(Remote *remote, Packet *packet)
result = ERROR_NOT_ENOUGH_MEMORY;
else
{
// Stat the file using the Microsoft stat wrapper so that we don't have to
// do translations
if (fs_stat(expanded, &buf) < 0)
result = GetLastError();
else
result = fs_stat(expanded, &buf);
if (0 == result)
packet_add_tlv_raw(response, TLV_TYPE_STAT_BUF, &buf,
sizeof(buf));
}
@ -288,7 +285,7 @@ DWORD request_fs_stat(Remote *remote, Packet *packet)
if (expanded)
free(expanded);
return ERROR_SUCCESS;
return result;
}
/*

View File

@ -64,6 +64,10 @@ int fs_stat(LPCSTR filename, struct meterp_stat *buf) {
buf->st_ctime = (unsigned long long)sbuf.st_ctime;
return 0;
} else {
return ret;
#ifdef _WIN32
return GetLastError();
#else
return errno;
#endif
}
}