summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-09-17 12:23:19 -0400
committerEdward Thomson <ethomson@microsoft.com>2015-09-17 12:23:19 -0400
commite164ddb11df0d7cd8178c759e323d18a7a7ea526 (patch)
tree8fbb054d635a972107d73b5559387a6710f9a87b
parent81aaf3704a2728b0478c0e9f347b2a8c61152081 (diff)
downloadlibgit2-e164ddb11df0d7cd8178c759e323d18a7a7ea526.tar.gz
win32: return EACCES in `p_lstat`
Don't coalesce all errors into ENOENT. At least identify EACCES. All callers should be handling this case already, as the POSIX `lstat` will return this.
-rw-r--r--src/win32/posix_w32.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index c909af6cc..414cb4701 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -148,12 +148,19 @@ static int lstat_w(
return git_win32__file_attribute_to_stat(buf, &fdata, path);
}
- errno = ENOENT;
+ switch (GetLastError()) {
+ case ERROR_ACCESS_DENIED:
+ errno = EACCES;
+ break;
+ default:
+ errno = ENOENT;
+ break;
+ }
/* To match POSIX behavior, set ENOTDIR when any of the folders in the
* file path is a regular file, otherwise set ENOENT.
*/
- if (posix_enotdir) {
+ if (errno == ENOENT && posix_enotdir) {
size_t path_len = wcslen(path);
/* scan up path until we find an existing item */