Skip to content

Commit f3c9296

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 2bb1e6e commit f3c9296

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

compat/mingw.c

+2-20
Original file line numberDiff line numberDiff line change
@@ -931,14 +931,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
931931
return 1;
932932
}
933933

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

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

0 commit comments

Comments
 (0)