aboutsummaryrefslogtreecommitdiff
path: root/win32/dirent.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2022-05-15 08:52:26 +0100
committerRon Yorston <rmy@pobox.com>2022-05-15 08:52:26 +0100
commit7fb95a2a569ca6d68dad4cef5b7b299e9fe68e2b (patch)
tree53e4d681990f6cc64b97e1f6d81f7e52cdb214bb /win32/dirent.c
parentb0696b94ab963fe0dd47f5c1ed6327a4337afa09 (diff)
downloadbusybox-w32-7fb95a2a569ca6d68dad4cef5b7b299e9fe68e2b.tar.gz
busybox-w32-7fb95a2a569ca6d68dad4cef5b7b299e9fe68e2b.tar.bz2
busybox-w32-7fb95a2a569ca6d68dad4cef5b7b299e9fe68e2b.zip
win32: try to get link count for directories
On Unix the link count of a directory reflects the number of subdirectories it contains. Enhance readdir(3) to return file types and use this to count subdirectories when stat(2) is called for a directory. As with other features that might slow down stat(2) this is controlled by the build-time setting FEATURE_EXTRA_FILE_DATA. (Commit d82db8e9a 'win32: make stat(2) fetch additional metadata'). (GitHub issue #254)
Diffstat (limited to 'win32/dirent.c')
-rw-r--r--win32/dirent.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/win32/dirent.c b/win32/dirent.c
index b7de19391..b5b379209 100644
--- a/win32/dirent.c
+++ b/win32/dirent.c
@@ -10,6 +10,17 @@ static inline void finddata2dirent(struct dirent *ent, WIN32_FIND_DATAA *fdata)
10{ 10{
11 /* copy file name from WIN32_FIND_DATA to dirent */ 11 /* copy file name from WIN32_FIND_DATA to dirent */
12 strcpy(ent->d_name, fdata->cFileName); 12 strcpy(ent->d_name, fdata->cFileName);
13
14#if ENABLE_FEATURE_EXTRA_FILE_DATA
15 if ((fdata->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
16 (fdata->dwReserved0 == IO_REPARSE_TAG_SYMLINK ||
17 fdata->dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT))
18 ent->d_type = DT_LNK;
19 else if (fdata->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
20 ent->d_type = DT_DIR;
21 else
22 ent->d_type = DT_REG;
23#endif
13} 24}
14 25
15DIR *opendir(const char *name) 26DIR *opendir(const char *name)