Skip to content

Commit 9e019ea

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 f028f90 commit 9e019ea

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
@@ -554,14 +554,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
554554
return 1;
555555
}
556556

557-
/* We keep the do_lstat code in a separate function to avoid recursion.
558-
* When a path ends with a slash, the stat will fail with ENOENT. In
559-
* this case, we strip the trailing slashes and stat again.
560-
*
561-
* If follow is true then act like stat() and report on the link
562-
* target. Otherwise report on the link itself.
563-
*/
564-
static int do_lstat(int follow, const char *file_name, struct stat *buf)
557+
int mingw_lstat(const char *file_name, struct stat *buf)
565558
{
566559
WIN32_FILE_ATTRIBUTE_DATA fdata;
567560
wchar_t wfilename[MAX_LONG_PATH];
@@ -595,13 +588,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
595588
if (handle != INVALID_HANDLE_VALUE) {
596589
if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
597590
(findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
598-
if (follow) {
599-
char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
600-
buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
601-
} else {
602-
buf->st_mode = S_IFLNK;
603-
}
604-
buf->st_mode |= S_IREAD;
591+
buf->st_mode = S_IFLNK | S_IREAD;
605592
if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
606593
buf->st_mode |= S_IWRITE;
607594
}
@@ -638,11 +625,6 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
638625

639626
int (*lstat)(const char *file_name, struct stat *buf) = mingw_lstat;
640627

641-
int mingw_lstat(const char *file_name, struct stat *buf)
642-
{
643-
return do_lstat(0, file_name, buf);
644-
}
645-
646628
static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
647629
{
648630
BY_HANDLE_FILE_INFORMATION fdata;

0 commit comments

Comments
 (0)