Skip to content

Commit 20fd2bd

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 2c69271 commit 20fd2bd

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
@@ -817,14 +817,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
817817
return 1;
818818
}
819819

820-
/* We keep the do_lstat code in a separate function to avoid recursion.
821-
* When a path ends with a slash, the stat will fail with ENOENT. In
822-
* this case, we strip the trailing slashes and stat again.
823-
*
824-
* If follow is true then act like stat() and report on the link
825-
* target. Otherwise report on the link itself.
826-
*/
827-
static int do_lstat(int follow, const char *file_name, struct stat *buf)
820+
int mingw_lstat(const char *file_name, struct stat *buf)
828821
{
829822
WIN32_FILE_ATTRIBUTE_DATA fdata;
830823
wchar_t wfilename[MAX_LONG_PATH];
@@ -858,13 +851,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
858851
if (handle != INVALID_HANDLE_VALUE) {
859852
if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
860853
(findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
861-
if (follow) {
862-
char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
863-
buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
864-
} else {
865-
buf->st_mode = S_IFLNK;
866-
}
867-
buf->st_mode |= S_IREAD;
854+
buf->st_mode = S_IFLNK | S_IREAD;
868855
if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
869856
buf->st_mode |= S_IWRITE;
870857
}
@@ -924,11 +911,6 @@ static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
924911
return 0;
925912
}
926913

927-
int mingw_lstat(const char *file_name, struct stat *buf)
928-
{
929-
return do_lstat(0, file_name, buf);
930-
}
931-
932914
int mingw_stat(const char *file_name, struct stat *buf)
933915
{
934916
wchar_t wfile_name[MAX_LONG_PATH];

0 commit comments

Comments
 (0)