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 <blees@dcon.de>
This commit is contained in:
Karsten Blees 2015-05-12 00:58:39 +02:00 коммит произвёл Matthew John Cheetham
Родитель 1557155bd5
Коммит 2ce2208a58
1 изменённых файлов: 2 добавлений и 20 удалений

Просмотреть файл

@ -844,14 +844,7 @@ static int has_valid_directory_prefix(wchar_t *wfilename)
return 1; return 1;
} }
/* We keep the do_lstat code in a separate function to avoid recursion. int mingw_lstat(const char *file_name, struct stat *buf)
* When a path ends with a slash, the stat will fail with ENOENT. In
* this case, we strip the trailing slashes and stat again.
*
* If follow is true then act like stat() and report on the link
* target. Otherwise report on the link itself.
*/
static int do_lstat(int follow, const char *file_name, struct stat *buf)
{ {
WIN32_FILE_ATTRIBUTE_DATA fdata; WIN32_FILE_ATTRIBUTE_DATA fdata;
wchar_t wfilename[MAX_LONG_PATH]; wchar_t wfilename[MAX_LONG_PATH];
@ -885,13 +878,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
if (handle != INVALID_HANDLE_VALUE) { if (handle != INVALID_HANDLE_VALUE) {
if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) && if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
(findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) { (findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
if (follow) { buf->st_mode = S_IFLNK | S_IREAD;
char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
} else {
buf->st_mode = S_IFLNK;
}
buf->st_mode |= S_IREAD;
if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
buf->st_mode |= S_IWRITE; buf->st_mode |= S_IWRITE;
} }
@ -951,11 +938,6 @@ static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
return 0; return 0;
} }
int mingw_lstat(const char *file_name, struct stat *buf)
{
return do_lstat(0, file_name, buf);
}
int mingw_stat(const char *file_name, struct stat *buf) int mingw_stat(const char *file_name, struct stat *buf)
{ {
wchar_t wfile_name[MAX_LONG_PATH]; wchar_t wfile_name[MAX_LONG_PATH];