diff options
-rw-r--r-- | coreutils/ls.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index 8589c854e..df4277fbd 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -941,6 +941,15 @@ static void sort_and_display_files(struct dnode **dn, unsigned nfiles) | |||
941 | # define sort_and_display_files(dn, nfiles) display_files(dn, nfiles) | 941 | # define sort_and_display_files(dn, nfiles) display_files(dn, nfiles) |
942 | #endif | 942 | #endif |
943 | 943 | ||
944 | #if ENABLE_PLATFORM_MINGW32 | ||
945 | static int hide_file(DWORD attr) | ||
946 | { | ||
947 | return | ||
948 | ((attr & FILE_ATTRIBUTE_HIDDEN) && !(option_mask32 & (OPT_a|OPT_A))) || | ||
949 | (((attr & HIDSYS) == HIDSYS) && MAX(G.a_count, G.A_count) > 1); | ||
950 | } | ||
951 | #endif | ||
952 | |||
944 | /* Returns NULL-terminated malloced vector of pointers (or NULL) */ | 953 | /* Returns NULL-terminated malloced vector of pointers (or NULL) */ |
945 | static struct dnode **scan_one_dir(const char *path, unsigned *nfiles_p) | 954 | static struct dnode **scan_one_dir(const char *path, unsigned *nfiles_p) |
946 | { | 955 | { |
@@ -983,11 +992,7 @@ static struct dnode **scan_one_dir(const char *path, unsigned *nfiles_p) | |||
983 | /* When showing link targets we must first check the | 992 | /* When showing link targets we must first check the |
984 | * attributes of the link itself to see if it's hidden. */ | 993 | * attributes of the link itself to see if it's hidden. */ |
985 | if ((option_mask32 & OPT_L) && !lstat(fullname, &statbuf)) { | 994 | if ((option_mask32 & OPT_L) && !lstat(fullname, &statbuf)) { |
986 | if (((statbuf.st_attr & FILE_ATTRIBUTE_HIDDEN) && | 995 | if (hide_file(statbuf.st_attr)) { |
987 | !(option_mask32 & (OPT_a|OPT_A))) || | ||
988 | (((statbuf.st_attr & HIDSYS) == HIDSYS) && | ||
989 | MAX(G.a_count, G.A_count) > 1) | ||
990 | ) { | ||
991 | free(fullname); | 996 | free(fullname); |
992 | continue; | 997 | continue; |
993 | } | 998 | } |
@@ -997,11 +1002,7 @@ static struct dnode **scan_one_dir(const char *path, unsigned *nfiles_p) | |||
997 | #if !ENABLE_PLATFORM_MINGW32 | 1002 | #if !ENABLE_PLATFORM_MINGW32 |
998 | if (!cur) { | 1003 | if (!cur) { |
999 | #else | 1004 | #else |
1000 | if (!cur || ((cur->dn_attr & FILE_ATTRIBUTE_HIDDEN) && | 1005 | if (!cur || hide_file(cur->dn_attr)) { |
1001 | !(option_mask32 & (OPT_a|OPT_A))) || | ||
1002 | (((cur->dn_attr & HIDSYS) == HIDSYS) && | ||
1003 | MAX(G.a_count, G.A_count) > 1) | ||
1004 | ) { | ||
1005 | /* skip invalid or hidden files */ | 1006 | /* skip invalid or hidden files */ |
1006 | #endif | 1007 | #endif |
1007 | free(fullname); | 1008 | free(fullname); |