summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEduardo Bart <edub4rt@gmail.com>2012-11-19 22:30:20 -0200
committerEduardo Bart <edub4rt@gmail.com>2012-11-19 22:30:20 -0200
commit52ead7877dfa24681bd17c9f82f6d3c1bb5a873a (patch)
tree76a866025787d29d302d2aa58619855d81ec90ad /src
parenta9069f6154d34c93d644a9eb4c2da55b01468982 (diff)
downloadlibgit2-52ead7877dfa24681bd17c9f82f6d3c1bb5a873a.tar.gz
Fix win32 lstat
Diffstat (limited to 'src')
-rw-r--r--src/win32/posix_w32.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index 7359e4e9f..06da7ca95 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -104,7 +104,7 @@ static int do_lstat(
return 0;
}
- last_error = GetLastError();
+ errno = ENOENT;
/* ERROR_PATH_NOT_FOUND can mean either that a parent directory is
* missing or that an expected directory is a regular file. If we need
@@ -112,38 +112,26 @@ static int do_lstat(
* (i.e. entry that is not a dir), and the first case should be ENOENT.
*/
- if (last_error == ERROR_PATH_NOT_FOUND && posix_enotdir) {
+ if (posix_enotdir) {
/* scan up path until we find an existing item */
while (1) {
/* remove last directory component */
for (--flen; flen > 0 && !WIN32_IS_WSEP(fbuf[flen]); --flen);
- if (flen <= 0) {
- last_error = ERROR_FILE_NOT_FOUND;
+ if (flen <= 0)
break;
- }
fbuf[flen] = L'\0';
if (GetFileAttributesExW(fbuf, GetFileExInfoStandard, &fdata)) {
- if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- last_error = ERROR_FILE_NOT_FOUND;
- else
- last_error = ERROR_PATH_NOT_FOUND;
- break;
+ if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
+ errno = ENOTDIR;
+ break;
+ }
}
-
- last_error = GetLastError();
- if (last_error == ERROR_FILE_NOT_FOUND)
- break;
}
}
- if (last_error == ERROR_FILE_NOT_FOUND)
- errno = ENOENT;
- else if (last_error == ERROR_PATH_NOT_FOUND)
- errno = ENOTDIR;
-
return -1;
}