Skip to content

Commit 6129d20

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 afe2828 commit 6129d20

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
@@ -943,14 +943,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
943943
return 1;
944944
}
945945

946-
/* We keep the do_lstat code in a separate function to avoid recursion.
947-
* When a path ends with a slash, the stat will fail with ENOENT. In
948-
* this case, we strip the trailing slashes and stat again.
949-
*
950-
* If follow is true then act like stat() and report on the link
951-
* target. Otherwise report on the link itself.
952-
*/
953-
static int do_lstat(int follow, const char *file_name, struct stat *buf)
946+
int mingw_lstat(const char *file_name, struct stat *buf)
954947
{
955948
WIN32_FILE_ATTRIBUTE_DATA fdata;
956949
wchar_t wfilename[MAX_LONG_PATH];
@@ -984,13 +977,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
984977
if (handle != INVALID_HANDLE_VALUE) {
985978
if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
986979
(findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
987-
if (follow) {
988-
char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
989-
buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
990-
} else {
991-
buf->st_mode = S_IFLNK;
992-
}
993-
buf->st_mode |= S_IREAD;
980+
buf->st_mode = S_IFLNK | S_IREAD;
994981
if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
995982
buf->st_mode |= S_IWRITE;
996983
}
@@ -1050,11 +1037,6 @@ static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
10501037
return 0;
10511038
}
10521039

1053-
int mingw_lstat(const char *file_name, struct stat *buf)
1054-
{
1055-
return do_lstat(0, file_name, buf);
1056-
}
1057-
10581040
int mingw_stat(const char *file_name, struct stat *buf)
10591041
{
10601042
wchar_t wfile_name[MAX_LONG_PATH];

0 commit comments

Comments
 (0)