comparison src/fileio.c @ 20790:5a9c42c6a69e v8.2.0947

patch 8.2.0947: readdirex() doesn't handle broken link properly Commit: https://github.com/vim/vim/commit/ab54032f297e9418b0d83970cbe3a414d6ef08c4 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 10 15:55:36 2020 +0200 patch 8.2.0947: readdirex() doesn't handle broken link properly Problem: Readdirex() doesn't handle broken link properly. Solution: Small fixes to readdirex(). (Christian Brabandt, closes https://github.com/vim/vim/issues/6226, closes #6213)
author Bram Moolenaar <Bram@vim.org>
date Wed, 10 Jun 2020 16:00:05 +0200
parents 2407ffaefc02
children db18625d8134
comparison
equal deleted inserted replaced
20789:7177dae667cd 20790:5a9c42c6a69e
4542 size_t len; 4542 size_t len;
4543 stat_T st; 4543 stat_T st;
4544 int ret, link = FALSE; 4544 int ret, link = FALSE;
4545 varnumber_T size; 4545 varnumber_T size;
4546 char_u permbuf[] = "---------"; 4546 char_u permbuf[] = "---------";
4547 char_u *q; 4547 char_u *q = NULL;
4548 struct passwd *pw; 4548 struct passwd *pw;
4549 struct group *gr; 4549 struct group *gr;
4550 4550
4551 item = dict_alloc(); 4551 item = dict_alloc();
4552 if (item == NULL) 4552 if (item == NULL)
4561 ret = mch_lstat(p, &st); 4561 ret = mch_lstat(p, &st);
4562 if (ret >= 0 && S_ISLNK(st.st_mode)) 4562 if (ret >= 0 && S_ISLNK(st.st_mode))
4563 { 4563 {
4564 link = TRUE; 4564 link = TRUE;
4565 ret = mch_stat(p, &st); 4565 ret = mch_stat(p, &st);
4566 if (ret < 0)
4567 q = (char_u*)"link";
4568
4566 } 4569 }
4567 vim_free(p); 4570 vim_free(p);
4568 4571
4569 if (dict_add_string(item, "name", name) == FAIL) 4572 if (dict_add_string(item, "name", name) == FAIL)
4570 goto theend; 4573 goto theend;
4615 { 4618 {
4616 if (dict_add_number(item, "size", -1) == FAIL) 4619 if (dict_add_number(item, "size", -1) == FAIL)
4617 goto theend; 4620 goto theend;
4618 if (dict_add_number(item, "time", -1) == FAIL) 4621 if (dict_add_number(item, "time", -1) == FAIL)
4619 goto theend; 4622 goto theend;
4620 if (dict_add_string(item, "type", (char_u*)"") == FAIL) 4623 if (dict_add_string(item, "type", q == NULL ? (char_u*)"" : q) == FAIL)
4621 goto theend; 4624 goto theend;
4622 if (dict_add_string(item, "perm", (char_u*)"") == FAIL) 4625 if (dict_add_string(item, "perm", (char_u*)"") == FAIL)
4623 goto theend; 4626 goto theend;
4624 if (dict_add_string(item, "user", (char_u*)"") == FAIL) 4627 if (dict_add_string(item, "user", (char_u*)"") == FAIL)
4625 goto theend; 4628 goto theend;
4717 4720
4718 wp = wfd.cFileName; 4721 wp = wfd.cFileName;
4719 ignore = wp[0] == L'.' && 4722 ignore = wp[0] == L'.' &&
4720 (wp[1] == NUL || 4723 (wp[1] == NUL ||
4721 (wp[1] == L'.' && wp[2] == NUL)); 4724 (wp[1] == L'.' && wp[2] == NUL));
4725 if (ignore)
4726 {
4727 ok = FindNextFileW(hFind, &wfd);
4728 continue;
4729 }
4722 # ifdef FEAT_EVAL 4730 # ifdef FEAT_EVAL
4723 if (withattr) 4731 if (withattr)
4724 item = (void*)create_readdirex_item(&wfd); 4732 item = (void*)create_readdirex_item(&wfd);
4725 else 4733 else
4726 # endif 4734 # endif
4785 p = (char_u *)dp->d_name; 4793 p = (char_u *)dp->d_name;
4786 4794
4787 ignore = p[0] == '.' && 4795 ignore = p[0] == '.' &&
4788 (p[1] == NUL || 4796 (p[1] == NUL ||
4789 (p[1] == '.' && p[2] == NUL)); 4797 (p[1] == '.' && p[2] == NUL));
4798 if (ignore)
4799 continue;
4790 # ifdef FEAT_EVAL 4800 # ifdef FEAT_EVAL
4791 if (withattr) 4801 if (withattr)
4792 item = (void*)create_readdirex_item(path, p); 4802 item = (void*)create_readdirex_item(path, p);
4793 else 4803 else
4794 # endif 4804 # endif