diff options
| author | Ron Yorston <rmy@pobox.com> | 2020-07-09 08:52:24 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2020-07-09 08:52:24 +0100 |
| commit | 86eb680bbfd096ab1a2664e36f80f4bea55e18cf (patch) | |
| tree | a6e088a2496f789b46a11f5e4c776c337038a7f2 /coreutils | |
| parent | ea3041f90d719e1f14c6149759a56af78dbae101 (diff) | |
| download | busybox-w32-86eb680bbfd096ab1a2664e36f80f4bea55e18cf.tar.gz busybox-w32-86eb680bbfd096ab1a2664e36f80f4bea55e18cf.tar.bz2 busybox-w32-86eb680bbfd096ab1a2664e36f80f4bea55e18cf.zip | |
ls: treat hidden files as if their names begin with a dot
On Unix 'ls' treats filenames starting with a dot as hidden and
only displays them if the '-a' or '-A' option is given.
Extend similar treatment to files with the Windows hidden flag.
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/ls.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index 3eff5a949..fb082f1f3 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
| @@ -316,6 +316,9 @@ struct dnode { | |||
| 316 | int dn_rdev_min; | 316 | int dn_rdev_min; |
| 317 | // dev_t dn_dev; | 317 | // dev_t dn_dev; |
| 318 | // blksize_t dn_blksize; | 318 | // blksize_t dn_blksize; |
| 319 | #if ENABLE_PLATFORM_MINGW32 | ||
| 320 | DWORD dn_attr; | ||
| 321 | #endif | ||
| 319 | }; | 322 | }; |
| 320 | 323 | ||
| 321 | struct globals { | 324 | struct globals { |
| @@ -742,6 +745,9 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f | |||
| 742 | 745 | ||
| 743 | /* cur->dstat = statbuf: */ | 746 | /* cur->dstat = statbuf: */ |
| 744 | cur->dn_mode = statbuf.st_mode ; | 747 | cur->dn_mode = statbuf.st_mode ; |
| 748 | #if ENABLE_PLATFORM_MINGW32 | ||
| 749 | cur->dn_attr = statbuf.st_attr ; | ||
| 750 | #endif | ||
| 745 | cur->dn_size = statbuf.st_size ; | 751 | cur->dn_size = statbuf.st_size ; |
| 746 | #if ENABLE_FEATURE_LS_TIMESTAMPS || ENABLE_FEATURE_LS_SORTFILES | 752 | #if ENABLE_FEATURE_LS_TIMESTAMPS || ENABLE_FEATURE_LS_SORTFILES |
| 747 | cur->dn_time = statbuf.st_mtime ; | 753 | cur->dn_time = statbuf.st_mtime ; |
| @@ -953,7 +959,13 @@ static struct dnode **scan_one_dir(const char *path, unsigned *nfiles_p) | |||
| 953 | } | 959 | } |
| 954 | fullname = concat_path_file(path, entry->d_name); | 960 | fullname = concat_path_file(path, entry->d_name); |
| 955 | cur = my_stat(fullname, bb_basename(fullname), 0); | 961 | cur = my_stat(fullname, bb_basename(fullname), 0); |
| 962 | #if !ENABLE_PLATFORM_MINGW32 | ||
| 956 | if (!cur) { | 963 | if (!cur) { |
| 964 | #else | ||
| 965 | if (!cur || ((cur->dn_attr & FILE_ATTRIBUTE_HIDDEN) && | ||
| 966 | !(option_mask32 & (OPT_a|OPT_A)))) { | ||
| 967 | /* skip invalid or hidden files */ | ||
| 968 | #endif | ||
| 957 | free(fullname); | 969 | free(fullname); |
| 958 | continue; | 970 | continue; |
| 959 | } | 971 | } |
