Skip to content

Commit b862761

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 85240f7 commit b862761

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
@@ -519,14 +519,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
519519
return 1;
520520
}
521521

522-
/* We keep the do_lstat code in a separate function to avoid recursion.
523-
* When a path ends with a slash, the stat will fail with ENOENT. In
524-
* this case, we strip the trailing slashes and stat again.
525-
*
526-
* If follow is true then act like stat() and report on the link
527-
* target. Otherwise report on the link itself.
528-
*/
529-
static int do_lstat(int follow, const char *file_name, struct stat *buf)
522+
int mingw_lstat(const char *file_name, struct stat *buf)
530523
{
531524
WIN32_FILE_ATTRIBUTE_DATA fdata;
532525
wchar_t wfilename[MAX_LONG_PATH];
@@ -560,13 +553,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
560553
if (handle != INVALID_HANDLE_VALUE) {
561554
if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
562555
(findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
563-
if (follow) {
564-
char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
565-
buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
566-
} else {
567-
buf->st_mode = S_IFLNK;
568-
}
569-
buf->st_mode |= S_IREAD;
556+
buf->st_mode = S_IFLNK | S_IREAD;
570557
if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
571558
buf->st_mode |= S_IWRITE;
572559
}
@@ -603,11 +590,6 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
603590

604591
int (*lstat)(const char *file_name, struct stat *buf) = mingw_lstat;
605592

606-
int mingw_lstat(const char *file_name, struct stat *buf)
607-
{
608-
return do_lstat(0, file_name, buf);
609-
}
610-
611593
static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
612594
{
613595
BY_HANDLE_FILE_INFORMATION fdata;

0 commit comments

Comments
 (0)