Skip to content

Commit 9833e1c

Browse files
kbleesGit for Windows Build Agent
authored andcommitted
Win32: remove separate do_lstat() function
With the new mingw_stat() implementation, do_lstat() is only called from mingw_lstat() (with follow == 0). Remove the extra function and the old mingw_stat()-specific (follow == 1) logic. Signed-off-by: Karsten Blees <[email protected]>
1 parent bdb4fe9 commit 9833e1c

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

compat/mingw.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -958,14 +958,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
958958
return 1;
959959
}
960960

961-
/* We keep the do_lstat code in a separate function to avoid recursion.
962-
* When a path ends with a slash, the stat will fail with ENOENT. In
963-
* this case, we strip the trailing slashes and stat again.
964-
*
965-
* If follow is true then act like stat() and report on the link
966-
* target. Otherwise report on the link itself.
967-
*/
968-
static int do_lstat(int follow, const char *file_name, struct stat *buf)
961+
int mingw_lstat(const char *file_name, struct stat *buf)
969962
{
970963
WIN32_FILE_ATTRIBUTE_DATA fdata;
971964
wchar_t wfilename[MAX_LONG_PATH];
@@ -999,13 +992,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
999992
if (handle != INVALID_HANDLE_VALUE) {
1000993
if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
1001994
(findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
1002-
if (follow) {
1003-
char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
1004-
buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
1005-
} else {
1006-
buf->st_mode = S_IFLNK;
1007-
}
1008-
buf->st_mode |= S_IREAD;
995+
buf->st_mode = S_IFLNK | S_IREAD;
1009996
if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
1010997
buf->st_mode |= S_IWRITE;
1011998
}
@@ -1065,11 +1052,6 @@ static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
10651052
return 0;
10661053
}
10671054

1068-
int mingw_lstat(const char *file_name, struct stat *buf)
1069-
{
1070-
return do_lstat(0, file_name, buf);
1071-
}
1072-
10731055
int mingw_stat(const char *file_name, struct stat *buf)
10741056
{
10751057
wchar_t wfile_name[MAX_LONG_PATH];

0 commit comments

Comments
 (0)