Skip to content

Commit f1f9949

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 20ba2ef commit f1f9949

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
@@ -705,14 +705,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
705705
return 1;
706706
}
707707

708-
/* We keep the do_lstat code in a separate function to avoid recursion.
709-
* When a path ends with a slash, the stat will fail with ENOENT. In
710-
* this case, we strip the trailing slashes and stat again.
711-
*
712-
* If follow is true then act like stat() and report on the link
713-
* target. Otherwise report on the link itself.
714-
*/
715-
static int do_lstat(int follow, const char *file_name, struct stat *buf)
708+
int mingw_lstat(const char *file_name, struct stat *buf)
716709
{
717710
WIN32_FILE_ATTRIBUTE_DATA fdata;
718711
wchar_t wfilename[MAX_LONG_PATH];
@@ -746,13 +739,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
746739
if (handle != INVALID_HANDLE_VALUE) {
747740
if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
748741
(findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
749-
if (follow) {
750-
char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
751-
buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
752-
} else {
753-
buf->st_mode = S_IFLNK;
754-
}
755-
buf->st_mode |= S_IREAD;
742+
buf->st_mode = S_IFLNK | S_IREAD;
756743
if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
757744
buf->st_mode |= S_IWRITE;
758745
}
@@ -812,11 +799,6 @@ static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
812799
return 0;
813800
}
814801

815-
int mingw_lstat(const char *file_name, struct stat *buf)
816-
{
817-
return do_lstat(0, file_name, buf);
818-
}
819-
820802
int mingw_stat(const char *file_name, struct stat *buf)
821803
{
822804
wchar_t wfile_name[MAX_LONG_PATH];

0 commit comments

Comments
 (0)