mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 20:42:23 +00:00
Fix win32 lstat
This commit is contained in:
parent
a9069f6154
commit
52ead7877d
@ -104,7 +104,7 @@ static int do_lstat(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
last_error = GetLastError();
|
errno = ENOENT;
|
||||||
|
|
||||||
/* ERROR_PATH_NOT_FOUND can mean either that a parent directory is
|
/* 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
|
* 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.
|
* (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 */
|
/* scan up path until we find an existing item */
|
||||||
while (1) {
|
while (1) {
|
||||||
/* remove last directory component */
|
/* remove last directory component */
|
||||||
for (--flen; flen > 0 && !WIN32_IS_WSEP(fbuf[flen]); --flen);
|
for (--flen; flen > 0 && !WIN32_IS_WSEP(fbuf[flen]); --flen);
|
||||||
|
|
||||||
if (flen <= 0) {
|
if (flen <= 0)
|
||||||
last_error = ERROR_FILE_NOT_FOUND;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
fbuf[flen] = L'\0';
|
fbuf[flen] = L'\0';
|
||||||
|
|
||||||
if (GetFileAttributesExW(fbuf, GetFileExInfoStandard, &fdata)) {
|
if (GetFileAttributesExW(fbuf, GetFileExInfoStandard, &fdata)) {
|
||||||
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||||
last_error = ERROR_FILE_NOT_FOUND;
|
errno = ENOTDIR;
|
||||||
else
|
break;
|
||||||
last_error = ERROR_PATH_NOT_FOUND;
|
}
|
||||||
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user