Skip to content

Commit e8f752c

Browse files
kbleesdscho
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 5f0de62 commit e8f752c

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
@@ -956,14 +956,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
956956
return 1;
957957
}
958958

959-
/* We keep the do_lstat code in a separate function to avoid recursion.
960-
* When a path ends with a slash, the stat will fail with ENOENT. In
961-
* this case, we strip the trailing slashes and stat again.
962-
*
963-
* If follow is true then act like stat() and report on the link
964-
* target. Otherwise report on the link itself.
965-
*/
966-
static int do_lstat(int follow, const char *file_name, struct stat *buf)
959+
int mingw_lstat(const char *file_name, struct stat *buf)
967960
{
968961
WIN32_FILE_ATTRIBUTE_DATA fdata;
969962
wchar_t wfilename[MAX_LONG_PATH];
@@ -997,13 +990,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
997990
if (handle != INVALID_HANDLE_VALUE) {
998991
if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
999992
(findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
1000-
if (follow) {
1001-
char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
1002-
buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
1003-
} else {
1004-
buf->st_mode = S_IFLNK;
1005-
}
1006-
buf->st_mode |= S_IREAD;
993+
buf->st_mode = S_IFLNK | S_IREAD;
1007994
if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
1008995
buf->st_mode |= S_IWRITE;
1009996
}
@@ -1063,11 +1050,6 @@ static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
10631050
return 0;
10641051
}
10651052

1066-
int mingw_lstat(const char *file_name, struct stat *buf)
1067-
{
1068-
return do_lstat(0, file_name, buf);
1069-
}
1070-
10711053
int mingw_stat(const char *file_name, struct stat *buf)
10721054
{
10731055
wchar_t wfile_name[MAX_LONG_PATH];

0 commit comments

Comments
 (0)