Skip to content

Commit a637541

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 26fc0b4 commit a637541

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
@@ -835,14 +835,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
835835
return 1;
836836
}
837837

838-
/* We keep the do_lstat code in a separate function to avoid recursion.
839-
* When a path ends with a slash, the stat will fail with ENOENT. In
840-
* this case, we strip the trailing slashes and stat again.
841-
*
842-
* If follow is true then act like stat() and report on the link
843-
* target. Otherwise report on the link itself.
844-
*/
845-
static int do_lstat(int follow, const char *file_name, struct stat *buf)
838+
int mingw_lstat(const char *file_name, struct stat *buf)
846839
{
847840
WIN32_FILE_ATTRIBUTE_DATA fdata;
848841
wchar_t wfilename[MAX_LONG_PATH];
@@ -876,13 +869,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
876869
if (handle != INVALID_HANDLE_VALUE) {
877870
if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
878871
(findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
879-
if (follow) {
880-
char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
881-
buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
882-
} else {
883-
buf->st_mode = S_IFLNK;
884-
}
885-
buf->st_mode |= S_IREAD;
872+
buf->st_mode = S_IFLNK | S_IREAD;
886873
if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
887874
buf->st_mode |= S_IWRITE;
888875
}
@@ -942,11 +929,6 @@ static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
942929
return 0;
943930
}
944931

945-
int mingw_lstat(const char *file_name, struct stat *buf)
946-
{
947-
return do_lstat(0, file_name, buf);
948-
}
949-
950932
int mingw_stat(const char *file_name, struct stat *buf)
951933
{
952934
wchar_t wfile_name[MAX_LONG_PATH];

0 commit comments

Comments
 (0)