Skip to content

Commit af7734a

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 de191d1 commit af7734a

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
@@ -932,14 +932,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
932932
return 1;
933933
}
934934

935-
/* We keep the do_lstat code in a separate function to avoid recursion.
936-
* When a path ends with a slash, the stat will fail with ENOENT. In
937-
* this case, we strip the trailing slashes and stat again.
938-
*
939-
* If follow is true then act like stat() and report on the link
940-
* target. Otherwise report on the link itself.
941-
*/
942-
static int do_lstat(int follow, const char *file_name, struct stat *buf)
935+
int mingw_lstat(const char *file_name, struct stat *buf)
943936
{
944937
WIN32_FILE_ATTRIBUTE_DATA fdata;
945938
wchar_t wfilename[MAX_LONG_PATH];
@@ -973,13 +966,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
973966
if (handle != INVALID_HANDLE_VALUE) {
974967
if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
975968
(findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
976-
if (follow) {
977-
char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
978-
buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
979-
} else {
980-
buf->st_mode = S_IFLNK;
981-
}
982-
buf->st_mode |= S_IREAD;
969+
buf->st_mode = S_IFLNK | S_IREAD;
983970
if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
984971
buf->st_mode |= S_IWRITE;
985972
}
@@ -1039,11 +1026,6 @@ static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
10391026
return 0;
10401027
}
10411028

1042-
int mingw_lstat(const char *file_name, struct stat *buf)
1043-
{
1044-
return do_lstat(0, file_name, buf);
1045-
}
1046-
10471029
int mingw_stat(const char *file_name, struct stat *buf)
10481030
{
10491031
wchar_t wfile_name[MAX_LONG_PATH];

0 commit comments

Comments
 (0)